Re: Problem with derived classes and overloaded member functions

Daniel Saner <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
> It shouldn't be. Everything in your post looks reasonable, so I guess
> this could be a bug. Could you possibly reduce this to a failing test
> that I can run?

It seems to be only happening with functions that are defined in the 
inheriting class, but were not declared in the base class. As long as it 
is declared in the base class and redefined in the inheriting class, the 
correct, redefined function is called. I can boil it all down to this:

I have a base class 'IPlugin' with a function
void base_f() {
  cout << "Base" << endl;
}

which I register with luabind like this:
luabind::module(L) [
        luabind::class_<IPlugin>("IPlugin")
        .def("base_f", &IPlugin::base_f)
];

I also have a derived class 'GenericPlugin':
class GenericPlugin : public IPlugin

which redefines base_f:
void base_f() {
  cout << "Derived" << endl;
}

and has an additional function der_f:
void der_f() {
  cout << "New" << endl;
}

I register the derived class and the new function like this:
luabind::module(L) [
        luabind::class_<GenericPlugin, IPlugin>("GenericPlugin")
        .def(luabind::constructor<>())
        .def("der_f", &GenericPlugin::der_f)
];

I can instantiate GenericPlugin from Lua (even using the constructor 
function and subsequently registering the created object as a global 
using luabind::globals(L)) and call 'base_f()' on it, which writes 
"Derived" to cout. However, when I try to call 'der_f()' on it, I again 
get:
No matching overload found, candidates:
void der_f(GenericPlugin&)

I suppose I have completely misunderstood something about the way 
derived classes are handled in luabind?

Thanks
Daniel

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.