From: John L. <jr...@us...> - 2009-05-19 03:21:01
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv15045/wxLua/modules/wxlua/src Modified Files: wxlbind.cpp wxlcallb.cpp wxlstate.cpp wxlua_bind.cpp Log Message: Do not export parts of the bindings that are only used internally. Declare them as extern within the cpp file of the binding. Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.180 retrieving revision 1.181 diff -C2 -d -r1.180 -r1.181 *** wxlstate.cpp 14 May 2009 05:06:21 -0000 1.180 --- wxlstate.cpp 19 May 2009 03:20:53 -0000 1.181 *************** *** 1150,1153 **** --- 1150,1157 ---- if (pCallback == NULL) wxlua_error(L, "wxLua: Out of memory creating wxLuaWinDestroyCallback."); + // assert should have been given in constructor so delete it + // since it's not attached as a callback user data + if (!pCallback->Ok()) + delete pCallback; } Index: wxlbind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlbind.cpp,v retrieving revision 1.122 retrieving revision 1.123 diff -C2 -d -r1.122 -r1.123 *** wxlbind.cpp 14 May 2009 05:06:21 -0000 1.122 --- wxlbind.cpp 19 May 2009 03:20:53 -0000 1.123 *************** *** 1074,1078 **** // Add us to the LUA_REGISTRYINDEX table of bindings lua_pushlightuserdata(L, &wxlua_lreg_wxluabindings_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (the bindings table) lua_pushlightuserdata(L, this); // push key --- 1074,1078 ---- // Add us to the LUA_REGISTRYINDEX table of bindings lua_pushlightuserdata(L, &wxlua_lreg_wxluabindings_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (the bindings table) lua_pushlightuserdata(L, this); // push key *************** *** 1096,1100 **** // install the classes, functions and methods, creating new wxLua types // if this is the first time we're registering them ! wxLuaBindClass *wxlClass = m_classArray; for (n = 0; n < m_classCount; ++n, ++wxlClass) { --- 1096,1100 ---- // install the classes, functions and methods, creating new wxLua types // if this is the first time we're registering them ! const wxLuaBindClass *wxlClass = m_classArray; for (n = 0; n < m_classCount; ++n, ++wxlClass) { *************** *** 1104,1112 **** // register the global C style functions ! wxLuaBindMethod* wxlMethod = m_functionArray; for (n = 0; n < m_functionCount; ++n, ++wxlMethod) { lua_pushstring(L, wxlMethod->name); ! lua_pushlightuserdata(L, wxlMethod); lua_pushcclosure(L, wxlMethod->wxluacfuncs[0].lua_cfunc, 1); lua_rawset(L, -3); --- 1104,1112 ---- // register the global C style functions ! const wxLuaBindMethod* wxlMethod = m_functionArray; for (n = 0; n < m_functionCount; ++n, ++wxlMethod) { lua_pushstring(L, wxlMethod->name); ! lua_pushlightuserdata(L, (void*)wxlMethod); lua_pushcclosure(L, wxlMethod->wxluacfuncs[0].lua_cfunc, 1); lua_rawset(L, -3); Index: wxlcallb.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlcallb.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** wxlcallb.cpp 23 Jan 2008 06:43:39 -0000 1.58 --- wxlcallb.cpp 19 May 2009 03:20:53 -0000 1.59 *************** *** 76,80 **** // Note: We use the callback userdata and not the event sink since the event sink // requires a wxEvtHandler object which is a fairly large class. ! // The userdata is also deleted for us which makes m_evtHandler->Connect(win_id, last_id, eventType, (wxObjectEventFunction)&wxLuaEventCallback::OnAllEvents, --- 76,80 ---- // Note: We use the callback userdata and not the event sink since the event sink // requires a wxEvtHandler object which is a fairly large class. ! // The userdata (i.e. this) is also deleted for us which makes our life easier. m_evtHandler->Connect(win_id, last_id, eventType, (wxObjectEventFunction)&wxLuaEventCallback::OnAllEvents, *************** *** 123,127 **** { // Cannot call it if Lua is gone or the interpreter has been destroyed ! // This can happen when the program exists since windows may be destroyed // after Lua has been deleted. if (!m_wxlState.Ok()) --- 123,127 ---- { // Cannot call it if Lua is gone or the interpreter has been destroyed ! // This can happen when the program exits since windows may be destroyed // after Lua has been deleted. if (!m_wxlState.Ok()) *************** *** 148,158 **** event_wxl_type = *wxlClass->wxluatype; else ! event_wxl_type = *p_wxluatype_wxEvent; // get the wxluatype_wxEvent } } else ! event_wxl_type = *p_wxluatype_wxEvent; // get the wxluatype_wxEvent ! // Should never get here, but error out in case we do wxCHECK_RET(event_wxl_type != WXLUA_TUNKNOWN, wxT("Unknown wxEvent wxLua tag for : ") + wxString(event->GetClassInfo()->GetClassName())); --- 148,158 ---- event_wxl_type = *wxlClass->wxluatype; else ! event_wxl_type = *p_wxluatype_wxEvent; // get the generic wxluatype_wxEvent } } else ! event_wxl_type = *p_wxluatype_wxEvent; // get the generic wxluatype_wxEvent ! // Should know our event type, but error out in case we don't wxCHECK_RET(event_wxl_type != WXLUA_TUNKNOWN, wxT("Unknown wxEvent wxLua tag for : ") + wxString(event->GetClassInfo()->GetClassName())); *************** *** 193,197 **** m_wxlState.AddTrackedWinDestroyCallback(this); ! // connect the event handler m_window->Connect(m_window->GetId(), wxEVT_DESTROY, (wxObjectEventFunction)&wxLuaWinDestroyCallback::OnAllDestroyEvents, --- 193,197 ---- m_wxlState.AddTrackedWinDestroyCallback(this); ! // connect the event handler and set this as the callback user data m_window->Connect(m_window->GetId(), wxEVT_DESTROY, (wxObjectEventFunction)&wxLuaWinDestroyCallback::OnAllDestroyEvents, *************** *** 242,251 **** // FIXME - Is it an error to receive an event after you've deleted Lua? // probably not if Lua is getting shutdown // Note: do not remove from wxLuaState's destroyHandlerList here, wait 'till destructor if (m_wxlState.Ok()) { // clear the metatable for all userdata we're tracking. ! wxluaO_untrackweakobject(m_wxlState.GetLuaState(), NULL, m_window); ! wxlua_removederivedmethods(m_wxlState.GetLuaState(), m_window); // Clear our own pointer to this window --- 242,254 ---- // FIXME - Is it an error to receive an event after you've deleted Lua? // probably not if Lua is getting shutdown + // Note: do not remove from wxLuaState's destroyHandlerList here, wait 'till destructor if (m_wxlState.Ok()) { + lua_State* L = m_wxlState.GetLuaState(); + // clear the metatable for all userdata we're tracking. ! wxluaO_untrackweakobject(L, NULL, m_window); ! wxlua_removederivedmethods(L, m_window); // Clear our own pointer to this window *************** *** 260,265 **** // but we're right in the middle of being destroyed and we crash. - lua_State* L = m_wxlState.GetLuaState(); - lua_pushlightuserdata(L, &wxlua_lreg_evtcallbacks_key); // push key lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) --- 263,266 ---- Index: wxlua_bind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlua_bind.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** wxlua_bind.cpp 14 May 2009 05:06:21 -0000 1.31 --- wxlua_bind.cpp 19 May 2009 03:20:53 -0000 1.32 *************** *** 1209,1212 **** --- 1209,1222 ---- static const char* wxluabaseclassnames_wxLuaState[] = { wxluaclassname_wxObject, NULL }; static wxLuaBindClass* wxluabaseclassbinds_wxLuaState[] = { NULL }; + // --------------------------------------------------------------------------- + // Lua Tag Method Values and Tables for each Class + // --------------------------------------------------------------------------- + + extern wxLuaBindMethod wxLuaObject_methods[]; + extern int wxLuaObject_methodCount; + extern wxLuaBindMethod wxLuaState_methods[]; + extern int wxLuaState_methodCount; + + |