From: John L. <jr...@us...> - 2005-11-25 02:43:10
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25355/wxLua/modules/wxlua/src Modified Files: Makefile internal.cpp Removed Files: interp.cpp library.cpp Log Message: started to break up internal.cpp into wxlstate, wxlcallb... rename library.h/cpp to wxlhandl since it only contains wxLuaHandler remove wxLuaApp code, it doesn't exist anymore compiles and runs in linux --- interp.cpp DELETED --- Index: internal.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/internal.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** internal.cpp 19 Nov 2005 07:08:39 -0000 1.5 --- internal.cpp 25 Nov 2005 02:43:02 -0000 1.6 *************** *** 36,40 **** #include "../../../bindings/wxwidgets/luasetup.h.in" // get the base library setup parameters #include "wxlua/include/internal.h" ! #include "wxlua/include/callback.h" #include "wxbind/include/wxbind.h" --- 36,40 ---- #include "../../../bindings/wxwidgets/luasetup.h.in" // get the base library setup parameters #include "wxlua/include/internal.h" ! #include "wxlua/include/wxlcallb.h" #include "wxbind/include/wxbind.h" *************** *** 52,305 **** extern int s_wxBitmap; ! #if defined(__WXGTK__) || defined(__WXMAC__) || defined(__WXMOTIF__) #include "../../../art/wxlua.xpm" #endif ! #include "wxlua/include/interp.h" ! ! // lua registry table ! static const char wxLuaReferences[] = "wxLuaReferences"; ! static const char wxNull[] = "wxNull"; ! ! #include "wx/listimpl.cpp" ! WX_DEFINE_LIST(wxLuaBindingList); ! ! static int LUACALL LuaTableErrorHandler(lua_State *L) ! { ! terror(L, "Cannot modify read-only wxLua table"); ! return 0; ! } ! ! /////////////////////////////////////////////////// ! // wxLua Binding Class ! // ! // ! // The wxLuaBinding object binds classes, functions, objects, and event callbacks ! // to the lua interpreter ! // ! IMPLEMENT_CLASS(wxLuaBinding, wxObject) ! ! wxLuaBinding::wxLuaBinding() ! : ! wxObject(), ! pfGetClassList(NULL), ! pfGetDefineList(NULL), ! pfGetEventList(NULL), ! pfGetObjectList(NULL), ! pfGetBuiltinList(NULL), ! m_classCount(0), ! m_classList(NULL), ! m_defineCount(0), ! m_defineList(NULL), ! m_eventCount(0), ! m_eventList(NULL), ! m_objectCount(0), ! m_objectList(NULL), ! m_builtinCount(0), ! m_builtinList(NULL), ! m_typesRegistered(false), ! m_startTag(0), ! m_lastTag(0), ! m_wxLuaTable(0) ! { ! } ! ! // Binds C Functions/Defines/Object/Events to Lua Table ! void wxLuaBinding::RegisterBinding(lua_State *L, bool registerTypes) ! { ! int luaTable = RegisterFunctions(L, registerTypes); ! ! // create a global ! lua_pushstring(L, wx2lua(nameSpace)); ! lua_pushvalue(L, luaTable); ! lua_rawset(L, LUA_GLOBALSINDEX); ! lua_pop(L, 1); ! } ! ! // Unbinds C Functions/Defines/Object/Events by clearing Lua Table ! void wxLuaBinding::UnRegisterBinding(lua_State *L) ! { ! lua_pushstring(L, wx2lua(nameSpace)); ! lua_pushnil(L); ! lua_rawset(L, LUA_GLOBALSINDEX); ! } ! ! // Registers binding, returns lua table reference to binding ! int LUACALL wxLuaBinding::RegisterFunctions(lua_State *L, bool registerTypes) ! { ! GET_LUASTATEVARS_MSG(L, 0) ! ! if (!registerTypes && !m_typesRegistered) ! terror(L, "wxLua: First time registration must register types"); ! ! // create references table in registry ! // lua_pushstring(L, wxLuaReferences); ! // lua_newtable(L); ! // lua_rawset(L, LUA_REGISTRYINDEX); ! ! // create a tag for the wxLua table ! if (registerTypes) ! m_wxLuaTable = tnewtag(L); ! ! // create the wxLua table ! lua_newtable(L); ! int tableOffset = lua_gettop(L); ! ! // set the table tag ! tsettag (L, m_wxLuaTable); ! ! // prevent changes from lua scripts ! tsettagmethod (L, m_wxLuaTable, "__newindex", LuaTableErrorHandler); ! ! // register all out classes etc. in the wxLua table ! RegisterGeneratedClasses(L, tableOffset, registerTypes); ! ! OnRegister(L, registerTypes, tableOffset); ! ! m_typesRegistered = true; ! ! return tableOffset; ! } ! ! // Function to compare to events by eventType ! static int eventListCompareFn(const void *p1, const void *p2) ! { ! return (*((const WXLUAEVENT *) p1)->eventType) - (*((const WXLUAEVENT *) p2)->eventType); ! } ! ! // Register the classes, definitions, objects and pointers generated by the binding ! // Sort the event list into order for faster event handler processing. ! void LUACALL wxLuaBinding::RegisterGeneratedClasses(lua_State *L, int tableOffset, bool registerTypes) ! { ! GET_LUASTATEVARS_RET(L) ! ! static const luaL_reg funcTable[] = ! { ! {"__gc", garbageCollect }, ! {"__index", getTableFunc }, ! {"__newindex", setTableFunc } ! }; ! const unsigned funcCount = sizeof(funcTable)/sizeof(funcTable[0]); ! ! size_t iClass; ! if (registerTypes) ! m_startTag = tnewtag(L); ! ! int iTag = m_startTag; ! ! // install the classes, functions and methods ! m_classList = (*pfGetClassList)(m_classCount); ! for (iClass = 0; iClass < m_classCount; ++iClass, ! iTag = registerTypes ? tnewtag(L) : iTag + 1) ! { ! WXLUACLASS *pClass = m_classList + iClass; ! ! *pClass->class_tag = iTag; ! ! //wxPrintf(wxT("RegisterGenClasses %d '%s'\n"), iTag, lua2wx(pClass->name).c_str()); ! ! for (unsigned iFunction = 0; iFunction < funcCount; iFunction++) ! { ! tsettagmethod (L, iTag, funcTable[iFunction].name, funcTable[iFunction].func, (void *) pClass); ! } ! ! for (int iMethod = 0; iMethod < pClass->num_methods; ++iMethod) ! { ! WXLUAMETHOD *pMethod = pClass->methods + iMethod; ! if ((pMethod->type == LuaConstructor) || (pMethod->type == LuaGlobal)) ! { ! lua_pushstring(L, pMethod->name); ! lua_pushcfunction(L, pMethod->func); ! lua_rawset(L, tableOffset); ! } ! } ! } ! m_lastTag = iTag; ! ! // register all the builtin functions ! m_builtinList = (*pfGetBuiltinList)(m_builtinCount); ! for (size_t iBuiltin= 0; iBuiltin < m_builtinCount; ++iBuiltin) ! { ! WXLUAMETHOD *pMethod = m_builtinList + iBuiltin; ! lua_pushstring(L, pMethod->name); ! lua_pushcfunction(L, pMethod->func); ! lua_rawset(L, tableOffset); ! } ! ! // for backward compatibility ! lua_pushliteral(L, "FALSE"); ! lua_pushboolean(L, false); ! lua_rawset(L, tableOffset); ! ! lua_pushliteral(L, "TRUE"); ! lua_pushboolean(L, true); ! lua_rawset(L, tableOffset); ! ! // install the definitions and strings ! m_defineList = (*pfGetDefineList)(m_defineCount); ! for (size_t iDefine = 0; iDefine < m_defineCount; ++iDefine) ! { ! WXLUADEFINE *pDefine = m_defineList + iDefine; ! lua_pushstring(L, pDefine->name); ! if (pDefine->isString) ! lua_pushstring(L, wx2lua(pDefine->strValue)); ! else ! lua_pushnumber(L, pDefine->value); ! lua_rawset(L, tableOffset); ! } ! ! // install the objects and pointers ! m_objectList = (*pfGetObjectList)(m_objectCount); ! for (size_t iObject = 0; iObject < m_objectCount; ++iObject) ! { ! WXLUAOBJECT *pObject = m_objectList + iObject; ! lua_pushstring(L, pObject->objName); ! if (pObject->objPtr != 0) ! tpushusertag(L, pObject->objPtr, *pObject->objClassTag); ! else ! tpushusertag(L, *pObject->pObjPtr, *pObject->objClassTag); ! lua_rawset(L, tableOffset); ! } ! ! // register all the event types ! m_eventList = (*pfGetEventList)(m_eventCount); ! for (size_t iEvent = 0; iEvent < m_eventCount; ++iEvent) ! { ! WXLUAEVENT *pEvent = m_eventList + iEvent; ! lua_pushstring(L, pEvent->eventName); ! lua_pushnumber(L, *pEvent->eventType); ! lua_rawset(L, tableOffset); ! } ! ! // sort the event list into order for faster lookup. ! qsort(m_eventList, ! m_eventCount, ! sizeof(WXLUAEVENT), ! eventListCompareFn); ! } ! ! // Look for base class in binding, set baseclass_tag ! bool wxLuaBinding::SetBaseClassTag(WXLUACLASS *pClass) ! { ! if (!pClass->baseclass) ! return false; ! ! if (!m_classList) ! return false; ! ! // install the classes, functions and methods ! for (size_t i = 0; i < m_classCount; ++i) ! { ! WXLUACLASS* baseClass = m_classList + i; ! if (strcmp(baseClass->name, pClass->baseclass) == 0) ! { ! pClass->baseclass_tag = *baseClass->class_tag; ! return true; ! } ! } ! return false; ! } // ---------------------------------------------------------------------------- --- 52,66 ---- extern int s_wxBitmap; ! #if defined(__WXGTK__) || defined(__WXMAC__) || defined(__WXMOTIF__) #include "../../../art/wxlua.xpm" #endif ! #include "wxlua/include/wxlintrp.h" ! extern int wxLuaEventListCompareFn(const void *p1, const void *p2); // in wxlbind.cpp ! // lua registry table ! static const char wxLuaReferences[] = "wxLuaReferences"; ! static const char wxLuaNull[] = "wxNull"; // ---------------------------------------------------------------------------- *************** *** 314,318 **** m_functionTag = 0; m_wxLuaTable = 0; ! m_wxNull = 0; m_wxDeleteTable = 0; m_inEventType = -1; --- 75,79 ---- m_functionTag = 0; m_wxLuaTable = 0; ! m_wxLuaNull = 0; m_wxDeleteTable = 0; m_inEventType = -1; *************** *** 367,371 **** node = node->GetNext(); } ! // don't "own" pointers to wxLuaCallbacks, let wxEventHandler do it m_pAppHandlerList->DeleteContents(false); --- 128,132 ---- node = node->GetNext(); } ! // don't "own" pointers to wxLuaCallbacks, let wxEventHandler do it m_pAppHandlerList->DeleteContents(false); *************** *** 386,390 **** { wxLuaBinding* binding = node->GetData(); - binding->RegisterBinding(L, registerTypes); } --- 147,150 ---- *************** *** 409,413 **** { wxLuaBinding* basebinding = basenode->GetData(); ! // found base class in binding? if (basebinding->SetBaseClassTag(pLuaClass)) --- 169,173 ---- { wxLuaBinding* basebinding = basenode->GetData(); ! // found base class in binding? if (basebinding->SetBaseClassTag(pLuaClass)) *************** *** 462,466 **** // Function to compare the class tag of two classes ! static int classListCompareByTag(const void *p1, const void *p2) { return (*((const WXLUACLASS *) p1)->class_tag) - (*((const WXLUACLASS *) p2)->class_tag); --- 222,226 ---- // Function to compare the class tag of two classes ! int wxLuaClassListCompareByTag(const void *p1, const void *p2) { return (*((const WXLUACLASS *) p1)->class_tag) - (*((const WXLUACLASS *) p2)->class_tag); *************** *** 484,490 **** binding->GetLuaClassCount(), sizeof(WXLUACLASS), ! classListCompareByTag); ! // found if (pLuaClass) return pLuaClass; --- 244,250 ---- binding->GetLuaClassCount(), sizeof(WXLUACLASS), ! wxLuaClassListCompareByTag); ! // found if (pLuaClass) return pLuaClass; *************** *** 554,560 **** binding->GetLuaEventCount(), sizeof(WXLUAEVENT), ! eventListCompareFn); ! // found if (pLuaEvent) return pLuaEvent; --- 314,320 ---- binding->GetLuaEventCount(), sizeof(WXLUAEVENT), ! wxLuaEventListCompareFn); ! // found if (pLuaEvent) return pLuaEvent; *************** *** 570,574 **** // from lua50/lib/lbaselib.c, the collectgarbage lua function ! // see int luaB_collectgarbage(lua_State *L); //lua_setgcthreshold(L, luaL_optint(L, 1, 0)); // = luaB_collectgarbage(L); --- 330,334 ---- // from lua50/lib/lbaselib.c, the collectgarbage lua function ! // see int luaB_collectgarbage(lua_State *L); //lua_setgcthreshold(L, luaL_optint(L, 1, 0)); // = luaB_collectgarbage(L); *************** *** 648,656 **** iCount = (int) lua_tonumber(L, -1); // get result value lua_pop(L, 1); // pop result ! iCount++; // next unallocated index ! lua_pushvalue(L, nTop); // push value to store ! lua_rawseti(L, -2, iCount); // store value, pop value lua_pushliteral(L, "n"); // push key --- 408,416 ---- iCount = (int) lua_tonumber(L, -1); // get result value lua_pop(L, 1); // pop result ! iCount++; // next unallocated index ! lua_pushvalue(L, nTop); // push value to store ! lua_rawseti(L, -2, iCount); // store value, pop value lua_pushliteral(L, "n"); // push key *************** *** 715,719 **** if (iIndex > 0 && iIndex <= iCount) // ensure in range ! { lua_pushnil(L); // push nil as value lua_rawseti(L, -2, iIndex); // set table, pop value --- 475,479 ---- if (iIndex > 0 && iIndex <= iCount) // ensure in range ! { lua_pushnil(L); // push nil as value lua_rawseti(L, -2, iIndex); // set table, pop value *************** *** 894,908 **** // Default constructor wxLuaObject::wxLuaObject() : m_luaState(NULL), m_iReference(LUA_NOREF), ! m_allocatedBool(FALSE), m_bool(FALSE), ! m_allocatedInt(FALSE), m_int(0), ! m_allocatedString(FALSE), m_allocatedArray(FALSE) { } // Constructor that is passed a lua state and a parameter index. ! wxLuaObject::wxLuaObject(lua_State *L, int iParam, int WXUNUSED(iRef)) ! : m_luaState(L), m_allocatedBool(FALSE), m_bool(FALSE), ! m_allocatedInt(FALSE), m_int(0), ! m_allocatedString(FALSE), m_allocatedArray(FALSE) { // set up the reference --- 654,668 ---- // Default constructor wxLuaObject::wxLuaObject() : m_luaState(NULL), m_iReference(LUA_NOREF), ! m_allocatedBool(false), m_bool(false), ! m_allocatedInt(false), m_int(0), ! m_allocatedString(false), m_allocatedArray(false) { } // Constructor that is passed a lua state and a parameter index. ! wxLuaObject::wxLuaObject(lua_State *L, int iParam, int WXUNUSED(iRef)) ! : m_luaState(L), m_allocatedBool(false), m_bool(false), ! m_allocatedInt(false), m_int(0), ! m_allocatedString(false), m_allocatedArray(false) { // set up the reference *************** *** 1264,1268 **** DumpType(lua_state, -1, valueType, value, valueInfo); ! wxString info = wxString::Format(wxT("%s%-32s\t%-15s\t%-20s\t%-10s\t%s"), indentStr.c_str(), indexValue.c_str(), --- 1024,1028 ---- DumpType(lua_state, -1, valueType, value, valueInfo); ! wxString info = wxString::Format(wxT("%s%-32s\t%-15s\t%-20s\t%-10s\t%s"), indentStr.c_str(), indexValue.c_str(), *************** *** 1311,1315 **** { bool result = false; ! GET_LUASTATEVARS_MSG(L, FALSE) wxObject *pDeleteObject = stateVars->m_pTrackedList->Delete((int) pObject); --- 1071,1075 ---- { bool result = false; ! GET_LUASTATEVARS_MSG(L, false) wxObject *pDeleteObject = stateVars->m_pTrackedList->Delete((int) pObject); *************** *** 1331,1346 **** 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; } --- 1091,1106 ---- 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; } *************** *** 1354,1358 **** GET_LUASTATEVARS_RET(L) ! // only need to track parent window, it deletes children for us if (!IsParentWindowTracked(stateVars->m_pWindowList, pWindow)) --- 1114,1118 ---- GET_LUASTATEVARS_RET(L) ! // only need to track parent window, it deletes children for us if (!IsParentWindowTracked(stateVars->m_pWindowList, pWindow)) *************** *** 1387,1391 **** if (stateVars->IsDerivedClass(iTag, iParamTag)) pReturn = ttouserdata(L, iParam); ! else if (stateVars->m_wxNull != iTag) goto error; } --- 1147,1151 ---- if (stateVars->IsDerivedClass(iTag, iParamTag)) pReturn = ttouserdata(L, iParam); ! else if (stateVars->m_wxLuaNull != iTag) goto error; } *************** *** 1398,1491 **** } - // ---------------------------------------------------------------------------- - // wxLuaDestroyCallback - // ---------------------------------------------------------------------------- - - IMPLEMENT_CLASS(wxLuaDestroyCallback, wxEvtHandler); - - wxLuaDestroyCallback::wxLuaDestroyCallback(lua_State *L, int id, wxEvtHandler *pHandler, int iTag) - : m_luaState(L), m_luaStateVars(NULL), m_pHandler(pHandler), m_id(id) - { - GET_LUASTATEVARS_RET(L) - m_luaStateVars = stateVars; - - // allocate a LUA proxy for the object - const void **ptr = (const void **) lua_newuserdata(L, sizeof(void *)); - if (ptr != NULL) - { - // save the address of the object in the proxy - *ptr = pHandler; - - // and set the metatable of the proxy - if (iTag != TLUA_NOTAG && tget(L, iTag)) - { - if (lua_setmetatable(L, -2) == 0) - { - terror(L, "wxLua: Unable to set metatable"); - } - } - - // get a reference to the destroy handler table - if (tget(L, stateVars->m_wxDeleteTable)) - { - // create a reference to object - lua_pushlightuserdata(L, pHandler); // key - lua_pushvalue(L, -3); // value - // save it in the destroy handler table - lua_rawset(L, -3); - lua_pop(L, 1); - } - - stateVars->m_pDestroyHandlerList->Append(this); - - // connect the event handler - pHandler->Connect(id, - wxEVT_DESTROY, - (wxObjectEventFunction)&wxLuaDestroyCallback::EventHandler, - this); - } - else - { - terror(L, "wxLua: Out of memory"); - } - } - - void wxLuaDestroyCallback::EventHandler(wxWindowDestroyEvent& event) - { - wxLuaDestroyCallback *theCallback = (wxLuaDestroyCallback *) event.m_callbackUserData; - if (theCallback && (((wxWindow*)event.GetEventObject())->GetEventHandler() == m_pHandler)) - { - theCallback->OnDestroy(); - } - - event.Skip(); - } - - void wxLuaDestroyCallback::OnDestroy() - { - // FIXME - Is it an error to receive an event after you've deleted lua? - // probably not if lua is getting shutdown - if (!m_luaState || !m_luaStateVars) - return; - - // Note: do not remove from m_pDestroyHandlerList here, wait 'till destructor - - if (tget(m_luaState, m_luaStateVars->m_wxDeleteTable)) - { - // clear the metatable reference in the lua proxy. - lua_pushlightuserdata(m_luaState, m_pHandler); - lua_rawget(m_luaState, -2); - lua_pushnil(m_luaState); - lua_setmetatable(m_luaState, -2); - lua_pop(m_luaState, 2); - } - } - - wxLuaDestroyCallback::~wxLuaDestroyCallback() - { - if (m_luaStateVars) - m_luaStateVars->m_pDestroyHandlerList->DeleteObject(this); - } - // Push a data type onto the stack and set its tag void LUACALL pushuserdatatype(lua_State *L, int iTag, const void *data) --- 1158,1161 ---- *************** *** 1567,1575 **** int num = (int) lua_toboolean(L, iParam); ! // This test is not reliable FALSE == 0 but TRUE !=0 not TRUE == 1 // The paramter can be the result of evaluating an expression as well as one of the two // boolean constants. ! // if (!(num == TRUE) || !(num == FALSE)) ! // terror(L, wxString::Format("wxLua: Expected 'TRUE' or 'FALSE' for parameter %d.", iParam)); return num ? true : false; --- 1237,1245 ---- int num = (int) lua_toboolean(L, iParam); ! // This test is not reliable false == 0 but true !=0 not true == 1 // The paramter can be the result of evaluating an expression as well as one of the two // boolean constants. ! // if (!(num == true) || !(num == false)) ! // terror(L, wxString::Format("wxLua: Expected 'true' or 'false' for parameter %d.", iParam)); return num ? true : false; *************** *** 2053,2058 **** GET_LUASTATEVARS_MSG(L, NULL) ! if (nTag == stateVars->m_wxNull) ! return wxNull; if (nTag == stateVars->m_functionTag) return "wxLuaFunction"; --- 1723,1728 ---- GET_LUASTATEVARS_MSG(L, NULL) ! if (nTag == stateVars->m_wxLuaNull) ! return wxLuaNull; if (nTag == stateVars->m_functionTag) return "wxLuaFunction"; *************** *** 2147,2151 **** pCallback = new wxLuaCallback(L, 3, id, (int) eventType, evtHandler); } ! break; } --- 1817,1821 ---- pCallback = new wxLuaCallback(L, 3, id, (int) eventType, evtHandler); } ! break; } *************** *** 2195,2317 **** } - //----------------------------------------------------------------------------- - // wxLuaCallback - //----------------------------------------------------------------------------- - - IMPLEMENT_CLASS(wxLuaCallback, wxEvtHandler); - - // Encapsulate a lua function reference for use by a event callback - wxLuaCallback::wxLuaCallback( lua_State *L, - int theRoutine, - int id, - wxEventType eventType, - wxEvtHandler *pEvtHandler ) - : m_luaState(L), m_luaStateVars(NULL), - m_pHandler(pEvtHandler), - m_id(id), m_eventType(eventType) - { - GET_LUASTATEVARS_RET(L) - m_luaStateVars = stateVars; - m_routine = tinsert(L, theRoutine); - - pEvtHandler->Connect( id, - eventType, - (wxObjectEventFunction)&wxLuaCallback::EventHandler, - this); - - // FIXME - Need to track events attached to an application object - // labenski - track all of them? useful to run ClearState when window is destroyed - //if (pEvtHandler->IsKindOf(CLASSINFO(wxApp))) - { - m_luaStateVars->m_pAppHandlerList->Append(this); - } - } - - wxLuaCallback::~wxLuaCallback() - { - // Remove the reference to the Lua function that we are going to call - if (m_luaState) - tremove(m_luaState, m_routine); - // delete the reference to this handler - if (m_luaStateVars) - m_luaStateVars->m_pAppHandlerList->DeleteObject(this); - } - - // This function is called with "this" being of the type which the event is arriving - // at. The user data is used to route it to the correct place. - void wxLuaCallback::EventHandler(wxEvent& event) - { - wxLuaCallback *theCallback = (wxLuaCallback *) event.m_callbackUserData; - - if (!theCallback || !theCallback->GetLuaState() || !theCallback->m_luaStateVars) - return; - - theCallback->m_luaStateVars->m_inEventType = event.GetEventType(); - - if (event.GetEventType() == wxEVT_DESTROY) - { - event.Skip(); - theCallback->m_luaStateVars->m_pWindowList->DeleteObject((wxWindow*)event.GetEventObject()); - - // Disconnect all callbacks associated with this window's evthandler - theCallback->ClearState(); - - wxEvtHandler *evtHandler = ((wxWindow*)event.GetEventObject())->GetEventHandler(); - - wxNode* node = theCallback->m_luaStateVars->m_pAppHandlerList->GetFirst(); - while (node) - { - wxLuaCallback *pCallback = (wxLuaCallback *) node->GetData(); - - if ((pCallback != NULL) && (pCallback->GetEvtHandler() == evtHandler)) - { - pCallback->ClearState(); - } - - node = node->GetNext(); - } - } - else //if (theCallback->m_luaState) - theCallback->CallFunction(&event); - - theCallback->m_luaStateVars->m_inEventType = -1; - } - - // Call a lua function to handle an event. The lua function will receive - // a single parameter, the type of event. - void wxLuaCallback::CallFunction(wxEvent *pEvent) - { - // 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_luaState || !wxFindLuaStateVariables(m_luaState)) - return; - - int eventClassTag = s_wxEvent; - - GET_LUASTATEVARS_RET(m_luaState) - const WXLUAEVENT *pLuaEvent = stateVars->GetLuaEvent(pEvent); - if (pLuaEvent) - eventClassTag = *pLuaEvent->eventClassTag; - - lua_checkstack(m_luaState,LUA_MINSTACK); - int oldTop = lua_gettop(m_luaState); - if (tget(m_luaState, m_routine)) - { - lua_pushvalue(m_luaState, LUA_GLOBALSINDEX); - if (lua_setfenv(m_luaState, -2) != 0) - { - tpushusertag(m_luaState, pEvent, eventClassTag); - LuaCall(m_luaState, 1, true); - } - else - terror(m_luaState, "wxLua: CallFunction: function is not a Lua function."); - } - else - terror(m_luaState, "wxLua: CallFunction: function has been garbage collected."); - - lua_settop(m_luaState, oldTop); - } int LUACALL CreateStandaloneBitmaps(lua_State *L) --- 1865,1868 ---- Index: Makefile =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile 20 Nov 2005 22:28:07 -0000 1.2 --- Makefile 25 Nov 2005 02:43:02 -0000 1.3 *************** *** 2,6 **** # Author: J Winwood # Created: 2002 ! # Updated: # Copyright: (c) 2002 Lomtick Software. All rights reserved. # --- 2,6 ---- # Author: J Winwood # Created: 2002 ! # Updated: # Copyright: (c) 2002 Lomtick Software. All rights reserved. # *************** *** 26,30 **** WXCXXFLAGS = $(shell $(WXCONFIG) --cxxflags) WXLDLIBS = $(shell $(WXCONFIG) --libs) ! WXCXX = $(shell $(WXCONFIG) --cxx) WXLIB_DIR = $(WXPREFIX)/lib # ---------------------------------------------------------------------------- --- 26,30 ---- WXCXXFLAGS = $(shell $(WXCONFIG) --cxxflags) WXLDLIBS = $(shell $(WXCONFIG) --libs) ! WXCXX = $(shell $(WXCONFIG) --cxx) WXLIB_DIR = $(WXPREFIX)/lib # ---------------------------------------------------------------------------- *************** *** 34,38 **** CXX = $(WXCXX) ! APPEXTRADEFS=-I../../ -I$(WXPREFIX)/contrib/include -fexceptions -DLUACALL= TARGET_LIBNAME = lib$(WXBASENAME)_wxlua-$(WXRELEASE) --- 34,38 ---- CXX = $(WXCXX) ! APPEXTRADEFS=-I../../ -I$(WXPREFIX)/contrib/include -fexceptions -DLUACALL= TARGET_LIBNAME = lib$(WXBASENAME)_wxlua-$(WXRELEASE) *************** *** 51,64 **** HEADERS = \ ! ../include/defs.h \ ../include/internal.h \ ! ../include/interp.h \ ! ../include/library.h \ ! ../include/wxlua.h SOURCES = \ internal.cpp \ ! interp.cpp \ ! library.cpp OBJECTS=$(SOURCES:.cpp=.o) --- 51,70 ---- HEADERS = \ ! ../include/wxldefs.h \ ../include/internal.h \ ! ../include/wxlua.h \ ! ../include/wxlbind.h \ ! ../include/wxlcallb.h \ ! ../include/wxlhandl.h \ ! ../include/wxlintrp.h \ ! ../include/wxlstate.h SOURCES = \ internal.cpp \ ! wxlbind.cpp \ ! wxlcallb.cpp \ ! wxlhandl.cpp \ ! wxlintrp.cpp \ ! wxlstate.cpp OBJECTS=$(SOURCES:.cpp=.o) *************** *** 66,74 **** .cpp.o: ! $(CXX) -c $(CXXFLAGS) $(APPEXTRADEFS)-o $@ $< all: $(TARGET_LIB_STATIC) $(TARGET_LIB_SHARED) ! $(TARGET_LIB_STATIC) : $(OBJECTS) @$(RM) $@ $(AR) $(AROPTIONS) $@ $(OBJECTS) --- 72,80 ---- .cpp.o: ! $(CXX) -c $(CXXFLAGS) $(APPEXTRADEFS) -o $@ $< all: $(TARGET_LIB_STATIC) $(TARGET_LIB_SHARED) ! $(TARGET_LIB_STATIC) : $(OBJECTS) @$(RM) $@ $(AR) $(AROPTIONS) $@ $(OBJECTS) *************** *** 86,90 **** $(TARGET_LIB_STATIC) $(TARGET_LIB_SHARED) \ $(TARGET_LIBDIR)/$(TARGET_LIB_LINK1) \ ! $(TARGET_LIBDIR)/$(TARGET_LIB_LINK2) -include $(DEPFILES) --- 92,96 ---- $(TARGET_LIB_STATIC) $(TARGET_LIB_SHARED) \ $(TARGET_LIBDIR)/$(TARGET_LIB_LINK1) \ ! $(TARGET_LIBDIR)/$(TARGET_LIB_LINK2) -include $(DEPFILES) --- library.cpp DELETED --- |