From: John L. <jr...@us...> - 2007-05-04 19:04:45
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv10286/wxLua/modules/wxlua/src Modified Files: wxlstate.cpp Log Message: add header to incircles.lua Bump version to 2.8.4 to match the upcomming wxWidgets release Fix wxlua_print function to respect __tostring metatable functions and match more closely luaL_print function using \t separators Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** wxlstate.cpp 27 Apr 2007 20:26:57 -0000 1.95 --- wxlstate.cpp 4 May 2007 19:04:41 -0000 1.96 *************** *** 74,77 **** --- 74,78 ---- { wxLuaState wxlState(L); // doesn't have to be ok + wxString msg; int i, n = lua_gettop(L); *************** *** 81,126 **** for (i = 1; i <= n; i++) { ! if (i > 1) msg.Append(wxT(", ")); ! if (lua_isstring(L, i)) ! msg += lua2wx(lua_tostring(L, i)); ! else if (lua_isnumber(L, i)) ! msg += wxString::Format(wxT("%lf"), lua_tonumber(L, i)); ! else if (lua_iscfunction(L, i)) ! msg += wxString::Format(wxT("C function %ld"), (long int)lua_tocfunction(L, i)); ! else if (lua_isuserdata(L, i)) { ! msg += wxString::Format(wxT("User data %ld"), (long int)lua_touserdata(L, i)); ! if (wxlState.Ok()) { ! int nTag = wxlState.ttag(i); ! if (nTag != TLUA_NOTAG) ! { ! wxString name = wxlState.GetLuaTagName(nTag); ! if (!name.IsEmpty()) ! msg += wxString::Format(wxT(" (%s)"), name.c_str()); ! } } - } - else if (lua_isboolean(L, i)) - msg += lua_toboolean(L,i) ? wxT("true") : wxT("false"); - else if (lua_isnil(L,i)) - msg += wxT("nil"); - else if (lua_isnone(L,i)) - msg += wxT("unknown"); - else - msg += wxString::Format(wxT("%s:%p"), lua2wx(lua_typename(L,lua_type(L,i))).c_str(), lua_topointer(L,i)); } ! if (!msg.IsEmpty()) { ! if (wxlState.Ok()) ! { ! wxLuaEvent event(wxEVT_LUA_PRINT, wxlState.GetId(), wxlState); ! event.SetString(msg); ! wxlState.SendEvent( event ); ! } } --- 82,120 ---- for (i = 1; i <= n; i++) { ! // code copied from luaB_print in lbaselib.c ! if (i > 1) msg.Append(wxT("\t")); // lua uses a tab too in luaB_print ! const char *s; ! lua_pushvalue(L, -1); /* function to be called */ ! lua_pushvalue(L, i); /* value to print */ ! lua_call(L, 1, 1); ! s = lua_tostring(L, -1); /* get result */ ! if (s == NULL) { ! // FIXME use terror here? right now terror doesn't do anything special - JL ! return luaL_error(L, LUA_QL("tostring") " must return a string to " ! LUA_QL("print")); ! } ! msg += lua2wx(s); ! lua_pop(L, 1); /* pop result */ ! // if we know the type, add it ! if (lua_isuserdata(L, i) && wxlState.Ok()) ! { ! int nTag = wxlState.ttag(i); ! if (nTag != TLUA_NOTAG) { ! wxString name = wxlState.GetLuaTagName(nTag); ! if (!name.IsEmpty()) ! msg += wxString::Format(wxT(" (%s)"), name.c_str()); } } } ! if (!msg.IsEmpty() && wxlState.Ok()) { ! wxLuaEvent event(wxEVT_LUA_PRINT, wxlState.GetId(), wxlState); ! event.SetString(msg); ! wxlState.SendEvent(event); } |