[luabind] Adding an overload for the assignment operator in lua for luabind classes
Brought to you by:
arvidn,
daniel_wallin
From: Abhijit N. <abh...@gm...> - 2015-10-16 08:54:31
|
Hi, Lua does not allow the assignment operator to be overloaded and has no meta function for it. I have got around this by using the proxy pattern and the __index/__newindex meta methods. Now I have begun using classes defined via luabind's object oriented system thats exposed to Lua. I am wondering if the C++ code for Luabind can be changed to allow the assignment operator to be overloaded without changing the code for the Lua interpretor itself. Perhaps such a overload would call into a new meta-method name thats not used by Lua such as '__assign()' This would not conflict with any meta method that Lua already uses and would apply only to instances of luabind classes. I am guessing that the luabind::adl::object class needs to be changed, or perhaps index_proxy. But I am not sufficiently familiar with how luabind forwards calls to existing Lua meta-methods, to its objects. Has anyone explored the C++ code in luabind that supports operator overloading in Lua? Edit: I see some attempts to add a new operator here: https://github.com/decimad/luabind-deboostified/commit/55b1bd9217205253b41ab7d4746637ee5b0d276f If I try the above with the assignment operator though, I do no see it getting called in Lua. Are there any other changes needed in C++ for this? http://stackoverflow.com/questions/33141507/adding-an-overload-for-the-assignment-operator-in-lua-for-luabind-classes Thanks, Abhi |