From: John L. <jr...@us...> - 2007-12-07 02:13:43
|
Update of /cvsroot/wxlua/wxLua/apps/wxluacan/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv12976/wxLua/apps/wxluacan/src Modified Files: wxluacan.cpp wxluacan.h wxluacan_bind.cpp Log Message: Too many changes to list... A large portion of the internal workings of the wxLuaState have been rewritten. All of the data that was stored in wxLuaStateData that might be needed by a function taking a lua_State* is now in the LUA_REGISTRYINDEX. C functions have been added to access these values. The generated bindings no longer need to have "wxLuaState wxlState(L);" since everything can be done with the C functions. The result is that wxLua should be faster. Index: wxluacan.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxluacan/src/wxluacan.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** wxluacan.cpp 18 Jun 2007 21:40:26 -0000 1.33 --- wxluacan.cpp 7 Dec 2007 02:13:09 -0000 1.34 *************** *** 33,41 **** static int LUACALL wxLua_wxlCanObj_AddObject(lua_State *L) { - wxLuaState wxlState(L); // wxlCanObj canobj ! wxlCanObj * canobj = (wxlCanObj *)wxlState.GetUserDataType(2, s_wxluatag_wxlCanObj); // get this ! wxlCanObj * self = (wxlCanObj *)wxlState.GetUserDataType(1, s_wxluatag_wxlCanObj); // call AddObject self->AddObject(canobj); --- 33,40 ---- static int LUACALL wxLua_wxlCanObj_AddObject(lua_State *L) { // wxlCanObj canobj ! wxlCanObj * canobj = (wxlCanObj *)wxluaT_getuserdatatype(L, 2, s_wxluatag_wxlCanObj); // get this ! wxlCanObj * self = (wxlCanObj *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxlCanObj); // call AddObject self->AddObject(canobj); *************** *** 50,57 **** static int LUACALL wxLua_wxlCanObj_GetX(lua_State *L) { - wxLuaState wxlState(L); double returns; // get this ! wxlCanObj * self = (wxlCanObj *)wxlState.GetUserDataType(1, s_wxluatag_wxlCanObj); // call GetX returns = (self->GetX()); --- 49,55 ---- static int LUACALL wxLua_wxlCanObj_GetX(lua_State *L) { double returns; // get this ! wxlCanObj * self = (wxlCanObj *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxlCanObj); // call GetX returns = (self->GetX()); *************** *** 68,75 **** static int LUACALL wxLua_wxlCanObj_GetY(lua_State *L) { - wxLuaState wxlState(L); double returns; // get this ! wxlCanObj * self = (wxlCanObj *)wxlState.GetUserDataType(1, s_wxluatag_wxlCanObj); // call GetY returns = (self->GetY()); --- 66,72 ---- static int LUACALL wxLua_wxlCanObj_GetY(lua_State *L) { double returns; // get this ! wxlCanObj * self = (wxlCanObj *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxlCanObj); // call GetY returns = (self->GetY()); *************** *** 88,96 **** static int LUACALL wxLua_wxlCanObj_SetBrush(lua_State *L) { - wxLuaState wxlState(L); // const wxBrush brush ! const wxBrush * brush = (const wxBrush *)wxlState.GetUserDataType(2, s_wxluatag_wxBrush); // get this ! wxlCanObj * self = (wxlCanObj *)wxlState.GetUserDataType(1, s_wxluatag_wxlCanObj); // call SetBrush self->SetBrush(*brush); --- 85,92 ---- static int LUACALL wxLua_wxlCanObj_SetBrush(lua_State *L) { // const wxBrush brush ! const wxBrush * brush = (const wxBrush *)wxluaT_getuserdatatype(L, 2, s_wxluatag_wxBrush); // get this ! wxlCanObj * self = (wxlCanObj *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxlCanObj); // call SetBrush self->SetBrush(*brush); *************** *** 105,113 **** static int LUACALL wxLua_wxlCanObj_SetPen(lua_State *L) { - wxLuaState wxlState(L); // const wxPen pen ! const wxPen * pen = (const wxPen *)wxlState.GetUserDataType(2, s_wxluatag_wxPen); // get this ! wxlCanObj * self = (wxlCanObj *)wxlState.GetUserDataType(1, s_wxluatag_wxlCanObj); // call SetPen self->SetPen(*pen); --- 101,108 ---- static int LUACALL wxLua_wxlCanObj_SetPen(lua_State *L) { // const wxPen pen ! const wxPen * pen = (const wxPen *)wxluaT_getuserdatatype(L, 2, s_wxluatag_wxPen); // get this ! wxlCanObj * self = (wxlCanObj *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxlCanObj); // call SetPen self->SetPen(*pen); *************** *** 124,128 **** static int LUACALL wxLua_wxlCanObj_SetPending(lua_State *L) { - wxLuaState wxlState(L); // get number of arguments int argCount = lua_gettop(L); --- 119,122 ---- *************** *** 130,134 **** bool pending = (argCount >= 2 ? wxlua_getbooleantype(L, 2) : true); // get this ! wxlCanObj * self = (wxlCanObj *)wxlState.GetUserDataType(1, s_wxluatag_wxlCanObj); // call SetPending self->SetPending(pending); --- 124,128 ---- bool pending = (argCount >= 2 ? wxlua_getbooleantype(L, 2) : true); // get this ! wxlCanObj * self = (wxlCanObj *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxlCanObj); // call SetPending self->SetPending(pending); *************** *** 143,147 **** static int LUACALL wxLua_wxlCanObj_SetPos(lua_State *L) { - wxLuaState wxlState(L); // double y double y = (double)wxlua_getnumbertype(L, 3); --- 137,140 ---- *************** *** 149,153 **** double x = (double)wxlua_getnumbertype(L, 2); // get this ! wxlCanObj * self = (wxlCanObj *)wxlState.GetUserDataType(1, s_wxluatag_wxlCanObj); // call SetPos self->SetPos(x, y); --- 142,146 ---- double x = (double)wxlua_getnumbertype(L, 2); // get this ! wxlCanObj * self = (wxlCanObj *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxlCanObj); // call SetPos self->SetPos(x, y); *************** *** 163,167 **** { wxluabind_removetableforcall(L); - wxLuaState wxlState(L); wxlCanObj *returns; // get number of arguments --- 156,159 ---- *************** *** 174,178 **** returns = new wxlCanObj(x, y); // push the constructed class pointer ! wxlState.PushUserDataType(s_wxluatag_wxlCanObj, returns); return 1; --- 166,170 ---- returns = new wxlCanObj(x, y); // push the constructed class pointer ! wxluaT_pushuserdatatype(L, s_wxluatag_wxlCanObj, returns); return 1; *************** *** 215,219 **** { wxluabind_removetableforcall(L); - wxLuaState wxlState(L); wxlCanObjRect *returns; // double h --- 207,210 ---- *************** *** 228,232 **** returns = new wxlCanObjRect(x, y, w, h); // push the constructed class pointer ! wxlState.PushUserDataType(s_wxluatag_wxlCanObjRect, returns); return 1; --- 219,223 ---- returns = new wxlCanObjRect(x, y, w, h); // push the constructed class pointer ! wxluaT_pushuserdatatype(L, s_wxluatag_wxlCanObjRect, returns); return 1; *************** *** 258,262 **** { wxluabind_removetableforcall(L); - wxLuaState wxlState(L); wxlCanObjCircle *returns; // double r --- 249,252 ---- *************** *** 269,273 **** returns = new wxlCanObjCircle(x, y, r); // push the constructed class pointer ! wxlState.PushUserDataType(s_wxluatag_wxlCanObjCircle, returns); return 1; --- 259,263 ---- returns = new wxlCanObjCircle(x, y, r); // push the constructed class pointer ! wxluaT_pushuserdatatype(L, s_wxluatag_wxlCanObjCircle, returns); return 1; *************** *** 299,306 **** { wxluabind_removetableforcall(L); - wxLuaState wxlState(L); wxlCanObjScript *returns; // const wxString name ! const wxString name = wxlState.GetwxStringType(3); // double y double y = (double)wxlua_getnumbertype(L, 2); --- 289,295 ---- { wxluabind_removetableforcall(L); wxlCanObjScript *returns; // const wxString name ! const wxString name = wxlua_getwxstringtype(L, 3); // double y double y = (double)wxlua_getnumbertype(L, 2); *************** *** 310,314 **** returns = new wxlCanObjScript(x, y, name); // push the constructed class pointer ! wxlState.PushUserDataType(s_wxluatag_wxlCanObjScript, returns); return 1; --- 299,303 ---- returns = new wxlCanObjScript(x, y, name); // push the constructed class pointer ! wxluaT_pushuserdatatype(L, s_wxluatag_wxlCanObjScript, returns); return 1; *************** *** 339,347 **** static int LUACALL wxLua_wxlCanObjAddScript_SetScript(lua_State *L) { - wxLuaState wxlState(L); // const wxString script ! const wxString script = wxlState.GetwxStringType(2); // get this ! wxlCanObjAddScript * self = (wxlCanObjAddScript *)wxlState.GetUserDataType(1, s_wxluatag_wxlCanObjAddScript); // call SetScript self->SetScript(script); --- 328,335 ---- static int LUACALL wxLua_wxlCanObjAddScript_SetScript(lua_State *L) { // const wxString script ! const wxString script = wxlua_getwxstringtype(L, 2); // get this ! wxlCanObjAddScript * self = (wxlCanObjAddScript *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxlCanObjAddScript); // call SetScript self->SetScript(script); *************** *** 357,364 **** { wxluabind_removetableforcall(L); - wxLuaState wxlState(L); wxlCanObjAddScript *returns; // const wxString script ! const wxString script = wxlState.GetwxStringType(3); // double y double y = (double)wxlua_getnumbertype(L, 2); --- 345,351 ---- { wxluabind_removetableforcall(L); wxlCanObjAddScript *returns; // const wxString script ! const wxString script = wxlua_getwxstringtype(L, 3); // double y double y = (double)wxlua_getnumbertype(L, 2); *************** *** 368,372 **** returns = new wxlCanObjAddScript(x, y, script); // push the constructed class pointer ! wxlState.PushUserDataType(s_wxluatag_wxlCanObjAddScript, returns); return 1; --- 355,359 ---- returns = new wxlCanObjAddScript(x, y, script); // push the constructed class pointer ! wxluaT_pushuserdatatype(L, s_wxluatag_wxlCanObjAddScript, returns); return 1; *************** *** 398,406 **** static int LUACALL wxLua_wxlCan_AddObject(lua_State *L) { - wxLuaState wxlState(L); // wxlCanObj canobj ! wxlCanObj * canobj = (wxlCanObj *)wxlState.GetUserDataType(2, s_wxluatag_wxlCanObj); // get this ! wxlCan * self = (wxlCan *)wxlState.GetUserDataType(1, s_wxluatag_wxlCan); // call AddObject self->AddObject(canobj); --- 385,392 ---- static int LUACALL wxLua_wxlCan_AddObject(lua_State *L) { // wxlCanObj canobj ! wxlCanObj * canobj = (wxlCanObj *)wxluaT_getuserdatatype(L, 2, s_wxluatag_wxlCanObj); // get this ! wxlCan * self = (wxlCan *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxlCan); // call AddObject self->AddObject(canobj); *************** *** 415,426 **** static int LUACALL wxLua_wxlCan_GetCmdh(lua_State *L) { - wxLuaState wxlState(L); wxlLuaCanCmd *returns; // get this ! wxlCan * self = (wxlCan *)wxlState.GetUserDataType(1, s_wxluatag_wxlCan); // call GetCmdh returns = (wxlLuaCanCmd *)self->GetCmdh(); // push the result datatype ! wxlState.PushUserDataType(s_wxluatag_wxlLuaCanCmd, returns); return 1; --- 401,411 ---- static int LUACALL wxLua_wxlCan_GetCmdh(lua_State *L) { wxlLuaCanCmd *returns; // get this ! wxlCan * self = (wxlCan *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxlCan); // call GetCmdh returns = (wxlLuaCanCmd *)self->GetCmdh(); // push the result datatype ! wxluaT_pushuserdatatype(L, s_wxluatag_wxlLuaCanCmd, returns); return 1; *************** *** 433,440 **** static int LUACALL wxLua_wxlCan_GetYaxis(lua_State *L) { - wxLuaState wxlState(L); bool returns; // get this ! wxlCan * self = (wxlCan *)wxlState.GetUserDataType(1, s_wxluatag_wxlCan); // call GetYaxis returns = (self->GetYaxis()); --- 418,424 ---- static int LUACALL wxLua_wxlCan_GetYaxis(lua_State *L) { bool returns; // get this ! wxlCan * self = (wxlCan *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxlCan); // call GetYaxis returns = (self->GetYaxis()); *************** *** 454,473 **** { wxluabind_removetableforcall(L); - wxLuaState wxlState(L); wxlCan *returns; // get number of arguments int argCount = lua_gettop(L); // const wxSize size = wxDefaultSize ! const wxSize * size = (argCount >= 4 ? (const wxSize *)wxlState.GetUserDataType(4, s_wxluatag_wxSize) : &wxDefaultSize); // const wxPoint pos = wxDefaultPosition ! const wxPoint * pos = (argCount >= 3 ? (const wxPoint *)wxlState.GetUserDataType(3, s_wxluatag_wxPoint) : &wxDefaultPosition); // wxWindowID id = -1 wxWindowID id = (argCount >= 2 ? (wxWindowID)wxlua_getnumbertype(L, 2) : -1); // wxWindow parent ! wxWindow * parent = (wxWindow *)wxlState.GetUserDataType(1, s_wxluatag_wxWindow); // call constructor returns = new wxlCan(parent, id, *pos, *size); // push the constructed class pointer ! wxlState.PushUserDataType(s_wxluatag_wxlCan, returns); return 1; --- 438,456 ---- { wxluabind_removetableforcall(L); wxlCan *returns; // get number of arguments int argCount = lua_gettop(L); // const wxSize size = wxDefaultSize ! const wxSize * size = (argCount >= 4 ? (const wxSize *)wxluaT_getuserdatatype(L, 4, s_wxluatag_wxSize) : &wxDefaultSize); // const wxPoint pos = wxDefaultPosition ! const wxPoint * pos = (argCount >= 3 ? (const wxPoint *)wxluaT_getuserdatatype(L, 3, s_wxluatag_wxPoint) : &wxDefaultPosition); // wxWindowID id = -1 wxWindowID id = (argCount >= 2 ? (wxWindowID)wxlua_getnumbertype(L, 2) : -1); // wxWindow parent ! wxWindow * parent = (wxWindow *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxWindow); // call constructor returns = new wxlCan(parent, id, *pos, *size); // push the constructed class pointer ! wxluaT_pushuserdatatype(L, s_wxluatag_wxlCan, returns); return 1; *************** *** 507,511 **** static int LUACALL wxLua_wxlLuaCanCmd_MoveObject(lua_State *L) { - wxLuaState wxlState(L); // double y double y = (double)wxlua_getnumbertype(L, 4); --- 490,493 ---- *************** *** 515,519 **** int index = (int)wxlua_getnumbertype(L, 2); // get this ! wxlLuaCanCmd * self = (wxlLuaCanCmd *)wxlState.GetUserDataType(1, s_wxluatag_wxlLuaCanCmd); // call MoveObject self->MoveObject(index, x, y); --- 497,501 ---- int index = (int)wxlua_getnumbertype(L, 2); // get this ! wxlLuaCanCmd * self = (wxlLuaCanCmd *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxlLuaCanCmd); // call MoveObject self->MoveObject(index, x, y); *************** *** 529,533 **** { wxluabind_removetableforcall(L); - wxLuaState wxlState(L); wxlLuaCanCmd *returns; // get number of arguments --- 511,514 ---- *************** *** 536,544 **** int maxCommands = (argCount >= 2 ? (int)wxlua_getnumbertype(L, 2) : -1); // wxlCan canvas ! wxlCan * canvas = (wxlCan *)wxlState.GetUserDataType(1, s_wxluatag_wxlCan); // call constructor returns = new wxlLuaCanCmd(canvas, maxCommands); // push the constructed class pointer ! wxlState.PushUserDataType(s_wxluatag_wxlLuaCanCmd, returns); return 1; --- 517,525 ---- int maxCommands = (argCount >= 2 ? (int)wxlua_getnumbertype(L, 2) : -1); // wxlCan canvas ! wxlCan * canvas = (wxlCan *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxlCan); // call constructor returns = new wxlLuaCanCmd(canvas, maxCommands); // push the constructed class pointer ! wxluaT_pushuserdatatype(L, s_wxluatag_wxlLuaCanCmd, returns); return 1; Index: wxluacan_bind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxluacan/src/wxluacan_bind.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** wxluacan_bind.cpp 17 Nov 2007 00:14:53 -0000 1.25 --- wxluacan_bind.cpp 7 Dec 2007 02:13:09 -0000 1.26 *************** *** 88,97 **** static int LUACALL wxLua_function_GetCan(lua_State *L) { - wxLuaState wxlState(L); wxlCan *returns; // call GetCan returns = (wxlCan *)GetCan(); // push the result datatype ! wxlState.PushUserDataType(s_wxluatag_wxlCan, returns); return 1; --- 88,96 ---- static int LUACALL wxLua_function_GetCan(lua_State *L) { wxlCan *returns; // call GetCan returns = (wxlCan *)GetCan(); // push the result datatype ! wxluaT_pushuserdatatype(L, s_wxluatag_wxlCan, returns); return 1; *************** *** 102,111 **** static int LUACALL wxLua_function_GetCmdhMain(lua_State *L) { - wxLuaState wxlState(L); wxlLuaCanCmd *returns; // call GetCmdhMain returns = (wxlLuaCanCmd *)GetCmdhMain(); // push the result datatype ! wxlState.PushUserDataType(s_wxluatag_wxlLuaCanCmd, returns); return 1; --- 101,109 ---- static int LUACALL wxLua_function_GetCmdhMain(lua_State *L) { wxlLuaCanCmd *returns; // call GetCmdhMain returns = (wxlLuaCanCmd *)GetCmdhMain(); // push the result datatype ! wxluaT_pushuserdatatype(L, s_wxluatag_wxlLuaCanCmd, returns); return 1; Index: wxluacan.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxluacan/src/wxluacan.h,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** wxluacan.h 17 Nov 2007 00:14:53 -0000 1.35 --- wxluacan.h 7 Dec 2007 02:13:09 -0000 1.36 *************** *** 18,24 **** // the current version of the bindings. // See 'bindings/genwxbind.lua' and 'modules/wxlua/include/wxldefs.h' ! #if WXLUA_BINDING_VERSION > 18 # error "The WXLUA_BINDING_VERSION in the bindings is too old, regenerate bindings." ! #endif //WXLUA_BINDING_VERSION > 18 // --------------------------------------------------------------------------- --- 18,24 ---- // the current version of the bindings. // See 'bindings/genwxbind.lua' and 'modules/wxlua/include/wxldefs.h' ! #if WXLUA_BINDING_VERSION > 19 # error "The WXLUA_BINDING_VERSION in the bindings is too old, regenerate bindings." ! #endif //WXLUA_BINDING_VERSION > 19 // --------------------------------------------------------------------------- |