From: John L. <jr...@us...> - 2006-12-14 01:01:34
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv1560/wxLua/modules/wxlua/include Modified Files: wxlbind.h wxlcallb.h wxldefs.h wxlstate.h Log Message: speed up genwxbind.lua add wxLuaBinding::GetBindingName as a unique name to know if it's added Rename *AddToTrackedMemory -> AddTrackedObject since it only tracks wxObjects Rename wxLuaState::AddTrackedEventHandler to AddTrackedCallback and only accept wxLuaCallbacks Rename wxLuaState::AddTrackedDestroyEventHandler to AddTrackedWinDestroyCallback and only accept wxLuaWinDestroyCallbacks Make type evaluation for the bindings more strict Index: wxlcallb.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlcallb.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** wxlcallb.h 12 Dec 2006 07:09:41 -0000 1.14 --- wxlcallb.h 14 Dec 2006 01:01:26 -0000 1.15 *************** *** 1,4 **** ///////////////////////////////////////////////////////////////////////////// ! // Purpose: wxLuaCallback and wxLuaDestroyCallback // Author: Francis Irving // Created: 21/01/2002 --- 1,5 ---- ///////////////////////////////////////////////////////////////////////////// ! // Name: wxlcallb.h ! // Purpose: wxLuaCallback and wxLuaWinDestroyCallback // Author: Francis Irving // Created: 21/01/2002 *************** *** 14,27 **** // ---------------------------------------------------------------------------- ! // wxLuaCallback - proxy class to pass a reference to a lua function ! // through the wxWidgets event system. // ---------------------------------------------------------------------------- ! class WXDLLIMPEXP_WXLUA wxLuaCallback : public wxEvtHandler { public: // winID and lastID follow the same notation as wxEvtHandler::Connect // if only one event Id is needed set lastId = wxID_ANY ! wxLuaCallback( const wxLuaState& state, int theRoutine, wxWindowID winId, wxWindowID lastId, wxEventType eventType, wxEvtHandler *pHandler ); --- 15,37 ---- // ---------------------------------------------------------------------------- ! // wxLuaCallback - Forward events from C++ wxWidgets wxEvtHandlers to lua functions ! // ! // The wxLuaCallback is created with the wxLuaState, the stack index of the ! // lua function to call when an event is received, the window id ranges, and ! // the wxEventType to connect to the wxEvtHandler with this as the callback ! // user data for event. ! // ! // Do NOT delete this, the wxEvtHandler deletes the callback user data itself. ! // ! // The function wxLuaCallback::EventHandler generically handles the events and ! // forwards them to the event's wxLuaCallback callback user data CallFunction(). // ---------------------------------------------------------------------------- ! class WXDLLIMPEXP_WXLUA wxLuaCallback : public wxObject { public: // winID and lastID follow the same notation as wxEvtHandler::Connect // if only one event Id is needed set lastId = wxID_ANY ! wxLuaCallback( const wxLuaState& state, int lua_func_stack_idx, wxWindowID winId, wxWindowID lastId, wxEventType eventType, wxEvtHandler *pHandler ); *************** *** 32,53 **** wxLuaState GetwxLuaState() const { return m_wxlState; } ! int GetId() const { return m_id; } wxEventType GetEventType() const { return m_eventType; } wxEvtHandler *GetEvtHandler() const { return m_pHandler; } ! // central event handler ! // This function is called with "this" being of the type which the event is ! // arriving at. The user data wxLuaCallback is used to route it to the ! // correct place by calling CallFunction with the event. void EventHandler(wxEvent& event); ! ! protected: ! // event handler dispatcher back to Lua ! // Call a lua function to handle an event. The lua function will receive ! // a single parameter, the type of event. virtual void CallFunction(wxEvent *pEvent); ! // reference to the lua routine to call ! int m_routine; // store the wxLuaState since we're added to a list of it's callbacks. --- 42,59 ---- wxLuaState GetwxLuaState() const { return m_wxlState; } ! wxWindowID GetId() const { return m_id; } ! wxWindowID GetLastId() const { return m_lastId; } wxEventType GetEventType() const { return m_eventType; } wxEvtHandler *GetEvtHandler() const { return m_pHandler; } ! // Central event handler that calls CallFunction() for the actual ! // wxLuaCallback callback user data void EventHandler(wxEvent& event); ! // Handle the event by calling the lua function to handle the event. ! // The lua function will receive a single parameter, the type of event. virtual void CallFunction(wxEvent *pEvent); ! protected: ! int m_routine; // reference to the lua routine to call // store the wxLuaState since we're added to a list of it's callbacks. *************** *** 63,78 **** // ---------------------------------------------------------------------------- ! // wxLuaDestroyCallback - proxy class to handle the destruction of wxWindow ! // derived objects using wxEVT_DESTROY // ---------------------------------------------------------------------------- ! class WXDLLIMPEXP_WXLUA wxLuaDestroyCallback : public wxEvtHandler { public: ! wxLuaDestroyCallback( const wxLuaState& state, ! wxWindowID id, wxEvtHandler *pHandler, ! int iTag ); ! virtual ~wxLuaDestroyCallback(); void ClearwxLuaState() { m_wxlState.UnRef(); } --- 69,87 ---- // ---------------------------------------------------------------------------- ! // wxLuaWinDestroyCallback - Handle the wxEVT_DESTROY event from wxWindows. ! // ! // Removes the reference to the window so lua won't delete it. ! // ! // Do NOT delete this, the wxEvtHandler deletes the callback user data itself. // ---------------------------------------------------------------------------- ! class WXDLLIMPEXP_WXLUA wxLuaWinDestroyCallback : public wxObject { public: ! wxLuaWinDestroyCallback(const wxLuaState& state, ! wxWindowID id, wxEvtHandler *pHandler, ! int iTag); ! virtual ~wxLuaWinDestroyCallback(); void ClearwxLuaState() { m_wxlState.UnRef(); } *************** *** 82,91 **** wxEvtHandler* GetEvtHandler() const { return m_pHandler; } ! // central event handler void EventHandler(wxWindowDestroyEvent& event); protected: - void OnDestroy(); - // store the wxLuaState since we're added to a list of it's callbacks. wxLuaState m_wxlState; --- 91,101 ---- wxEvtHandler* GetEvtHandler() const { return m_pHandler; } ! // Central event handler that calls OnDestroy() for the actual ! // wxLuaWinDestroyCallback callback user data void EventHandler(wxWindowDestroyEvent& event); + // Handle the event by clearing the metatable for the window + virtual void OnDestroy(wxWindowDestroyEvent& event); protected: // store the wxLuaState since we're added to a list of it's callbacks. wxLuaState m_wxlState; *************** *** 94,98 **** private: ! DECLARE_ABSTRACT_CLASS(wxLuaDestroyCallback) }; --- 104,108 ---- private: ! DECLARE_ABSTRACT_CLASS(wxLuaWinDestroyCallback) }; Index: wxldefs.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxldefs.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** wxldefs.h 13 Dec 2006 06:57:50 -0000 1.10 --- wxldefs.h 14 Dec 2006 01:01:26 -0000 1.11 *************** *** 49,53 **** //----------------------------------------------------------------------------- ! #define WXLUA_BINDING_VERSION 2 // ---------------------------------------------------------------------------- --- 49,53 ---- //----------------------------------------------------------------------------- ! #define WXLUA_BINDING_VERSION 3 // ---------------------------------------------------------------------------- Index: wxlbind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlbind.h,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** wxlbind.h 12 Dec 2006 07:09:41 -0000 1.30 --- wxlbind.h 14 Dec 2006 01:01:26 -0000 1.31 *************** *** 215,219 **** #define wxLUA_DECLARE_ENCAPSULATION(IMPEXPSYMBOL, className, objName) \ ! IMPEXPSYMBOL void LUACALL wxLua_AddToTrackedMemoryList(wxLuaState& wxlState, className *); \ class IMPEXPSYMBOL wxObject_##objName : public wxObject \ { \ --- 215,219 ---- #define wxLUA_DECLARE_ENCAPSULATION(IMPEXPSYMBOL, className, objName) \ ! IMPEXPSYMBOL void LUACALL wxLua_AddTrackedObject(wxLuaState& wxlState, className *); \ class IMPEXPSYMBOL wxObject_##objName : public wxObject \ { \ *************** *** 232,238 **** if (m_p##objName != NULL) delete m_p##objName; \ } \ ! void LUACALL wxLua_AddToTrackedMemoryList(wxLuaState& wxlState, className *p##objName) \ { \ ! wxlState.AddToTrackedMemoryList((long)p##objName, new wxObject_##objName(p##objName)); \ } --- 232,238 ---- if (m_p##objName != NULL) delete m_p##objName; \ } \ ! void LUACALL wxLua_AddTrackedObject(wxLuaState& wxlState, className *p##objName) \ { \ ! wxlState.AddTrackedObject((long)p##objName, new wxObject_##objName(p##objName)); \ } *************** *** 240,244 **** // garbage collection purposes. This is a C function for symmetry with // the functions defined using wxLUA_DECLARE_ENCAPSULATION. ! WXDLLIMPEXP_WXLUA void LUACALL wxLua_AddToTrackedMemoryList(wxLuaState& wxlState, wxObject *); // ---------------------------------------------------------------------------- --- 240,244 ---- // garbage collection purposes. This is a C function for symmetry with // the functions defined using wxLUA_DECLARE_ENCAPSULATION. ! WXDLLIMPEXP_WXLUA void LUACALL wxLua_AddTrackedObject(wxLuaState& wxlState, wxObject *); // ---------------------------------------------------------------------------- *************** *** 298,301 **** --- 298,307 ---- virtual void UnRegisterBinding(lua_State* L); + // Get/Set the binding name, a unique name of the binding. + // By default it is the "hook_cpp_namespace" used in the binding + // generator which needs to be a unique name. + wxString GetBindingName() const { return m_bindingName; } + void SetBindingName(const wxString& name) { m_bindingName = name; } + // Get/Set the namespace in lua that this binding will be installed to wxString GetLuaNamespace() const { return m_nameSpace; } *************** *** 360,363 **** --- 366,370 ---- WXLUAMETHOD* m_functionList; + wxString m_bindingName; // A unique name of the binding wxString m_nameSpace; // lua table namespace e.g. "wx" bool m_bindings_registered; // Is the binding registered Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** wxlstate.h 12 Dec 2006 07:09:41 -0000 1.56 --- wxlstate.h 14 Dec 2006 01:01:26 -0000 1.57 *************** *** 48,51 **** --- 48,53 ---- class WXDLLIMPEXP_WXLUA wxLuaState; class WXDLLIMPEXP_WXLUA wxLuaStateRefData; + class WXDLLIMPEXP_WXLUA wxLuaCallback; + class WXDLLIMPEXP_WXLUA wxLuaWinDestroyCallback; WX_DECLARE_STRING_HASH_MAP_WITH_DECL(long, wxLuaStringToLongHashMap, class WXDLLIMPEXP_WXLUA); *************** *** 212,224 **** wxEventType m_inEventType; // wxEventType set when in event, else wxEVT_NULL ! wxLongToLongHashMap m_pDerivedList; // derived objects. ! wxLongToLongHashMap m_pTrackedList; // tracked objects. ! wxList m_eventHandlerList; // event objects for wxLuaCallback ! wxList m_destroyHandlerList; // wxLuaDestroyCallbacks installed ! wxList m_windowList; // all wxWindow objects, wxWidgets will delete these ! // but for an embedded program they must be deleted before ! // shutting down the interpreter, else they dangle ! wxArrayInt m_unusedReferenceIndexes; // array of unused (available) table indicies in the ! // wxLuaReferences registry table bool m_is_running; // is the lua_State running a script --- 214,226 ---- wxEventType m_inEventType; // wxEventType set when in event, else wxEVT_NULL ! wxLongToLongHashMap m_pDerivedList; // derived objects. ! wxLongToLongHashMap m_trackedObjects; // tracked objects. ! wxList m_callbackList; // event objects for wxLuaCallback ! wxList m_winDestroyCallbackList; // wxLuaWinDestroyCallback installed ! wxList m_windowList; // all wxWindow objects, wxWidgets will delete these ! // but for an embedded program they must be deleted before ! // shutting down the interpreter, else they dangle ! wxArrayInt m_unusedReferenceIndexes; // array of unused (available) table indicies in the ! // wxLuaReferences registry table bool m_is_running; // is the lua_State running a script *************** *** 355,358 **** --- 357,362 ---- // event handler. Be careful about destroying lua when in an event handler. wxEventType GetInEventType() const; + // Set the wxEventType that the lua code is currently running (internal use) + void SetInEventType(wxEventType eventType); // ----------------------------------------------------------------------- *************** *** 451,461 **** wxLUA_UNUSED_NOTUNICODE(void RegisterFunction(lua_CFunction func, const wxString &funcName) { RegisterFunction(func, wx2lua(funcName)); }) // Register all the bindings in the wxLuaStateData, this is done ! // automatically by default void RegisterBindings(bool registerTypes); ! // Get the wxLuaBinding with the given nameSpace or NULL for no match ! // only returns the first binding with the given namespace, but more than ! // two can share the same namespace. ! wxLuaBinding* GetLuaBinding(const wxString& nameSpace) const; // Get WXLUACLASS for given lua Tag, the number lua uses to track the class --- 455,464 ---- wxLUA_UNUSED_NOTUNICODE(void RegisterFunction(lua_CFunction func, const wxString &funcName) { RegisterFunction(func, wx2lua(funcName)); }) // Register all the bindings in the wxLuaStateData, this is done ! // automatically by default (internal use) void RegisterBindings(bool registerTypes); ! // Get the installed wxLuaBinding with the given ! // wxLuaBinding::GetBindingName or NULL for no match. ! wxLuaBinding* GetLuaBinding(const wxString& bindingName) const; // Get WXLUACLASS for given lua Tag, the number lua uses to track the class *************** *** 489,505 **** // 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; --- 492,509 ---- // Track this object and delete it when lua calls the gc method for it ! void AddTrackedObject(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 AddTrackedObject(long obj_ptr, wxObject *pObject); // Remove the object from the tracked memory and if fDelete, delete it too. ! bool RemoveTrackedObject(void *pObject, bool fDelete = true); ! wxLongToLongHashMap* GetTrackedObjects(); // Add a wxWindow to track and delete when we're closed, only track ! // the parent window, not it's children. ! void AddTrackedWindow(wxWindow *win); ! // Don't track this window anymore and don't delete it. ! bool 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; *************** *** 509,522 **** 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); ! wxList* GetTrackedDestroyEventHandlerList(); // ----------------------------------------------------------------------- --- 513,525 ---- void GarbageCollectWindows(bool closeWindows); ! // Add or remove a tracked wxLuaCallback connected to a wxEvtHandler ! void AddTrackedCallback(wxLuaCallback* callback); ! bool RemoveTrackedCallback(wxLuaCallback* callback); ! wxList* GetTrackedCallbackList(); ! // Add or remove a tracked wxLuaWinDestroyCallback connected to wxEVT_DESTROY. ! void AddTrackedWinDestroyCallback(wxLuaWinDestroyCallback* callback); ! bool RemoveTrackedWinDestroyCallback(wxLuaWinDestroyCallback* callback); ! wxList* GetTrackedWinDestroyCallbackList(); // ----------------------------------------------------------------------- |