From: John L. <jr...@us...> - 2005-11-26 08:47:06
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25224/wxLua/modules/wxlua/include Modified Files: internal.h wxlbind.h wxlcallb.h wxldefs.h wxlintrp.h wxlstate.h Log Message: Use the new wxLuaState in place of wxLuaStateVariables (removed) Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** wxlstate.h 26 Nov 2005 03:15:19 -0000 1.3 --- wxlstate.h 26 Nov 2005 08:46:57 -0000 1.4 *************** *** 43,47 **** } ! #include "wxlua/include/internal.h" class WXDLLIMPEXP_WXLUA wxLuaState; --- 43,48 ---- } ! //#include "wxlua/include/internal.h" ! #include "wxlua/include/wxlbind.h" class WXDLLIMPEXP_WXLUA wxLuaState; *************** *** 52,56 **** //---------------------------------------------------------------------------- ! // wxLuaStateRefData - the internal data for the wxLuaState. // please use the wxLuaStare accessor functions //---------------------------------------------------------------------------- --- 53,57 ---- //---------------------------------------------------------------------------- ! // wxLuaStateRefData - the internal data for the wxLuaState. // please use the wxLuaStare accessor functions //---------------------------------------------------------------------------- *************** *** 65,72 **** // destroy and cleanup the lua_State, returns success // if 'force' then make sure all wxWindows are destroyed. ! bool Destroy(bool force); ! // clear all wxLuaCallbacks on destruction void ClearCallbacks(); lua_State *m_lua_State; --- 66,76 ---- // destroy and cleanup the lua_State, returns success // if 'force' then make sure all wxWindows are destroyed. ! bool CloseLuaState(bool force); ! // Free up the tracked resources list. ! void CleanupWxLua(bool closeLua = true); // clear all wxLuaCallbacks on destruction void ClearCallbacks(); + // remove all the bindings + void UnRegisterBindings(); lua_State *m_lua_State; *************** *** 85,96 **** wxEventType m_inEventType; // wxEventType set when in event, else -1 ! wxHashTable* m_pDerivedList; // derived objects. ! wxHashTable* m_pTrackedList; // tracked objects. ! wxList m_pAppHandlerList; // event objects associated with the application object ! wxList m_pDestroyHandlerList; // wxLuaDestroyCallbacks installed ! wxList m_pWindowList; // all wxWindow objects, wxWidgets will delete these ! // but for an embedded program they must be deleted before ! // shutting down the interpreter, else they dangle ! // used in destructor wxArrayInt m_usedIndexes; --- 89,100 ---- wxEventType m_inEventType; // wxEventType set when in event, else -1 ! wxHashTable* m_pDerivedList; // derived objects. ! wxHashTable* m_pTrackedList; // tracked objects. ! wxList* m_pAppHandlerList; // event objects associated with the application object ! wxList* m_pDestroyHandlerList; // wxLuaDestroyCallbacks installed ! wxList* m_pWindowList; // all wxWindow objects, wxWidgets will delete these ! // but for an embedded program they must be deleted before ! // shutting down the interpreter, else they dangle ! // used in destructor wxArrayInt m_usedIndexes; *************** *** 122,128 **** virtual ~wxLuaState() {} - // Destroy the refed data - void Destroy() { UnRef(); } - // Ref the given wxLuaState void Create(const wxLuaState& wxlState); --- 126,129 ---- *************** *** 136,149 **** // Is this wxLuaState valid, has refed data ! bool Ok() const { return m_refData != NULL; } // Get the lua_State lua_State* GetLuaState() const; // ----------------------------------------------------------------------- // Binding functions ! void LUACALL RegisterBindings(bool registerTypes); ! void LUACALL UnRegisterBindings(); wxLuaBinding* GetLuaBinding(const wxString& nameSpace); --- 137,156 ---- // Is this wxLuaState valid, has refed data ! bool Ok() const; ! ! // Destroy the refed data ! void Destroy() { UnRef(); } ! // ! bool CloseLuaState(bool force); // Get the lua_State lua_State* GetLuaState() const; + // Get the ref data (internal use) + wxLuaStateRefData* GetLuaStateRefData() const { return (wxLuaStateRefData*)GetRefData(); } // ----------------------------------------------------------------------- // Binding functions ! void RegisterBindings(bool registerTypes); wxLuaBinding* GetLuaBinding(const wxString& nameSpace); *************** *** 156,159 **** --- 163,174 ---- const WXLUAEVENT * GetLuaEvent(wxEvent *pEvent); + void GarbageCollectWindows(bool closeWindows); + + // ----------------------------------------------------------------------- + // memory tracking functions + bool removeTrackedMemory(void *pObject, bool fDelete); + void addToTrackedMemoryList(wxObject *pObject); + void addToTrackedWindowList(wxWindow *); + // ----------------------------------------------------------------------- // wxLua Lua Registry Table Functions *************** *** 225,229 **** // Given a lua tag, return the corresponding tag name ! const char* LUACALL GetLuaTagName(int nTag); // get the method or 'get' property for the class at cpIndex --- 240,244 ---- // Given a lua tag, return the corresponding tag name ! const char* GetLuaTagName(int nTag); // get the method or 'get' property for the class at cpIndex Index: wxldefs.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxldefs.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** wxldefs.h 25 Nov 2005 02:46:53 -0000 1.1 --- wxldefs.h 26 Nov 2005 08:46:57 -0000 1.2 *************** *** 46,48 **** --- 46,55 ---- #endif + // ---------------------------------------------------------------------------- + // Classes + // ---------------------------------------------------------------------------- + + class WXDLLIMPEXP_WXLUA wxLuaInterpreter; + class WXDLLIMPEXP_WXLUA wxLuaState; + #endif // __WX_WXLDEFS_H__ Index: wxlcallb.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlcallb.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** wxlcallb.h 25 Nov 2005 02:46:53 -0000 1.1 --- wxlcallb.h 26 Nov 2005 08:46:57 -0000 1.2 *************** *** 26,30 **** { public: ! wxLuaCallback( lua_State *state, int theRoutine, wxWindowID id, --- 26,30 ---- { public: ! wxLuaCallback( const wxLuaState& state, int theRoutine, wxWindowID id, *************** *** 34,41 **** virtual ~wxLuaCallback(); ! void ClearState() { m_luaState = NULL; } ! void ClearStateVars() { m_luaStateVars = NULL; } ! lua_State* GetLuaState() const { return m_luaState; } int GetId() const { return m_id; } wxEventType GetEventType() const { return m_eventType; } --- 34,40 ---- virtual ~wxLuaCallback(); ! void ClearState(); ! wxLuaState GetwxLuaState() const { return m_wxlState; } int GetId() const { return m_id; } wxEventType GetEventType() const { return m_eventType; } *************** *** 51,60 **** // reference to the routine to call int m_routine; - // Lua state instance - lua_State *m_luaState; // store the state variables since we're added to a list of callbacks. // The lua_State is NULLed when the window (handler) is destroyed, // but we still want to remove us from the state vars callback list. ! wxLuaStateVariables *m_luaStateVars; wxEvtHandler *m_pHandler; wxWindowID m_id; --- 50,58 ---- // reference to the routine to call int m_routine; // store the state variables since we're added to a list of callbacks. // The lua_State is NULLed when the window (handler) is destroyed, // but we still want to remove us from the state vars callback list. ! wxLuaState m_wxlState; ! wxEvtHandler *m_pHandler; wxWindowID m_id; *************** *** 72,76 **** { public: ! wxLuaDestroyCallback( lua_State *state, wxWindowID id, wxEvtHandler *pHandler, --- 70,74 ---- { public: ! wxLuaDestroyCallback( const wxLuaState& state, wxWindowID id, wxEvtHandler *pHandler, *************** *** 79,86 **** virtual ~wxLuaDestroyCallback(); ! void ClearState() { m_luaState = NULL; } ! void ClearStateVars() { m_luaStateVars = NULL; } ! lua_State* GetLuaState() const { return m_luaState; } wxEvtHandler* GetEvtHandler() const { return m_pHandler; } --- 77,83 ---- virtual ~wxLuaDestroyCallback(); ! void ClearState() { m_wxlState.UnRef(); } ! wxLuaState GetwxLuaState() const { return m_wxlState; } wxEvtHandler* GetEvtHandler() const { return m_pHandler; } *************** *** 92,96 **** // Lua state instance ! lua_State *m_luaState; // store the state variables see wxLuaCallback for reasoning wxLuaStateVariables *m_luaStateVars; --- 89,93 ---- // Lua state instance ! wxLuaState m_wxlState; // store the state variables see wxLuaCallback for reasoning wxLuaStateVariables *m_luaStateVars; Index: wxlintrp.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlintrp.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** wxlintrp.h 25 Nov 2005 10:09:11 -0000 1.2 --- wxlintrp.h 26 Nov 2005 08:46:57 -0000 1.3 *************** *** 17,20 **** --- 17,21 ---- #include "wxlua/include/wxldefs.h" + #include "wxlua/include/wxlstate.h" extern "C" *************** *** 121,126 **** // Get a pointer to the lua_State that "is" lua lua_State *GetLuaState() const; ! // Get a pointer to additional wxLua variables used for this lua_State ! wxLuaStateVariables *GetStateVariables() const; // ----------------------------------------------------------------------- --- 122,126 ---- // Get a pointer to the lua_State that "is" lua lua_State *GetLuaState() const; ! wxLuaState GetwxLuaState() const { return m_wxlState; } // ----------------------------------------------------------------------- *************** *** 150,156 **** wxString m_break_msg; ! wxLuaStateVariables *m_luaStateVariables; ! lua_State *m_lua_State; ! bool m_luaAllocated; int m_lua_debug_hook_count; --- 150,154 ---- wxString m_break_msg; ! wxLuaState m_wxlState; int m_lua_debug_hook_count; Index: wxlbind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlbind.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** wxlbind.h 25 Nov 2005 02:46:53 -0000 1.1 --- wxlbind.h 26 Nov 2005 08:46:57 -0000 1.2 *************** *** 15,20 **** #include "wxlua/include/wxldefs.h" - #include "wxlua/include/wxlua.h" - #include "wxlua/include/wxlintrp.h" extern "C" --- 15,18 ---- Index: internal.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/internal.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** internal.h 26 Nov 2005 03:15:19 -0000 1.7 --- internal.h 26 Nov 2005 08:46:57 -0000 1.8 *************** *** 17,22 **** #include "wxlua/include/wxldefs.h" #include "wxlua/include/wxlbind.h" #include "wxlua/include/wxlua.h" - #include "wxlua/include/wxlintrp.h" extern "C" --- 17,22 ---- #include "wxlua/include/wxldefs.h" #include "wxlua/include/wxlbind.h" + #include "wxlua/include/wxlstate.h" #include "wxlua/include/wxlua.h" extern "C" *************** *** 29,32 **** --- 29,34 ---- // with standard lua functions. + #define WXLUAREFERENCES "wxLuaReferences" + #define wxFileRead read #define wxFileWrite write *************** *** 45,113 **** #endif - // ---------------------------------------------------------------------------- - // wxLuaStateVariables - state variables for a wxLua instance - // ---------------------------------------------------------------------------- - - class WXDLLIMPEXP_WXLUA wxLuaStateVariables - { - public: - wxLuaStateVariables(); - ~wxLuaStateVariables(); - - void ClearCallbacks(); - - void LUACALL RegisterBindings(lua_State *L, bool registerTypes); - void LUACALL UnRegisterBindings(lua_State *L); - - wxLuaBinding* GetLuaBinding(const wxString& nameSpace); - - const WXLUACLASS * GetLuaClass(int iClassTag); - const WXLUACLASS * GetLuaClass(const char* className); - const WXLUACLASS * GetBaseLuaClass(int iClassTag); - bool IsDerivedClass(int iClassTag, int iBaseClassTag); - - const WXLUAEVENT * GetLuaEvent(wxEvent *pEvent); - - wxLuaBindingList m_bindings; // A list of generated lua bindings - - 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_functionTag; // The lua tag for function objects. - int m_wxLuaTable; // The lua tag for the wxLua private tables - int m_wxLuaNull; // The lua tag for wxLuaNull (for NULL pointers) - int m_wxDeleteTable; // The lua tag for the wxWindow destroy tracking table - - wxEventType m_inEventType; // wxEventType set when in event, else -1 - - wxHashTable *m_pDerivedList; // The list of derived objects. - wxHashTable *m_pTrackedList; // The list of tracked objects. - wxList *m_pAppHandlerList; // The list of event objects associated with the application object - wxList *m_pDestroyHandlerList; // The list of wxLuaDestroyCallbacks installed - wxList *m_pWindowList; // The list of all wxWindow objects, wxWidgets will delete these - // but for an embedded program they must be deleted before - // deleting shutting down the interpreter, else they dangle - // used in ~wxLuaInterpreter - wxArrayInt m_usedIndexes; - }; - - // GET_LUASTATEVARS_XXX returns an instance of the wxLuaStateVariables for the - // corresponding lua_State - - extern wxLuaStateVariables *wxFindLuaStateVariables(lua_State *L); extern wxLuaInterpreter *wxFindLuaInterpreter(lua_State *L); - // these follow wxCHECK_MSG/RET semantics - #define GET_LUASTATEVARS_MSG(L, return_val) \ - wxLuaStateVariables *stateVars = wxFindLuaStateVariables(L); \ - wxCHECK_MSG(stateVars, return_val, wxT("invalid wxLuaInterpreter")); - - #define GET_LUASTATEVARS_RET(L) \ - wxLuaStateVariables *stateVars = wxFindLuaStateVariables(L); \ - wxCHECK_RET(stateVars, wxT("invalid wxLuaInterpreter")); - - // Call this on application exit, to let wxLua tidy up - void LUACALL CleanupWxLua(lua_State *L, bool closeLua = true); - // ---------------------------------------------------------------------------- // wxLuaSmartStringArray - Wraps a "new" array of wxStrings with an automatic --- 47,52 ---- *************** *** 172,180 **** void LUACALL addToTrackedMemoryList(lua_State *L, theObject *p##theObject) \ { \ ! GET_LUASTATEVARS_RET(L) \ ! if (stateVars->m_pTrackedList == NULL) \ ! stateVars->m_pTrackedList = new wxHashTable(wxKEY_INTEGER); \ ! if (stateVars->m_pTrackedList != NULL) \ ! stateVars->m_pTrackedList->Put((int)p##theObject, new theObject##Object(p##theObject)); \ } --- 111,119 ---- void LUACALL addToTrackedMemoryList(lua_State *L, theObject *p##theObject) \ { \ ! wxLuaState wxlState(L); \ ! wxCHECK_RET(wxlState.Ok(), wxT("Invalid wxLuaState")); \ ! if (wxlState.GetLuaStateRefData()->m_pTrackedList == NULL) { \ ! wxlState.GetLuaStateRefData()->m_pTrackedList = new wxHashTable(wxKEY_INTEGER); \ ! wxlState.GetLuaStateRefData()->m_pTrackedList->Put((int)p##theObject, new theObject##Object(p##theObject)); } \ } *************** *** 207,221 **** { public: ! wxLuaObject(); // Constructor that is passed a lua state and a parameter index. wxLuaObject(lua_State *, int iParam, int iRef = 1); ~wxLuaObject(); ! // Get the value of the reference object (or a proxy if the object has // been aliased for a wxValidator class. bool GetObject(); // Remove any existing reference and allocated another void SetObject(int iParam); ! // Set the reference and lua state up from a supplied parameter. void SetObject(lua_State *, int iParam); --- 146,162 ---- { public: ! wxLuaObject(); // Constructor that is passed a lua state and a parameter index. wxLuaObject(lua_State *, int iParam, int iRef = 1); + // Constructor that is passed a lua state and a parameter index. + wxLuaObject(const wxLuaState& wxlState, int iParam, int iRef = 1); ~wxLuaObject(); ! // Get the value of the reference object (or a proxy if the object has // been aliased for a wxValidator class. bool GetObject(); // Remove any existing reference and allocated another void SetObject(int iParam); ! // Set the reference and lua state up from a supplied parameter. void SetObject(lua_State *, int iParam); *************** *** 233,240 **** void ModifyAllocationFlags(int iValue); ! lua_State *GetLuaState() const { return m_luaState; } private: ! lua_State *m_luaState; int m_iReference; bool m_bool; --- 174,182 ---- void ModifyAllocationFlags(int iValue); ! wxLuaState GetwxLuaState() const { return m_wxlState; } ! lua_State *GetLuaState() const { return m_wxlState.GetLuaState(); } private: ! wxLuaState m_wxlState; // can't declare full class int m_iReference; bool m_bool; |