From: John L. <jr...@us...> - 2005-11-30 04:46:28
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31708/wxLua/modules/wxlua/src Modified Files: internal.cpp wxlbind.cpp Log Message: LuaDebugTarget -> wxLuaDebugTarget wxLuaBind uses wxLuaState more switching to wxLuaState wxDEPRECATED for all C functions that require the wxLuaState (Varaibles) use class functions instead Index: internal.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/internal.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** internal.cpp 29 Nov 2005 23:52:12 -0000 1.18 --- internal.cpp 30 Nov 2005 04:46:17 -0000 1.19 *************** *** 162,166 **** { *ptr = u; ! if (tag != TLUA_NOTAG && tget(L, tag)) { if (lua_setmetatable(L, -2) == 0) --- 162,166 ---- { *ptr = u; ! if ((tag != TLUA_NOTAG) && tget(L, tag)) { if (lua_setmetatable(L, -2) == 0) *************** *** 174,178 **** void LUACALL tsettag(lua_State *L, int tag) { ! if (tag != TLUA_NOTAG && tget(L, tag)) { if (!lua_setmetatable(L, -2)) --- 174,178 ---- void LUACALL tsettag(lua_State *L, int tag) { ! if ((tag != TLUA_NOTAG) && tget(L, tag)) { if (!lua_setmetatable(L, -2)) *************** *** 242,246 **** { lua_pushstring(L, wxLuaReferences); //, strlen(wxLuaReferences)-1); // FIXME this used to be #define tpushliteralstring(str, sizeof(str)-1) - } --- 242,245 ---- *************** *** 411,419 **** // ---------------------------------------------------------------------------- ! wxLuaCheckStack::wxLuaCheckStack(lua_State *lua_state, const wxString &msg) { ! m_luastate = lua_state; m_msg = msg; ! m_top = lua_gettop(m_luastate); } --- 410,418 ---- // ---------------------------------------------------------------------------- ! wxLuaCheckStack::wxLuaCheckStack(lua_State *L, const wxString &msg) { ! m_luaState = L; m_msg = msg; ! m_top = lua_gettop(m_luaState); } *************** *** 431,467 **** #if defined(__WXMSW__) ! wxString buf = wxString::Format(_("Stack state in %s: in %u out %u\r\n"), message.c_str(), m_top, lua_gettop(m_luastate)); OutputDebugString(buf); #elif defined(__WXGTK__) || defined(__WXMAC__) ! fprintf(stderr, "Stack state in %s: in %u out %u\r\n", (const char *)wx2lua(msg), m_top, lua_gettop(m_luastate)); #endif } ! void wxLuaCheckStack::DumpGlobals(lua_State *lua_state) { wxHashTable* dumpList = new wxHashTable(wxKEY_INTEGER); ! lua_pushvalue(lua_state, LUA_GLOBALSINDEX); ! DumpTable(lua_state, lua_gettop(lua_state), wxT("Globals"), *dumpList, 0); ! lua_pop(lua_state, 1); delete dumpList; } ! void wxLuaCheckStack::DumpTable(lua_State *lua_state, const wxString &name) { wxHashTable dumpList(wxKEY_INTEGER); ! lua_pushstring(lua_state, wx2lua(name)); ! lua_gettable(lua_state, LUA_GLOBALSINDEX); ! DumpTable(lua_state, lua_gettop(lua_state), name, dumpList, 0); ! lua_pop(lua_state, 1); } ! int wxLuaCheckStack::GetTableInfo(lua_State *lua_state, int index, wxString& address, wxString& info) { ! int nTag = ttag(lua_state, index); ! int nItems = luaL_getn(lua_state, index); ! const void *pItem = lua_topointer(lua_state, index); address = wxString::Format(wxT("%p"), pItem); --- 430,466 ---- #if defined(__WXMSW__) ! wxString buf = wxString::Format(_("Stack state in %s: in %u out %u\r\n"), message.c_str(), m_top, lua_gettop(m_luaState)); OutputDebugString(buf); #elif defined(__WXGTK__) || defined(__WXMAC__) ! fprintf(stderr, "Stack state in %s: in %u out %u\r\n", (const char *)wx2lua(msg), m_top, lua_gettop(m_luaState)); #endif } ! void wxLuaCheckStack::DumpGlobals(lua_State *L) { wxHashTable* dumpList = new wxHashTable(wxKEY_INTEGER); ! lua_pushvalue(L, LUA_GLOBALSINDEX); ! DumpTable(L, lua_gettop(L), wxT("Globals"), *dumpList, 0); ! lua_pop(L, 1); delete dumpList; } ! void wxLuaCheckStack::DumpTable(lua_State *L, const wxString &name) { wxHashTable dumpList(wxKEY_INTEGER); ! lua_pushstring(L, wx2lua(name)); ! lua_gettable(L, LUA_GLOBALSINDEX); ! DumpTable(L, lua_gettop(L), name, dumpList, 0); ! lua_pop(L, 1); } ! int wxLuaCheckStack::GetTableInfo(lua_State *L, int index, wxString& address, wxString& info) { ! int nTag = ttag(L, index); ! int nItems = luaL_getn(L, index); ! const void *pItem = lua_topointer(L, index); address = wxString::Format(wxT("%p"), pItem); *************** *** 485,489 **** } ! void wxLuaCheckStack::DumpType(lua_State *lua_state, int index, wxString& type, wxString& value, wxString& info) { type = wxEmptyString; --- 484,488 ---- } ! void wxLuaCheckStack::DumpType(lua_State *L, int index, wxString& type, wxString& value, wxString& info) { type = wxEmptyString; *************** *** 491,498 **** info = wxEmptyString; ! switch (lua_type(lua_state, index)) { default: ! type = wxString::Format(wxT("%u"), lua_type(lua_state, index)); value = wxT("?"); break; --- 490,497 ---- info = wxEmptyString; ! switch (lua_type(L, index)) { default: ! type = wxString::Format(wxT("%u"), lua_type(L, index)); value = wxT("?"); break; *************** *** 505,531 **** case LUA_TNUMBER: type = wxT("Number"); ! value = MakeNumber(lua_tonumber(lua_state, index)); break; case LUA_TSTRING: type = wxT("String"); ! value = lua2wx(lua_tostring(lua_state, index)); break; case LUA_TTABLE: type = wxT("Table"); ! GetTableInfo(lua_state, index, value, info); break; case LUA_TFUNCTION: ! if (lua_iscfunction(lua_state, index)) { type = wxT("C Function"); ! value = wxString::Format(wxT("%p"), lua_tocfunction(lua_state, index)); } else { type = wxT("Lua Function"); ! value = wxString::Format(wxT("%p"), lua_topointer(lua_state, index)); } --- 504,530 ---- case LUA_TNUMBER: type = wxT("Number"); ! value = MakeNumber(lua_tonumber(L, index)); break; case LUA_TSTRING: type = wxT("String"); ! value = lua2wx(lua_tostring(L, index)); break; case LUA_TTABLE: type = wxT("Table"); ! GetTableInfo(L, index, value, info); break; case LUA_TFUNCTION: ! if (lua_iscfunction(L, index)) { type = wxT("C Function"); ! value = wxString::Format(wxT("%p"), lua_tocfunction(L, index)); } else { type = wxT("Lua Function"); ! value = wxString::Format(wxT("%p"), lua_topointer(L, index)); } *************** *** 534,538 **** case LUA_TUSERDATA: type = wxT("User Data"); ! value = GetUserDataInfo(lua_state, index); break; } --- 533,537 ---- case LUA_TUSERDATA: type = wxT("User Data"); ! value = GetUserDataInfo(L, index); break; } *************** *** 541,558 **** } ! wxString wxLuaCheckStack::GetUserDataInfo(lua_State *lua_state, int index) { wxString userdataInfo; wxString tagName; ! int nTag = ttag(lua_state, index); if (nTag != TLUA_NOTAG) ! tagName = lua2wx(GetLuaTagName(lua_state, nTag)); if (!tagName.IsEmpty()) ! userdataInfo = wxString::Format(wxT("%p (%s)"), lua_touserdata(lua_state, index), tagName.c_str()); else ! userdataInfo = wxString::Format(wxT("%p (%u)"), lua_touserdata(lua_state, index), nTag); return userdataInfo; --- 540,558 ---- } ! wxString wxLuaCheckStack::GetUserDataInfo(lua_State *L, int index) { wxString userdataInfo; wxString tagName; + wxLuaState wxlState(L); ! int nTag = ttag(L, index); if (nTag != TLUA_NOTAG) ! tagName = lua2wx(wxlState.GetLuaTagName(nTag)); if (!tagName.IsEmpty()) ! userdataInfo = wxString::Format(wxT("%p (%s)"), lua_touserdata(L, index), tagName.c_str()); else ! userdataInfo = wxString::Format(wxT("%p (%u)"), lua_touserdata(L, index), nTag); return userdataInfo; *************** *** 577,581 **** } ! void wxLuaCheckStack::DumpTable(lua_State *lua_state, int index, const wxString& tablename, wxHashTable& dumpList, int indent) { wxString indentStr; --- 577,581 ---- } ! void wxLuaCheckStack::DumpTable(lua_State *L, int index, const wxString& tablename, wxHashTable& dumpList, int indent) { wxString indentStr; *************** *** 595,606 **** indentStr += wxT(">"); ! lua_pushnil(lua_state); ! while(lua_next(lua_state, index) != 0) { wxString indexType, indexValue, indexInfo; wxString valueType, value, valueInfo; ! DumpType(lua_state, -2, indexType, indexValue, indexInfo); ! DumpType(lua_state, -1, valueType, value, valueInfo); wxString info = wxString::Format(wxT("%s%-32s\t%-15s\t%-20s\t%-10s\t%s"), --- 595,606 ---- indentStr += wxT(">"); ! lua_pushnil(L); ! while(lua_next(L, index) != 0) { wxString indexType, indexValue, indexInfo; wxString valueType, value, valueInfo; ! DumpType(L, -2, indexType, indexValue, indexInfo); ! DumpType(L, -1, valueType, value, valueInfo); wxString info = wxString::Format(wxT("%s%-32s\t%-15s\t%-20s\t%-10s\t%s"), *************** *** 622,629 **** dumpList.Put(key, (wxObject*)true); ! int tableIndex = lua_gettop(lua_state); ! // lua_pushvalue(lua_state, lua_gettop(lua_state)); ! DumpTable(lua_state, tableIndex, tname, dumpList, indent+1); } else --- 622,629 ---- dumpList.Put(key, (wxObject*)true); ! int tableIndex = lua_gettop(L); ! // lua_pushvalue(L, lua_gettop(L)); ! DumpTable(L, tableIndex, tname, dumpList, indent+1); } else *************** *** 638,644 **** // fprintf(stderr, wx2lua(outputIndex + outputValue)); //#endif ! lua_pop(lua_state, 1); } ! lua_pop(lua_state, 1); wxLog::FlushActive(); --- 638,644 ---- // fprintf(stderr, wx2lua(outputIndex + outputValue)); //#endif ! lua_pop(L, 1); } ! lua_pop(L, 1); wxLog::FlushActive(); *************** *** 662,681 **** } - bool IsParentWindowTracked(wxList *list, wxWindow* win) - { - wxCHECK_MSG(list && win, false, wxT("Invalid list or parent")); - wxWindow *parent = win; - - while (parent) - { - if (list->Find(parent)) - return true; - - parent = parent->GetParent(); - } - - return false; - } - void LUACALL addToTrackedWindowList(lua_State *L, wxWindow *pWindow) { --- 662,665 ---- *************** *** 1239,1243 **** wxCHECK_MSG(wxlState.Ok(), 0, wxT("Invalid wxLuaState")); ! if (lua_isuserdata(L, 1) && (lua_islightuserdata(L, 1) == 0) && (ttag(L, 1) == wxlState.GetLuaFunctionTag())) { wxLuaFunction *pFunction = (wxLuaFunction *)wxlState.ttouserdata(1); --- 1223,1227 ---- wxCHECK_MSG(wxlState.Ok(), 0, wxT("Invalid wxLuaState")); ! if (lua_isuserdata(L, 1) && (lua_islightuserdata(L, 1) == 0) && (wxlState.ttag(1) == wxlState.GetLuaFunctionTag())) { wxLuaFunction *pFunction = (wxLuaFunction *)wxlState.ttouserdata(1); Index: wxlbind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlbind.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** wxlbind.cpp 29 Nov 2005 23:52:12 -0000 1.6 --- wxlbind.cpp 30 Nov 2005 04:46:17 -0000 1.7 *************** *** 71,78 **** } ! void wxLuaBinding::RegisterBinding(lua_State *L, bool registerTypes) { ! int luaTable = RegisterFunctions(L, registerTypes); // create a global lua_pushstring(L, wx2lua(nameSpace)); --- 71,79 ---- } ! void wxLuaBinding::RegisterBinding(const wxLuaState& wxlState, bool registerTypes) { ! int luaTable = RegisterFunctions(wxlState, registerTypes); + lua_State *L = wxlState.GetLuaState(); // create a global lua_pushstring(L, wx2lua(nameSpace)); *************** *** 82,87 **** } ! void wxLuaBinding::UnRegisterBinding(lua_State *L) { lua_pushstring(L, wx2lua(nameSpace)); lua_pushnil(L); --- 83,89 ---- } ! void wxLuaBinding::UnRegisterBinding(const wxLuaState& wxlState) { + lua_State *L = wxlState.GetLuaState(); lua_pushstring(L, wx2lua(nameSpace)); lua_pushnil(L); *************** *** 89,96 **** } ! int LUACALL wxLuaBinding::RegisterFunctions(lua_State *L, bool registerTypes) { if (!registerTypes && !m_typesRegistered) ! terror(L, "wxLua: First time registration must register types"); // create references table in registry --- 91,101 ---- } ! int LUACALL wxLuaBinding::RegisterFunctions(const wxLuaState& wxlState_, bool registerTypes) { + wxLuaState wxlState(wxlState_); if (!registerTypes && !m_typesRegistered) ! wxlState.terror("wxLua: First time registration must register types"); ! ! lua_State *L = wxlState.GetLuaState(); // create references table in registry *************** *** 101,105 **** // create a tag for the wxLua table if (registerTypes) ! m_wxLuaTable = tnewtag(L); // create the wxLua table --- 106,110 ---- // create a tag for the wxLua table if (registerTypes) ! m_wxLuaTable = wxlState.tnewtag(); // create the wxLua table *************** *** 108,120 **** // set the table tag ! tsettag (L, m_wxLuaTable); // prevent changes from lua scripts ! tsettagmethod (L, m_wxLuaTable, "__newindex", wxLuaTableErrorHandler); // register all out classes etc. in the wxLua table ! RegisterGeneratedClasses(L, tableOffset, registerTypes); ! OnRegister(L, registerTypes, tableOffset); m_typesRegistered = true; --- 113,125 ---- // set the table tag ! wxlState.tsettag(m_wxLuaTable); // prevent changes from lua scripts ! wxlState.tsettagmethod(m_wxLuaTable, "__newindex", wxLuaTableErrorHandler); // register all out classes etc. in the wxLua table ! RegisterGeneratedClasses(wxlState, tableOffset, registerTypes); ! OnRegister(wxlState, registerTypes, tableOffset); m_typesRegistered = true; *************** *** 123,127 **** } ! void LUACALL wxLuaBinding::RegisterGeneratedClasses(lua_State *L, int tableOffset, bool registerTypes) { static const luaL_reg funcTable[] = --- 128,132 ---- } ! void LUACALL wxLuaBinding::RegisterGeneratedClasses(const wxLuaState& wxlState_, int tableOffset, bool registerTypes) { static const luaL_reg funcTable[] = *************** *** 131,139 **** {"__newindex", setTableFunc } }; ! const unsigned funcCount = sizeof(funcTable)/sizeof(funcTable[0]); size_t iClass; if (registerTypes) ! m_startTag = tnewtag(L); int iTag = m_startTag; --- 136,147 ---- {"__newindex", setTableFunc } }; ! static const unsigned funcCount = sizeof(funcTable)/sizeof(funcTable[0]); ! ! wxLuaState wxlState(wxlState_); ! lua_State *L = wxlState.GetLuaState(); size_t iClass; if (registerTypes) ! m_startTag = wxlState.tnewtag(); int iTag = m_startTag; *************** *** 142,146 **** m_classList = (*pfGetClassList)(m_classCount); for (iClass = 0; iClass < m_classCount; ++iClass, ! iTag = registerTypes ? tnewtag(L) : iTag + 1) { WXLUACLASS *pClass = m_classList + iClass; --- 150,154 ---- m_classList = (*pfGetClassList)(m_classCount); for (iClass = 0; iClass < m_classCount; ++iClass, ! iTag = registerTypes ? wxlState.tnewtag() : iTag + 1) { WXLUACLASS *pClass = m_classList + iClass; *************** *** 152,156 **** for (size_t iFunction = 0; iFunction < funcCount; iFunction++) { ! tsettagmethod (L, iTag, funcTable[iFunction].name, funcTable[iFunction].func, (void *) pClass); } --- 160,164 ---- for (size_t iFunction = 0; iFunction < funcCount; iFunction++) { ! wxlState.tsettagmethod(iTag, funcTable[iFunction].name, funcTable[iFunction].func, (void *) pClass); } |