Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed String.fromCharCode when using reflection #1104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/hxString.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions src/String.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -2406,6 +2411,8 @@ void String::__boot()
Static(__StringClass) = hx::_hx_RegisterClass(HX_CSTRING("String"),TCanCast<StringData>,sStringStatics, sStringFields,
&CreateEmptyString, &CreateString, 0, 0, 0
);
__StringClass->mGetStaticField = &String::__GetStatic;
__StringClass->mSetStaticField = &::hx::Class_obj::SetNoStaticField;
}


Expand Down