Skip to content

Commit

Permalink
Added FindClass
Browse files Browse the repository at this point in the history
Allows for classes to be looked up during run time without having to use string casting.
  • Loading branch information
Boondorl authored and RicardoLuis0 committed Feb 20, 2025
1 parent 9f6c1d6 commit 236c9b4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/common/scripting/backend/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12367,7 +12367,7 @@ static PClass *NativeNameToClass(int _clsname, PClass *desttype)
if (clsname != NAME_None)
{
cls = PClass::FindClass(clsname);
if (cls != nullptr && (cls->VMType == nullptr || !cls->IsDescendantOf(desttype)))
if (cls != nullptr && (cls->VMType == nullptr || (desttype != nullptr && !cls->IsDescendantOf(desttype))))
{
// does not match required parameters or is invalid.
return nullptr;
Expand Down
1 change: 1 addition & 0 deletions wadsrc/static/zscript/engine/base.zs
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@ class Object native
private native static bool CheckDeprecatedFlags(Object obj, int index);

native static Name ValidateNameIndex(int index);
static class<Object> FindClass(Name cls, class<Object> baseType = null) { return BuiltinNameToClass(cls, baseType); }

native static uint MSTime();
native static double MSTimeF();
Expand Down

0 comments on commit 236c9b4

Please sign in to comment.