|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Deriving inherited classes with LuabindSo if I have a class structure in C++ as follows
class A { virtual void f(); }; class B : public A { }; class C : public B { }; And I want to set up a wrapper so I can derive classes from A and B in Lua, how exactly should I go about that? I can get it to work properly with just the wrapper for A, but I don't know how to do it for the child classes. If, in the luabind defs, I use luabind::bases<A, WrapperA>, it crashes. Thanks. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ luabind-user mailing list luabind-user@... https://lists.sourceforge.net/lists/listinfo/luabind-user |
|
|
Re: Deriving inherited classes with LuabindSeems I misworded my question. The issue isn't doing the derivation - at least, it may not be. Turns out I'm not even far enough to know, because I can't call the function I overrode in Lua from C++. I followed the example from the documentation, and my Lua looks like:
globalone = base() function globalone:f() print("here!") end set(newone) set() just takes a pointer to a base, and sets a global variable in c++ to it. I then call this in c++: globalBase->f(); but I get the output from the C++ version of the function. My bindings are: luabind::module(myLuaState) [ luabind::class_<base, base_wrapper>("base") .def(luabind::constructor<>()) .def("f", &base::f, &base_wrapper::default_f), luabind::def("set", &set) ]; And the class declarations are: class base { public: base() { std::cout << "Making a base in C++" << std::endl; } virtual void f() { std::cout << "C++ Version" << std::endl; } }; base* globalBase; struct base_wrapper : base, luabind::wrap_base { base_wrapper() : base() { std::cout << "Making a base_wrapper in C++" << std::endl; } virtual void f() { call<void>("f"); } static void default_f(base* ptr) { return ptr->base::f(); } }; void set(base* ptr) { std::cout << "setting" << std::endl; globalBase = ptr; }
On Sun, Aug 16, 2009 at 10:08 PM, Michael Gulak <michaelgulak@...> wrote: So if I have a class structure in C++ as follows ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ luabind-user mailing list luabind-user@... https://lists.sourceforge.net/lists/listinfo/luabind-user |
| Free embeddable forum powered by Nabble | Forum Help |