From: John L. <jr...@us...> - 2008-01-05 00:15:49
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv10306/wxLua/modules/wxlua/include Modified Files: wxlstate.h Log Message: A little more cleanup. Fix for Lua clearing weak refs even before the __gc call is made so we miscounted how many instances of the userdata we had and deleted it thinking it was the last. Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.113 retrieving revision 1.114 diff -C2 -d -r1.113 -r1.114 *** wxlstate.h 4 Jan 2008 00:21:08 -0000 1.113 --- wxlstate.h 5 Jan 2008 00:15:45 -0000 1.114 *************** *** 224,228 **** // // Possible values for the "void* lightuserdata_reg_key" are ! // wxlua_lreg_types_key, wxlua_lreg_refs_key, wxlua_lreg_debug_refs_key // unless you are using these functions for your own table in the LUA_REGISTRYINDEX. //---------------------------------------------------------------------------- --- 224,228 ---- // // Possible values for the "void* lightuserdata_reg_key" are ! // &wxlua_lreg_types_key, &wxlua_lreg_refs_key, &wxlua_lreg_debug_refs_key // unless you are using these functions for your own table in the LUA_REGISTRYINDEX. //---------------------------------------------------------------------------- *************** *** 231,245 **** // lightuserdata_reg_key in the LUA_REGISTRYINDEX table. Does not pop the object. // Returns the table index or LUA_REFNIL if the item on the stack is none or nil (an error). ! WXDLLIMPEXP_WXLUA int LUACALL wxluaR_ref(lua_State* L, int stack_idx, const void* lightuserdata_reg_key); // Remove a reference to the object at the index in a table with the key // lightuserdata_reg_key in the LUA_REGISTRYINDEX table, returns success. ! WXDLLIMPEXP_WXLUA bool LUACALL wxluaR_unref(lua_State* L, int wxlref_idx, const void* lightuserdata_reg_key); // Push onto the top of the stack the object at the index in a table with the key // lightuserdata_reg_key in the LUA_REGISTRYINDEX table, if the index is LUA_REFNIL or the // value is nil it returns false and doesn't leave anything on the stack. ! WXDLLIMPEXP_WXLUA bool LUACALL wxluaR_getref(lua_State* L, int wxlref_idx, const void* lightuserdata_reg_key); // Is the item at the stack_idx in the table with the key lightuserdata_reg_key // in the LUA_REGISTRYINDEX table. Returns the ref index or LUA_NOREF if it's not. ! WXDLLIMPEXP_WXLUA int LUACALL wxluaR_isrefed(lua_State* L, int stack_idx, const void* lightuserdata_reg_key); //---------------------------------------------------------------------------- --- 231,245 ---- // lightuserdata_reg_key in the LUA_REGISTRYINDEX table. Does not pop the object. // Returns the table index or LUA_REFNIL if the item on the stack is none or nil (an error). ! WXDLLIMPEXP_WXLUA int LUACALL wxluaR_ref(lua_State* L, int stack_idx, void* lightuserdata_reg_key); // Remove a reference to the object at the index in a table with the key // lightuserdata_reg_key in the LUA_REGISTRYINDEX table, returns success. ! WXDLLIMPEXP_WXLUA bool LUACALL wxluaR_unref(lua_State* L, int wxlref_idx, void* lightuserdata_reg_key); // Push onto the top of the stack the object at the index in a table with the key // lightuserdata_reg_key in the LUA_REGISTRYINDEX table, if the index is LUA_REFNIL or the // value is nil it returns false and doesn't leave anything on the stack. ! WXDLLIMPEXP_WXLUA bool LUACALL wxluaR_getref(lua_State* L, int wxlref_idx, void* lightuserdata_reg_key); // Is the item at the stack_idx in the table with the key lightuserdata_reg_key // in the LUA_REGISTRYINDEX table. Returns the ref index or LUA_NOREF if it's not. ! WXDLLIMPEXP_WXLUA int LUACALL wxluaR_isrefed(lua_State* L, int stack_idx, void* lightuserdata_reg_key); //---------------------------------------------------------------------------- *************** *** 265,273 **** // 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. ! // If WXLUA_DELETE_OBJECT_ALL or if this is the last userdata it will also remove all // wxlua_lreg_weakobjects_key and wxlua_lreg_derivedmethods_key since the object is gone. WXDLLIMPEXP_WXLUA bool LUACALL wxluaO_deletegcobject(lua_State *L, void* udata, void *obj_ptr, int flags); --- 265,273 ---- // 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, 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. ! // If flags = WXLUA_DELETE_OBJECT_ALL or if this is the last userdata it will also remove all // wxlua_lreg_weakobjects_key and wxlua_lreg_derivedmethods_key since the object is gone. WXDLLIMPEXP_WXLUA bool LUACALL wxluaO_deletegcobject(lua_State *L, void* udata, void *obj_ptr, int flags); *************** *** 295,303 **** WXDLLIMPEXP_WXLUA int LUACALL wxluaO_untrackweakobject(lua_State *L, void* udata, void *obj_ptr); // Check if this object with the given wxLua type is in the wxlua_lreg_weakobjects_key ! // table of the LUA_REGISTRYINDEX. // If the object is found with the right wxLua type and push_on_stack is true ! // the Lua userdata for the object is pushed on top of the stack. If it's not ! // found then it returns false and nothing is left on the stack. WXDLLIMPEXP_WXLUA bool LUACALL wxluaO_istrackedweakobject(lua_State *L, void *obj_ptr, int wxl_type, bool push_on_stack); //---------------------------------------------------------------------------- --- 295,307 ---- WXDLLIMPEXP_WXLUA int LUACALL wxluaO_untrackweakobject(lua_State *L, void* udata, void *obj_ptr); // Check if this object with the given wxLua type is in the wxlua_lreg_weakobjects_key ! // table of the LUA_REGISTRYINDEX. // If the object is found with the right wxLua type and push_on_stack is true ! // the Lua userdata for the object is pushed on top of the stack. If it's not ! // found then it returns false and nothing is left on the stack. WXDLLIMPEXP_WXLUA bool LUACALL wxluaO_istrackedweakobject(lua_State *L, void *obj_ptr, int wxl_type, bool push_on_stack); + // Get a wxArrayString of the info in the wxlua_lreg_weakobjects_key LUA_REGISTRYINDEX table. + // Strings are of the form "&obj_ptr = wxLuaTypeName1(&udata, type=wxLuaType), ..." + // If the object is casted to multiple types there will be wxLuaTypeName2(...) and so on. + WXDLLIMPEXP_WXLUA wxArrayString LUACALL wxluaO_gettrackedweakobjectinfo(lua_State *L); //---------------------------------------------------------------------------- *************** *** 493,496 **** --- 497,503 ---- WXDLLIMPEXP_WXLUA void LUACALL wxlua_pushwxString(lua_State* L, const wxString& str); + // Helper function to concatenate a wxArrayString into a wxString. + WXDLLIMPEXP_WXLUA wxString wxlua_concatwxArrayString(const wxArrayString& arr, const wxString& sep = wxT("\n")); + //---------------------------------------------------------------------------- // Derived class member functions for classes in wxLua. The data is stored *************** *** 870,874 **** void AddGCObject(wxObject *wxobj); // See wxluaO_addgcobject(). ! void AddGCObject(const void* obj_ptr, wxObject *wxobj); // See wxluaO_deletegcobject(). bool DeleteGCObject(void* udata, void *obj_ptr, int flags); --- 877,881 ---- void AddGCObject(wxObject *wxobj); // See wxluaO_addgcobject(). ! void AddGCObject(void* obj_ptr, wxObject *wxobj); // See wxluaO_deletegcobject(). bool DeleteGCObject(void* udata, void *obj_ptr, int flags); *************** *** 919,925 **** // wxLua Lua Registry Table Functions ! int wxluaR_Ref(int stack_idx, const void* lightuserdata_reg_key); ! bool wxluaR_Unref(int wxlref_index, const void* lightuserdata_reg_key); ! bool wxluaR_GetRef(int wxlref_index, const void* lightuserdata_reg_key); int wxluaT_NewMetatable(); --- 926,932 ---- // wxLua Lua Registry Table Functions ! int wxluaR_Ref(int stack_idx, void* lightuserdata_reg_key); ! bool wxluaR_Unref(int wxlref_index, void* lightuserdata_reg_key); ! bool wxluaR_GetRef(int wxlref_index, void* lightuserdata_reg_key); int wxluaT_NewMetatable(); |