From b84d28e9a7ff61cd4d12468d994463a1e3cb7c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Fri, 25 Oct 2024 21:32:52 -0300 Subject: [PATCH] Allow using `Self` as the class name in the default block to refer to the current class --- src/scripting/zscript/zcc_compile_doom.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/scripting/zscript/zcc_compile_doom.cpp b/src/scripting/zscript/zcc_compile_doom.cpp index 3563967e59..a86ea9a0e1 100644 --- a/src/scripting/zscript/zcc_compile_doom.cpp +++ b/src/scripting/zscript/zcc_compile_doom.cpp @@ -724,8 +724,15 @@ void ZCCDoomCompiler::ProcessDefaultProperty(PClassActor *cls, ZCC_PropertyStmt } else if (namenode->SiblingNext->SiblingNext == namenode) { + FName name(namenode->Id); + + if(name == NAME_self) + { + name = cls->TypeName; + } + // a two-name property - propname << FName(namenode->Id).GetChars() << "." << FName(static_cast(namenode->SiblingNext)->Id).GetChars(); + propname << name.GetChars() << "." << FName(static_cast(namenode->SiblingNext)->Id).GetChars(); } else { @@ -784,6 +791,13 @@ void ZCCDoomCompiler::ProcessDefaultFlag(PClassActor *cls, ZCC_FlagStmt *flg) else if (namenode->SiblingNext->SiblingNext == namenode) { // a two-name flag + + if(namenode->Id == NAME_self) + { + n1 = cls->TypeName.GetChars(); + } + + n2 = FName(static_cast(namenode->SiblingNext)->Id).GetChars(); } else