diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index 09a3b1c94..2f536c300 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -1547,50 +1547,6 @@ PStateLabel::PStateLabel() mDescriptiveName = "StateLabel"; } -/* PStatePointer **********************************************************/ - -IMPLEMENT_CLASS(PStatePointer, false, false, false, false) - -//========================================================================== -// -// PStatePointer Default Constructor -// -//========================================================================== - -PStatePointer::PStatePointer() -: PBasicType(sizeof(FState *), alignof(FState *)) -{ - mDescriptiveName = "State"; - storeOp = OP_SP; - loadOp = OP_LP; - moveOp = OP_MOVEA; - RegType = REGT_POINTER; -} - -//========================================================================== -// -// PStatePointer :: WriteValue -// -//========================================================================== - -void PStatePointer::WriteValue(FSerializer &ar, const char *key,const void *addr) const -{ - ar(key, *(FState **)addr); -} - -//========================================================================== -// -// PStatePointer :: ReadValue -// -//========================================================================== - -bool PStatePointer::ReadValue(FSerializer &ar, const char *key, void *addr) const -{ - bool res = false; - ::Serialize(ar, key, *(FState **)addr, nullptr, &res); - return res; -} - /* PPointer ***************************************************************/ IMPLEMENT_CLASS(PPointer, false, true, false, false) @@ -1736,6 +1692,48 @@ PPointer *NewPointer(PType *type, bool isconst) return static_cast(ptype); } +/* PStatePointer **********************************************************/ + +IMPLEMENT_CLASS(PStatePointer, false, false, false, false) + +//========================================================================== +// +// PStatePointer Default Constructor +// +//========================================================================== + +PStatePointer::PStatePointer() +{ + mDescriptiveName = "Pointer"; + PointedType = NewNativeStruct(NAME_State, nullptr); + IsConst = true; +} + +//========================================================================== +// +// PStatePointer :: WriteValue +// +//========================================================================== + +void PStatePointer::WriteValue(FSerializer &ar, const char *key, const void *addr) const +{ + ar(key, *(FState **)addr); +} + +//========================================================================== +// +// PStatePointer :: ReadValue +// +//========================================================================== + +bool PStatePointer::ReadValue(FSerializer &ar, const char *key, void *addr) const +{ + bool res = false; + ::Serialize(ar, key, *(FState **)addr, nullptr, &res); + return res; +} + + /* PClassPointer **********************************************************/ diff --git a/src/dobjtype.h b/src/dobjtype.h index 6134bbf90..f464e36f8 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -551,16 +551,6 @@ public: // Pointers ----------------------------------------------------------------- -class PStatePointer : public PBasicType -{ - DECLARE_CLASS(PStatePointer, PBasicType); -public: - PStatePointer(); - - void WriteValue(FSerializer &ar, const char *key,const void *addr) const override; - bool ReadValue(FSerializer &ar, const char *key,void *addr) const override; -}; - class PPointer : public PBasicType { DECLARE_CLASS(PPointer, PBasicType); @@ -583,6 +573,17 @@ protected: void SetOps(); }; +class PStatePointer : public PPointer +{ + DECLARE_CLASS(PStatePointer, PPointer); +public: + PStatePointer(); + + void WriteValue(FSerializer &ar, const char *key, const void *addr) const override; + bool ReadValue(FSerializer &ar, const char *key, void *addr) const override; +}; + + class PClassPointer : public PPointer { DECLARE_CLASS(PClassPointer, PPointer);