Re: Problem with derived classes and overloaded member functions
"Saner Daniel" <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
Thank you for the quick response. (I hope I didn't mess up the 'reply-to') Unfortunately this was not the problem, I am always calling the function with the double dot. In fact, the error message is exactly the same though as if I was writing it with the dot and no 'self' argument. I'm afraid to say that only now I noticed that the problem does in fact not relate to the functions being overloaded. I failed to notice that by chance, *all* functions of the class in questions were overloaded. I added a non-overloaded dummy function to the class and it gives the same error: > obj:doNothing() No matching overload found, candidates: void doNothing(PluginCLGeneric&) I was thinking that maybe this is a problem related to how I register the object itself with Lua. The object is not created directly by calling the constructor from Lua, but a factory function which takes the name to give the object as a string argument. Calling this factory from Lua creates the object and then registers it as a global: luabind::globals(L)[objectName] = createdInstance; where 'createdInstance' is a pointer to the created object. Also, the class of the object and its functions have been registered with Luabind beforehand. This multi-step process was necessary due to the plugin architecture I am using it for. The process cannot be a complete failure though, as the object is accessible from Lua under 'objectName', and also the functions of the class have been registered. If any of these are not given, the error message does not reference the possible overload candidates anymore. As the exact same procedure for an object of a non-derived class that is created at startup works flawlessly, I am lead to believe that it is indeed a problem of inheritance, but I was still not able to find the culprit. Maybe Lua is confused about the class of the created object? Daniel > How are you calling the 'help' function in Lua? > > Remember that: > > classInstance:method( param ) > > is just syntactic sugar for > > classInstance.method( classInstance, param ) > > so in your case if you called help as > > instance.help() > > it will not match any of your bound functions, as the 'self' argument is > not given. I personally see this all the time, as I have a Lua based > console in the game I'm writing, and I often misstype '.' where I should > have written ":" > > Nigel ------------------------------------------------------------------------------ Download Intel® 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