I’m trying to make a small C++/Lua system where I would create my objects and attach behaviors to them in Lua. Right now I’m using LuaWrapper (a small header with basic C++ to Lua stuff), my problem is that as far as I can see Lua only let me register static class methods (or non-static functions), a little research and I figured its because the Lua typedef expects a method with only one parameter lua_State* L and non-static methods have the implicit this.
I was hoping for a way to solve this without dependency on other libraries, all I need is non-static classes/properties in Lua, so I see no reason to use LuaBind+Boost or other heavy-dependant wrappers.
LuaWrapper isn’t meant to hook up directly to non-static functions in a class. I suppose it could be with some special trickery, but this is how I designed it to be used:
I usually keep the non-lua stuff in a separate file. In this case Widget.cpp/hpp. Then I have a LuaWidget file which just contains bindings like these which I write as needed. (I also have a number of snipmate snippets to make writing these functions quick and painless. If you’re using vim I’d be happy to share them)