Closed dark7god closed 11 years ago
Looks nice, thanks!
Did you check the current stuff still works with this change? I have been using the repl.html page as a 'test suite' ;)
Looks like yes :)
Great!
Looks like this broke print("i made an ArrayBuffer of size " .. js.global.ArrayBuffer.new(20).byteLength)
which is on the repl page.
Taking a look ..
Oh cool! It looks like javascript is not a very smart language, its hash tables cant be indexed by complex objects; yet it does not throw an error, it just silently converts to a string. So all ArrayBuffers are the same to it. I do not see much solutions, either we remove the 1 to 1 mapping, which kinda sucks, or we use an array and iterate over it to find the value, but this is kinda pointless as it defeats the goal of being fast.
Hum or .. is it "allowed" to add your own field to any object; if so when an object is created we could add a __lua_store_id to it which would remove the need for the reverseWrapper table
Yeah, we could store something on the object I guess. There is a WeakMap feature that helps with this kind of thing, but it is not yet supported in all browsers, so we shouldn't use that (yet).
On Fri, Jun 7, 2013 at 1:39 AM, dark7god notifications@github.com wrote:
Oh cool! It looks like javascript is not a very smart language, its hash tables cant be indexed by complex objects; yet it does not throw an error, it just silently converts to a string. So all ArrayBuffers are the same to it. I do not see much solutions, either we remove the 1 to 1 mapping, which kinda sucks, or we use an array and iterate over it to find the value, but this is kinda pointless as it defeats the goal of being fast.
Hum or .. is it "allowed" to add your own field to any object; if so when an object is created we could add a __lua_store_id to it which would remove the need for the reverseWrapper table
— Reply to this email directly or view it on GitHubhttps://github.com/kripken/lua.vm.js/pull/2#issuecomment-19095339 .
js.get always return the same table if the same js object/function is referenced garbage collection work, so when a js.get'ed variable is collected in lua, the corresponding thing in the Lua.wrappers table will be freed too parent object is tracked to make calls with a correct "this" foo.bar = zog works, correctly assigning it on the JS side when a lua callback is called, if "this" is in the lua store it gets passed as the first parameter (aka "self")