-
-
Notifications
You must be signed in to change notification settings - Fork 46
Description
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:
const lua = await factory.createEngine({ enableProxy: false, injectObjects: false });
lua.global.set('null_isnot_nil', () => { const o={ notnil: null }; return o; });
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:
result = null_isnot_nil();
print (type(result));
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.