From: John L. <jr...@us...> - 2008-01-15 01:04:08
|
Update of /cvsroot/wxlua/wxLua/apps/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv3556/wxLua/apps/wxlua/src Modified Files: wxlua.cpp wxlua.h Log Message: * Changed wxLuaState_Type enum for wxLuaState(lua_State*, wxLuaState_Type) Removed wxLUASTATE_USESTATE and you now | together wxLUASTATE_SETSTATE with wxLUASTATE_OPENBINDINGS if you want the bindings opened. Cleans up the creation of the wxLuaState so a precreated lua_State should be able to be used easier. - Remove poorly named wxLuaState::LuaError() and CheckRunError() and replaced them with the C functions wxlua_errorinfo() and wxlua_LUA_ERR_msg() respectively. - Added wxlua_pushargs(wxChar**, int) for a standard way to push args into Lua. - Copy Lua's print() function to print_lua() instead of simply overwriting it in case someone really wants to use it. Index: wxlua.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxlua/src/wxlua.cpp,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** wxlua.cpp 16 Jul 2007 19:34:12 -0000 1.49 --- wxlua.cpp 15 Jan 2008 01:04:04 -0000 1.50 *************** *** 116,120 **** m_luaConsole = NULL; m_want_console = false; ! m_pDebugTarget = NULL; m_mem_bitmap_added = false; --- 116,120 ---- m_luaConsole = NULL; m_want_console = false; ! m_wxlDebugTarget = NULL; m_mem_bitmap_added = false; *************** *** 194,202 **** arg_count++; // remove -e arg int rc = m_wxlState.RunString(luaCode, wxT("=(command line)")); ! wxString errorStr; ! run_ok = wxLuaState::CheckRunError(rc, &errorStr); ! if (!run_ok) { ! DisplayMessage(errorStr, true, m_wxlState); break; } --- 194,201 ---- arg_count++; // remove -e arg int rc = m_wxlState.RunString(luaCode, wxT("=(command line)")); ! if (rc != 0) { ! run_ok = false; ! DisplayMessage(wxlua_LUA_ERR_msg(rc), true, m_wxlState); break; } *************** *** 221,228 **** if (debugString.AfterFirst(wxT(':')).ToLong(&portNumber)) { ! m_pDebugTarget = new wxLuaDebugTarget(m_wxlState, serverName, (int)portNumber); ! if (m_pDebugTarget != NULL) { ! bool ok = m_pDebugTarget->Run(); //wxSafeShowMessage(wxT("Target"), wxString::Format(wxT("PID %ld TIME %s ok %d"), (long)wxGetProcessId(), wxT(__TIME__), int(ok))); return ok; --- 220,227 ---- if (debugString.AfterFirst(wxT(':')).ToLong(&portNumber)) { ! m_wxlDebugTarget = new wxLuaDebugTarget(m_wxlState, serverName, (int)portNumber); ! if (m_wxlDebugTarget != NULL) { ! bool ok = m_wxlDebugTarget->Run(); //wxSafeShowMessage(wxT("Target"), wxString::Format(wxT("PID %ld TIME %s ok %d"), (long)wxGetProcessId(), wxT(__TIME__), int(ok))); return ok; *************** *** 252,262 **** arg_count = FindFirstCmdParam(arg_count, openFileName, argc, argv); ! PushArgs(argv, argc, arg_count); int rc = m_wxlState.RunBuffer(wxLuaEditor, wxLuaEditor_len, m_programName); ! wxString errorStr; ! run_ok = wxLuaState::CheckRunError(rc, &errorStr); ! if (!run_ok) ! DisplayMessage(errorStr, true, m_wxlState); break; --- 251,262 ---- arg_count = FindFirstCmdParam(arg_count, openFileName, argc, argv); ! wxlua_pushargs(m_wxlState.GetLuaState(), argv, argc, arg_count); int rc = m_wxlState.RunBuffer(wxLuaEditor, wxLuaEditor_len, m_programName); ! if (rc != 0) ! { ! run_ok = false; ! DisplayMessage(wxlua_LUA_ERR_msg(rc), true, m_wxlState); ! } break; *************** *** 276,286 **** arg_count++; // skip the program we're running ! PushArgs(argv, argc, arg_count); int rc = m_wxlState.RunFile(runFileName); ! wxString errorStr; ! run_ok = wxLuaState::CheckRunError(rc, &errorStr); ! if (!run_ok) ! DisplayMessage(errorStr, true, m_wxlState); break; --- 276,287 ---- arg_count++; // skip the program we're running ! wxlua_pushargs(m_wxlState.GetLuaState(), argv, argc, arg_count); int rc = m_wxlState.RunFile(runFileName); ! if (rc != 0) ! { ! run_ok = false; ! DisplayMessage(wxlua_LUA_ERR_msg(rc), true, m_wxlState); ! } break; *************** *** 309,317 **** { // If acting as a debuggee, we're done - disconnect from the debugger. ! if (m_pDebugTarget != NULL) { ! m_pDebugTarget->Stop(); ! delete m_pDebugTarget; ! m_pDebugTarget = NULL; } --- 310,318 ---- { // If acting as a debuggee, we're done - disconnect from the debugger. ! if (m_wxlDebugTarget != NULL) { ! m_wxlDebugTarget->Stop(); ! delete m_wxlDebugTarget; ! m_wxlDebugTarget = NULL; } *************** *** 368,373 **** else { ! if (m_pDebugTarget != NULL) ! m_pDebugTarget->DisplayError(msg); else if (m_luaConsole != NULL) { --- 369,374 ---- else { ! if (m_wxlDebugTarget != NULL) ! m_wxlDebugTarget->DisplayError(msg); else if (m_luaConsole != NULL) { *************** *** 389,437 **** } - void wxLuaStandaloneApp::CreateSimpleArgs() - { - lua_State* L = m_wxlState.GetLuaState(); - lua_newtable(L); - lua_pushstring(L, wx2lua(m_programName)); - lua_rawseti(L, -2, 0); - lua_setglobal(L, "arg"); - } - - // Push the program args into lua, see lua.c function - // static int getargs (lua_State *L, char **argv, int n) - int wxLuaStandaloneApp::PushArgs(wxChar **argv, int argc, int start_n) - { - lua_State* L = m_wxlState.GetLuaState(); - - int i = 0; - int narg = argc - (start_n + 1); // number of arguments to the script - if (narg < 1) - { - // no real args, just stick in the name of this program - lua_newtable(L); - lua_pushstring(L, wx2lua(argv[0])); - lua_rawseti(L, -2, 0); - lua_setglobal(L, "arg"); - } - else - { - luaL_checkstack(L, narg + 3, "too many arguments to script"); - for (i = start_n+1; i < argc; i++) - lua_pushstring(L, wx2lua(argv[i])); - - lua_createtable(L, narg, start_n + 1); - - for (i = 0; i < argc; i++) - { - lua_pushstring(L, wx2lua(argv[i])); - lua_rawseti(L, -2, i - start_n); - } - - lua_setglobal(L, "arg"); - } - - return narg; - } - void wxLuaStandaloneApp::OnLua( wxLuaEvent &event ) { --- 390,393 ---- Index: wxlua.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxlua/src/wxlua.h,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** wxlua.h 12 Dec 2006 01:23:40 -0000 1.23 --- wxlua.h 15 Jan 2008 01:04:04 -0000 1.24 *************** *** 33,39 **** const wxLuaState& wxlState = wxNullLuaState); - void CreateSimpleArgs(); - int PushArgs(wxChar **argv, int argc, int start_n); - void OnLua(wxLuaEvent &event); --- 33,36 ---- *************** *** 43,47 **** bool m_want_console; bool m_mem_bitmap_added; ! wxLuaDebugTarget *m_pDebugTarget; private: --- 40,44 ---- bool m_want_console; bool m_mem_bitmap_added; ! wxLuaDebugTarget *m_wxlDebugTarget; private: |