From: John L. <jr...@us...> - 2005-12-22 18:42:45
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19516/wxLua/modules/wxlua/include Modified Files: wxlbind.h wxldefs.h wxlintrp.h wxlstate.h Log Message: Removed the wxLuaInterpreter - all functions transferred to the wxLuaState wxLuaInterpreter is typedefed to wxLuaState temporarily Index: wxlintrp.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlintrp.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** wxlintrp.h 28 Nov 2005 01:28:54 -0000 1.4 --- wxlintrp.h 22 Dec 2005 18:42:35 -0000 1.5 *************** *** 30,46 **** class WXDLLEXPORT wxEvtHandler; - class WXDLLIMPEXP_WXLUA wxLuaEvent; - class WXDLLIMPEXP_WXLUA wxLuaInterpreter; - - #include "wx/hashmap.h" - WX_DECLARE_VOIDPTR_HASH_MAP( wxLuaInterpreter *, wxHashMapLuaInterpreter ); - extern wxHashMapLuaInterpreter s_wxHashMapLuaInterpreter; - - //----------------------------------------------------------------------------- - // Extra wxLua helpers that use the lua_State to find owner wxLuaInterpreter - //----------------------------------------------------------------------------- - - extern wxLuaInterpreter *wxFindLuaInterpreter(lua_State *L); //----------------------------------------------------------------------------- --- 30,34 ---- *************** *** 51,165 **** //----------------------------------------------------------------------------- ! class WXDLLIMPEXP_WXLUA wxLuaInterpreter : public wxObject ! { ! public: ! // default constructor - must call Create in order to use ! wxLuaInterpreter(); ! // Create a wxLua instance, handler and id can be null/wxID_ANY for don't care ! wxLuaInterpreter(wxEvtHandler *handler, wxWindowID id = wxID_ANY); ! wxLuaInterpreter(lua_State *L, wxEvtHandler *handler, wxWindowID id = wxID_ANY); ! ! virtual ~wxLuaInterpreter(); ! ! // (re)Create a new wxLua instance, handler and id can be null/wxID_ANY for don't care ! // don't forget to ShutDown the last one first (if you want to) ! bool Create(lua_State *L, wxEvtHandler *handler=NULL, wxWindowID id = wxID_ANY); ! bool Create(wxEvtHandler *handler=NULL, wxWindowID id = wxID_ANY) ! { return Create(NULL, handler, id); } ! // destroy and cleanup the interpreter, returns sucess ! // if 'force' then make sure all wxWindows are destroyed. ! bool Destroy(bool force = true); ! ! // cleanup window list ! void GarbageCollectWindows(bool closeWindows = false); ! ! // has the interpreter been sucessfully created ! bool Ok() const; ! ! // Set the event handler that the events will be sent to, can be null ! void SetEventHandler(wxEvtHandler *evtHandler); ! wxEvtHandler *GetEventHandler() const { return m_evtHandler; } ! ! // Get/Set the id that the events will be sent with ! void SetId(int id) { m_id = id; } ! int GetId() const { return m_id; } ! ! // Run a lua file ! int RunFile(const wxString &fileName); ! // Run a string that contains lua code ! int RunString(const wxString &script, const wxString& name = wxEmptyString); ! // Run a char array #include(d) from bin2c compilation ! int RunBuffer(const unsigned char buf[], size_t size, const wxString &name = wxT("= lua")); - // Is a program running now - bool IsRunning() const { return m_is_running; } - // Break a currently running lua program - void Break(const wxString &message = wxT("Interpreter stopped")); - // has Break() been called - bool GetBreak() const { return m_user_break; } - wxString GetBreakMessage() const { return m_break_msg; } ! // Have lua run an internal hook function with this mask ! // hook = LUA_MASKCALL | LUA_MASKRET | LUA_MASKLINE | LUA_MASKCOUNT ! // Every count hook mask a wxEVT_LUA_DEBUG_HOOK event is sent if send_debug_evt ! // if yield > 0 then wxYield is called every yield milliseconds ! // I don't know what resonable values are ! // turn the hook off with count < 1 ! void SetLuaDebugHook(int count = 1000, ! int yield = 50, ! bool send_debug_evt = false, ! int hook = LUA_MASKCOUNT); ! int GetLuaDebugHookCount() const { return m_lua_debug_hook_count; } ! int GetLuaDebugHookYield() const { return m_lua_debug_hook_yield; } ! bool GetLuaDebugHookSendEvt() const { return m_lua_debug_hook_send_evt; } ! int GetLuaDebugHook() const { return m_lua_debug_hook; } ! ! // registers a new function for Lua ! void RegisterFunction(lua_CFunction func, const wxString &funcName); - // Get a pointer to the lua_State that "is" lua - lua_State *GetLuaState() const; - wxLuaState GetwxLuaState() const { return m_wxlState; } // ----------------------------------------------------------------------- // implementation ! // generic function to generate a wxEVT_LUA_ERROR with the string message ! void DisplayError( const wxString &errorMsg ); ! ! // checks return val of 'lua_load' and `lua_pcall', if error send wxEVT_LUA_ERROR ! bool CheckRunError(int rc); ! ! // internally used so debug hook events are sent no more often than yield time ! unsigned long GetLastLuaDebugHookTime() const; ! void SetLastLuaDebugHookTime(unsigned long t); ! ! void SendEvent( wxLuaEvent &event ) const; ! ! // operators ! operator lua_State*() { return GetLuaState(); } ! ! protected: ! bool m_is_running; ! ! unsigned long m_last_debug_hook_time; ! ! bool m_user_break; ! wxString m_break_msg; ! ! wxLuaState m_wxlState; ! ! int m_lua_debug_hook_count; ! int m_lua_debug_hook_yield; ! bool m_lua_debug_hook_send_evt; ! int m_lua_debug_hook; ! ! wxEvtHandler *m_evtHandler; ! int m_id; ! ! private : ! void Init(); ! DECLARE_ABSTRACT_CLASS(wxLuaInterpreter) ! }; //----------------------------------------------------------------------------- --- 39,52 ---- //----------------------------------------------------------------------------- ! typedef class wxLuaState wxLuaInterpreter; ! /* // ----------------------------------------------------------------------- // implementation ! */ //----------------------------------------------------------------------------- *************** *** 171,180 **** public: wxLuaEvent(wxEventType commandType = wxEVT_NULL, wxWindowID id = wxID_ANY, ! wxLuaInterpreter *intrepreter=NULL); wxLuaEvent( const wxLuaEvent &event ) : wxNotifyEvent(event) { m_stop_interpreter = event.m_stop_interpreter; ! m_luaInterpreter = event.m_luaInterpreter; m_lua_Debug = event.m_lua_Debug; } --- 58,67 ---- public: wxLuaEvent(wxEventType commandType = wxEVT_NULL, wxWindowID id = wxID_ANY, ! const wxLuaState& wxlState = wxNullLuaState); wxLuaEvent( const wxLuaEvent &event ) : wxNotifyEvent(event) { m_stop_interpreter = event.m_stop_interpreter; ! m_wxlState = event.m_wxlState; m_lua_Debug = event.m_lua_Debug; } *************** *** 187,194 **** int GetLineNum() const { return m_commandInt; } ! wxLuaInterpreter *GetLuaInterpreter() const { return m_luaInterpreter; } ! void SetLuaInterpreter(wxLuaInterpreter *interp) { m_luaInterpreter = interp; } ! lua_State *GetLuaState() const { return m_luaInterpreter ? m_luaInterpreter->GetLuaState() : NULL; } // non null only for EVT_LUA_DEBUG_HOOK lua_Debug *GetLuaDebug() const { return m_lua_Debug; } --- 74,81 ---- int GetLineNum() const { return m_commandInt; } ! wxLuaState GetwxLuaState() const { return m_wxlState; } ! void SetwxLuaState(const wxLuaState& wxlState) { m_wxlState = wxlState; } ! lua_State *GetLuaState() const { return m_wxlState.GetLuaState(); } // non null only for EVT_LUA_DEBUG_HOOK lua_Debug *GetLuaDebug() const { return m_lua_Debug; } *************** *** 198,202 **** bool m_stop_interpreter; ! wxLuaInterpreter *m_luaInterpreter; lua_Debug *m_lua_Debug; }; --- 85,89 ---- bool m_stop_interpreter; ! wxLuaState m_wxlState; lua_Debug *m_lua_Debug; }; Index: wxldefs.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxldefs.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** wxldefs.h 26 Nov 2005 08:46:57 -0000 1.2 --- wxldefs.h 22 Dec 2005 18:42:34 -0000 1.3 *************** *** 50,54 **** // ---------------------------------------------------------------------------- - class WXDLLIMPEXP_WXLUA wxLuaInterpreter; class WXDLLIMPEXP_WXLUA wxLuaState; --- 50,53 ---- Index: wxlbind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlbind.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** wxlbind.h 12 Dec 2005 05:16:31 -0000 1.7 --- wxlbind.h 22 Dec 2005 18:42:34 -0000 1.8 *************** *** 136,140 **** virtual void RegisterBinding(const wxLuaState& wxlState, bool registerTypes); // Unbinds C Functions/Defines/Object/Events by clearing Lua Table ! virtual void UnRegisterBinding(const wxLuaState& wxlState); size_t GetLuaClassCount() const { return m_classCount; } --- 136,140 ---- virtual void RegisterBinding(const wxLuaState& wxlState, bool registerTypes); // Unbinds C Functions/Defines/Object/Events by clearing Lua Table ! virtual void UnRegisterBinding(lua_State* L); size_t GetLuaClassCount() const { return m_classCount; } Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** wxlstate.h 12 Dec 2005 05:16:31 -0000 1.11 --- wxlstate.h 22 Dec 2005 18:42:35 -0000 1.12 *************** *** 46,49 **** --- 46,50 ---- #include "wxlua/include/wxlbind.h" + class WXDLLIMPEXP_WXLUA wxLuaEvent; class WXDLLIMPEXP_WXLUA wxLuaState; class WXDLLIMPEXP_WXLUA wxLuaStateRefData; *************** *** 148,152 **** // shutting down the interpreter, else they dangle // used in destructor ! wxArrayInt m_usedIndexes; static wxLuaStateRefData* GetLuaStateRefData(lua_State* L); --- 149,167 ---- // shutting down the interpreter, else they dangle // used in destructor ! wxArrayInt m_usedIndexes; // array of the lua tags ! ! bool m_is_running; // is the lua_State running a script ! ! 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 ! int m_lua_debug_hook_count; ! int m_lua_debug_hook_yield; ! bool m_lua_debug_hook_send_evt; ! int m_lua_debug_hook; ! ! wxEvtHandler *m_evtHandler; // event handler to send events to ! wxWindowID m_id; // event id to send the events with static wxLuaStateRefData* GetLuaStateRefData(lua_State* L); *************** *** 176,188 **** public: wxLuaState(bool create = false) : wxObject() { if (create) Create(); } wxLuaState(lua_State* L, wxLuaState_Type type = WXLUASTATE_ATTACH) { Create(L, type); } wxLuaState(const wxLuaState& wxlState) { Create(wxlState); } ! virtual ~wxLuaState() {} // Ref the given wxLuaState void Create(const wxLuaState& wxlState); // Create a new lua_State ! bool Create(); // Create a new lua_State if L = NULL or just attach to the // input lua_State --- 191,206 ---- public: wxLuaState(bool create = false) : wxObject() { if (create) Create(); } + wxLuaState(wxEvtHandler *handler, wxWindowID id = wxID_ANY) : wxObject() { Create(handler, id); } wxLuaState(lua_State* L, wxLuaState_Type type = WXLUASTATE_ATTACH) { Create(L, type); } wxLuaState(const wxLuaState& wxlState) { Create(wxlState); } ! virtual ~wxLuaState() { Destroy(); } // Ref the given wxLuaState void Create(const wxLuaState& wxlState); // Create a new lua_State ! bool Create() { return Create(NULL, wxID_ANY); } ! // Create a new lua_State and send events to this handler ! bool Create(wxEvtHandler *handler, wxWindowID id = wxID_ANY); // Create a new lua_State if L = NULL or just attach to the // input lua_State *************** *** 195,199 **** // Destroy the refed data ! void Destroy() { UnRef(); } // Close the lua_State and if 'force' close all attached wxWindows // if not force then popup dialog to ask if windows should be destroyed. --- 213,217 ---- // Destroy the refed data ! void Destroy(); // Close the lua_State and if 'force' close all attached wxWindows // if not force then popup dialog to ask if windows should be destroyed. *************** *** 209,214 **** --- 227,291 ---- // ----------------------------------------------------------------------- + + // Set the event handler that the events will be sent to, can be null + void SetEventHandler(wxEvtHandler *evtHandler); + wxEvtHandler *GetEventHandler() const; + + // Get/Set the id that the events will be sent with + void SetId(wxWindowID id); + wxWindowID GetId() const; + + // generic function to generate a wxEVT_LUA_ERROR with the string message + void DisplayError( const wxString &errorMsg ); + + // checks return val of 'lua_load' and `lua_pcall', if error send wxEVT_LUA_ERROR + bool CheckRunError(int rc); + + void SendEvent( wxLuaEvent &event ) const; + + // ----------------------------------------------------------------------- + + // Run a lua file + int RunFile(const wxString &fileName); + // Run a string that contains lua code + int RunString(const wxString &script, const wxString& name = wxEmptyString); + // Run a char array #include(d) from bin2c compilation + int RunBuffer(const unsigned char buf[], size_t size, const wxString &name = wxT("= lua")); + + // Is a program running now + bool IsRunning() const; + // Break a currently running lua program + void DebugHookBreak(const wxString &message = wxT("Interpreter stopped")); + wxDEPRECATED( void Break(const wxString &message = wxT("Interpreter stopped")) { DebugHookBreak(message); } ); + // has Break() been called + bool GetDebugHookBreak() const; + wxString GetDebugHookBreakMessage() const; + + unsigned long GetLastLuaDebugHookTime() const; + void SetLastLuaDebugHookTime(unsigned long t); + + // ----------------------------------------------------------------------- + + // Have lua run an internal hook function with this mask + // hook = LUA_MASKCALL | LUA_MASKRET | LUA_MASKLINE | LUA_MASKCOUNT + // Every count hook mask a wxEVT_LUA_DEBUG_HOOK event is sent if send_debug_evt + // if yield > 0 then wxYield is called every yield milliseconds + // I don't know what resonable values are + // turn the hook off with count < 1 + void SetLuaDebugHook(int count = 1000, + int yield = 50, + bool send_debug_evt = false, + int hook = LUA_MASKCOUNT); + int GetLuaDebugHookCount() const; + int GetLuaDebugHookYield() const; + bool GetLuaDebugHookSendEvt() const; + int GetLuaDebugHook() const; + + // ----------------------------------------------------------------------- // Binding functions + // registers a new function for Lua + void RegisterFunction(lua_CFunction func, const wxString &funcName); + void RegisterBindings(bool registerTypes); |