From: John L. <jr...@us...> - 2008-12-05 21:15:16
|
Update of /cvsroot/wxlua/wxLua/apps/wxluaedit/src In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv1652/wxLua/apps/wxluaedit/src Modified Files: wxledit.cpp Log Message: Allow convertion of wxStrings to const char in wxlua_getstringtype() Make wxLua app allow for printing to stdout, msgdlg, and/or console as cmd line option Check for and don't crash if someone replaces tostring() with garbage Index: wxledit.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxluaedit/src/wxledit.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** wxledit.cpp 3 Dec 2008 05:26:03 -0000 1.36 --- wxledit.cpp 5 Dec 2008 21:15:11 -0000 1.37 *************** *** 183,188 **** if (ret && (top2 > top1)) { for (int n = top1+1; n <= top2; n++) ! AppendText(m_wxlState.lua_TowxString(n) + wxT("\n")); } --- 183,205 ---- if (ret && (top2 > top1)) { + m_wxlState.lua_GetGlobal("tostring"); + + if (!m_wxlState.lua_IsFunction(-1)) + { + // This code is also used in wxlua_printFunction() + AppendText(wxT("wxLua ERROR: Unable to print() without the tostring() function. Did you remove it?\n")); + m_wxlState.lua_Pop(1); // pop the nil or whatever replaced tostring() + top2 = top1; // don't let for loop run + } + for (int n = top1+1; n <= top2; n++) ! { ! m_wxlState.lua_PushValue(-1); // push tostring function to be called ! m_wxlState.lua_PushValue(n); // value to print ! m_wxlState.lua_Call(1, 1); // run tostring function ! ! AppendText(m_wxlState.lua_TowxString(-1) + wxT("\n")); ! m_wxlState.lua_Pop(1); // pop string from "tostring" function ! } } |