-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Unable to handle null values between js and the lua vm #104
Comments
Hi @janfrodej
Setting a field to undefined/nil means the field is not sent at all. When you set injectObjects to true |
That was the behaviour before @tims-bsquare, I think it makes sense when injectObjects is false. What do you think about a builtin type extension "lightnull" to be used in this case which just convert to nil/undefined? |
I've put some comments on his PR and I think overall he has a fair point but I'm not certain on the implementation |
The package does not handle null values properly when sending data structures between javascript and the lua vm.
First of all, the enableProxy setting needs to be set to false to ensure that data structures from javascript is not delivered as userdata, which is impossible to for iterate or recurse if such needs exists on the data.
If injectObjects is set to false, it will halt the execution with "decoration.target is null" when trying to deliver data to the lua vm. If injectObjects is set to true, it will successfully deliver the data structure to the lua vm, however any null-value attribute will be of type userdata.
The issue: it would be nice if null data can be delivered as nil in lua.
Example with injectObjects is false:
in the lua code:
result = null_isnot_nil();
This will result in the mentioned: "decoration.target is null".
Example with injectObjects is true:
const lua = await factory.createEngine({ enableProxy: false, injectObjects: true });
in the lua code:
This will give the answer "userdata". It would be nice that null values are delivered as nil in lua. Userdata is not particularly useful and userdata from javascript is also protected, so it is impossible to get the metatable of the data.
The text was updated successfully, but these errors were encountered: