mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 15:22:15 +00:00
- made all iterator classes natively abstract so that they do not get a ConstructNative method so that OP_NEW can refuse creating them without the need to mark them as abstract.
- block creation of actors with the 'new' instruction. Unlike the above these cannot be made abstract because without ConstructNative they cannot be serialized.
This commit is contained in:
parent
20c56f6dda
commit
878e6015df
4 changed files with 18 additions and 5 deletions
|
@ -3084,6 +3084,7 @@ DObject *PClass::CreateNew()
|
||||||
|
|
||||||
if (ConstructNative == nullptr)
|
if (ConstructNative == nullptr)
|
||||||
{
|
{
|
||||||
|
M_Free(mem);
|
||||||
I_Error("Attempt to instantiate abstract class %s.", TypeName.GetChars());
|
I_Error("Attempt to instantiate abstract class %s.", TypeName.GetChars());
|
||||||
}
|
}
|
||||||
ConstructNative (mem);
|
ConstructNative (mem);
|
||||||
|
|
|
@ -709,7 +709,7 @@ DThinker *FThinkerIterator::Next (bool exact)
|
||||||
|
|
||||||
class DThinkerIterator : public DObject, public FThinkerIterator
|
class DThinkerIterator : public DObject, public FThinkerIterator
|
||||||
{
|
{
|
||||||
DECLARE_CLASS(DThinkerIterator, DObject)
|
DECLARE_ABSTRACT_CLASS(DThinkerIterator, DObject)
|
||||||
|
|
||||||
DThinkerIterator()
|
DThinkerIterator()
|
||||||
{
|
{
|
||||||
|
@ -722,7 +722,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_CLASS(DThinkerIterator, false, false);
|
IMPLEMENT_CLASS(DThinkerIterator, true, false);
|
||||||
DEFINE_ACTION_FUNCTION(DThinkerIterator, Create)
|
DEFINE_ACTION_FUNCTION(DThinkerIterator, Create)
|
||||||
{
|
{
|
||||||
PARAM_PROLOGUE;
|
PARAM_PROLOGUE;
|
||||||
|
|
|
@ -7866,7 +7866,7 @@ DEFINE_ACTION_FUNCTION(AActor, GetBobOffset)
|
||||||
|
|
||||||
class DActorIterator : public DObject, public NActorIterator
|
class DActorIterator : public DObject, public NActorIterator
|
||||||
{
|
{
|
||||||
DECLARE_CLASS(DActorIterator, DObject)
|
DECLARE_ABSTRACT_CLASS(DActorIterator, DObject)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DActorIterator(PClassActor *cls= nullptr, int tid = 0)
|
DActorIterator(PClassActor *cls= nullptr, int tid = 0)
|
||||||
|
@ -7875,7 +7875,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_CLASS(DActorIterator, false, false);
|
IMPLEMENT_CLASS(DActorIterator, true, false);
|
||||||
DEFINE_ACTION_FUNCTION(DActorIterator, Create)
|
DEFINE_ACTION_FUNCTION(DActorIterator, Create)
|
||||||
{
|
{
|
||||||
PARAM_PROLOGUE;
|
PARAM_PROLOGUE;
|
||||||
|
|
|
@ -811,7 +811,19 @@ begin:
|
||||||
{
|
{
|
||||||
b = B;
|
b = B;
|
||||||
PClass *cls = (PClass*)(pc->op == OP_NEW ? reg.a[b] : konsta[b].v);
|
PClass *cls = (PClass*)(pc->op == OP_NEW ? reg.a[b] : konsta[b].v);
|
||||||
if (cls->ObjectFlags & OF_Abstract) ThrowAbortException(X_OTHER, "Cannot instantiate abstract class %s", cls->TypeName.GetChars());
|
if (cls->ConstructNative == nullptr)
|
||||||
|
{
|
||||||
|
ThrowAbortException(X_OTHER, "Class %s requires native construction", cls->TypeName.GetChars());
|
||||||
|
}
|
||||||
|
if (cls->ObjectFlags & OF_Abstract)
|
||||||
|
{
|
||||||
|
ThrowAbortException(X_OTHER, "Cannot instantiate abstract class %s", cls->TypeName.GetChars());
|
||||||
|
}
|
||||||
|
// Creating actors here must be outright prohibited,
|
||||||
|
if (cls->IsDescendantOf(RUNTIME_CLASS(AActor)))
|
||||||
|
{
|
||||||
|
ThrowAbortException(X_OTHER, "Cannot create actors with 'new'");
|
||||||
|
}
|
||||||
// [ZZ] validate readonly and between scope construction
|
// [ZZ] validate readonly and between scope construction
|
||||||
c = C;
|
c = C;
|
||||||
if (c) FScopeBarrier::ValidateNew(cls, c - 1);
|
if (c) FScopeBarrier::ValidateNew(cls, c - 1);
|
||||||
|
|
Loading…
Reference in a new issue