lua / luabind - Add and overwrite class methods through lua

I'm using lua 5.2.2 with luabind 0.9.

I'd like to be able to add additional class-methods through lua for any classes that I've bound in c++, but I'm unsure how to do it.

The problem is that luabind uses a function as the __index-metamethod for any bound classes instead of a table, so I don't see a way to access the class-methods at all.

e.g., I'm binding my classes like this:

1
2
3
4
5
6
luabind::module(lua)
[
	luabind::class_<testClass>("TestClass")
	.def(luabind::constructor<>())
	.def("TestFunc",&TestFunc)
];


What I essentially want to do is to add a lua-function to the list of methods for this class, and be able to overwrite existing ones:

1
2
3
4
local t = tableOfClassMethods
local r = t.TestFunc -- Reference to the c++-function we've bound
t.SomeFunction = function(o) end -- New function for all objects of this class
t.TestFunc = function(o) end -- Should overwrite the c++-function of the same name 


Any help would be appreciated.
You should ask this on a(n) LUA forum, since this is more of a(n) LUA question than a C++ question.
The official lua forum is 'down for maintanence' and has been for a while, so I don't really know where else I could get help. (Already tried on stack overflow as well)
Topic archived. No new replies allowed.