LUABind: Export all classes in a single file?
Is it possible to export all your classes to lua in a single file?
I have created a file called lua_exports.cpp and i include the headers for the classes i wish to export and the headers for luabind, and i procede to try and export a class using the module syntax but it will not compile.
The compiler appears to not like the syntax for exporting the classes. i have gotten this to work before in a file in which the class was defined.. but that method seems a little messy.
thanks,
-gf
Well if you're exposing methods that aren't public, then a global free function will not be able to bind them to Luabind.
Good design says you shouldn't be giving scripts access to functions that aren't public anyway; but if you absolutely need to you could always use the friend keyword...
Good design says you shouldn't be giving scripts access to functions that aren't public anyway; but if you absolutely need to you could always use the friend keyword...
void registerLuaBindings(lua_State* L) { module(L) [ class_<MyClass>("MyClass") .def("privateFunction",&MyClass::privateFunction) ];}...class MyClass {private: int privateFunction() { return 42; } friend void registerLuaBindings(lua_State* L);};
Yeah, i realize that.
Im just trying to create a single file in which everything i need exported is exported.
So i include all the headers for the classes whos methods i am exporting, and then export them all in a single function call.
However this is not working, i get alot of wierd template errors and syntax errors.
The only way i can get the exporting to work is if i have the class declaration and definition in the same file in which i am attempting to export.
thanks,
-gf
Im just trying to create a single file in which everything i need exported is exported.
So i include all the headers for the classes whos methods i am exporting, and then export them all in a single function call.
However this is not working, i get alot of wierd template errors and syntax errors.
The only way i can get the exporting to work is if i have the class declaration and definition in the same file in which i am attempting to export.
thanks,
-gf
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement