Skip to content

Commit d576847

Browse files
committed
Fixed String.fromCharCode when using reflection
1 parent 450d112 commit d576847

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
@@ -2402,6 +2402,11 @@ hx::Val String::__Field(const String &inString, hx::PropertyAccess inCallProp)
24022402
return null();
24032403
}
24042404

2405+
bool String::__GetStatic(const ::String &inName, Dynamic &outValue, ::hx::PropertyAccess inCallProp)
2406+
{
2407+
if (HX_FIELD_EQ(inName,"fromCharCode")) { outValue = fromCharCode_dyn(); return true; }
2408+
return false;
2409+
}
24052410

24062411
static String sStringStatics[] = {
24072412
HX_CSTRING("fromCharCode"),
@@ -2632,4 +2637,6 @@ void String::__boot()
26322637
Static(__StringClass) = hx::_hx_RegisterClass(HX_CSTRING("String"),TCanCast<StringData>,sStringStatics, sStringFields,
26332638
&CreateEmptyString, &CreateString, 0, 0, 0
26342639
);
2640+
__StringClass->mGetStaticField = &String::__GetStatic;
2641+
__StringClass->mSetStaticField = &::hx::Class_obj::SetNoStaticField;
26352642
}

0 commit comments

Comments
 (0)