diff --git a/src/dobject.h b/src/dobject.h index b5f7ef8c4..5bcb81c50 100644 --- a/src/dobject.h +++ b/src/dobject.h @@ -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 TObjPtr; diff --git a/src/sc_man_scanner.re b/src/sc_man_scanner.re index f4aac0cb5..ba839813f 100644 --- a/src/sc_man_scanner.re +++ b/src/sc_man_scanner.re @@ -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); } diff --git a/src/sc_man_tokens.h b/src/sc_man_tokens.h index fdcb72229..320601414 100644 --- a/src/sc_man_tokens.h +++ b/src/sc_man_tokens.h @@ -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'") diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index edc5066fb..1700dd3e6 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -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); } diff --git a/src/scripting/vm/vmexec.h b/src/scripting/vm/vmexec.h index d47a3bf48..64ea0b7c3 100644 --- a/src/scripting/vm/vmexec.h +++ b/src/scripting/vm/vmexec.h @@ -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); diff --git a/src/scripting/zscript/zcc-parse.lemon b/src/scripting/zscript/zcc-parse.lemon index 2f412f5cf..f80a09974 100644 --- a/src/scripting/zscript/zcc-parse.lemon +++ b/src/scripting/zscript/zcc-parse.lemon @@ -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; } diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index 68b22a05e..923b52cfd 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -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 &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++) diff --git a/src/scripting/zscript/zcc_parser.cpp b/src/scripting/zscript/zcc_parser.cpp index 9f1117193..e48033bcc 100644 --- a/src/scripting/zscript/zcc_parser.cpp +++ b/src/scripting/zscript/zcc_parser.cpp @@ -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); diff --git a/src/scripting/zscript/zcc_parser.h b/src/scripting/zscript/zcc_parser.h index 7cc41318d..c414c0e9c 100644 --- a/src/scripting/zscript/zcc_parser.h +++ b/src/scripting/zscript/zcc_parser.h @@ -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