From: John L. <jr...@us...> - 2005-11-25 10:09:22
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1505/wxLua/modules/wxlua/src Modified Files: internal.cpp wxlbind.cpp wxlintrp.cpp wxlstate.cpp Log Message: flesh out the wxLuaState SmartString/IntArray to wxLuaSmartXXX TRUE/FALSE - true/false Index: internal.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/internal.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** internal.cpp 25 Nov 2005 02:43:02 -0000 1.6 --- internal.cpp 25 Nov 2005 10:09:11 -0000 1.7 *************** *** 488,492 **** { tpushliteralstring(L, wxLuaReferences); ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (refs table) lua_pushliteral(L, "n"); --- 488,492 ---- { tpushliteralstring(L, wxLuaReferences); ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (refs table) lua_pushliteral(L, "n"); Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** wxlstate.cpp 25 Nov 2005 02:46:53 -0000 1.1 --- wxlstate.cpp 25 Nov 2005 10:09:11 -0000 1.2 *************** *** 7,10 **** --- 7,27 ---- ///////////////////////////////////////////////////////////////////////////// + /* **************************************************************************** + + Portions of code in this file have been taken from LuaPlus. + LuaPlus was written and maintained by Joshua Jensen (jj...@wo...) + and resides as http://wwhiz.com/LuaPlus/index.html . LuaPlus is distributed + with the Lua Licence as described below. + [...1538 lines suppressed...] + { + wxCHECK_MSG(Ok(), NULL, wxT("Invalid wxLuaState")); + return lua_setlocal(M_WXLSTATEDATA->m_lua_State, ar, n); + } + + int wxLuaState::SetHook(lua_Hook func, int mask, int count) + { + wxCHECK_MSG(Ok(), 0, wxT("Invalid wxLuaState")); + return lua_sethook(M_WXLSTATEDATA->m_lua_State, func, mask, count); + } + lua_Hook wxLuaState::GetHook() + { + wxCHECK_MSG(Ok(), 0, wxT("Invalid wxLuaState")); + return lua_gethook(M_WXLSTATEDATA->m_lua_State); + } + unsigned long wxLuaState::GetHookMask() + { + wxCHECK_MSG(Ok(), 0, wxT("Invalid wxLuaState")); + return lua_gethookmask(M_WXLSTATEDATA->m_lua_State); + } Index: wxlbind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlbind.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** wxlbind.cpp 25 Nov 2005 02:46:53 -0000 1.1 --- wxlbind.cpp 25 Nov 2005 10:09:11 -0000 1.2 *************** *** 97,102 **** 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"); --- 97,100 ---- *************** *** 133,138 **** void LUACALL wxLuaBinding::RegisterGeneratedClasses(lua_State *L, int tableOffset, bool registerTypes) { - GET_LUASTATEVARS_RET(L) - static const luaL_reg funcTable[] = { --- 131,134 ---- Index: wxlintrp.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlintrp.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** wxlintrp.cpp 25 Nov 2005 02:46:53 -0000 1.1 --- wxlintrp.cpp 25 Nov 2005 10:09:11 -0000 1.2 *************** *** 31,34 **** --- 31,35 ---- extern int s_wxLuaInterpreter; + extern bool wxLuaCleanupWindows(wxList *list, bool only_check); // in wxlstate.cpp wxHashMapLuaInterpreter s_wxHashMapLuaInterpreter; *************** *** 117,245 **** // ---------------------------------------------------------------------------- - // wxFindWindowByPointer - find a window by it's pointer - // return NULL if doesn't exist, see wxFindWindowByID and wxFindWindowByLabel - // ---------------------------------------------------------------------------- - static wxWindow *wxFindWindowPointerRecursively(const wxWindow *parent, const wxWindow *win) - { - wxCHECK_MSG(win, NULL, wxT("invalid window in wxFindWindowPointerRecursively")); - - if ( parent ) - { - // see if this is the one we're looking for - if ( parent == win ) - return (wxWindow*)win; - - // It wasn't, so check all its children - for ( wxWindowList::Node * node = parent->GetChildren().GetFirst(); - node; - node = node->GetNext() ) - { - // recursively check each child - wxWindow *child_win = (wxWindow *)node->GetData(); - wxWindow *retwin = wxFindWindowPointerRecursively(child_win, win); - if (retwin) - return retwin; - } - } - - // Not found - return NULL; - } - - // Check to see if wxWidgets still thinks "win" is a valid window - // parent is the window to start with, if parent=NULL check all windows - static wxWindow* wxFindWindowByPointer(const wxWindow *parent, const wxWindow *win) - { - wxCHECK_MSG(win, NULL, wxT("Invalid window in wxFindWindowByPointer")); - - if ( parent ) - { - // just check parent and all its children - return wxFindWindowPointerRecursively(parent, win); - } - // start at very top of wx's windows - for ( wxWindowList::Node * top_node = wxTopLevelWindows.GetFirst(); - top_node; - top_node = top_node->GetNext() ) - { - // recursively check each window & its children - wxWindow *top_win = top_node->GetData(); - wxWindow *retwin = wxFindWindowPointerRecursively(top_win, win); - if (retwin) - return retwin; - } - - return NULL; - } - - // ---------------------------------------------------------------------------- - // wxLuaCleanupWindows - given a wxList of wxWindows it runs wxFindWindowByPointer - // on it to remove dead pointers from the list if only_check=TRUE or - // Destroy() the windows and remove them from the list if !only_check. - // This is for use with wxLuaStateVariables::m_pWindowList. - // returns TRUE if any windows removed, ie. the list has changed - // ---------------------------------------------------------------------------- - bool wxLuaCleanupWindows(wxList *list, bool only_check) - { - bool removed = FALSE; - - wxNode *node = list->GetFirst(); - - while (node != NULL) - { - wxWindow *win = (wxWindow *)node->GetData(); - - if (!win) - { - wxNode *lastNode = node; - node = node->GetNext(); - list->DeleteNode(lastNode); - } - else if (wxFindWindowByPointer(NULL, win) == NULL) - { - removed = TRUE; - wxNode *lastNode = node; - node = node->GetNext(); - //printf("%d %d\n", int(lastNode), int(node)); fflush(stdout); - list->DeleteNode(lastNode); - } - else if (!only_check) - { - removed = TRUE; - if (win->HasCapture()) - win->ReleaseMouse(); - - // release capture for children since we may be abruptly ending - for ( wxWindowList::compatibility_iterator childNode = win->GetChildren().GetFirst(); - childNode; - childNode = childNode->GetNext() ) - { - wxWindow *child = childNode->GetData(); - list->DeleteObject(child); - if (child->HasCapture()) - child->ReleaseMouse(); - } - - if (!win->IsBeingDeleted()) - { - delete win; - } - - // wxLuaWindowDestroyHandler should destroy this node - // and also delete all the children and their nodes - // it's probably best to start from the top again - list->DeleteObject(win); - - //wxPrintf(wxT("%d %d\n"), int(1), int(win)); fflush(stdout); - - node = list->GetFirst(); - } - else - node = node->GetNext(); - } - return removed; - } - - // ---------------------------------------------------------------------------- // lua hooks and function replacements for embedding into wxWidgets // ---------------------------------------------------------------------------- --- 118,121 ---- *************** *** 485,489 **** m_luaInterpreter = interpreter; m_lua_Debug = NULL; ! m_stop_interpreter = FALSE; } --- 361,365 ---- m_luaInterpreter = interpreter; m_lua_Debug = NULL; ! m_stop_interpreter = false; } *************** *** 509,514 **** #endif //WXLUA_THREAD_INTERCEPTION ! m_is_running = FALSE; ! m_user_break = FALSE; m_last_debug_hook_time = wxGetLocalTimeMillis().GetLo(); --- 385,390 ---- #endif //WXLUA_THREAD_INTERCEPTION ! m_is_running = false; ! m_user_break = false; m_last_debug_hook_time = wxGetLocalTimeMillis().GetLo(); *************** *** 522,526 **** m_lua_debug_hook_count = 100; m_lua_debug_hook_yield = 50; ! m_lua_debug_hook_send_evt = FALSE; m_lua_debug_hook = 0; } --- 398,402 ---- m_lua_debug_hook_count = 100; m_lua_debug_hook_yield = 50; ! m_lua_debug_hook_send_evt = false; m_lua_debug_hook = 0; } *************** *** 605,615 **** bool wxLuaInterpreter::Destroy(bool force) { ! wxCHECK_MSG(Ok(), FALSE, wxT("Interpreter not created")); ! wxCHECK_MSG(!m_is_running, FALSE, wxT("Interpreter still running, can't destroy")); // remove deleted windows first if (m_luaStateVariables->m_pWindowList && m_luaStateVariables->m_pWindowList->GetCount()) ! wxLuaCleanupWindows(m_luaStateVariables->m_pWindowList, TRUE); // are there still windows? ask to abort deleting them if !force --- 481,491 ---- bool wxLuaInterpreter::Destroy(bool force) { ! wxCHECK_MSG(Ok(), false, wxT("Interpreter not created")); ! wxCHECK_MSG(!m_is_running, false, wxT("Interpreter still running, can't destroy")); // remove deleted windows first if (m_luaStateVariables->m_pWindowList && m_luaStateVariables->m_pWindowList->GetCount()) ! wxLuaCleanupWindows(m_luaStateVariables->m_pWindowList, true); // are there still windows? ask to abort deleting them if !force *************** *** 626,630 **** if (ret == wxCANCEL) ! return FALSE; //wxPrintf(wxT("Deleting windows\n")); --- 502,506 ---- if (ret == wxCANCEL) ! return false; //wxPrintf(wxT("Deleting windows\n")); *************** *** 632,636 **** // delete windows and their eventhandler since they delete the LuaCallbacks // which require a lua_State ! wxLuaCleanupWindows(m_luaStateVariables->m_pWindowList, FALSE); // wait for wxWindow::Destroy() to really delete the windows //wxYieldIfNeeded(); --- 508,512 ---- // delete windows and their eventhandler since they delete the LuaCallbacks // which require a lua_State ! wxLuaCleanupWindows(m_luaStateVariables->m_pWindowList, false); // wait for wxWindow::Destroy() to really delete the windows //wxYieldIfNeeded(); *************** *** 646,650 **** m_evtHandler = NULL; ! return TRUE; } --- 522,526 ---- m_evtHandler = NULL; ! return true; } *************** *** 663,676 **** wxCHECK_MSG(Ok(), -1, wxT("lua interpreter not created")); wxCHECK_MSG(!m_is_running, -1, wxT("lua interpreter is already running")); ! m_user_break = FALSE; ! m_is_running = TRUE; // int ret_val = lua_dofile(m_lua_State, wx2lua(filename)); int ret_val = LuaDoFile(m_lua_State, filename); // FIXME use LuaDoFile in RunFile ? ! m_is_running = FALSE; if (!m_user_break) (void)CheckRunError(ret_val); ! m_user_break = FALSE; return ret_val; } --- 539,552 ---- wxCHECK_MSG(Ok(), -1, wxT("lua interpreter not created")); wxCHECK_MSG(!m_is_running, -1, wxT("lua interpreter is already running")); ! m_user_break = false; ! m_is_running = true; // int ret_val = lua_dofile(m_lua_State, wx2lua(filename)); int ret_val = LuaDoFile(m_lua_State, filename); // FIXME use LuaDoFile in RunFile ? ! m_is_running = false; if (!m_user_break) (void)CheckRunError(ret_val); ! m_user_break = false; return ret_val; } *************** *** 680,689 **** wxCHECK_MSG(Ok(), -1, wxT("lua interpreter not created")); wxCHECK_MSG(!m_is_running, -1, wxT("lua interpreter is already running")); ! m_user_break = FALSE; ! m_is_running = TRUE; //int ret_val = luaL_loadbuffer(m_lua_State, wx2lua(script), script.Len(), wx2lua(name)); int ret_val = lua_dostring(m_lua_State, wx2lua(script)); ! m_is_running = FALSE; // if it's been stopped then don't send this error message, already sent stopped one --- 556,565 ---- wxCHECK_MSG(Ok(), -1, wxT("lua interpreter not created")); wxCHECK_MSG(!m_is_running, -1, wxT("lua interpreter is already running")); ! m_user_break = false; ! m_is_running = true; //int ret_val = luaL_loadbuffer(m_lua_State, wx2lua(script), script.Len(), wx2lua(name)); int ret_val = lua_dostring(m_lua_State, wx2lua(script)); ! m_is_running = false; // if it's been stopped then don't send this error message, already sent stopped one *************** *** 691,695 **** (void)CheckRunError(ret_val); ! m_user_break = FALSE; return ret_val; } --- 567,571 ---- (void)CheckRunError(ret_val); ! m_user_break = false; return ret_val; } *************** *** 699,713 **** wxCHECK_MSG(Ok(), -1, wxT("lua interpreter not created")); wxCHECK_MSG(!m_is_running, -1, wxT("lua interpreter is already running")); ! m_user_break = FALSE; ! m_is_running = TRUE; //int ret_val = luaL_loadbuffer(m_lua_State, (const char*)buf, size, wx2lua(name)); int ret_val = lua_dobuffer(m_lua_State, (const char*)buf, size, wx2lua(name)); ! m_is_running = FALSE; if (!m_user_break) (void)CheckRunError(ret_val); ! m_user_break = FALSE; return ret_val; } --- 575,589 ---- wxCHECK_MSG(Ok(), -1, wxT("lua interpreter not created")); wxCHECK_MSG(!m_is_running, -1, wxT("lua interpreter is already running")); ! m_user_break = false; ! m_is_running = true; //int ret_val = luaL_loadbuffer(m_lua_State, (const char*)buf, size, wx2lua(name)); int ret_val = lua_dobuffer(m_lua_State, (const char*)buf, size, wx2lua(name)); ! m_is_running = false; if (!m_user_break) (void)CheckRunError(ret_val); ! m_user_break = false; return ret_val; } *************** *** 722,728 **** m_break_msg = msg; ! m_user_break = TRUE; ! SetLuaDebugHook(1, -1, FALSE); ! m_is_running = FALSE; } --- 598,604 ---- m_break_msg = msg; ! m_user_break = true; ! SetLuaDebugHook(1, -1, false); ! m_is_running = false; } *************** *** 787,793 **** event.SetInt(-1); // don't know what line the error occured SendEvent( event ); ! return FALSE; } ! return TRUE; } --- 663,669 ---- event.SetInt(-1); // don't know what line the error occured SendEvent( event ); ! return false; } ! return true; } |