From: John L. <jr...@us...> - 2007-12-18 05:56:20
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv8412/wxLua/modules/wxlua/src Modified Files: wxlbind.cpp Log Message: Test using experimental function calls w/o the wxLuaFunction userdata intermediatary with the __call metatable function. Index: wxlbind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlbind.cpp,v retrieving revision 1.105 retrieving revision 1.106 diff -C2 -d -r1.105 -r1.106 *** wxlbind.cpp 13 Dec 2007 06:23:55 -0000 1.105 --- wxlbind.cpp 18 Dec 2007 05:56:15 -0000 1.106 *************** *** 93,96 **** --- 93,104 ---- // ---------------------------------------------------------------------------- + + static int LUACALL wxlua_CallOverloadedFunction(lua_State* L) + { + wxLuaBindMethod* wxlMethod = (wxLuaBindMethod *)lua_touserdata(L, lua_upvalueindex(1)); // lightuserdata + wxCHECK_MSG(wxlMethod, 0, wxT("Invalid wxLuaBindMethod")); + return wxlua_CallOverloadedFunction(L, wxlMethod); + } + int LUACALL wxlua_CallOverloadedFunction(lua_State* L, struct wxLuaBindMethod* wxlMethod) { *************** *** 656,660 **** // name is NULL if it's not a string wxlua_error(L, wxString::Format(_("wxLua: Attempt to call a class method using '%s' on a '%s' type."), ! lua2wx(lua_typename(L, lua_type(L, 2))).c_str(), lua2wx(wxlClass ? wxlClass->name : "").c_str())); } else if ((wxlClass != NULL) && wxlua_iswxuserdata(L, 1) && (wxluaT_gettag(L, 1) == *wxlClass->class_tag)) --- 664,668 ---- // name is NULL if it's not a string wxlua_error(L, wxString::Format(_("wxLua: Attempt to call a class method using '%s' on a '%s' type."), ! wxlua_gettypename(L, 2).c_str(), lua2wx(wxlClass ? wxlClass->name : "").c_str())); } else if ((wxlClass != NULL) && wxlua_iswxuserdata(L, 1) && (wxluaT_gettag(L, 1) == *wxlClass->class_tag)) *************** *** 698,704 **** --- 706,724 ---- found = true; result = 1; + + #if 1 + // experimental function calls w/o using the wxLuaFunction + if (wxlMethod->basemethod) + { + lua_pushlightuserdata(L, wxlMethod); + lua_pushcclosure(L, wxlua_CallOverloadedFunction, 1); + } + else + lua_pushcclosure(L, wxlMethod->funcs[0].func, 0); + #else wxLuaFunction *wxlFunc = new wxLuaFunction(wxlMethod, pObject); // Don't track the wxLuaFunction for speed wxluaT_pushusertag(L, wxlFunc, g_wxluatag_wxLuaFunction, false); + #endif } } |