From: John L. <jr...@us...> - 2008-12-03 05:26:08
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv3179/wxLua/modules/wxlua/src Modified Files: wxlstate.cpp Log Message: Make wxLuaEdit print items on the stack and use '=' as the Lua executable. Changed wxLuaState::RunBuffer() to take const char*, not const unsigned char*. Allow wxLuaState::RunString/Buffer() to leave values on the stack. Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.174 retrieving revision 1.175 diff -C2 -d -r1.174 -r1.175 *** wxlstate.cpp 17 Mar 2008 03:05:04 -0000 1.174 --- wxlstate.cpp 3 Dec 2008 05:26:03 -0000 1.175 *************** *** 277,281 **** if (line_num_) *line_num_ = (int)line_num; ! return false; } --- 277,281 ---- if (line_num_) *line_num_ = (int)line_num; ! return true; } *************** *** 2525,2529 **** // ---------------------------------------------------------------------------- ! int wxLuaState::RunFile(const wxString &filename) { wxCHECK_MSG(Ok(), LUA_ERRRUN, wxT("Lua interpreter not created")); --- 2525,2529 ---- // ---------------------------------------------------------------------------- ! int wxLuaState::RunFile(const wxString &filename, int nresults) { wxCHECK_MSG(Ok(), LUA_ERRRUN, wxT("Lua interpreter not created")); *************** *** 2536,2544 **** int status = luaL_LoadFile(wx2lua(filename)); if (status == 0) ! status = LuaPCall(0, 0); // no args and no results else SendLuaErrorEvent(status, top); // compilation error ! lua_SetTop(top); // restore original top (removes err msg) M_WXLSTATEDATA->m_wxlStateData->m_debug_hook_break = false; --- 2536,2545 ---- int status = luaL_LoadFile(wx2lua(filename)); if (status == 0) ! status = LuaPCall(0, nresults); // no args and nresults else SendLuaErrorEvent(status, top); // compilation error ! if (nresults == 0) ! lua_SetTop(top); // restore original top (removes err msg) M_WXLSTATEDATA->m_wxlStateData->m_debug_hook_break = false; *************** *** 2548,2558 **** } ! int wxLuaState::RunString(const wxString &script, const wxString& name) { wxLuaCharBuffer buf(script); ! return RunBuffer((unsigned char*)buf.GetData(), buf.Length(), name); } ! int wxLuaState::RunBuffer(const unsigned char buf[], size_t size, const wxString &name) { wxCHECK_MSG(Ok(), LUA_ERRRUN, wxT("Invalid wxLuaState")); --- 2549,2559 ---- } ! int wxLuaState::RunString(const wxString &script, const wxString& name, int nresults) { wxLuaCharBuffer buf(script); ! return RunBuffer(buf.GetData(), buf.Length(), name, nresults); } ! int wxLuaState::RunBuffer(const char buf[], size_t size, const wxString &name, int nresults) { wxCHECK_MSG(Ok(), LUA_ERRRUN, wxT("Invalid wxLuaState")); *************** *** 2563,2573 **** int top = lua_GetTop(); ! int status = luaL_LoadBuffer((const char*)buf, size, wx2lua(name)); if (status == 0) ! status = LuaPCall(0, 0); // no args and no results else SendLuaErrorEvent(status, top); // compilation error ! lua_SetTop(top); // restore original top (removes err msg) M_WXLSTATEDATA->m_wxlStateData->m_debug_hook_break = false; --- 2564,2575 ---- int top = lua_GetTop(); ! int status = luaL_LoadBuffer(buf, size, wx2lua(name)); if (status == 0) ! status = LuaPCall(0, nresults); // no args and nresults else SendLuaErrorEvent(status, top); // compilation error ! if (nresults == 0) ! lua_SetTop(top); // restore original top (removes err msg) M_WXLSTATEDATA->m_wxlStateData->m_debug_hook_break = false; *************** *** 2618,2622 **** --- 2620,2627 ---- if (status != 0) + { SendLuaErrorEvent(status, top - (narg + 1)); + lua_settop(L, top); // restore original top (removes err msg) + } return status; *************** *** 2652,2658 **** { wxLuaCharBuffer buf(script); ! return CompileBuffer((unsigned char*)buf.GetData(), buf.Length(), name, errMsg_, line_num_); } ! int wxLuaState::CompileBuffer(const unsigned char buf[], size_t size, const wxString &name, wxString* errMsg_, int* line_num_) { // create a new lua_State so we don't mess up our own --- 2657,2663 ---- { wxLuaCharBuffer buf(script); ! return CompileBuffer(buf.GetData(), buf.Length(), name, errMsg_, line_num_); } ! int wxLuaState::CompileBuffer(const char buf[], size_t size, const wxString &name, wxString* errMsg_, int* line_num_) { // create a new lua_State so we don't mess up our own *************** *** 2661,2667 **** int top = lua_gettop(L); int status = luaL_loadbuffer(L, (const char*)buf, size, wx2lua(name)); ! status = wxlua_errorinfo(L, status, top, errMsg_, line_num_); lua_close(L); - return 1; return status; } --- 2666,2671 ---- int top = lua_gettop(L); int status = luaL_loadbuffer(L, (const char*)buf, size, wx2lua(name)); ! wxlua_errorinfo(L, status, top, errMsg_, line_num_); lua_close(L); return status; } |