mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
Removed nonew class modifier
This commit is contained in:
parent
78533cc316
commit
3a57a9809f
9 changed files with 7 additions and 41 deletions
|
@ -206,9 +206,8 @@ enum EObjectFlags
|
|||
OF_Spawned = 1 << 12, // Thinker was spawned at all (some thinkers get deleted before spawning)
|
||||
OF_Released = 1 << 13, // Object was released from the GC system and should not be processed by GC function
|
||||
OF_Abstract = 1 << 14, // Marks a class that cannot be created with new() function at all
|
||||
OF_NoNew = 1 << 15, // Marks a class that can only be created with new() in the exact class that has this keyword
|
||||
OF_UI = 1 << 16, // Marks a class that defaults to VARF_UI for it's fields/methods
|
||||
OF_Play = 1 << 17, // Marks a class that defaults to VARF_Play for it's fields/methods
|
||||
OF_UI = 1 << 15, // Marks a class that defaults to VARF_UI for it's fields/methods
|
||||
OF_Play = 1 << 16, // Marks a class that defaults to VARF_Play for it's fields/methods
|
||||
};
|
||||
|
||||
template<class T> class TObjPtr;
|
||||
|
|
|
@ -170,7 +170,6 @@ std2:
|
|||
'virtual' { RET(TK_Virtual); }
|
||||
'override' { RET(TK_Override); }
|
||||
'vararg' { RET(TK_VarArg); }
|
||||
'nonew' { RET(TK_NoNew); }
|
||||
'ui' { RET(TK_UI); }
|
||||
'play' { RET(TK_Play); }
|
||||
'clearscope' { RET(TK_ClearScope); }
|
||||
|
|
|
@ -112,7 +112,6 @@ xx(TK_Optional, "'optional'")
|
|||
xx(TK_Export, "'expert'")
|
||||
xx(TK_Virtual, "'virtual'")
|
||||
xx(TK_VarArg, "'vararg'")
|
||||
xx(TK_NoNew, "'nonew'")
|
||||
xx(TK_UI, "'ui'")
|
||||
xx(TK_Play, "'play'")
|
||||
xx(TK_ClearScope, "'clearscope'")
|
||||
|
|
|
@ -5095,19 +5095,6 @@ FxExpression *FxNew::Resolve(FCompileContext &ctx)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (cls->ObjectFlags & OF_NoNew)
|
||||
{
|
||||
PClass* pcls = cls;
|
||||
while (pcls && pcls->ParentClass && (pcls->ParentClass->ObjectFlags & OF_NoNew))
|
||||
pcls = pcls->ParentClass;
|
||||
if (pcls != ctx.Class)
|
||||
{
|
||||
ScriptPosition.Message(MSG_ERROR, "Cannot instantiate class %s directly", cls->TypeName.GetChars());
|
||||
delete this;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
ValueType = NewPointer(cls);
|
||||
}
|
||||
|
||||
|
|
|
@ -801,18 +801,6 @@ begin:
|
|||
PClass *cls = (PClass*)(pc->op == OP_NEW ? reg.a[b] : konsta[b].v);
|
||||
PFunction *callingfunc = (PFunction*)konsta[C].o; // [ZZ] due to how this is set, it's always const
|
||||
if (cls->ObjectFlags & OF_Abstract) ThrowAbortException(X_OTHER, "Cannot instantiate abstract class %s", cls->TypeName.GetChars());
|
||||
if (cls->ObjectFlags & OF_NoNew)
|
||||
{
|
||||
// trace to the first nonew class in the hierarchy.
|
||||
// compare that class to the context class.
|
||||
// if not matching, disallow creation.
|
||||
// this ensures that only the root class can have a static factory method that can also create instances of subclasses via new().
|
||||
PClass* pcls = cls;
|
||||
while (pcls && pcls->ParentClass && (pcls->ParentClass->ObjectFlags & OF_NoNew))
|
||||
pcls = pcls->ParentClass;
|
||||
if (!callingfunc || pcls != callingfunc->OwningClass)
|
||||
ThrowAbortException(X_OTHER, "Cannot instantiate class %s directly", cls->TypeName.GetChars());
|
||||
}
|
||||
// [ZZ] validate readonly and between scope construction
|
||||
if (callingfunc)
|
||||
FScopeBarrier_ValidateNew(cls, callingfunc);
|
||||
|
|
|
@ -212,7 +212,6 @@ class_ancestry(X) ::= COLON dottable_id(A). { X = A; /*X-overwrites-A*/ }
|
|||
%type class_flags{ClassFlagsBlock}
|
||||
class_flags(X) ::= . { X.Flags = 0; X.Replaces = NULL; }
|
||||
class_flags(X) ::= class_flags(A) ABSTRACT. { X.Flags = A.Flags | ZCC_Abstract; X.Replaces = A.Replaces; }
|
||||
class_flags(X) ::= class_flags(A) NONEW. { X.Flags = A.Flags | ZCC_NoNew; X.Replaces = A.Replaces; }
|
||||
class_flags(X) ::= class_flags(A) NATIVE. { X.Flags = A.Flags | ZCC_Native; X.Replaces = A.Replaces; }
|
||||
class_flags(X) ::= class_flags(A) UI. { X.Flags = A.Flags | ZCC_UIFlag; X.Replaces = A.Replaces; }
|
||||
class_flags(X) ::= class_flags(A) PLAY. { X.Flags = A.Flags | ZCC_Play; X.Replaces = A.Replaces; }
|
||||
|
|
|
@ -611,9 +611,6 @@ void ZCCCompiler::CreateClassTypes()
|
|||
if (c->Type() == nullptr) c->cls->Type = parent->FindClassTentative(c->NodeName());
|
||||
if (c->cls->Flags & ZCC_Abstract)
|
||||
c->Type()->ObjectFlags |= OF_Abstract;
|
||||
// [ZZ] inherit nonew keyword
|
||||
if (c->cls->Flags & ZCC_NoNew || (parent->ObjectFlags & OF_NoNew))
|
||||
c->Type()->ObjectFlags |= OF_NoNew;
|
||||
//
|
||||
static int incompatible[] = { ZCC_UIFlag, ZCC_Play, ZCC_ClearScope };
|
||||
int incompatiblecnt = 0;
|
||||
|
@ -1273,7 +1270,7 @@ bool ZCCCompiler::CompileProperties(PClass *type, TArray<ZCC_Property *> &Proper
|
|||
FString ZCCCompiler::FlagsToString(uint32_t flags)
|
||||
{
|
||||
|
||||
const char *flagnames[] = { "native", "static", "private", "protected", "latent", "final", "meta", "action", "deprecated", "readonly", "const", "abstract", "extend", "virtual", "override", "transient", "vararg", "nonew", "ui", "play", "clearscope", "virtualscope" };
|
||||
const char *flagnames[] = { "native", "static", "private", "protected", "latent", "final", "meta", "action", "deprecated", "readonly", "const", "abstract", "extend", "virtual", "override", "transient", "vararg", "ui", "play", "clearscope", "virtualscope" };
|
||||
FString build;
|
||||
|
||||
for (size_t i = 0; i < countof(flagnames); i++)
|
||||
|
|
|
@ -141,7 +141,6 @@ static void InitTokenMap()
|
|||
TOKENDEF (TK_Play, ZCC_PLAY);
|
||||
TOKENDEF (TK_ClearScope, ZCC_CLEARSCOPE);
|
||||
TOKENDEF (TK_VirtualScope, ZCC_VIRTUALSCOPE);
|
||||
TOKENDEF (TK_NoNew, ZCC_NONEW);
|
||||
TOKENDEF (TK_Override, ZCC_OVERRIDE);
|
||||
TOKENDEF (TK_Final, ZCC_FINAL);
|
||||
TOKENDEF (TK_Meta, ZCC_META);
|
||||
|
|
|
@ -37,11 +37,10 @@ enum
|
|||
ZCC_Override = 1 << 14,
|
||||
ZCC_Transient = 1 << 15,
|
||||
ZCC_VarArg = 1 << 16,
|
||||
ZCC_NoNew = 1 << 17,
|
||||
ZCC_UIFlag = 1 << 18, // there's also token called ZCC_UI
|
||||
ZCC_Play = 1 << 19,
|
||||
ZCC_ClearScope = 1 << 20,
|
||||
ZCC_VirtualScope = 1 << 21,
|
||||
ZCC_UIFlag = 1 << 17, // there's also token called ZCC_UI
|
||||
ZCC_Play = 1 << 18,
|
||||
ZCC_ClearScope = 1 << 19,
|
||||
ZCC_VirtualScope = 1 << 20,
|
||||
};
|
||||
|
||||
// Function parameter modifiers
|
||||
|
|
Loading…
Reference in a new issue