From: John L. <jr...@us...> - 2008-01-24 00:18:24
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv5955/wxLua/modules/wxlua/include Modified Files: wxlbind.h wxldefs.h wxlstate.h wxlua_bind.h Log Message: * The wxLua type numbers are now generated when the first wxLuaState is created rather then when the bindings are registered into Lua. This means that each wxLua type stays the same for the life of the program no matter what bindings are installed or in what order. - The copy of the wxLuaBindingList in the wxLuaState was removed since it is no longer needed. Renamed the functions static wxLuaBinding::GetBindXXX() to FindBindXXX() since they no longer needed the extra wxLuaBindingList parameter and they had the same signature as the existing GetBindXXX() functions. - Added wxLuaState::RegisterBinding(wxLuaBinding*) function to register single bindings at a time. You may also reregister bindings, which means that their metatable functions are simple rewritten. Index: wxldefs.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxldefs.h,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** wxldefs.h 23 Jan 2008 06:43:38 -0000 1.42 --- wxldefs.h 24 Jan 2008 00:18:17 -0000 1.43 *************** *** 65,69 **** //----------------------------------------------------------------------------- ! #define WXLUA_BINDING_VERSION 22 // ---------------------------------------------------------------------------- --- 65,69 ---- //----------------------------------------------------------------------------- ! #define WXLUA_BINDING_VERSION 23 // ---------------------------------------------------------------------------- Index: wxlbind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlbind.h,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** wxlbind.h 23 Jan 2008 06:43:38 -0000 1.80 --- wxlbind.h 24 Jan 2008 00:18:17 -0000 1.81 *************** *** 546,574 **** // ----------------------------------------------------------------------- ! // These functions search through the input wxLuaBindingList or if NULL ! // the static wxLuaBinding::GetBindingList(). // Get the installed wxLuaBinding with the given // wxLuaBinding::GetBindingName() or NULL for no match. ! static wxLuaBinding* GetLuaBinding(const wxString& bindingName, const wxLuaBindingList* bindingList); // Get wxLuaBindClass for given wxLua type using wxLuaBindClass::wxluatype, // returns NULL on failure. ! static const wxLuaBindClass* GetBindClass(int wxl_type, const wxLuaBindingList* bindingList); // Get the first wxLuaBindClass that has this particular wxLuaBindMethod // returns NULL on failure. ! static const wxLuaBindClass* GetBindClass(const wxLuaBindMethod* wxlMethod, const wxLuaBindingList* bindingList); // Get the first wxLuaBindClass that has this particular wxLuaBindCFunc in its methods // returns NULL on failure. ! static const wxLuaBindClass* GetBindClass(const wxLuaBindCFunc* wxlCFunc, const wxLuaBindingList* bindingList); // Get wxLuaBindEvent for given wxEventType (wxEvent::GetEventType()) by finding // the matching wxLuaBindEvent::eventType. // returns NULL on failure. ! static const wxLuaBindEvent* GetBindEvent(wxEventType eventType, const wxLuaBindingList* bindingList); // Get the wxLuaBinding that has this wxLuaBindMethod in its wxLuaBinding::GetFunctionArray(). // returns NULL on failure. ! static wxLuaBinding* GetFunctionBinding(const wxLuaBindMethod* wxlMethod, const wxLuaBindingList* bindingList); // ----------------------------------------------------------------------- --- 546,574 ---- // ----------------------------------------------------------------------- ! // These functions search through the static wxLuaBinding::GetBindingList() ! // for the items. // Get the installed wxLuaBinding with the given // wxLuaBinding::GetBindingName() or NULL for no match. ! static wxLuaBinding* GetLuaBinding(const wxString& bindingName); // Get wxLuaBindClass for given wxLua type using wxLuaBindClass::wxluatype, // returns NULL on failure. ! static const wxLuaBindClass* FindBindClass(int wxl_type); // Get the first wxLuaBindClass that has this particular wxLuaBindMethod // returns NULL on failure. ! static const wxLuaBindClass* FindBindClass(const wxLuaBindMethod* wxlMethod); // Get the first wxLuaBindClass that has this particular wxLuaBindCFunc in its methods // returns NULL on failure. ! static const wxLuaBindClass* FindBindClass(const wxLuaBindCFunc* wxlCFunc); // Get wxLuaBindEvent for given wxEventType (wxEvent::GetEventType()) by finding // the matching wxLuaBindEvent::eventType. // returns NULL on failure. ! static const wxLuaBindEvent* FindBindEvent(wxEventType eventType); // Get the wxLuaBinding that has this wxLuaBindMethod in its wxLuaBinding::GetFunctionArray(). // returns NULL on failure. ! static wxLuaBinding* FindMethodBinding(const wxLuaBindMethod* wxlMethod); // ----------------------------------------------------------------------- *************** *** 628,639 **** 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 ! int m_first_wxluatype; // The first wxLua type allocated for a class ! int m_last_wxluatype; // The last wxLua type of registered classes ! int m_luaTable_ref; // The Lua ref for the wxLua private tables static wxLuaBindingList sm_bindingList; static bool sm_bindingList_initialized; ! static int sm_wxluatype_counter; DECLARE_ABSTRACT_CLASS(wxLuaBinding) --- 628,637 ---- wxString m_bindingName; // A unique name of the binding wxString m_nameSpace; // Lua table namespace e.g. "wx" ! int m_first_wxluatype; // The first wxLua type allocated for a class ! int m_last_wxluatype; // The last wxLua type of registered classes static wxLuaBindingList sm_bindingList; static bool sm_bindingList_initialized; ! static int sm_wxluatype_max; DECLARE_ABSTRACT_CLASS(wxLuaBinding) Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.117 retrieving revision 1.118 diff -C2 -d -r1.117 -r1.118 *** wxlstate.h 23 Jan 2008 06:43:38 -0000 1.117 --- wxlstate.h 24 Jan 2008 00:18:17 -0000 1.118 *************** *** 19,26 **** class WXDLLIMPEXP_WXLUA wxLuaEvent; class WXDLLIMPEXP_WXLUA wxLuaState; class WXDLLIMPEXP_WXLUA wxLuaStateRefData; class WXDLLIMPEXP_WXLUA wxLuaEventCallback; class WXDLLIMPEXP_WXLUA wxLuaWinDestroyCallback; - class WXDLLIMPEXP_WXLUA wxLuaDebugHookData; // ---------------------------------------------------------------------------- --- 19,26 ---- class WXDLLIMPEXP_WXLUA wxLuaEvent; class WXDLLIMPEXP_WXLUA wxLuaState; + class WXDLLIMPEXP_WXLUA wxLuaStateData; class WXDLLIMPEXP_WXLUA wxLuaStateRefData; class WXDLLIMPEXP_WXLUA wxLuaEventCallback; class WXDLLIMPEXP_WXLUA wxLuaWinDestroyCallback; // ---------------------------------------------------------------------------- *************** *** 85,89 **** // Note: The wxLua types WXLUA_TXXX that correspond to the Lua LUA_TXXX types // are not stored in this table since they do not use our metatables. ! // The keys in this table are all > 1. // LUA_REGISTRYINDEX[&wxlua_lreg_types_key][wxLua type number] = { metatable for a C++ class } extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_types_key; --- 85,90 ---- // Note: The wxLua types WXLUA_TXXX that correspond to the Lua LUA_TXXX types // are not stored in this table since they do not use our metatables. ! // The keys in this table are all > 1. They values are either tables or 0 ! // if the wxLuaBinding containing the wxLua type was not registered. // LUA_REGISTRYINDEX[&wxlua_lreg_types_key][wxLua type number] = { metatable for a C++ class } extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_types_key; *************** *** 94,99 **** extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_refs_key; // The key in the LUA_REGISTRYINDEX table that is a numerically keyed table ! // with references to objects the wxLuaDebugData wants to keep a handle to and ! // stores their value for lookup. It is used only for the wxLuaDebugData. // LUA_REGISTRYINDEX[&wxlua_lreg_debug_refs_key][ref number] = Lua object extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_debug_refs_key; --- 95,100 ---- extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_refs_key; // The key in the LUA_REGISTRYINDEX table that is a numerically keyed table ! // with references to objects the wxLuaDebugData wants to keep a handle to by ! // storing their value for lookup. It is used only for the wxLuaDebugData. // LUA_REGISTRYINDEX[&wxlua_lreg_debug_refs_key][ref number] = Lua object extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_debug_refs_key; *************** *** 111,114 **** --- 112,119 ---- // LUA_REGISTRYINDEX[&wxlua_lreg_wxluastate_key] = lightuserdata(&wxLuaState) extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_wxluastate_key; + // The key in the LUA_REGISTRYINDEX table that is a table of lightuserdata + // wxLuaBindings and the ref to the Lua table they were installed into. + // LUA_REGISTRYINDEX[&wxlua_lreg_wxluabindings_key] = {lightuserdata(&wxLuaBinding) = wxlua_lreg_refs_key ref#, ...} + extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_wxluabindings_key; // The key in the LUA_REGISTRYINDEX table that is a table of all // objects that we've pushed into Lua using wxluaT_pushuserdatatype(). *************** *** 149,156 **** // LUA_REGISTRYINDEX[&wxlua_lreg_wxeventtype_key] = wxEventType (wxEVT_NULL) extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_wxeventtype_key; ! // The key in the LUA_REGISTRYINDEX table that has a wxLuaDebugHookData // lightuserdata value for the wxLuaState. ! // LUA_REGISTRYINDEX[&wxlua_lreg_wxluadebughookdata_key] = lightuserdata(&wxLuaDebugHookData) ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_wxluadebughookdata_key; // The key in the LUA_REGISTRYINDEX table that is a weak keyed table of // the tables wxLua pushed into the registry with their keys as values. --- 154,161 ---- // LUA_REGISTRYINDEX[&wxlua_lreg_wxeventtype_key] = wxEventType (wxEVT_NULL) extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_wxeventtype_key; ! // The key in the LUA_REGISTRYINDEX table that has a wxLuaStateData class // lightuserdata value for the wxLuaState. ! // LUA_REGISTRYINDEX[&wxlua_lreg_wxluastatedata_key] = lightuserdata(&wxLuaStateData) ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_wxluastatedata_key; // The key in the LUA_REGISTRYINDEX table that is a weak keyed table of // the tables wxLua pushed into the registry with their keys as values. *************** *** 199,206 **** // Get information from the return value of lua_pcall(), luaL_loadbuffer(), etc ! // and builds an errMsg with wxlua_LUA_ERR_msg() and if the current top // is > than top it tries to get Lua's error string from the top of the stack. ! // Returns true if status != 0 and the errMsg and line_num are filled. ! // If errMsg and line_num aren't null then fill them with the msg and line. // status is the return from lua_pcall(), luaL_loadbuffer(), etc, LUA_ERRxxx // top is the lua_gettop from before the call that may have generated the error. --- 204,211 ---- // Get information from the return value of lua_pcall(), luaL_loadbuffer(), etc ! // The errMsg input is filled with wxlua_LUA_ERR_msg() and if the current top // is > than top it tries to get Lua's error string from the top of the stack. ! // Returns true if the input status != 0 and the errMsg and line_num are filled. ! // If errMsg and line_num aren't NULL then fill them with the msg and line. // status is the return from lua_pcall(), luaL_loadbuffer(), etc, LUA_ERRxxx // top is the lua_gettop from before the call that may have generated the error. *************** *** 346,350 **** // Allocate a new table (a metatable for a userdata) with a ! // wxlua_metatable_type_key key equal to the number from wxluaR_ref() and // store it in the wxlua_lreg_types_key LUA_REGISTRYINDEX table. // Returns the index into the wxLua types table which is a new wxLua type. --- 351,355 ---- // Allocate a new table (a metatable for a userdata) with a ! // wxlua_metatable_type_key key equal to the input wxl_type and // store it in the wxlua_lreg_types_key LUA_REGISTRYINDEX table. // Returns the index into the wxLua types table which is a new wxLua type. *************** *** 515,519 **** ! // Push the program args into a global table called "args" as the lua executable does. // start_n is the arg to start pushing until max args "argc". // returns the number of args pushed. --- 520,524 ---- ! // Push the program args into a global table called "args" as the Lua executable does. // start_n is the arg to start pushing until max args "argc". // returns the number of args pushed. *************** *** 564,594 **** WXDLLIMPEXP_WXLUA void LUACALL wxlua_setwxeventtype(lua_State* L, wxEventType evt_type); ! // Get the wxlua_lreg_wxluadebughookdata_key wxLuaDebugHookData value from // the LUA_REGISTRYINDEX table for the owner wxLuaState. // Note: It returns NULL if the lua_State is about to be closed. ! WXDLLIMPEXP_WXLUA wxLuaDebugHookData* LUACALL wxlua_getwxluadebughookdata(lua_State* L); ! ! //---------------------------------------------------------------------------- ! // wxLuaDebugHookData - data for setting/getting the debug hook settings ! //---------------------------------------------------------------------------- ! ! class WXDLLIMPEXP_WXLUA wxLuaDebugHookData ! { ! public: ! wxLuaDebugHookData() : m_lua_debug_hook_count(100), m_lua_debug_hook_yield(50), ! m_lua_debug_hook(0), m_lua_debug_hook_send_evt(false), ! m_last_debug_hook_time(0), m_debug_hook_break(false), ! m_debug_hook_break_msg(wxT("Break")) {} ! ! int m_lua_debug_hook_count; // values from wxLuaState::SetLuaDebugHook() ! int m_lua_debug_hook_yield; ! int m_lua_debug_hook; ! bool m_lua_debug_hook_send_evt; ! ! unsigned long m_last_debug_hook_time; // last time the debug hook was called ! ! 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 ! }; //---------------------------------------------------------------------------- --- 569,576 ---- WXDLLIMPEXP_WXLUA void LUACALL wxlua_setwxeventtype(lua_State* L, wxEventType evt_type); ! // Get the wxlua_lreg_wxluastatedata_key wxLuaStateData value from // the LUA_REGISTRYINDEX table for the owner wxLuaState. // Note: It returns NULL if the lua_State is about to be closed. ! WXDLLIMPEXP_WXLUA wxLuaStateData* LUACALL wxlua_getwxluastatedata(lua_State* L); //---------------------------------------------------------------------------- *************** *** 605,616 **** ~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 - bool m_is_running; // is the lua_State running a script bool m_is_closing; // are we currently being closed ! wxLuaDebugHookData m_debugHookData; // Data for the wxLuaState::SetLuaDebugHook() wxEvtHandler *m_evtHandler; // event handler to send wxLuaEvents to --- 587,602 ---- ~wxLuaStateData(); bool m_is_running; // is the lua_State running a script bool m_is_closing; // are we currently being closed ! int m_lua_debug_hook_count; // values from wxLuaState::SetLuaDebugHook() ! int m_lua_debug_hook_yield; ! int m_lua_debug_hook; ! bool m_lua_debug_hook_send_evt; ! ! unsigned long m_last_debug_hook_time; // last time the debug hook was called ! ! 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 wxEvtHandler *m_evtHandler; // event handler to send wxLuaEvents to *************** *** 644,649 **** bool m_lua_State_coroutine; // this is a coroutine, don't close it ! wxLuaStateData* m_wxlStateData; // the data shared for this state ! bool m_own_stateData; // not a coroutine when true, so delete it when done }; --- 630,635 ---- bool m_lua_State_coroutine; // this is a coroutine, don't close it ! wxLuaStateData* m_wxlStateData; // the data shared for this state ! bool m_own_stateData; // not a coroutine when true, so delete it when done }; *************** *** 668,672 **** wxLUASTATE_OPENBINDINGS = 0x20, // Install all the bindings in // wxLuaBinding::GetBindingList() into the ! // lua_State. }; --- 654,660 ---- wxLUASTATE_OPENBINDINGS = 0x20, // Install all the bindings in // wxLuaBinding::GetBindingList() into the ! // lua_State. You may install the bindings ! // one at a time using ! // wxLuaState::RegisterBinding(wxLuaBinding*) }; *************** *** 875,881 **** void RegisterFunction(lua_CFunction func, const char* funcName); wxLUA_UNICODE_ONLY(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 on creation. (internal use) ! void RegisterBindings(); // Get the installed wxLuaBinding with the given --- 863,872 ---- void RegisterFunction(lua_CFunction func, const char* funcName); wxLUA_UNICODE_ONLY(void RegisterFunction(lua_CFunction func, const wxString &funcName) { RegisterFunction(func, wx2lua(funcName)); }) ! ! // Register a single wxLuaBinding. ! bool RegisterBinding(wxLuaBinding* binding); ! // Register all the bindings in the wxLuaBinding::GetBindingList(), this is done ! // automatically if the wxLuaState is created with wxLUASTATE_OPENBINDINGS. ! bool RegisterBindings(); // Get the installed wxLuaBinding with the given *************** *** 903,914 **** const wxLuaBindEvent* GetBindEvent(wxEventType eventType) const; - // Get the wxLuaBinding list of classes/objects installed into Lua. - // You may add or remove bindings before the creation of any wxLuaStates - // or once they have all been Destroy()ed. However, while any wxLuaStates - // are created they must have the same bindings in the same order! - wxLuaBindingList* GetLuaBindingList() const; - - bool GetBindingsRegistered() const; // Are the binding registered - // See wxlua_setcallbaseclassfunction() and wxlua_getcallbaseclassfunction(). void SetCallBaseClassFunction(bool call_base); --- 894,897 ---- Index: wxlua_bind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlua_bind.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** wxlua_bind.h 23 Jan 2008 06:43:38 -0000 1.11 --- wxlua_bind.h 24 Jan 2008 00:18:17 -0000 1.12 *************** *** 17,23 **** // the current version of the bindings. // See 'bindings/genwxbind.lua' and 'modules/wxlua/include/wxldefs.h' ! #if WXLUA_BINDING_VERSION > 22 # error "The WXLUA_BINDING_VERSION in the bindings is too old, regenerate bindings." ! #endif //WXLUA_BINDING_VERSION > 22 // --------------------------------------------------------------------------- --- 17,23 ---- // the current version of the bindings. // See 'bindings/genwxbind.lua' and 'modules/wxlua/include/wxldefs.h' ! #if WXLUA_BINDING_VERSION > 23 # error "The WXLUA_BINDING_VERSION in the bindings is too old, regenerate bindings." ! #endif //WXLUA_BINDING_VERSION > 23 // --------------------------------------------------------------------------- *************** *** 37,42 **** - // bind wxLuaBinding_wxlua to a single wxLuaState - extern WXDLLIMPEXP_WXLUA bool wxLuaBinding_wxlua_bind(const wxLuaState& wxlState); // initialize wxLuaBinding_wxlua for all wxLuaStates extern WXDLLIMPEXP_WXLUA bool wxLuaBinding_wxlua_init(); --- 37,40 ---- |