From: John L. <jr...@us...> - 2007-12-07 02:13:20
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv12976/wxLua/modules/wxlua/include Modified Files: wxlbind.h wxlcallb.h wxldefs.h wxlstate.h wxlua_bind.h Log Message: Too many changes to list... A large portion of the internal workings of the wxLuaState have been rewritten. All of the data that was stored in wxLuaStateData that might be needed by a function taking a lua_State* is now in the LUA_REGISTRYINDEX. C functions have been added to access these values. The generated bindings no longer need to have "wxLuaState wxlState(L);" since everything can be done with the C functions. The result is that wxLua should be faster. Index: wxlcallb.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlcallb.h,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** wxlcallb.h 4 Dec 2007 05:20:28 -0000 1.22 --- wxlcallb.h 7 Dec 2007 02:13:14 -0000 1.23 *************** *** 53,56 **** --- 53,60 ---- const wxLuaBindEvent* GetwxLuaBindEvent() const { return m_wxlBindEvent; } + // Get a human readable string + // "wxEVT_XXX(evt#) -> wxLuaCallback(&callback, ids %d %d)|wxEvtHandler(&evthandler) -> wxEvtHandlerClassName" + wxString GetInfo() const; // Get a human readable string + // Central event handler that calls CallFunction() for the actual // wxLuaCallback callback user data. This function is treated like a *************** *** 99,102 **** --- 103,110 ---- wxWindow* GetWindow() const { return m_window; } + // Get a human readable string + // "wxWindowClassName(&win, id=%d)|wxLuaDestroyCallback(&callback)" + wxString GetInfo() const; + // Central event handler that calls OnDestroy() for the actual // wxLuaWinDestroyCallback callback user data. This function is treated like a Index: wxldefs.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxldefs.h,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** wxldefs.h 28 Nov 2007 00:20:49 -0000 1.36 --- wxldefs.h 7 Dec 2007 02:13:14 -0000 1.37 *************** *** 67,71 **** //----------------------------------------------------------------------------- ! #define WXLUA_BINDING_VERSION 18 // ---------------------------------------------------------------------------- --- 67,71 ---- //----------------------------------------------------------------------------- ! #define WXLUA_BINDING_VERSION 19 // ---------------------------------------------------------------------------- Index: wxlbind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlbind.h,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** wxlbind.h 5 Dec 2007 05:54:11 -0000 1.68 --- wxlbind.h 7 Dec 2007 02:13:14 -0000 1.69 *************** *** 239,242 **** --- 239,252 ---- // ---------------------------------------------------------------------------- + // Central function to call for overloaded functions + // ---------------------------------------------------------------------------- + + // Redirect Lua function call to 1 method from a list of overloaded functions + WXDLLIMPEXP_WXLUA int LUACALL wxlua_CallOverloadedFunction(lua_State* L, struct wxLuaBindMethod* wxlMethod); + + // Return a human readable string of the args for the functions in the method + WXDLLIMPEXP_WXLUA wxArrayString wxlua_CreateMethodArgTagsMsg(lua_State* L, struct wxLuaBindMethod* method); + + // ---------------------------------------------------------------------------- // wxLuaObject - wraps a reference to a Lua object reference inside a // wxObject-derived class so that a Lua object can be used for *************** *** 375,378 **** --- 385,460 ---- // ---------------------------------------------------------------------------- + // wxLuaSmartwxArrayString - Wraps a "new" wxArrayString with an automatic + // destructor to delete them to make binding easier + // ---------------------------------------------------------------------------- + + class WXDLLIMPEXP_WXLUA wxLuaSmartwxArrayString : public wxObject + { + public: + wxLuaSmartwxArrayString(const wxLuaSmartwxArrayString& arr) { Ref(arr); } + wxLuaSmartwxArrayString(wxArrayString *arr, bool del); + + wxArrayString* GetArray() const; + + operator const wxArrayString *() const { return GetArray(); } + operator const wxArrayString &() const { return *GetArray(); } + operator wxArrayString &() { return *GetArray(); } + + wxLuaSmartwxArrayString& operator = (const wxLuaSmartwxArrayString& arr) + { + Ref(arr); + return *this; + } + }; + + // ---------------------------------------------------------------------------- + // wxLuaSmartwxSortedArrayString - Wraps a "new" wxSortedArrayString with an automatic + // destructor to delete them to make binding easier + // ---------------------------------------------------------------------------- + + class WXDLLIMPEXP_WXLUA wxLuaSmartwxSortedArrayString : public wxObject + { + public: + wxLuaSmartwxSortedArrayString(const wxLuaSmartwxArrayString& arr) { Ref(arr); } + wxLuaSmartwxSortedArrayString(wxSortedArrayString *arr, bool del); + + wxSortedArrayString* GetArray() const; + + operator const wxSortedArrayString *() const { return GetArray(); } + operator const wxSortedArrayString &() const { return *GetArray(); } + operator wxSortedArrayString &() { return *GetArray(); } + + wxLuaSmartwxSortedArrayString& operator = (const wxLuaSmartwxSortedArrayString& arr) + { + Ref(arr); + return *this; + } + }; + + // ---------------------------------------------------------------------------- + // wxLuaSmartwxArrayInt - Wraps a "new" wxArrayInt with an automatic + // destructor to delete them to make binding easier + // ---------------------------------------------------------------------------- + + class WXDLLIMPEXP_WXLUA wxLuaSmartwxArrayInt : public wxObject + { + public: + wxLuaSmartwxArrayInt(const wxLuaSmartwxArrayInt& arr) { Ref(arr); } + wxLuaSmartwxArrayInt(wxArrayInt *arr = NULL, bool del = true); + + wxArrayInt* GetArray() const; + + operator const wxArrayInt *() const { return GetArray(); } + operator const wxArrayInt &() const { return *GetArray(); } + operator wxArrayInt &() { return *GetArray(); } + + wxLuaSmartwxArrayInt& operator = (const wxLuaSmartwxArrayInt& arr) + { + Ref(arr); + return *this; + } + }; + + // ---------------------------------------------------------------------------- // wxLuaBinding - binds classes, functions, objects, and event callbacks to // the wxLuaState. Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.100 retrieving revision 1.101 diff -C2 -d -r1.100 -r1.101 *** wxlstate.h 5 Dec 2007 05:54:11 -0000 1.100 --- wxlstate.h 7 Dec 2007 02:13:14 -0000 1.101 *************** *** 21,24 **** --- 21,25 ---- class WXDLLIMPEXP_WXLUA wxLuaCallback; class WXDLLIMPEXP_WXLUA wxLuaWinDestroyCallback; + class WXDLLIMPEXP_WXLUA wxLuaDebugHookData; // ---------------------------------------------------------------------------- *************** *** 101,105 **** // The key in the LUA_REGISTRYINDEX table that is table of all // objects that we've pushed into Lua. t[lightuserdata] = [weak valued full userdata] ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_objects_key; // The key in the LUA_REGISTRYINDEX table that is table of all // wxLuaCallbacks that we've created. --- 102,112 ---- // The key in the LUA_REGISTRYINDEX table that is table of all // objects that we've pushed into Lua. t[lightuserdata] = [weak valued full userdata] ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_weakobjects_key; ! // The key in the LUA_REGISTRYINDEX table that is table of all ! // objects we pushed into Lua and want to delete when done with them. ! // t[lightuserdata(&object)] = lightuserdata(wxObject derived class) ! // Note that non wxObject classes use wxLUA_DECLARE_ENCAPSULATION so ! // the key is the object pointer and the value is the wxObject encapsulation. ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_delobjects_key; // The key in the LUA_REGISTRYINDEX table that is table of all // wxLuaCallbacks that we've created. *************** *** 111,119 **** // t[lightuserdata wxWindow] = lightuserdata wxLuaWinDestroyCallback extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_windestroycallbacks_key; ! // The key in the LUA_REGISTRYINDEX table that is a boolean value // of whether the Lua code has prepended a '_' to function name to indicate // that they want the base class function called. extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_callbaseclassfunc_key; ! // Light user data used as keys in the metatables created for the class userdata objects. --- 118,135 ---- // t[lightuserdata wxWindow] = lightuserdata wxLuaWinDestroyCallback extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_windestroycallbacks_key; ! // The key in the LUA_REGISTRYINDEX table that is table of all ! // top level windows that we've created and need to destroy when closed. ! // t[lightuserdata wxWindow] = 1 (the number 1) ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_topwindows_key; ! // The key in the LUA_REGISTRYINDEX table that has a boolean value // of whether the Lua code has prepended a '_' to function name to indicate // that they want the base class function called. extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_callbaseclassfunc_key; ! // The key in the LUA_REGISTRYINDEX table that has a wxEventType (integer) value ! // of the current wxEvent is that is being run or wxEVT_NULL if not in an event. ! 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. ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_wxluadebughookdata_key; // Light user data used as keys in the metatables created for the class userdata objects. *************** *** 138,141 **** --- 154,161 ---- wxLUA_UNICODE_ONLY(inline WXDLLIMPEXP_WXLUA void LUACALL wxlua_error(lua_State* L, const wxString& errorMsg) { wxlua_error(L, wx2lua(errorMsg)); }) + // Get the userdata at the stack index, if null_ptr then set the pointer wrapped + // by Lua's userdata to NULL to clear it. + WXDLLIMPEXP_WXLUA void* LUACALL wxlua_touserdata(lua_State* L, int stack_idx, bool null_ptr = false); + //---------------------------------------------------------------------------- // wxluaR_XXX - functions operate on tables in Lua's LUA_REGISTRYINDEX which *************** *** 144,147 **** --- 164,168 ---- // Possible values for the "void* lightuserdata_reg_key" are // wxlua_lreg_tags_key, wxlua_lreg_refs_key, wxlua_lreg_debug_refs_key + // unless you are using these functions for your own table. //---------------------------------------------------------------------------- *************** *** 162,168 **** //---------------------------------------------------------------------------- ! // wxluaT_XXX - functions operate on the "Tags" which is a numerical index in the ! // wxlua_lreg_tags_key table in Lua's LUA_REGISTRYINDEX to determine the C++ ! // class for a Lua userdata. //---------------------------------------------------------------------------- --- 183,189 ---- //---------------------------------------------------------------------------- ! // wxluaT_XXX - functions operate on the "Tags" which are a numerical indexes ! // in the wxlua_lreg_tags_key table in Lua's LUA_REGISTRYINDEX to determine ! // the C++ class for a Lua userdata. //---------------------------------------------------------------------------- *************** *** 180,209 **** // wxlua_lreg_tags_key LUA_REGISTRYINDEX table using wxluaR_getref(tag). WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_settag(lua_State* L, int tag); // Push the object u onto the top of the stack wrapped in a newuserdata // with it's metatable set to the table from wxluaR_getref(L, tag, &wxlua_lreg_tags_key). // Returns true if the tag is known and the metatable was set. // If track=true then push the object as a lightuser data key into the ! // wxlua_lreg_objects_key table of the Lua LUA_REGISTRYINDEX table so that if we need to // push it again we just push the full userdata value. WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_pushusertag(lua_State* L, const void* u, int tag, bool track); //---------------------------------------------------------------------------- // wxluaO_XXX - functions operate on the "Objects" which are userdata wrapping ! // C++ class objects and are stored in the wxlua_lreg_objects_key table in ! // Lua's LUA_REGISTRYINDEX. //---------------------------------------------------------------------------- ! // If an object was pushed into Lua using wxluaT_pushusertag with track=true ! // then this function will remove the object from being tracked in the ! // wxlua_lreg_objects_key Lua LUA_REGISTRYINDEX table. ! WXDLLIMPEXP_WXLUA void LUACALL wxluaO_untrackuserdata(lua_State* L, const void* u); // If an object was pushed into Lua using wxluaT_pushusertag with track=true // then this function will remove the metable of the object being tracked in the ! // wxlua_lreg_objects_key Lua LUA_REGISTRYINDEX table. WXDLLIMPEXP_WXLUA void LUACALL wxluaO_cleartrackedmetatable(lua_State* L, const void* u); ! // Get the userdata at the stack index, if null_ptr then set the pointer wrapped ! // by Lua's userdata to NULL to clear it. ! WXDLLIMPEXP_WXLUA void* LUACALL wxlua_touserdata(lua_State* L, int stack_idx, bool null_ptr = false); // ---------------------------------------------------------------------------- --- 201,285 ---- // wxlua_lreg_tags_key LUA_REGISTRYINDEX table using wxluaR_getref(tag). WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_settag(lua_State* L, int tag); + + // Get the wxLuaBindClass* for this class_tag or NULL if the tag is invalid. + // Gets the wxLuaBindClass from the metatable stored in the wxlua_lreg_tags_key registry table + // for the classes that have been installed into Lua. + WXDLLIMPEXP_WXLUA const wxLuaBindClass* LUACALL wxluaT_getclass(lua_State* L, int class_tag); + // Get the wxLuaBindClass* for this class_name or NULL if the name is invalid. + // Gets the wxLuaBindClass from the "wxLuaClasses" table in the Lua registry. + WXDLLIMPEXP_WXLUA const wxLuaBindClass* LUACALL wxluaT_getclass(lua_State* L, const char* class_name); + // Get the name of the class with this tag. + WXDLLIMPEXP_WXLUA wxString LUACALL wxluaT_gettagname(lua_State* L, int class_tag); + // Get the tag for the class with the given name + WXDLLIMPEXP_WXLUA int LUACALL wxluaT_gettag(lua_State* L, const char* name); + + // Get the userdata object at the stack_idx that is of the class type tag or a + // class derived from the tag. + // If the data type does not have the correct tag, or if the parameter isn't a + // userdata then wxlua_error() is called and NULL is returned. + WXDLLIMPEXP_WXLUA void* LUACALL wxluaT_getuserdatatype(lua_State* L, int stack_idx, int wxl_tag); // Push the object u onto the top of the stack wrapped in a newuserdata // with it's metatable set to the table from wxluaR_getref(L, tag, &wxlua_lreg_tags_key). // Returns true if the tag is known and the metatable was set. // If track=true then push the object as a lightuser data key into the ! // wxlua_lreg_weakobjects_key table of the Lua LUA_REGISTRYINDEX table so that if we need to // push it again we just push the full userdata value. WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_pushusertag(lua_State* L, const void* u, int tag, bool track); + // Push a data type onto the stack and set its tag by calling wxluaT_pushusertag() + // after checking if the object is a wxWindow and adding it to the + // wxlua_lreg_windestroycallbacks_key table if it is. + WXDLLIMPEXP_WXLUA void LUACALL wxluaT_pushuserdatatype(lua_State* L, int wxl_tag, const void *data); //---------------------------------------------------------------------------- // wxluaO_XXX - functions operate on the "Objects" which are userdata wrapping ! // C++ class objects and are stored in the wxlua_lreg_weakobjects_key table ! // and the wxlua_lreg_delobjects_key in Lua's LUA_REGISTRYINDEX. //---------------------------------------------------------------------------- ! enum wxLuaRemoveTrackedObject_flags ! { ! wxLUA_UNDELETE_OBJECT = 0, // stop tracking for deletion (someone else owns this) ! wxLUA_DELETE_OBJECT = 0x0001, // delete the object ! wxLUA_CLEAR_TRACKED_OBJECT = 0x0002, // clear tracking the object in Lua reg table ! wxLUA_CLEAR_DERIVED_METHODS = 0x0004, // clear any derived methods in Lua reg table ! wxLUA_DELETE_CLEAR_OBJECT = wxLUA_DELETE_OBJECT|wxLUA_CLEAR_TRACKED_OBJECT|wxLUA_CLEAR_DERIVED_METHODS ! }; ! ! // Track this wxObject and delete it when Lua calls the __gc method for it. ! // The object is stored in the wxlua_lreg_delobjects_key of the LUA_REGISTRYINDEX ! // as t[lightuserdata(obj_ptr)] = lightuserdata(wxobj). ! // The second version is used when the non-wxObject class is encapsulated and so ! // the obj_ptr points to the actual object that the wxObject encapsulates. ! WXDLLIMPEXP_WXLUA void LUACALL wxluaO_addtrackedobject(lua_State* L, wxObject* wxobj); ! WXDLLIMPEXP_WXLUA void LUACALL wxluaO_addtrackedobject(lua_State* L, const void* obj_ptr, wxObject* wxobj); ! // Remove this tracked wxObject from the wxlua_lreg_delobjects_key table of the ! // LUA_REGISTRYINDEX. ! // The object can be deleted and other items assicated may be cleared ! // by setting the "flags" from ored values of enum wxLuaRemoveTrackedObject_flags ! WXDLLIMPEXP_WXLUA bool LUACALL wxluaO_removetrackedobject(lua_State *L, void *obj_ptr, int flags); ! // Check if this object is in the wxlua_lreg_delobjects_key table of the ! // LUA_REGISTRYINDEX. ! WXDLLIMPEXP_WXLUA bool LUACALL wxluaO_istrackedobject(lua_State *L, void *obj_ptr); ! // If an object was pushed into Lua using wxluaT_pushusertag with track=true // then this function will remove the metable of the object being tracked in the ! // wxlua_lreg_weakobjects_key Lua LUA_REGISTRYINDEX table. WXDLLIMPEXP_WXLUA void LUACALL wxluaO_cleartrackedmetatable(lua_State* L, const void* u); ! //---------------------------------------------------------------------------- ! // wxluaW_XXX - functions operate on tracked wxWindows stored in the ! // wxlua_lreg_topwindows_key in Lua's LUA_REGISTRYINDEX. ! //---------------------------------------------------------------------------- ! ! // Add the wxObject which is presumably a wxWindow (this will check) and ! // to the wxlua_lreg_topwindows_key table of the LUA_REGISTRYINDEX table if ! // it has not already been added. ! WXDLLIMPEXP_WXLUA void LUACALL wxluaW_addtrackedwindow(lua_State *L, wxObject* obj); ! // Remove the wxWindow from the wxlua_lreg_topwindows_key table of the ! // LUA_REGISTRYINDEX table. ! WXDLLIMPEXP_WXLUA void LUACALL wxluaW_removetrackedwindow(lua_State *L, wxWindow* win); ! // Is this wxWindow or one of it's parents already added to the ! // wxlua_lreg_topwindows_key table of the LUA_REGISTRYINDEX table ! WXDLLIMPEXP_WXLUA bool LUACALL wxluaW_istrackedwindow(lua_State *L, wxWindow* win, bool check_parents); // ---------------------------------------------------------------------------- *************** *** 211,221 **** // ---------------------------------------------------------------------------- - // Get the wxLuaBindClass* for this class_tag or NULL if the tag is invalid. - // Gets the wxLuaBindClass from the metatable stored in the wxlua_lreg_tags_key registry table - // for the classes that have been installed into Lua. - WXDLLIMPEXP_WXLUA const wxLuaBindClass* LUACALL wxluaT_getclass(lua_State* L, int class_tag); - // Get the wxLuaBindClass* for this class_name or NULL if the name is invalid. - // Gets the wxLuaBindClass from the "wxLuaClasses" table in the Lua registry. - WXDLLIMPEXP_WXLUA const wxLuaBindClass* LUACALL wxluaT_getclass(lua_State* L, const char* class_name); // Is a class with the class_tag equal to or derived from a class with the base_class_tag. // 0 means same class, +1 means base is parent, +2 base is grandparent, ... --- 287,290 ---- *************** *** 229,236 **** // Note that this function does not do a direct mapping between wxlua_getwxluatype() // and wxlua_getluatype() since it allows a small amount of coersion between types. ! // It also doesn't account for the automatic conversion of certain Lua types ! // to wxluatypes, (wxString, wxArrayString, wxArrayInt) ! // see wxLuaState::IswxLuaType which is more complete. ! WXDLLIMPEXP_WXLUA int LUACALL wxlua_iswxluatype(int luatype, int wxluaarg_tag); // Get a human readable name for the predefined WXLUAARG_XXX or s_wxluaarg_XXX tags. // returns empty string if the tag was not one of the predefined types. --- 298,306 ---- // Note that this function does not do a direct mapping between wxlua_getwxluatype() // and wxlua_getluatype() since it allows a small amount of coersion between types. ! // If the input lua_State is not NULL it will account for the automatic conversion of ! // (wxString, wxArrayString, wxArrayInt) to and from Lua types to wxluatypes, ! WXDLLIMPEXP_WXLUA int LUACALL wxlua_iswxluatype(int luatype, int wxluaarg_tag, lua_State* L = NULL); ! // Is the item at stack_idx of the userdata type with or derived from the the given tag. ! WXDLLIMPEXP_WXLUA bool wxlua_isuserdatatype(lua_State* L, int stack_idx, int tag); // Get a human readable name for the predefined WXLUAARG_XXX or s_wxluaarg_XXX tags. // returns empty string if the tag was not one of the predefined types. *************** *** 242,245 **** --- 312,317 ---- // returns -1 (LUA_TNONE) if the tag was not one of the predefined types. WXDLLIMPEXP_WXLUA int wxlua_getluatype(int wxluatype); + // Get the lua_typename(lua_type(stack_idx)) as a wxString + WXDLLIMPEXP_WXLUA wxString LUACALL wxlua_gettypename(lua_State* L, int stack_idx); // Is this data a userdata object that wxLua has pushed into Lua? *************** *** 253,258 **** // Note: wxLua has a stricter sense of type than Lua and we don't want to // always allow coersion between types since oftentimes there's an error. ! // Note: The wxLuaState::IsStringType function takes both a Lua string and a wxString ! // userdata as valid strings. #define wxlua_isstringtype(L, stack_idx) (wxlua_iswxluatype(lua_type(L, stack_idx), WXLUAARG_String) == 1) #define wxlua_isbooleantype(L, stack_idx) (wxlua_iswxluatype(lua_type(L, stack_idx), WXLUAARG_Boolean) == 1) --- 325,329 ---- // Note: wxLua has a stricter sense of type than Lua and we don't want to // always allow coersion between types since oftentimes there's an error. ! WXDLLIMPEXP_WXLUA bool wxlua_iswxstringtype(lua_State* L, int stack_idx); #define wxlua_isstringtype(L, stack_idx) (wxlua_iswxluatype(lua_type(L, stack_idx), WXLUAARG_String) == 1) #define wxlua_isbooleantype(L, stack_idx) (wxlua_iswxluatype(lua_type(L, stack_idx), WXLUAARG_Boolean) == 1) *************** *** 266,269 **** --- 337,341 ---- // of both a Lua string and a userdata wxString to a wxString. WXDLLIMPEXP_WXLUA const char* LUACALL wxlua_getstringtype(lua_State* L, int stack_idx); + WXDLLIMPEXP_WXLUA wxString LUACALL wxlua_getwxstringtype(lua_State* L, int stack_idx); WXDLLIMPEXP_WXLUA bool LUACALL wxlua_getbooleantype(lua_State* L, int stack_idx); WXDLLIMPEXP_WXLUA long LUACALL wxlua_getintegertype(lua_State* L, int stack_idx); *************** *** 284,287 **** --- 356,382 ---- WXDLLIMPEXP_WXLUA const char** LUACALL wxlua_getchararray(lua_State* L, int stack_idx, int& count); + + // Convert a table or a wxArrayString object at the stack_idx to an array of wxStrings. + // If it's a table, it must have integer keys and string or wxString values. + // Returns a pointer to a new array of wxStrings and set the size in count. + // the return value will need to be deleted. + WXDLLIMPEXP_WXLUA wxString* LUACALL wxlua_getwxStringarray(lua_State* L, int stack_idx, int& count); + // Convert a table or a wxArrayInt object at the stack_idx to an array of integers. + // If it's a table, it must have integer keys and values. + // Returns a pointer to a new array of ints and set the size in count + // You must delete the return value if not NULL. + WXDLLIMPEXP_WXLUA int* LUACALL wxlua_getintarray(lua_State* L, int stack_idx, int& count); + + // Convert a table or a wxArrayString object at the stack_idx to a wxArrayString. + // If it's a table, it must have integer keys and string or wxString values. + WXDLLIMPEXP_WXLUA wxLuaSmartwxArrayString LUACALL wxlua_getwxArrayString(lua_State* L, int stack_idx); + // Convert a table or a wxSortedArrayString object at the stack_idx to a wxSortedArrayString. + // If it's a table, it must have integer keys and string or wxString values. + WXDLLIMPEXP_WXLUA wxLuaSmartwxSortedArrayString LUACALL wxlua_getwxSortedArrayString(lua_State* L, int stack_idx); + // Convert a table or a wxArrayInt object at the stack_idx to a wxArrayInt. + // If it's a table, it must have integer keys and values. + WXDLLIMPEXP_WXLUA wxLuaSmartwxArrayInt LUACALL wxlua_getwxArrayInt(lua_State* L, int stack_idx); + + // Creates a Lua table and pushes the strings into it, returns the number of items added // The table is left on the stack *************** *** 290,293 **** --- 385,390 ---- // The table is left on the stack WXDLLIMPEXP_WXLUA int LUACALL wxlua_pushwxArrayInttable(lua_State* L, const wxArrayInt& intArray); + // Push the wxString into Lua after converting it. + WXDLLIMPEXP_WXLUA void LUACALL wxlua_pushwxString(lua_State* L, const wxString& str); //---------------------------------------------------------------------------- *************** *** 311,321 **** WXDLLIMPEXP_WXLUA bool LUACALL wxlua_removederivedmethod(lua_State* L, void *pObject); ! // Get the value of the flag set to determine if a virtual C++ class member ! // function should call it's own base class function or a wxLua derived method. WXDLLIMPEXP_WXLUA bool LUACALL wxlua_getcallbaseclassfunction(lua_State*L); // Set if the class member function call has a prepended '_' to imply that // the user wants the base class function and not the derived method. WXDLLIMPEXP_WXLUA void LUACALL wxlua_setcallbaseclassfunction(lua_State*L, bool call_base); //---------------------------------------------------------------------------- // wxLuaStateData - the internal data for the wxLuaState. --- 408,459 ---- WXDLLIMPEXP_WXLUA bool LUACALL wxlua_removederivedmethod(lua_State* L, void *pObject); ! //---------------------------------------------------------------------------- ! // Other functions for wxLua's keys in the ! //---------------------------------------------------------------------------- ! ! // Get the wxlua_lreg_callbaseclassfunc_key value of the LUA_REGISTRYINDEX table ! // to determines whether a virtual C++ class member function should call it's own ! // base class function or a wxLua derived method. WXDLLIMPEXP_WXLUA bool LUACALL wxlua_getcallbaseclassfunction(lua_State*L); // Set if the class member function call has a prepended '_' to imply that // the user wants the base class function and not the derived method. + // Sets the wxlua_lreg_callbaseclassfunc_key value of the LUA_REGISTRYINDEX table. WXDLLIMPEXP_WXLUA void LUACALL wxlua_setcallbaseclassfunction(lua_State*L, bool call_base); + // Get the wxlua_lreg_wxeventtype_key value of the LUA_REGISTRYINDEX table + // to see if we're currently in a wxEvent callback. + WXDLLIMPEXP_WXLUA wxEventType LUACALL wxlua_getwxeventtype(lua_State*L); + // Set the wxlua_lreg_wxeventtype_key value of the LUA_REGISTRYINDEX table + // with the current wxEventType we're in or wxEVT_NULL if none. + 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_send_evt(false), m_lua_debug_hook(0), + 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; + bool m_lua_debug_hook_send_evt; + int m_lua_debug_hook; + + 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 + }; + //---------------------------------------------------------------------------- // wxLuaStateData - the internal data for the wxLuaState. *************** *** 331,364 **** ~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 ! ! wxEventType m_inEventType; // wxEventType set when in event, else wxEVT_NULL ! ! wxLongToLongHashMap m_trackedObjects; // tracked wxObjects that we will delete when the ! // wxLuaState is closed or Lua gc them. ! // key is (long)object* and value is the wxObject ! // Note that non wxObject classes use ! // wxLUA_DECLARE_ENCAPSULATION so the key is the object pointer ! // and the value is the wxObject encapsulation. ! wxWindowList 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 ! ! bool m_is_running; // is the lua_State running a script ! bool m_is_closing; // are we currently being closed ! 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 ! int m_lua_debug_hook_count; // values from SetLuaDebugHook ! 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 wxLuaEvents to ! wxWindowID m_id; // event id to send the events with }; --- 469,483 ---- ~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 ! wxWindowID m_id; // event id to send the events with }; *************** *** 489,500 **** // ----------------------------------------------------------------------- - // Get the wxEventType that Lua may currently be in, wxEVT_NULL if not in an - // 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); - - // ----------------------------------------------------------------------- - // Set the event handler that the wxLuaEvents from this will be sent to, can be NULL. // See wxEVT_LUA_XXX for a list of possible events that may be sent. --- 608,611 ---- *************** *** 551,554 **** --- 662,671 ---- static bool CheckRunError(int status, wxString *msg); + // Get the wxEventType that Lua may currently be in, wxEVT_NULL if not in an + // 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); + // ----------------------------------------------------------------------- *************** *** 582,586 **** // Lua code and SetLuaDebugHook is turned on unsigned long GetLastLuaDebugHookTime() const; ! // Set to an arbitrary time to control debug timing void SetLastLuaDebugHookTime(unsigned long t); --- 699,703 ---- // Lua code and SetLuaDebugHook is turned on unsigned long GetLastLuaDebugHookTime() const; ! // Set to an specific time to control debug timing void SetLastLuaDebugHookTime(unsigned long t); *************** *** 636,648 **** // memory tracking functions (internal use) - enum RemoveTrackedObject_flags - { - UNDELETE_OBJECT = 0, // stop tracking for deletion (someone else owns this) - DELETE_OBJECT = 0x0001, // delete the object - CLEAR_TRACKED_OBJECT = 0x0002, // clear tracking the object in Lua reg table - CLEAR_DERIVED_METHODS = 0x0004, // clear any derived methods in Lua reg table - DELETE_CLEAR_OBJECT = DELETE_OBJECT|CLEAR_TRACKED_OBJECT|CLEAR_DERIVED_METHODS - }; - // Track this object and delete it when Lua calls the gc method for it void AddTrackedObject(wxObject *pObject); --- 753,756 ---- *************** *** 650,662 **** // 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 optionally delete it. ! // flags are ored values of enum RemoveTrackedObject_flags bool RemoveTrackedObject(void *pObject, int flags); // Is this object currently tracked? bool IsTrackedObject(void *pObject) const; - // The the hashtable of [long object pointer] = [long wxObject (container) pointer] - // The key = value for wxObject derived classes, but are different for non wxObject classes. - wxLongToLongHashMap* GetTrackedObjects(); // Get an array of strings "wxObject_classname count#" wxArrayString GetTrackedObjectStrings(); --- 758,767 ---- // 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(const void* obj_ptr, wxObject *pObject); // Remove the object from the tracked memory and optionally delete it. ! // flags are ored values of enum wxLuaRemoveTrackedObject_flags bool RemoveTrackedObject(void *pObject, int flags); // Is this object currently tracked? bool IsTrackedObject(void *pObject) const; // Get an array of strings "wxObject_classname count#" wxArrayString GetTrackedObjectStrings(); *************** *** 667,677 **** // function for all objects with classinfo in the bindings and we // want to minimize the code in the bindings. ! bool AddTrackedWindow(wxObject *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; // Get an array of strings "wxWindow_classname count#" ! wxArrayString GetTrackedWindowStrings(); // delete all stray wxWindow derived classes that have been destroyed --- 772,782 ---- // function for all objects with classinfo in the bindings and we // want to minimize the code in the bindings. ! void AddTrackedWindow(wxObject *win); // Don't track this window anymore and don't delete it. ! void RemoveTrackedWindow(wxWindow *win); // Is this window tracked, if check_parents see if a parent of it is. ! bool IsTrackedWindow(wxWindow *win, bool check_parents = true) const; // Get an array of strings "wxWindow_classname count#" ! wxArrayString GetTrackedWindowStrings() const; // delete all stray wxWindow derived classes that have been destroyed *************** *** 684,688 **** bool RemoveTrackedCallback(wxLuaCallback* callback); // Get an array of strings "wxEVT_XXX (wxEventType #) count#" ! wxArrayString GetTrackedCallbackStrings(); // Add or remove a tracked wxLuaWinDestroyCallback connected to wxEVT_DESTROY. --- 789,793 ---- bool RemoveTrackedCallback(wxLuaCallback* callback); // Get an array of strings "wxEVT_XXX (wxEventType #) count#" ! wxArrayString GetTrackedCallbackStrings() const; // Add or remove a tracked wxLuaWinDestroyCallback connected to wxEVT_DESTROY. *************** *** 690,694 **** bool RemoveTrackedWinDestroyCallback(wxLuaWinDestroyCallback* callback); // Get an array of strings "wxWindow_classname count#" ! wxArrayString GetTrackedWinDestroyCallbackStrings(); // ----------------------------------------------------------------------- --- 795,799 ---- bool RemoveTrackedWinDestroyCallback(wxLuaWinDestroyCallback* callback); // Get an array of strings "wxWindow_classname count#" ! wxArrayString GetTrackedWinDestroyCallbackStrings() const; // ----------------------------------------------------------------------- *************** *** 698,701 **** --- 803,808 ---- wxLUA_UNICODE_ONLY(void wxlua_Error(const wxString& errorMsg) const { wxlua_Error(wx2lua(errorMsg)); }) + void* wxlua_ToUserdata(int stack_idx, bool null_ptr = false) const; + // ----------------------------------------------------------------------- // wxLua Lua Registry Table Functions *************** *** 704,713 **** bool wxluaR_Unref(int wxlref_index, const void* lightuserdata_reg_key); bool wxluaR_GetRef(int wxlref_index, const void* lightuserdata_reg_key); ! bool wxluaT_PushUserTag(const void *u, int tag, bool track); ! int wxluaT_GetTag(int stack_idx) const; ! void* wxlua_ToUserdata(int stack_idx, bool null_ptr = false) const; int wxluaT_NewTag(); bool wxluaT_SetTag(int tag); // ----------------------------------------------------------------------- // wxLua get data type --- 811,821 ---- bool wxluaR_Unref(int wxlref_index, const void* lightuserdata_reg_key); bool wxluaR_GetRef(int wxlref_index, const void* lightuserdata_reg_key); ! int wxluaT_NewTag(); + int wxluaT_GetTag(int stack_idx) const; bool wxluaT_SetTag(int tag); + bool wxluaT_PushUserTag(const void *u, int tag, bool track); + // ----------------------------------------------------------------------- // wxLua get data type *************** *** 721,729 **** // Check if the item at the Lua stack index is user data type tag bool IsUserDataType(int stack_idx, int tag) const; ! // Return a pointer to the object that corresponds to the specified stack ! // index and tag. Get a user data type either allocated by wxLua or a ! // system allocated tag. ! // If the data type does not have the correct tag, or if the parameter ! // stack_idx is nil, NULL is returned, otherwise wxlua_error is called. void* GetUserDataType(int stack_idx, int iTag) const; // Push a data type onto the stack and set its tag --- 829,836 ---- // Check if the item at the Lua stack index is user data type tag bool IsUserDataType(int stack_idx, int tag) const; ! // Get the userdata object at the stack_idx that is of the class type tag or a ! // class derived from the tag. ! // If the data type does not have the correct tag, or if the parameter isn't a ! // userdata then wxlua_error is called and NULL is returned. void* GetUserDataType(int stack_idx, int iTag) const; // Push a data type onto the stack and set its tag *************** *** 755,772 **** // be converted into the type by Lua, returns false if not (no errors) bool IsStringType(int stack_idx) const; bool IsBooleanType(int stack_idx) const; bool IsIntegerType(int stack_idx) const; bool IsNumberType(int stack_idx) const; ! // Validate that the object at the stack index specified is a table object ! // or a wxArrayString and convert it to an array of wxStrings. ! // If it's a table, this assumes that each numeric entry in the table is a ! // string object or can be converted to a string. // Returns a pointer to a new array of wxStrings and set the size in count. // the return value will need to be deleted. ! wxString* GetStringArray(int stack_idx, int &count); ! // Convert a parameter which is either an wxArrayString or a table into a wxArrayString. ! // returns the number of values in the array. ! int GetwxArrayString(int stack_idx, wxArrayString &strArray); // Convert a parameter which is presumably a table into a character pointer array. // returns the number of character strings in the array in count. --- 862,878 ---- // be converted into the type by Lua, returns false if not (no errors) bool IsStringType(int stack_idx) const; + bool IswxStringType(int stack_idx) const; bool IsBooleanType(int stack_idx) const; bool IsIntegerType(int stack_idx) const; bool IsNumberType(int stack_idx) const; ! // Convert a table or a wxArrayString object at the stack_idx to an array of wxStrings. ! // If it's a table, it must have integer keys and string or wxString values. // Returns a pointer to a new array of wxStrings and set the size in count. // the return value will need to be deleted. ! wxString* GetwxStringArray(int stack_idx, int &count); ! // Convert a table or a wxArrayString object at the stack_idx to a wxArrayString. ! // If it's a table, it must have integer keys and string or wxString values. ! wxLuaSmartwxArrayString GetwxArrayString(int stack_idx); // Convert a parameter which is presumably a table into a character pointer array. // returns the number of character strings in the array in count. *************** *** 774,787 **** const char** GetCharArray(int stack_idx, int &count); ! // Validate that the object at the stack index specified is a table object ! // or a wxArrayInt and convert it to an array of ints. ! // If it's a table, this assumes that each numeric entry in the table is a ! // numeric object or can be converted to a number // Returns a pointer to a new array of ints and set the size in count // You must delete the return value if not NULL. int* GetIntArray(int stack_idx, int &count); ! // convert a parameter which is presumably a table into a wxArrayInt. ! // returns the number of values put into the array. ! int GetwxArrayInt(int stack_idx, wxArrayInt &intArray); // Convert a wxArrayString object to a table of strings, returns number of values --- 880,891 ---- const char** GetCharArray(int stack_idx, int &count); ! // Convert a table or a wxArrayInt object at the stack_idx to an array of integers. ! // If it's a table, it must have integer keys and values. // Returns a pointer to a new array of ints and set the size in count // You must delete the return value if not NULL. int* GetIntArray(int stack_idx, int &count); ! // Convert a table or a wxArrayInt object at the stack_idx to a wxArrayInt. ! // If it's a table, it must have integer keys and values. ! wxLuaSmartwxArrayInt GetwxArrayInt(int stack_idx); // Convert a wxArrayString object to a table of strings, returns number of values *************** *** 848,852 **** int lua_Type(int index) const; wxString lua_TypeName(int type) const; - wxString lua_TypeNameIndex(int index) const { return lua_TypeName(lua_Type(index)); } int lua_Equal(int index1, int index2) const; --- 952,955 ---- Index: wxlua_bind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlua_bind.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** wxlua_bind.h 17 Nov 2007 00:15:01 -0000 1.6 --- wxlua_bind.h 7 Dec 2007 02:13:14 -0000 1.7 *************** *** 17,23 **** // the current version of the bindings. // See 'bindings/genwxbind.lua' and 'modules/wxlua/include/wxldefs.h' ! #if WXLUA_BINDING_VERSION > 18 # error "The WXLUA_BINDING_VERSION in the bindings is too old, regenerate bindings." ! #endif //WXLUA_BINDING_VERSION > 18 // --------------------------------------------------------------------------- --- 17,23 ---- // the current version of the bindings. // See 'bindings/genwxbind.lua' and 'modules/wxlua/include/wxldefs.h' ! #if WXLUA_BINDING_VERSION > 19 # error "The WXLUA_BINDING_VERSION in the bindings is too old, regenerate bindings." ! #endif //WXLUA_BINDING_VERSION > 19 // --------------------------------------------------------------------------- |