Skip to content

Commit 36eb476

Browse files
committed
Fixed String.fromCharCode when using reflection
1 parent fd957c2 commit 36eb476

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

include/hxString.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,9 @@ class HXCPP_EXTERN_CLASS_ATTRIBUTES String
375375
// This is used by the string-wrapped-as-dynamic class
376376
hx::Val __Field(const ::String &inString, hx::PropertyAccess inCallProp);
377377

378+
// Allows for reflection to be able to get the static functions
379+
static bool __GetStatic(const String&, Dynamic&, hx::PropertyAccess);
380+
378381
// The actual implementation.
379382
// Note that "__s" is const - if you want to change it, you should create a new string.
380383
// this allows for multiple strings to point to the same data.

src/String.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2405,6 +2405,11 @@ hx::Val String::__Field(const String &inString, hx::PropertyAccess inCallProp)
24052405
return null();
24062406
}
24072407

2408+
bool String::__GetStatic(const ::String &inName, Dynamic &outValue, ::hx::PropertyAccess inCallProp)
2409+
{
2410+
if (HX_FIELD_EQ(inName,"fromCharCode")) { outValue = fromCharCode_dyn(); return true; }
2411+
return false;
2412+
}
24082413

24092414
static String sStringStatics[] = {
24102415
HX_CSTRING("fromCharCode"),
@@ -2635,4 +2640,6 @@ void String::__boot()
26352640
Static(__StringClass) = hx::_hx_RegisterClass(HX_CSTRING("String"),TCanCast<StringData>,sStringStatics, sStringFields,
26362641
&CreateEmptyString, &CreateString, 0, 0, 0
26372642
);
2643+
__StringClass->mGetStaticField = &String::__GetStatic;
2644+
__StringClass->mSetStaticField = &::hx::Class_obj::SetNoStaticField;
26382645
}

0 commit comments

Comments
 (0)