I do something identical to this in a project; the userdata pointer in Lua
is exactly the same as any C++ reference to the object in the way it is
reference counted. As you say, the gc just decrements the count. This
also works well with multiple Lua references to the same object via
different userdata objects (in 4.1), as each different one just holds a
ref on the object.
I don't have the requirement of C++ having a Lua table, as in this example,
but I can't see why that wouldn't work more or less the same way; Lua maintains
the refcount, C++ can effectively hold a ref as long as it likes, and release
it when it wants.
Love, Light and Peace,
- Peter Loveday
eyeon Software