matthewdean/proxy.lua — pull request #1 by Anaminus (2013-11-28 01:28:31+00:00)
Title: Rewrote proxy.lua

Some unresolved issues:
- If something errors, then the stack level will be wrong, since wrap/unwrap can be recursive.
- Haven't verified this: roblox objects that don't have any strong lua references may get collected by the lua garbage collector. That is, having an object in the game hierarchy or set as the value of a property isn't considered a strong reference. This is bad for the lookup tables, which use weak references.
- Unwrapped tables are cloned, but not lookup'd. This is because we treat tables as immutable. However, this is bad for functions like getmetatable, which treat received tables as mutable.

Possible solution: When a user-made table gets unwrapped, hijack the original wrapped table by setting its metatable. This metatable will detect changes made to the wrapped table, and will update its unwrapped counterpart. If the wrapped table already has a metatable (created by the user), then that metatable will be unwrapped, and transferred to the unwrapped table.

If the user uses get/setmetatable on the wrapped table, then it will get or set the metatable of the unwrapped table, so this should be fine.