mirror of
https://github.com/ZDoom/Raze.git
synced 2025-03-01 14:41:00 +00:00
- added a serializer for VMFunction pointers.
This commit is contained in:
parent
64d012b073
commit
ddfb485424
8 changed files with 329 additions and 5 deletions
|
@ -87,8 +87,8 @@ VMFunction* LookupFunction(const char* qname, bool validate)
|
||||||
size_t p = strcspn(qname, ".");
|
size_t p = strcspn(qname, ".");
|
||||||
if (p == 0)
|
if (p == 0)
|
||||||
I_Error("Call to undefined function %s", qname);
|
I_Error("Call to undefined function %s", qname);
|
||||||
FString clsname(qname, p);
|
FName clsname(qname, p, true);
|
||||||
FString funcname = qname + p + 1;
|
FName funcname(qname + p + 1, true);
|
||||||
|
|
||||||
auto func = PClass::FindFunction(clsname, funcname);
|
auto func = PClass::FindFunction(clsname, funcname);
|
||||||
if (func == nullptr)
|
if (func == nullptr)
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
#include "textures.h"
|
#include "textures.h"
|
||||||
#include "texturemanager.h"
|
#include "texturemanager.h"
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
|
#include "vm.h"
|
||||||
|
|
||||||
extern DObject *WP_NOCHANGE;
|
extern DObject *WP_NOCHANGE;
|
||||||
bool save_full = false; // for testing. Should be removed afterward.
|
bool save_full = false; // for testing. Should be removed afterward.
|
||||||
|
@ -1565,6 +1566,35 @@ template<> FSerializer &Serialize(FSerializer &arc, const char *key, Dictionary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> FSerializer& Serialize(FSerializer& arc, const char* key, VMFunction*& func, VMFunction**)
|
||||||
|
{
|
||||||
|
if (arc.isWriting())
|
||||||
|
{
|
||||||
|
arc.WriteKey(key);
|
||||||
|
if (func) arc.w->String(func->QualifiedName);
|
||||||
|
else arc.w->Null();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
func = nullptr;
|
||||||
|
|
||||||
|
auto val = arc.r->FindKey(key);
|
||||||
|
if (val != nullptr && val->IsString())
|
||||||
|
{
|
||||||
|
auto qname = val->GetString();
|
||||||
|
size_t p = strcspn(qname, ".");
|
||||||
|
if (p != 0)
|
||||||
|
{
|
||||||
|
FName clsname(qname, p, true);
|
||||||
|
FName funcname(qname + p + 1, true);
|
||||||
|
func = PClass::FindFunction(clsname, funcname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return arc;
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// Handler to retrieve a numeric value of any kind.
|
// Handler to retrieve a numeric value of any kind.
|
||||||
|
|
|
@ -310,6 +310,7 @@ inline FSerializer& Serialize(FSerializer& arc, const char* key, BitArray& value
|
||||||
template<> FSerializer& Serialize(FSerializer& arc, const char* key, PClass*& clst, PClass** def);
|
template<> FSerializer& Serialize(FSerializer& arc, const char* key, PClass*& clst, PClass** def);
|
||||||
template<> FSerializer& Serialize(FSerializer& arc, const char* key, FFont*& font, FFont** def);
|
template<> FSerializer& Serialize(FSerializer& arc, const char* key, FFont*& font, FFont** def);
|
||||||
template<> FSerializer &Serialize(FSerializer &arc, const char *key, Dictionary *&dict, Dictionary **def);
|
template<> FSerializer &Serialize(FSerializer &arc, const char *key, Dictionary *&dict, Dictionary **def);
|
||||||
|
template<> FSerializer& Serialize(FSerializer& arc, const char* key, VMFunction*& dict, VMFunction** def);
|
||||||
|
|
||||||
inline FSerializer &Serialize(FSerializer &arc, const char *key, DVector3 &p, DVector3 *def)
|
inline FSerializer &Serialize(FSerializer &arc, const char *key, DVector3 &p, DVector3 *def)
|
||||||
{
|
{
|
||||||
|
|
|
@ -790,7 +790,7 @@ VMFunction *FFunctionBuildList::AddFunction(PNamespace *gnspc, const VersionInfo
|
||||||
it.PrintableName = name;
|
it.PrintableName = name;
|
||||||
it.Function = new VMScriptFunction;
|
it.Function = new VMScriptFunction;
|
||||||
it.Function->Name = functype->SymbolName;
|
it.Function->Name = functype->SymbolName;
|
||||||
it.Function->PrintableName = ClassDataAllocator.Strdup(name);
|
it.Function->QualifiedName = it.Function->PrintableName = ClassDataAllocator.Strdup(name);
|
||||||
it.Function->ImplicitArgs = functype->GetImplicitArgs();
|
it.Function->ImplicitArgs = functype->GetImplicitArgs();
|
||||||
it.Proto = nullptr;
|
it.Proto = nullptr;
|
||||||
it.FromDecorate = fromdecorate;
|
it.FromDecorate = fromdecorate;
|
||||||
|
|
|
@ -198,6 +198,7 @@ void InitImports()
|
||||||
{
|
{
|
||||||
assert(afunc->VMPointer != NULL);
|
assert(afunc->VMPointer != NULL);
|
||||||
*(afunc->VMPointer) = new VMNativeFunction(afunc->Function, afunc->FuncName);
|
*(afunc->VMPointer) = new VMNativeFunction(afunc->Function, afunc->FuncName);
|
||||||
|
(*(afunc->VMPointer))->QualifiedName = ClassDataAllocator.Strdup(FStringf("%s.%s", afunc->ClassName + 1, afunc->FuncName));
|
||||||
(*(afunc->VMPointer))->PrintableName = ClassDataAllocator.Strdup(FStringf("%s.%s [Native]", afunc->ClassName+1, afunc->FuncName));
|
(*(afunc->VMPointer))->PrintableName = ClassDataAllocator.Strdup(FStringf("%s.%s [Native]", afunc->ClassName+1, afunc->FuncName));
|
||||||
(*(afunc->VMPointer))->DirectNativeCall = afunc->DirectNative;
|
(*(afunc->VMPointer))->DirectNativeCall = afunc->DirectNative;
|
||||||
AFTable.Push(*afunc);
|
AFTable.Push(*afunc);
|
||||||
|
|
|
@ -450,7 +450,8 @@ public:
|
||||||
FName Name;
|
FName Name;
|
||||||
const uint8_t *RegTypes = nullptr;
|
const uint8_t *RegTypes = nullptr;
|
||||||
TArray<TypedVMValue> DefaultArgs;
|
TArray<TypedVMValue> DefaultArgs;
|
||||||
const char * PrintableName = nullptr; // so that the VM can print meaningful info if something in this function goes wrong. (allocated from the memory arena)
|
const char* QualifiedName = nullptr;
|
||||||
|
const char* PrintableName = nullptr; // same as QualifiedName, but can have additional annotations.
|
||||||
|
|
||||||
class PPrototype *Proto;
|
class PPrototype *Proto;
|
||||||
TArray<uint32_t> ArgFlags; // Should be the same length as Proto->ArgumentTypes
|
TArray<uint32_t> ArgFlags; // Should be the same length as Proto->ArgumentTypes
|
||||||
|
|
|
@ -828,9 +828,9 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, USER& w, USER* def
|
||||||
("filler", w.filler, def->filler)
|
("filler", w.filler, def->filler)
|
||||||
("wallshade", w.WallShade)
|
("wallshade", w.WallShade)
|
||||||
("rotator", w.rotator)
|
("rotator", w.rotator)
|
||||||
|
("actoractionfunc", w.__legacyState.ActorActionFunc)
|
||||||
("oz", w.oz, def->oz);
|
("oz", w.oz, def->oz);
|
||||||
|
|
||||||
SerializeCodePtr(arc, "ActorActionFunc", (void**)&w.__legacyState.ActorActionFunc);
|
|
||||||
arc.EndObject();
|
arc.EndObject();
|
||||||
|
|
||||||
if (arc.isReading())
|
if (arc.isReading())
|
||||||
|
|
|
@ -1,3 +1,294 @@
|
||||||
class SWActor : CoreActor native
|
class SWActor : CoreActor native
|
||||||
{
|
{
|
||||||
|
// all ANIMATORs.
|
||||||
|
native int DoBunnyMove();
|
||||||
|
native int DoBunnyGrowUp();
|
||||||
|
native int DoBunnyEat();
|
||||||
|
native int DoBunnyScrew();
|
||||||
|
native int NullBunny();
|
||||||
|
native int InitBunnySlash();
|
||||||
|
native int DoBunnyStandKill();
|
||||||
|
native int DoBunnyPain();
|
||||||
|
native int DoBunnyMoveJump();
|
||||||
|
native int DoBunnyBeginJumpAttack();
|
||||||
|
native int BunnySpew();
|
||||||
|
|
||||||
|
native int DoCoolgMove();
|
||||||
|
native int NullCoolg();
|
||||||
|
native int InitCoolgBash();
|
||||||
|
native int InitCoolgFire();
|
||||||
|
native int DoCoolgPain();
|
||||||
|
native int DoCoolgDeath();
|
||||||
|
native int DoCoolgBirth();
|
||||||
|
|
||||||
|
native int DoCoolieMove();
|
||||||
|
native int CooliePain();
|
||||||
|
native int NullCoolie();
|
||||||
|
native int SpawnCoolieExp();
|
||||||
|
native int DoCoolieWaitBirth();
|
||||||
|
native int SpawnCoolg();
|
||||||
|
|
||||||
|
native int DoEelMove();
|
||||||
|
native int InitEelFire();
|
||||||
|
native int NullEel();
|
||||||
|
native int DoEelDeath();
|
||||||
|
|
||||||
|
native int NullGirlNinja();
|
||||||
|
native int DoGirlNinjaMove();
|
||||||
|
native int DoGirlNinjaPain();
|
||||||
|
native int DoGirlNinjaSpecial();
|
||||||
|
|
||||||
|
native int InitEnemyMine();
|
||||||
|
native int InitEnemyCrossbow();
|
||||||
|
|
||||||
|
native int DoGoroMove();
|
||||||
|
native int NullGoro();
|
||||||
|
native int InitGoroChop();
|
||||||
|
native int DoGoroPain();
|
||||||
|
native int InitEnemyFireball();
|
||||||
|
|
||||||
|
native int DoHornetMove();
|
||||||
|
native int DoHornetDeath();
|
||||||
|
|
||||||
|
native int BloodSprayFall();
|
||||||
|
native int DoSuicide();
|
||||||
|
native int DoRadiationCloud();
|
||||||
|
native int DoChemBomb();
|
||||||
|
native int DoCaltrops();
|
||||||
|
native int DoCaltropsStick();
|
||||||
|
native int DoCarryFlag();
|
||||||
|
native int DoCarryFlagNoDet();
|
||||||
|
native int DoFlag();
|
||||||
|
native int DoPhosphorus();
|
||||||
|
native int DoBloodSpray();
|
||||||
|
native int DoWallBloodDrip();
|
||||||
|
|
||||||
|
native int DoLavaMove();
|
||||||
|
native int NullLava();
|
||||||
|
native int InitLavaThrow();
|
||||||
|
native int InitLavaFlame();
|
||||||
|
|
||||||
|
native int DoActorDeathMove();
|
||||||
|
native int QueueFloorBlood();
|
||||||
|
native int DoActorDebris();
|
||||||
|
native int InitActorDecide();
|
||||||
|
|
||||||
|
native int DoToiletGirl();
|
||||||
|
native int ToiletGirlPain();
|
||||||
|
native int ToiletGirlUzi();
|
||||||
|
native int InitEnemyUzi();
|
||||||
|
native int DoWashGirl();
|
||||||
|
native int WashGirlUzi();
|
||||||
|
native int DoTrashCan();
|
||||||
|
native int TrashCanPain();
|
||||||
|
native int PachinkoLightOperate();
|
||||||
|
native int Pachinko1Operate();
|
||||||
|
native int PachinkoCheckWin();
|
||||||
|
native int DoCarGirl();
|
||||||
|
native int CarGirlPain();
|
||||||
|
native int CarGirlUzi();
|
||||||
|
native int DoMechanicGirl();
|
||||||
|
native int MechanicGirlPain();
|
||||||
|
native int MechanicGirlDrill();
|
||||||
|
native int DoSailorGirl();
|
||||||
|
native int SailorGirlPain();
|
||||||
|
native int SailorGirlThrow();
|
||||||
|
native int DoPruneGirl();
|
||||||
|
native int PruneGirlPain();
|
||||||
|
native int WashGirlPain();
|
||||||
|
|
||||||
|
native int DoNinjaMove();
|
||||||
|
native int NullNinja();
|
||||||
|
native int DoNinjaCeiling();
|
||||||
|
native int DoNinjaPain();
|
||||||
|
native int InitEnemyStar();
|
||||||
|
native int InitEnemyMirv();
|
||||||
|
native int InitEnemyNapalm();
|
||||||
|
native int InitEnemyRocket();
|
||||||
|
native int InitSpriteGrenade();
|
||||||
|
native int InitFlashBomb();
|
||||||
|
native int CheckFire();
|
||||||
|
native int DoNinjaSpecial();
|
||||||
|
native int DoNinjaGrabThroat();
|
||||||
|
native int DoNinjaHariKari();
|
||||||
|
|
||||||
|
native int DoRipperMove();
|
||||||
|
native int NullRipper();
|
||||||
|
native int InitRipperSlash();
|
||||||
|
native int DoRipperStandHeart();
|
||||||
|
native int DoRipperHang();
|
||||||
|
native int DoRipperPain();
|
||||||
|
native int DoRipperMoveJump();
|
||||||
|
native int DoRipperBeginJumpAttack();
|
||||||
|
native int DoRipperHangJF();
|
||||||
|
|
||||||
|
native int DoRipper2Move();
|
||||||
|
native int NullRipper2();
|
||||||
|
native int DoRipper2Hang();
|
||||||
|
native int DoRipper2Pain();
|
||||||
|
native int DoRipper2MoveJump();
|
||||||
|
native int DoRipper2BeginJumpAttack();
|
||||||
|
native int DoRipper2HangJF();
|
||||||
|
native int DoRipper2StandHeart();
|
||||||
|
native int ChestRipper2();
|
||||||
|
|
||||||
|
native int DoSerpMove();
|
||||||
|
native int NullSerp();
|
||||||
|
native int InitSerpSlash();
|
||||||
|
native int InitSerpRing();
|
||||||
|
native int InitSerpSpell();
|
||||||
|
native int InitSerpMonstSpell();
|
||||||
|
native int DoDeathSpecial();
|
||||||
|
|
||||||
|
native int DoSkelMove();
|
||||||
|
native int NullSkel();
|
||||||
|
native int InitSkelSlash();
|
||||||
|
native int InitSkelSpell();
|
||||||
|
native int DoSkelPain();
|
||||||
|
native int DoSkelInitTeleport();
|
||||||
|
native int DoSkelTeleport();
|
||||||
|
native int DoSkelTermTeleport();
|
||||||
|
|
||||||
|
native int DoSkullWait();
|
||||||
|
native int DoSerpRing();
|
||||||
|
native int DoSkullJump();
|
||||||
|
native int DoDamageTest();
|
||||||
|
native int DoSkullSpawnShrap();
|
||||||
|
native int DoBettyWait();
|
||||||
|
native int DoBettyJump();
|
||||||
|
|
||||||
|
native int DoSumoMove();
|
||||||
|
native int NullSumo();
|
||||||
|
native int InitSumoFart();
|
||||||
|
native int InitSumoClap();
|
||||||
|
native int InitSumoStomp();
|
||||||
|
native int DoSumoDeathMelt();
|
||||||
|
|
||||||
|
native int DoDefaultStat();
|
||||||
|
native int DoPuff();
|
||||||
|
native int DoRailPuff();
|
||||||
|
native int DoTracer();
|
||||||
|
native int DoEMP();
|
||||||
|
native int DoEMPBurst();
|
||||||
|
native int DoFastShrapJumpFall();
|
||||||
|
|
||||||
|
native int DoTankShell();
|
||||||
|
native int DoVehicleSmoke();
|
||||||
|
native int DoWaterSmoke();
|
||||||
|
native int DoUziSmoke();
|
||||||
|
native int DoShotgunSmoke();
|
||||||
|
native int DoUziBullet();
|
||||||
|
native int DoBubble();
|
||||||
|
native int DoCrossBolt();
|
||||||
|
native int DoStar();
|
||||||
|
native int DoLavaBoulder();
|
||||||
|
native int DoShrapDamage();
|
||||||
|
native int DoVulcanBoulder();
|
||||||
|
native int DoGrenade();
|
||||||
|
native int DoMineStuck();
|
||||||
|
native int DoMine();
|
||||||
|
native int DoMineSpark();
|
||||||
|
native int DoMeteor();
|
||||||
|
native int DoMirvMissile();
|
||||||
|
native int DoSerpMeteor();
|
||||||
|
native int DoSpear();
|
||||||
|
native int DoRocket();
|
||||||
|
native int DoRail();
|
||||||
|
native int DoLaser();
|
||||||
|
native int DoMicro();
|
||||||
|
native int DoMicroMini();
|
||||||
|
native int DoBoltThinMan();
|
||||||
|
native int DoBoltSeeker();
|
||||||
|
native int DoBoltFatMan();
|
||||||
|
native int DoBoltShrapnel();
|
||||||
|
native int DoCoolgFire();
|
||||||
|
native int DoCoolgDrip();
|
||||||
|
native int DoPlasma();
|
||||||
|
native int DoShrapJumpFall();
|
||||||
|
|
||||||
|
native int DoTracerShrap();
|
||||||
|
native int DoVomitSplash();
|
||||||
|
native int DoVomit();
|
||||||
|
native int DoMirv();
|
||||||
|
native int DoBloodWorm();
|
||||||
|
native int DoNapalm();
|
||||||
|
native int DoRing();
|
||||||
|
native int DoFireball();
|
||||||
|
native int DoBreakFlames();
|
||||||
|
native int DoFireballFlames();
|
||||||
|
native int DoSectorExp();
|
||||||
|
native int SpawnShrapX();
|
||||||
|
native int DoExpDamageTest();
|
||||||
|
native int DoMineExpMine();
|
||||||
|
native int DoMineExp();
|
||||||
|
native int SpawnGrenadeSmallExp();
|
||||||
|
native int DoElectro();
|
||||||
|
native int DoTeleRipper();
|
||||||
|
native int DoPlasmaDone();
|
||||||
|
native int DoPlasmaFountain();
|
||||||
|
native int DoFootPrints();
|
||||||
|
native int DoPlayerSpriteReset();
|
||||||
|
|
||||||
|
native int DoFloorBlood();
|
||||||
|
native int DoWallBlood();
|
||||||
|
|
||||||
|
native int DoGet();
|
||||||
|
native int DoCoin();
|
||||||
|
native int DoFireFly();
|
||||||
|
|
||||||
|
native int DoZillaMove();
|
||||||
|
native int DoZillaStomp();
|
||||||
|
native int NullZilla();
|
||||||
|
native int InitZillaRail();
|
||||||
|
native int InitZillaRocket();
|
||||||
|
native int DoZillaDeathMelt();
|
||||||
|
|
||||||
|
native int DoZombieMove();
|
||||||
|
native int NullZombie();
|
||||||
|
native int DoZombiePain();
|
||||||
|
native int InitEnemyNuke();
|
||||||
|
native int InitEnemyRail();
|
||||||
|
|
||||||
|
native int InitActorRunAway();
|
||||||
|
native int InitActorAttack();
|
||||||
|
native int InitActorDuck();
|
||||||
|
native int InitActorEvade();
|
||||||
|
native int InitActorFindPlayer();
|
||||||
|
native int InitActorMoveCloser();
|
||||||
|
native int InitActorReposition();
|
||||||
|
native int InitActorWanderAround();
|
||||||
|
native int InitCoolgCircle();
|
||||||
|
native int InitCoolieCharge();
|
||||||
|
native int InitHornetCircle();
|
||||||
|
native int InitHornetSting();
|
||||||
|
native int InitRipper2Charge();
|
||||||
|
native int InitRipper2Hang();
|
||||||
|
native int InitRipperHang();
|
||||||
|
native int InitActorRunToward();
|
||||||
|
native int InitActorSetDecide();
|
||||||
|
native int DoActorDecide();
|
||||||
|
native int DoActorMoveJump();
|
||||||
|
native int DoActorDuck();
|
||||||
|
native int NinjaJumpActionFunc();
|
||||||
|
native int DoActorMoveCloser();
|
||||||
|
native int DoActorAttack();
|
||||||
|
native int DoActorReposition();
|
||||||
|
native int DoCoolgCircle();
|
||||||
|
native int DoHornetCircle();
|
||||||
|
native int GenerateDrips();
|
||||||
|
native int DoSpawnSpot();
|
||||||
|
native int DoGrating();
|
||||||
|
native int DoVator();
|
||||||
|
native int DoVatorAuto();
|
||||||
|
native int DoRotator();
|
||||||
|
native int DoActorPause();
|
||||||
|
native int DoSlidor();
|
||||||
|
native int DoSpike();
|
||||||
|
native int DoSpikeAuto();
|
||||||
|
native int DoLavaErupt();
|
||||||
|
native int SpawnVehicleSmoke();
|
||||||
|
native int DoLaserStart();
|
||||||
|
native int DoTracerStart();
|
||||||
|
native int DoRailStart();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue