From: John L. <jr...@us...> - 2007-12-19 06:16:41
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv10699/wxLua/modules/wxlua/include Modified Files: wxlbind.h wxlstate.h Log Message: Give better error messages using the upvalue wxLuaBindMethod we push for function calls. Index: wxlbind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlbind.h,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** wxlbind.h 15 Dec 2007 16:56:41 -0000 1.72 --- wxlbind.h 19 Dec 2007 06:16:35 -0000 1.73 *************** *** 251,256 **** WXDLLIMPEXP_WXLUA int LUACALL wxlua_CallOverloadedFunction(lua_State* L, struct wxLuaBindMethod* wxlMethod); ! // Return a human readable string of the args for the functions in the method ! WXDLLIMPEXP_WXLUA wxArrayString wxlua_CreateMethodArgTagsMsg(lua_State* L, struct wxLuaBindMethod* method); // ---------------------------------------------------------------------------- --- 251,259 ---- WXDLLIMPEXP_WXLUA int LUACALL wxlua_CallOverloadedFunction(lua_State* L, struct wxLuaBindMethod* wxlMethod); ! // Get a human readable string of the Lua args (items on the stack) for a function call ! WXDLLIMPEXP_WXLUA wxString wxlua_getLuaArgsMsg(lua_State* L, int start_stack_idx, int end_stack_idx); ! ! // Get a human readable wxArrayString of the wxLua args for the functions in the method ! WXDLLIMPEXP_WXLUA wxArrayString wxlua_getBindMethodArgsMsg(lua_State* L, struct wxLuaBindMethod* method); // ---------------------------------------------------------------------------- Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.109 retrieving revision 1.110 diff -C2 -d -r1.109 -r1.110 *** wxlstate.h 19 Dec 2007 00:42:10 -0000 1.109 --- wxlstate.h 19 Dec 2007 06:16:35 -0000 1.110 *************** *** 90,94 **** extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_refs_key; // The key in the LUA_REGISTRYINDEX table that is a numerically keyed table ! // with references to objects the wxLuaDebugData wants to keep a handle to. It // stores their value for faster lookup. It is used only for the wxLuaDebugData. // LUA_REGISTRYINDEX[&wxlua_lreg_debug_refs_key][ref number] = Lua object --- 90,94 ---- extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_refs_key; // The key in the LUA_REGISTRYINDEX table that is a numerically keyed table ! // with references to objects the wxLuaDebugData wants to keep a handle to. It // stores their value for faster lookup. It is used only for the wxLuaDebugData. // LUA_REGISTRYINDEX[&wxlua_lreg_debug_refs_key][ref number] = Lua object *************** *** 100,104 **** // The key in the LUA_REGISTRYINDEX table that is a table // of Lua functions assigned to wxLua userdata programatically in Lua. ! // LUA_REGISTRYINDEX[&wxlua_lreg_derivedmethods_key][lightuserdata(obj_ptr)] = // {["derived func/value name"] = wxLuaObject(Lua function/value), ...} extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_derivedmethods_key; --- 100,104 ---- // The key in the LUA_REGISTRYINDEX table that is a table // of Lua functions assigned to wxLua userdata programatically in Lua. ! // LUA_REGISTRYINDEX[&wxlua_lreg_derivedmethods_key][lightuserdata(obj_ptr)] = // {["derived func/value name"] = wxLuaObject(Lua function/value), ...} extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_derivedmethods_key; *************** *** 111,115 **** // Note: A single object like a wxWindow may be pushed with multiple tags. // e.g. wxWindow* w = wx.wxWindow() retrieve the window later from wxObject* wxEvent:GetEventObject() ! // LUA_REGISTRYINDEX[&wxlua_lreg_weakobjects_key][lightuserdata(obj_ptr)] = // { tag1 = weak fulluserdata, tag2 = weak fulluserdata... } extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_weakobjects_key; --- 111,115 ---- // Note: A single object like a wxWindow may be pushed with multiple tags. // e.g. wxWindow* w = wx.wxWindow() retrieve the window later from wxObject* wxEvent:GetEventObject() ! // LUA_REGISTRYINDEX[&wxlua_lreg_weakobjects_key][lightuserdata(obj_ptr)] = // { tag1 = weak fulluserdata, tag2 = weak fulluserdata... } extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_weakobjects_key; *************** *** 119,135 **** // the key is the object pointer and the value is the wxObject encapsulation. // If not encapsulated both the key and the value are the same. ! // LUA_REGISTRYINDEX[&wxlua_lreg_gcobjects_key][lightuserdata(obj_ptr)] = // lightuserdata(wxObject derived class) extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_gcobjects_key; // The key in the LUA_REGISTRYINDEX table that is table of all // wxLuaEventCallbacks that we've created. ! // LUA_REGISTRYINDEX[&wxlua_lreg_evtcallbacks_key][lightuserdata(&wxLuaEventCallback)] = // lightuserdata(&wxEvtHandler) extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_evtcallbacks_key; // The key in the LUA_REGISTRYINDEX table that is table of all ! // wxLuaWinDestroyCallbacks that we've created. // Two key/value pairs are created for fast lookup. // LUA_REGISTRYINDEX[&wxlua_lreg_windestroycallbacks_key][lightuserdata(&wxLuaWinDestroyCallback)] = 1 ! // LUA_REGISTRYINDEX[&wxlua_lreg_windestroycallbacks_key][lightuserdata(&wxWindow)] = // lightuserdata(wxLuaWinDestroyCallback) extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_windestroycallbacks_key; --- 119,135 ---- // the key is the object pointer and the value is the wxObject encapsulation. // If not encapsulated both the key and the value are the same. ! // LUA_REGISTRYINDEX[&wxlua_lreg_gcobjects_key][lightuserdata(obj_ptr)] = // lightuserdata(wxObject derived class) extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_gcobjects_key; // The key in the LUA_REGISTRYINDEX table that is table of all // wxLuaEventCallbacks that we've created. ! // LUA_REGISTRYINDEX[&wxlua_lreg_evtcallbacks_key][lightuserdata(&wxLuaEventCallback)] = // lightuserdata(&wxEvtHandler) extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_evtcallbacks_key; // The key in the LUA_REGISTRYINDEX table that is table of all ! // wxLuaWinDestroyCallbacks that we've created. // Two key/value pairs are created for fast lookup. // LUA_REGISTRYINDEX[&wxlua_lreg_windestroycallbacks_key][lightuserdata(&wxLuaWinDestroyCallback)] = 1 ! // LUA_REGISTRYINDEX[&wxlua_lreg_windestroycallbacks_key][lightuserdata(&wxWindow)] = // lightuserdata(wxLuaWinDestroyCallback) extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_windestroycallbacks_key; *************** *** 155,159 **** // This is used by the wxLuaDebugData to know if the table is one of the wxLua // registry tables for better wxLuaStackDialog performance. ! // LUA_REGISTRYINDEX[&wxlua_lreg_regtable_key][weak {wxlua_lreg_XXX_key table}] = // lightuserdata(&wxlua_lreg_XXX_key) extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_regtable_key; --- 155,159 ---- // This is used by the wxLuaDebugData to know if the table is one of the wxLua // registry tables for better wxLuaStackDialog performance. ! // LUA_REGISTRYINDEX[&wxlua_lreg_regtable_key][weak {wxlua_lreg_XXX_key table}] = // lightuserdata(&wxlua_lreg_XXX_key) extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_regtable_key; *************** *** 175,179 **** // wxlua_lreg_tags_key table this metatable is for. extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_metatable_tag_key; ! // The key of a metatable used for wxLua userdata that stores a lightuserdata // of the wxLuaBindClass struct for this class. extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_metatable_wxluabindclass_key; --- 175,179 ---- // wxlua_lreg_tags_key table this metatable is for. extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_metatable_tag_key; ! // The key of a metatable used for wxLua userdata that stores a lightuserdata // of the wxLuaBindClass struct for this class. extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_metatable_wxluabindclass_key; *************** *** 196,199 **** --- 196,203 ---- wxLUA_UNICODE_ONLY(WXDLLIMPEXP_WXLUA inline void LUACALL wxlua_error(lua_State* L, const wxString& errorMsg) { wxlua_error(L, wx2lua(errorMsg)); }) + // Create an error message that the item at the stack_idx is not of the type wxl_tag + // and call wxlua_error(). + WXDLLIMPEXP_WXLUA void LUACALL wxlua_argerror(lua_State *L, int stack_idx, const wxString& expectedType); + // Get the userdata at the stack index, if null_ptr then set the pointer wrapped // by Lua's userdata to NULL to clear it. *************** *** 260,264 **** // Get the userdata object at the stack_idx that is of the class type tag or a ! // class derived from the tag. If the data type does not have the correct tag, // or if the parameter isn't a userdata then wxlua_error() is called and NULL is returned. WXDLLIMPEXP_WXLUA void* LUACALL wxluaT_getuserdatatype(lua_State* L, int stack_idx, int wxl_tag); --- 264,268 ---- // Get the userdata object at the stack_idx that is of the class type tag or a ! // class derived from the tag. If the data type does not have the correct tag, // or if the parameter isn't a userdata then wxlua_error() is called and NULL is returned. WXDLLIMPEXP_WXLUA void* LUACALL wxluaT_getuserdatatype(lua_State* L, int stack_idx, int wxl_tag); *************** *** 277,281 **** //---------------------------------------------------------------------------- // wxluaO_XXX - functions operate on wxLua "Objects" which are userdata wrapping ! // C++ class objects and are stored in the wxlua_lreg_weakobjects_key // and the wxlua_lreg_gcobjects_key table in the LUA_REGISTRYINDEX. //---------------------------------------------------------------------------- --- 281,285 ---- //---------------------------------------------------------------------------- // wxluaO_XXX - functions operate on wxLua "Objects" which are userdata wrapping ! // C++ class objects and are stored in the wxlua_lreg_weakobjects_key // and the wxlua_lreg_gcobjects_key table in the LUA_REGISTRYINDEX. //---------------------------------------------------------------------------- *************** *** 286,290 **** // last userdata referece to it. ! WXLUA_DELETE_OBJECT_ALL = 0x0001, // Delete the object and clear all // userdata references to it. }; --- 290,294 ---- // last userdata referece to it. ! WXLUA_DELETE_OBJECT_ALL = 0x0001, // Delete the object and clear all // userdata references to it. }; *************** *** 292,302 **** // Track this wxObject and delete it when Lua calls the __gc method for it. // The object is stored in the wxlua_lreg_gcobjects_key of the LUA_REGISTRYINDEX. ! // The second version is used when a non-wxObject class is encapsulated and // the obj_ptr points to the actual object that the wxObject encapsulates. // Note that the lua userdata internal pointer is the obj_ptr and the ! // wxobj is *only* stored in the wxlua_lreg_gcobjects_key. WXDLLIMPEXP_WXLUA void LUACALL wxluaO_addgcobject(lua_State* L, wxObject* wxobj); WXDLLIMPEXP_WXLUA void LUACALL wxluaO_addgcobject(lua_State* L, const void* obj_ptr, wxObject* wxobj); ! // Remove this obj_ptr wrapped in a Lua userdata, udata, from the // wxlua_lreg_gcobjects_key table of the LUA_REGISTRYINDEX. // It is deleted depending on the flags enum wxLuaGCObject_Flags. --- 296,306 ---- // Track this wxObject and delete it when Lua calls the __gc method for it. // The object is stored in the wxlua_lreg_gcobjects_key of the LUA_REGISTRYINDEX. ! // The second version is used when a non-wxObject class is encapsulated and // the obj_ptr points to the actual object that the wxObject encapsulates. // Note that the lua userdata internal pointer is the obj_ptr and the ! // wxobj is *only* stored in the wxlua_lreg_gcobjects_key. WXDLLIMPEXP_WXLUA void LUACALL wxluaO_addgcobject(lua_State* L, wxObject* wxobj); WXDLLIMPEXP_WXLUA void LUACALL wxluaO_addgcobject(lua_State* L, const void* obj_ptr, wxObject* wxobj); ! // Remove this obj_ptr wrapped in a Lua userdata, udata, from the // wxlua_lreg_gcobjects_key table of the LUA_REGISTRYINDEX. // It is deleted depending on the flags enum wxLuaGCObject_Flags. *************** *** 315,327 **** WXDLLIMPEXP_WXLUA wxArrayString LUACALL wxluaO_getgcobjectinfo(lua_State *L); ! // Track the obj_ptr and it's Lua userdata at udata_stack_idx in the // wxlua_lreg_weakobjects_key table of the LUA_REGISTRYINDEX so we can push // it again if needed. WXDLLIMPEXP_WXLUA void LUACALL wxluaO_trackweakobject(lua_State *L, int udata_stack_idx, void *obj_ptr, int tag); // Remove the obj_ptr key from the wxlua_lreg_weakobjects_key table of ! // the LUA_REGISTRYINDEX. It removes the metatable for the single Lua userdata, ! // "udata", since this function is called before the object is deleted. // e.g. p1 = wx.wxPoint(); p2 = p1; p2:delete(); p1:SetX(5) errors, but doesn't segfault ! // If udata == NULL it removes ALL tracked userdata for this obj_ptr and clears // all of their metatables. WXDLLIMPEXP_WXLUA int LUACALL wxluaO_untrackweakobject(lua_State *L, void* udata, void *obj_ptr); --- 319,331 ---- WXDLLIMPEXP_WXLUA wxArrayString LUACALL wxluaO_getgcobjectinfo(lua_State *L); ! // Track the obj_ptr and it's Lua userdata at udata_stack_idx in the // wxlua_lreg_weakobjects_key table of the LUA_REGISTRYINDEX so we can push // it again if needed. WXDLLIMPEXP_WXLUA void LUACALL wxluaO_trackweakobject(lua_State *L, int udata_stack_idx, void *obj_ptr, int tag); // Remove the obj_ptr key from the wxlua_lreg_weakobjects_key table of ! // the LUA_REGISTRYINDEX. It removes the metatable for the single Lua userdata, ! // "udata", since this function is called before the object is deleted. // e.g. p1 = wx.wxPoint(); p2 = p1; p2:delete(); p1:SetX(5) errors, but doesn't segfault ! // If udata == NULL it removes ALL tracked userdata for this obj_ptr and clears // all of their metatables. WXDLLIMPEXP_WXLUA int LUACALL wxluaO_untrackweakobject(lua_State *L, void* udata, void *obj_ptr); *************** *** 350,355 **** // ---------------------------------------------------------------------------- ! // Functions to get info about the tags or the args wxLua uses to determine ! // the lua_type() or C++ class type. // Used to determine what to expect for a function call in the bindings. // ---------------------------------------------------------------------------- --- 354,359 ---- // ---------------------------------------------------------------------------- ! // Functions to get info about the tags or the args wxLua uses to determine ! // the lua_type() or C++ class type. // Used to determine what to expect for a function call in the bindings. // ---------------------------------------------------------------------------- *************** *** 378,382 **** // returns -1 (LUA_TNONE) if the tag was not one of the predefined types. WXDLLIMPEXP_WXLUA int wxlua_getluatype(int wxluatype); ! // Get the lua_typename(lua_type(stack_idx)) as a wxString WXDLLIMPEXP_WXLUA wxString LUACALL wxlua_gettypename(lua_State* L, int stack_idx); --- 382,386 ---- // returns -1 (LUA_TNONE) if the tag was not one of the predefined types. WXDLLIMPEXP_WXLUA int wxlua_getluatype(int wxluatype); ! // Get the lua_typename(lua_type(L, stack_idx)) as a wxString WXDLLIMPEXP_WXLUA wxString LUACALL wxlua_gettypename(lua_State* L, int stack_idx); *************** *** 454,458 **** //---------------------------------------------------------------------------- ! // Derived class member functions for classes in wxLua. The data is stored // in the wxlua_lreg_derivedmethods_key table in the LUA_REGISTRYINDEX. //---------------------------------------------------------------------------- --- 458,462 ---- //---------------------------------------------------------------------------- ! // Derived class member functions for classes in wxLua. The data is stored // in the wxlua_lreg_derivedmethods_key table in the LUA_REGISTRYINDEX. //---------------------------------------------------------------------------- *************** *** 461,472 **** // wxLua userdata object that we will push onto the stack when they access // the __index of the object with the "method_name". The obj_ptr is the ! // object the Lua userdata stores and the new wxLuaObject wraps the Lua // function or value which will be deleted by wxLua when the userdata is deleted. WXDLLIMPEXP_WXLUA bool LUACALL wxlua_setderivedmethod(lua_State* L, void *obj_ptr, const char *method_name, wxLuaObject* wxlObj); ! // Is there a derived method for the given obj_ptr with the method_name that was // added by calling wxlua_setderivedmethod()? // If push_method then push the method onto the stack. WXDLLIMPEXP_WXLUA bool LUACALL wxlua_hasderivedmethod(lua_State* L, void *obj_ptr, const char *method_name, bool push_method); ! // Remove any derived functions or values for the obj_ptr that have been added with // wxlua_setderivedmethod(). // This is called when an object is being garbage collected by wxluaO_deletegcobject() --- 465,476 ---- // wxLua userdata object that we will push onto the stack when they access // the __index of the object with the "method_name". The obj_ptr is the ! // object the Lua userdata stores and the new wxLuaObject wraps the Lua // function or value which will be deleted by wxLua when the userdata is deleted. WXDLLIMPEXP_WXLUA bool LUACALL wxlua_setderivedmethod(lua_State* L, void *obj_ptr, const char *method_name, wxLuaObject* wxlObj); ! // Is there a derived method for the given obj_ptr with the method_name that was // added by calling wxlua_setderivedmethod()? // If push_method then push the method onto the stack. WXDLLIMPEXP_WXLUA bool LUACALL wxlua_hasderivedmethod(lua_State* L, void *obj_ptr, const char *method_name, bool push_method); ! // Remove any derived functions or values for the obj_ptr that have been added with // wxlua_setderivedmethod(). // This is called when an object is being garbage collected by wxluaO_deletegcobject() *************** *** 490,494 **** // Get the wxlua_lreg_wxeventtype_key value of the LUA_REGISTRYINDEX table // to see if we're currently in a wxEvent callback. ! // Returns wxEVT_NULL if not in an event handler. // Be careful about destroying Lua when in an event handler. WXDLLIMPEXP_WXLUA wxEventType LUACALL wxlua_getwxeventtype(lua_State* L); --- 494,498 ---- // Get the wxlua_lreg_wxeventtype_key value of the LUA_REGISTRYINDEX table // to see if we're currently in a wxEvent callback. ! // Returns wxEVT_NULL if not in an event handler. // Be careful about destroying Lua when in an event handler. WXDLLIMPEXP_WXLUA wxEventType LUACALL wxlua_getwxeventtype(lua_State* L); *************** *** 510,515 **** public: wxLuaDebugHookData() : m_lua_debug_hook_count(100), m_lua_debug_hook_yield(50), ! m_lua_debug_hook(0), m_lua_debug_hook_send_evt(false), ! m_last_debug_hook_time(0), m_debug_hook_break(false), m_debug_hook_break_msg(wxT("Break")) {} --- 514,519 ---- public: wxLuaDebugHookData() : m_lua_debug_hook_count(100), m_lua_debug_hook_yield(50), ! m_lua_debug_hook(0), m_lua_debug_hook_send_evt(false), ! m_last_debug_hook_time(0), m_debug_hook_break(false), m_debug_hook_break_msg(wxT("Break")) {} |