From: John L. <jr...@us...> - 2007-02-22 00:01:41
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv16385/wxLua/modules/wxlua/src Modified Files: wxlstate.cpp Log Message: Added wxLuaState::GetwxStringType who's input is either a lua string or a wxString userdata Use it in bindings instead of GetStringType wxNode::IndexOf is now protected in wxWidgets 2.8 so remove it Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** wxlstate.cpp 21 Jan 2007 23:13:07 -0000 1.86 --- wxlstate.cpp 22 Feb 2007 00:01:36 -0000 1.87 *************** *** 853,856 **** --- 853,857 ---- m_wxluatag_wxEvent(0), m_wxluatag_wxWindow(0), + m_wxluatag_wxString(0), m_callbase_func(false), m_inEventType(wxEVT_NULL), *************** *** 1871,1874 **** --- 1872,1889 ---- return M_WXLSTATEDATA->m_wxlStateData->m_wxluatag_wxWindow; } + int wxLuaState::GetwxStringTag() const + { + wxCHECK_MSG(Ok(), 0, wxT("Invalid wxLuaState")); + + // Find the wxWindow tag once and store it for later use + if (M_WXLSTATEDATA->m_wxlStateData->m_wxluatag_wxString == 0) + { + const WXLUACLASS* luaClass = GetLuaClass("wxString"); + wxCHECK_MSG(luaClass, 0, wxT("wxString lua tag is missing in wxLuaState, forgot to add wxWidgets binding?")); + M_WXLSTATEDATA->m_wxlStateData->m_wxluatag_wxString = *luaClass->class_tag; + } + + return M_WXLSTATEDATA->m_wxlStateData->m_wxluatag_wxString; + } void wxLuaState::SetCallBaseClassFunction(bool call_base) *************** *** 2313,2316 **** --- 2328,2356 ---- return wxLua_lua_getstringtype(M_WXLSTATEDATA->m_lua_State, stack_idx); } + wxString wxLuaState::GetwxStringType(int stack_idx) + { + wxCHECK_MSG(Ok(), wxEmptyString, wxT("Invalid wxLuaState")); + + lua_State* L = M_WXLSTATEDATA->m_lua_State; + + if (wxLua_lua_isstringtype(L, stack_idx)) + return lua2wx(lua_tostring(L, stack_idx)); + else if (lua_isuserdata(L, stack_idx) && !lua_islightuserdata(L, stack_idx)) + { + int stack_tag = wxLua_lua_ttag(L, stack_idx); + + if (IsDerivedClass(stack_tag, GetwxStringTag())) + { + wxString* wxstr = (wxString*)wxLua_lua_ttouserdata(L, stack_idx, false); + return *wxstr; + } + } + + wxString msg(wxString::Format(_("wxLua: Expected a string or wxString for parameter %d, but got '%s'."), + stack_idx, lua2wx(lua_typename(L, lua_type(L, stack_idx))).c_str())); + wxLua_lua_terror(L, wx2lua(msg)); + + return wxEmptyString; + } bool wxLuaState::GetBooleanType(int stack_idx) { |