ceifa / wasmoon

A real lua 5.4 VM with JS bindings made with webassembly
MIT License
462 stars 27 forks source link

Misc cleanup #25

Closed timstableford closed 3 years ago

timstableford commented 3 years ago
ceifa commented 3 years ago

After that commit I'm having this error when trying to decorate a object with both reference and metatable:

Error: data already has associated metatable

I'm testing it in demoon project

timstableford commented 3 years ago

@ceifa That's correct. Because the user data already has an associated metatable to do the GC if the user tries to set a metatable on it then that would overwrite the existing one, disabling the GC

timstableford commented 3 years ago

For cases where you need a reference and a metatable you could have an outer-table that contains the reference to the GC'd JS object along along with the methods? It may be possible to have that as the default for the userdata type? I can put together a demo/test if you like? Though knowing you you've probably already done it :)

ceifa commented 3 years ago

Idk if I understood it well, a demo would be very nice! I was thinking in merge the metatables, but idk if it's a good solution too.