From: John L. <jr...@us...> - 2006-12-12 07:09:45
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv18786/wxLua/modules/wxlua/include Modified Files: wxlbind.h wxlcallb.h wxlstate.h Log Message: lots of little cleanups Add wx.NULL to replace wx.wxNull (which still exists) to be more C like Don't have static WXLUAMETHODs and then en extern pointer to them, just don't have them static More variable/function name changes to make the code more readable Index: wxlcallb.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlcallb.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** wxlcallb.h 12 Dec 2006 01:23:40 -0000 1.13 --- wxlcallb.h 12 Dec 2006 07:09:41 -0000 1.14 *************** *** 29,33 **** virtual ~wxLuaCallback(); ! void ClearLuaState() { m_wxlState.UnRef(); } wxLuaState GetwxLuaState() const { return m_wxlState; } --- 29,33 ---- virtual ~wxLuaCallback(); ! void ClearwxLuaState() { m_wxlState.UnRef(); } wxLuaState GetwxLuaState() const { return m_wxlState; } *************** *** 76,80 **** virtual ~wxLuaDestroyCallback(); ! void ClearLuaState() { m_wxlState.UnRef(); } wxLuaState GetwxLuaState() const { return m_wxlState; } --- 76,80 ---- virtual ~wxLuaDestroyCallback(); ! void ClearwxLuaState() { m_wxlState.UnRef(); } wxLuaState GetwxLuaState() const { return m_wxlState; } Index: wxlbind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlbind.h,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** wxlbind.h 12 Dec 2006 01:23:40 -0000 1.29 --- wxlbind.h 12 Dec 2006 07:09:41 -0000 1.30 *************** *** 360,368 **** WXLUAMETHOD* m_functionList; ! wxString m_nameSpace; // lua table namespace e.g. "wx" ! bool m_typesRegistered; // Is the binding registered ! int m_startTag; // The first wxLua allocated lua tag ! int m_lastTag; // The last wxLua lua tag of registered classes ! int m_wxLuaTable; // The lua tag for the wxLua private tables static wxLuaBindingList sm_bindingList; --- 360,368 ---- WXLUAMETHOD* m_functionList; ! wxString m_nameSpace; // lua table namespace e.g. "wx" ! bool m_bindings_registered; // Is the binding registered ! int m_startTag; // The first wxLua allocated lua tag ! int m_lastTag; // The last wxLua lua tag of registered classes ! int m_wxLuaTable; // The lua tag for the wxLua private tables static wxLuaBindingList sm_bindingList; Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** wxlstate.h 12 Dec 2006 01:23:40 -0000 1.55 --- wxlstate.h 12 Dec 2006 07:09:41 -0000 1.56 *************** *** 141,146 **** // Push the "wxLuaReferences" string onto the stack WXDLLIMPEXP_WXLUA void LUACALL wxLua_lua_push_wxLuaReferences(lua_State* L); - // push the "wxLuaNull" string onto the stack - WXDLLIMPEXP_WXLUA void LUACALL wxLua_lua_push_wxLuaNull(lua_State* L); // Helper functions to get numbers, booleans and strings safer --- 141,144 ---- *************** *** 151,155 **** WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_isenumerationtype(lua_State* L, int stack_idx); WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_isnumbertype(lua_State* L, int stack_idx); ! // After verifying using wxLua_lua_isXXXtype return the value WXDLLIMPEXP_WXLUA const char* LUACALL wxLua_lua_getstringtype(lua_State* L, int stack_idx); WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_getbooleantype(lua_State* L, int stack_idx); --- 149,154 ---- WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_isenumerationtype(lua_State* L, int stack_idx); WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_isnumbertype(lua_State* L, int stack_idx); ! // After verifying using wxLua_lua_isXXXtype return the value, else calls ! // WXDLLIMPEXP_WXLUA const char* LUACALL wxLua_lua_getstringtype(lua_State* L, int stack_idx); WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_getbooleantype(lua_State* L, int stack_idx); *************** *** 165,172 **** // Return a pointer to the array of wxStrings (you need to delete them) // and returns the number of strings in the array in count. ! WXDLLIMPEXP_WXLUA wxString* LUACALL wxLua_lua_getwxstringarray(lua_State* L, int stack_idx, int& count); // Adds the table at stack index to the wxArrayString // Return the number of strings added to the array in count. ! WXDLLIMPEXP_WXLUA int LUACALL wxLua_lua_getwxarraystring(lua_State* L, int stack_idx, wxArrayString& strArray); // Convert the table at stack index to a "new" array of const char* strings. // Return a pointer to the array of strings (you need to delete them) --- 164,171 ---- // Return a pointer to the array of wxStrings (you need to delete them) // and returns the number of strings in the array in count. ! WXDLLIMPEXP_WXLUA wxString* LUACALL wxLua_lua_getwxStringarray(lua_State* L, int stack_idx, int& count); // Adds the table at stack index to the wxArrayString // Return the number of strings added to the array in count. ! WXDLLIMPEXP_WXLUA int LUACALL wxLua_lua_getwxArrayString(lua_State* L, int stack_idx, wxArrayString& strArray); // Convert the table at stack index to a "new" array of const char* strings. // Return a pointer to the array of strings (you need to delete them) *************** *** 179,190 **** // Adds the table at stack index to the wxArrayInt // Return the number of strings added to the array in count. ! WXDLLIMPEXP_WXLUA int LUACALL wxLua_lua_getwxarrayint(lua_State* L, int stack_idx, wxArrayInt& intArray); // Creates a lua table and pushes the strings into it, returns the number of items added // The table is left on the stack ! WXDLLIMPEXP_WXLUA int LUACALL wxLua_lua_pushwxarraystringtable(lua_State* L, const wxArrayString& strArray); // Creates a lua table and pushes the ints into it, returns the number of items added // The table is left on the stack ! WXDLLIMPEXP_WXLUA int LUACALL wxLua_lua_pushwxarrayinttable(lua_State* L, const wxArrayInt& intArray); //---------------------------------------------------------------------------- --- 178,189 ---- // Adds the table at stack index to the wxArrayInt // Return the number of strings added to the array in count. ! WXDLLIMPEXP_WXLUA int LUACALL wxLua_lua_getwxArrayInt(lua_State* L, int stack_idx, wxArrayInt& intArray); // Creates a lua table and pushes the strings into it, returns the number of items added // The table is left on the stack ! WXDLLIMPEXP_WXLUA int LUACALL wxLua_lua_pushwxArrayStringtable(lua_State* L, const wxArrayString& strArray); // Creates a lua table and pushes the ints into it, returns the number of items added // The table is left on the stack ! WXDLLIMPEXP_WXLUA int LUACALL wxLua_lua_pushwxArrayInttable(lua_State* L, const wxArrayInt& intArray); //---------------------------------------------------------------------------- *************** *** 199,211 **** ~wxLuaStateData(); ! wxLuaBindingList m_bindings; // A wxList of generated lua bindings ! // that are loaded into lua on startup - bool m_typesRegistered; // Are the bindings registered into the lua_State int m_wxluatag_wxLuaFunction; // The lua tag for wxLuaFunctions. ! int m_wxluatag_wxLuaNull; // The lua tag for wxLuaNull (for NULL pointers) int m_wxluatag_wxWinDestroyTable; // The lua tag for the wxWindow destroy tracking table ! int m_wxluatag_wxEventTag; // The lua tag for wxEvents ! int m_wxluatag_wxWindowTag; // The lua tag for wxWindows bool m_callbase_func; // call the base class function instead of derived func --- 198,210 ---- ~wxLuaStateData(); ! wxLuaBindingList m_bindingList; // A wxList of generated lua bindings ! // that are loaded into lua on startup ! bool m_bindings_registered; // Are the bindings registered into the lua_State int m_wxluatag_wxLuaFunction; // The lua tag for wxLuaFunctions. ! int m_wxluatag_NULL; // The lua tag for NULL pointer int m_wxluatag_wxWinDestroyTable; // The lua tag for the wxWindow destroy tracking table ! int m_wxluatag_wxEvent; // The lua tag for wxEvents ! int m_wxluatag_wxWindow; // The lua tag for wxWindows bool m_callbase_func; // call the base class function instead of derived func *************** *** 227,231 **** bool m_debug_hook_break; // should the lua_State break for next debug_hook ! wxString m_debug_hook_break_msg; // message when the breaking in the debug_hook unsigned long m_last_debug_hook_time; // last time the debug hook was called --- 226,230 ---- bool m_debug_hook_break; // should the lua_State break for next debug_hook ! wxString m_debug_hook_break_msg; // message when breaking in the debug_hook unsigned long m_last_debug_hook_time; // last time the debug hook was called *************** *** 237,243 **** wxEvtHandler *m_evtHandler; // event handler to send wxLuaEvents to wxWindowID m_id; // event id to send the events with - - private: - void Init(); }; --- 236,239 ---- *************** *** 247,253 **** //---------------------------------------------------------------------------- - #include "wx/dynarray.h" - WX_DECLARE_OBJARRAY_WITH_DECL(wxLuaState, wxArrayLuaState, class WXDLLIMPEXP_WXLUA); - #include "wx/hashmap.h" WX_DECLARE_VOIDPTR_HASH_MAP_WITH_DECL(wxLuaStateRefData *, wxHashMapLuaStateRefData, class WXDLLIMPEXP_WXLUA); --- 243,246 ---- *************** *** 277,281 **** wxLuaStateData* m_wxlStateData; // the data shared for this state bool m_own_stateData; // not a coroutine when true - wxArrayLuaState m_coroutineStates; // a list of all coroutine states // Get the wxLuaStateRefData from the corresponding lua_State --- 270,273 ---- *************** *** 283,290 **** static wxLuaStateRefData* GetLuaStateRefData(lua_State* L); // A mapping between hashmap[lua_State* L] = *wxLuaStateRefData static wxHashMapLuaStateRefData s_wxHashMapLuaStateRefData; - - private: - void Init(); }; --- 275,281 ---- static wxLuaStateRefData* GetLuaStateRefData(lua_State* L); // A mapping between hashmap[lua_State* L] = *wxLuaStateRefData + // Note: The coroutines are not hashed since we cannot know when they + // are deleted. We create wxLuaStates for them on the fly. static wxHashMapLuaStateRefData s_wxHashMapLuaStateRefData; }; *************** *** 376,380 **** // Sends a wxLuaEvent, after checking that this is valid, to the set ! // wxEventHandler (see SetEventHandler) which may be NULL. void SendEvent( wxLuaEvent &event ) const; --- 367,371 ---- // Sends a wxLuaEvent, after checking that this is valid, to the set ! // wxEventHandler with the set id (see SetEventHandler) which may be NULL. void SendEvent( wxLuaEvent &event ) const; *************** *** 393,397 **** // Replacement for lua_pcall that sends a wxEVT_LUA_ERROR on error ! // narg in the number of args to the function to call // if clear then the function is void and no return values, // else nresults is LUA_MULTRET to leave all of them on the stack --- 384,388 ---- // Replacement for lua_pcall that sends a wxEVT_LUA_ERROR on error ! // narg is the number of args to the function to call // if clear then the function is void and no return values, // else nresults is LUA_MULTRET to leave all of them on the stack *************** *** 482,488 **** // you may add or remove bindings before creation wxLuaBindingList* GetLuaBindingList() const; ! bool GetTypesRegistered() const; // Is the binding registered int GetwxLuaFunctionTag() const; // The lua tag for wxLuaFunction objects. ! int GetLuaNull() const; // The lua tag for wxLuaNull (for NULL pointers) int GetLuaWinDestroyTable() const; // The lua tag for the wxWindow destroy tracking table int GetwxEventTag() const; // The lua tag for wxEvents --- 473,479 ---- // you may add or remove bindings before creation wxLuaBindingList* GetLuaBindingList() const; ! bool GetBindingsRegistered() const; // Are the binding registered int GetwxLuaFunctionTag() const; // The lua tag for wxLuaFunction objects. ! int GetLuaNULL() const; // The lua tag for NULL pointer int GetLuaWinDestroyTable() const; // The lua tag for the wxWindow destroy tracking table int GetwxEventTag() const; // The lua tag for wxEvents *************** *** 497,518 **** // memory tracking functions (internal use) void AddToTrackedMemoryList(wxObject *pObject); void AddToTrackedMemoryList(long obj_ptr, wxObject *pObject); bool RemoveTrackedMemory(void *pObject, bool fDelete = true); void AddToTrackedWindowList(wxWindow *win); void RemoveTrackedWindow(wxWindow *win); bool IsWindowTracked(wxWindow *win, bool check_parents = true) const; ! // delete all stray wxWindow dervied classes that have been destroyed ! // by wxWidgets (eg. a child window) (for debugging perhaps) void GarbageCollectWindows(bool closeWindows); ! // add or remove a wxEvtHandler used by lua code, see usage in wxLuaCallback void AddTrackedEventHandler(wxEvtHandler* evtHandler); bool RemoveTrackedEventHandler(wxEvtHandler* evtHandler); wxList* GetTrackedEventHandlerList(); ! // add or remove a wxEvtHandler used by lua code, see usage in wxLuaDestroyCallback void AddTrackedDestroyEventHandler(wxEvtHandler* evtHandler); bool RemoveTrackedDestroyEventHandler(wxEvtHandler* evtHandler); --- 488,519 ---- // memory tracking functions (internal use) + // Track this object and delete it when lua calls the gc method for it void AddToTrackedMemoryList(wxObject *pObject); + // Track this object, but hash it on the obj_ptr which may differ from the + // pObject and delete it when lua calls the gc method for it. + // This is used for encapsulated classes that are wrapped in a wxObject. void AddToTrackedMemoryList(long obj_ptr, wxObject *pObject); + // Remove the object from the tracked memory and if fDelete, delete it too. bool RemoveTrackedMemory(void *pObject, bool fDelete = true); + // Add a wxWindow to track and delete when we're closed, only track + // the parent window, no it's children. void AddToTrackedWindowList(wxWindow *win); + // Don't track this window anymore. void RemoveTrackedWindow(wxWindow *win); + // Is this window tracked, if check_parents see if a parent of it is. bool IsWindowTracked(wxWindow *win, bool check_parents = true) const; ! // delete all stray wxWindow derived classes that have been destroyed ! // by wxWidgets (eg. a child window) (not needed, for debugging perhaps?) void GarbageCollectWindows(bool closeWindows); ! // Add or remove a wxEvtHandler used by lua code, see usage in wxLuaCallback void AddTrackedEventHandler(wxEvtHandler* evtHandler); bool RemoveTrackedEventHandler(wxEvtHandler* evtHandler); wxList* GetTrackedEventHandlerList(); ! // Add or remove a wxEvtHandler connected to wxEVT_DESTROY used by lua code, ! // see usage in wxLuaDestroyCallback void AddTrackedDestroyEventHandler(wxEvtHandler* evtHandler); bool RemoveTrackedDestroyEventHandler(wxEvtHandler* evtHandler); *************** *** 619,623 **** // Convert a wxArrayString object to a table of strings, returns number of values ! int PushwxArrayStringTable(wxArrayString &strArray); // Convert a wxArrayInt object to a table of numbers, returns number of values int PushwxArrayIntTable(const wxArrayInt &intArray); --- 620,624 ---- // Convert a wxArrayString object to a table of strings, returns number of values ! int PushwxArrayStringTable(const wxArrayString &strArray); // Convert a wxArrayInt object to a table of numbers, returns number of values int PushwxArrayIntTable(const wxArrayInt &intArray); *************** *** 753,757 **** // Raw lua garbage-collection functions, lua.h ! int lua_GetGCCount(); // ----------------------------------------------------------------------- --- 754,758 ---- // Raw lua garbage-collection functions, lua.h ! int lua_GetGCCount(); // ----------------------------------------------------------------------- *************** *** 798,808 **** wxLUA_UNUSED_NOTUNICODE(int lua_GetInfo(const wxString& what, lua_Debug* ar) { return lua_GetInfo(wx2lua(what), ar); }) const char* lua_GetLocal(const lua_Debug* ar, int n); - wxString lua_GetLocalwxString(const lua_Debug* ar, int n) { return lua2wx(lua_GetLocal(ar, n)); } const char* lua_SetLocal(const lua_Debug* ar, int n); - wxString lua_SetLocalwxString(const lua_Debug* ar, int n) { return lua2wx(lua_SetLocal(ar, n)); } const char* lua_GetUpValue(int funcindex, int n); - wxString lua_GetUpValuewxString(int funcindex, int n) { return lua2wx(lua_GetUpValue(funcindex, n)); } const char* lua_SetUpValue(int funcindex, int n); - wxString lua_SetUpValuewxString(int funcindex, int n) { return lua2wx(lua_SetUpValue(funcindex, n)); } int lua_SetHook(lua_Hook func, int mask, int count); --- 799,805 ---- |