Guppy Posted September 21, 2014 Share Posted September 21, 2014 template <typename T,int (T::*memberFunction) (lua_State *L)> class luaMemberFunction: public luaType{ public: luaMemberFunction(T* _objectPtr):objectPtr(_objectPtr){} virtual void push() { lua_pushlightuserdata( Leadwerks::Interpreter::L, objectPtr ); lua_pushcclosure(Leadwerks::Interpreter::L,forwarder,1); } T* objectPtr; static int forwarder(lua_State *L){ //return ((T*)lua_touserdata( L, lua_upvalueindex(1) ))->*memberFunction(L); return ((T*)lua_touserdata( L, lua_upvalueindex(1) )).*memberFunction(L); } }; called else where as luaType temp= new luaMemberFunction<eventForwarder,&eventForwarder::testMemberFunction>(this); produces this error ../../Source/util/lua_tablehelper.h|91|error: must use ‘.*’ or ‘->*’ to call pointer-to-member function in ‘&MyGUI::eventForwarder::testMemberFunction (...)’, e.g. ‘(... ->* &MyGUI::eventForwarder::testMemberFunction) (...)’| As you can properly tell from the comment above I've tried both - I feel like I'm missing something obvious but after two hours of starting at the code I'm still at a loss. Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
Guppy Posted September 21, 2014 Author Share Posted September 21, 2014 It should be return (((T*)lua_touserdata( L, lua_upvalueindex(1) ))->*memberFunction)(L); I'd like to thank the forum for playing the part of rubber duck Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.