From b482bec7bfaed9e147d2838ee27012fdc2b1f694 Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Thu, 25 Apr 2024 23:53:51 +0200 Subject: [PATCH] Fixed String.fromCharCode when using reflection --- include/hxString.h | 3 +++ src/String.cpp | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/include/hxString.h b/include/hxString.h index b53ddd4a3..81000e999 100644 --- a/include/hxString.h +++ b/include/hxString.h @@ -354,6 +354,9 @@ class HXCPP_EXTERN_CLASS_ATTRIBUTES String // This is used by the string-wrapped-as-dynamic class hx::Val __Field(const ::String &inString, hx::PropertyAccess inCallProp); + // Allows for reflection to be able to get the static functions + static bool __GetStatic(const String&, Dynamic&, hx::PropertyAccess); + // The actual implementation. // Note that "__s" is const - if you want to change it, you should create a new string. // this allows for multiple strings to point to the same data. diff --git a/src/String.cpp b/src/String.cpp index c79ec2fc3..f3926176a 100644 --- a/src/String.cpp +++ b/src/String.cpp @@ -2174,6 +2174,11 @@ hx::Val String::__Field(const String &inString, hx::PropertyAccess inCallProp) return null(); } +bool String::__GetStatic(const ::String &inName, Dynamic &outValue, ::hx::PropertyAccess inCallProp) +{ + if (HX_FIELD_EQ(inName,"fromCharCode")) { outValue = fromCharCode_dyn(); return true; } + return false; +} static String sStringStatics[] = { HX_CSTRING("fromCharCode"), @@ -2406,6 +2411,8 @@ void String::__boot() Static(__StringClass) = hx::_hx_RegisterClass(HX_CSTRING("String"),TCanCast,sStringStatics, sStringFields, &CreateEmptyString, &CreateString, 0, 0, 0 ); + __StringClass->mGetStaticField = &String::__GetStatic; + __StringClass->mSetStaticField = &::hx::Class_obj::SetNoStaticField; }