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

Incorrect JS return value when calling a C++ method that returns an enum #64

Open
Deco opened this issue Aug 17, 2020 · 0 comments
Open

Comments

@Deco
Copy link

Deco commented Aug 17, 2020

In UnrealJS\Source\V8\Private\JavascriptIsolate_Private.cpp, in FJavascriptIsolateImplementation, in InternalReadProperty, in the else if(auto p = CastField<FEnumProperty>(Property)) branch, the following code is incorrect:

int32 Value = p->GetUnderlyingProperty()->GetValueTypeHash(Buffer);
return I.Keyword(p->GetEnum()->GetNameStringByIndex(Value));

Unlike the other branches, which call p->GetPropertyValue_InContainer(Buffer), this branch does not factor in the property's offset within the buffer (stored in Offset_Internal). This means it interprets whatever is at the head of the buffer as the property's value, resulting in incorrect return values in JS when calling a C++ method that returns an enum.

Locally, I'm using this and it seems to work:

int32 Value = p->GetUnderlyingProperty()->GetValueTypeHash(Buffer + p->GetOffset_ForInternal());
return I.Keyword(p->GetEnum()->GetNameStringByIndex(Value));
getnamo added a commit to getnamo/UnrealJs that referenced this issue Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant