Closed JMLX42 closed 10 years ago
Hm, that could work.
One question though, if I added a wrapper for Lua tables, and allowed passing them to C++, would also work? I think not being able to pass tables around is probably a rather big missing feature. At any rate, adding a table wrapper is going to happen.
Well I don't pass tables from C++ to Lua. And when I'm dealing with Lua tables in C++, I actually only need somekind of comparable ref: not the actual table and its content. I just want to be able to "compare types".
Anyway we could have a LuaGlueTable object with get/set methods: those won't weight anything since they'll just mess with the Lua stack when called. Right?
I guess the two features can be implemented in a single class then...
Yeah, I meant passing tables from lua to C++.
But yeah, I see what you want.. I'm just not sure it needs to be implemented in the core like that. What about adding a global function that grabs the type from any LuaGlue object/class? then you can pass that in as a string (not sure exporting the class idx is a good idea, its an internal implementation detail, and the actual integer value will change based on the order things are added to the symtab).
Ok, I've pushed up a "typeid" function that can be called on a Class or an instance. Let me know if this works for you.
closing for now. if theres something I've missed, please reopen.
Hi,
the idea is the same as described in #25 but for Lua "classes" tables. In C++, there is no way to manipulate a "class object". Yet, as Lua stores classes as tables, we can easily emulate some aspects of C++ meta-programming if we were able to get a reference to a comparable Lua class table object.
So I was thinking about having a LuaGlueClassRef and the required stack<> specializations. This class should only store the things required to identify and compare Lua class bound from C++ using LuaGlue. For example, we could compare their METATABLE_CLASSIDX_FIELD field.
What do you think?