From: John L. <jr...@us...> - 2007-06-14 23:59:52
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv16698/wxLua/modules/wxlua/include Modified Files: wxlbind.h wxlstate.h Log Message: Add "voidptr_long" binding tag to allow using void* as a number Speed up bindings by using numbers as keys in the registry (avoid lua doing a string copy) Get rid of wxLuaState::GetXXXTag functions, something better needs to be implemented, using global vars for the few tags that we really use often now Allow the wxLuaStackDialog to be able to show lua's registry lots of cleanup in bindings.wx.lua Index: wxlbind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlbind.h,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** wxlbind.h 13 Jun 2007 00:09:04 -0000 1.50 --- wxlbind.h 14 Jun 2007 23:59:48 -0000 1.51 *************** *** 46,49 **** --- 46,61 ---- // wxlua arg tags for common lua types + #define WXLUAARG_None 0 + #define WXLUAARG_Nil -2 + #define WXLUAARG_Boolean -3 + #define WXLUAARG_LightUserData -4 + #define WXLUAARG_Number -5 + #define WXLUAARG_String -6 + #define WXLUAARG_LuaTable -7 + #define WXLUAARG_LuaFunction -8 + #define WXLUAARG_UserData -9 + #define WXLUAARG_LuaThread -10 + #define WXLUAARG_Integer -11 + extern WXDLLIMPEXP_DATA_WXLUA(int) s_wxluaarg_None; extern WXDLLIMPEXP_DATA_WXLUA(int) s_wxluaarg_Nil; *************** *** 58,72 **** extern WXDLLIMPEXP_DATA_WXLUA(int) s_wxluaarg_Integer; ! #define WXLUAARG_None 0 ! #define WXLUAARG_Nil -2 ! #define WXLUAARG_Boolean -3 ! #define WXLUAARG_LightUserData -4 ! #define WXLUAARG_Number -5 ! #define WXLUAARG_String -6 ! #define WXLUAARG_LuaTable -7 ! #define WXLUAARG_LuaFunction -8 ! #define WXLUAARG_UserData -9 ! #define WXLUAARG_LuaThread -10 ! #define WXLUAARG_Integer -11 typedef int* wxLuaArgTag; // address of class tag (a pointer to it) --- 70,81 ---- extern WXDLLIMPEXP_DATA_WXLUA(int) s_wxluaarg_Integer; ! // copies of wxlua arg tags for binding types that are used very often ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxLuaFunction; // The lua tag for wxLuaFunctions. ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxWinDestroyTable; // The lua tag for the wxWindow destroy tracking table ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_NULL; // The lua tag for NULL pointer ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxEvent; // The lua tag for wxEvents ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxWindow; // The lua tag for wxWindows ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxString; // The lua tag for wxStrings ! typedef int* wxLuaArgTag; // address of class tag (a pointer to it) *************** *** 196,201 **** // wxLuaObject - wraps a reference to a Lua object reference inside a // wxObject-derived class so that a Lua object can be used for ! // user data, and also with a simple extension by the ! // input/output mechanism of the wxValidator classes. // ---------------------------------------------------------------------------- --- 205,210 ---- // wxLuaObject - wraps a reference to a Lua object reference inside a // wxObject-derived class so that a Lua object can be used for ! // user data, and also with a simple extension by a proxy member ! // value it can be used to provide pointers to the wxValidator classes. // ---------------------------------------------------------------------------- *************** *** 209,216 **** }; ! class WXDLLIMPEXP_WXLUA wxLuaObject : public wxObject { public: ! // Wrap the item at the lua_State's stack index and create a reference to it. // in the wxLuaReferences registy table wxLuaObject(const wxLuaState& wxlState, int stack_idx = 1); --- 218,225 ---- }; ! class WXDLLIMPEXP_WXLUA wxLuaObject : public wxObject, wxClientData { public: ! // Wrap the item at the lua_State's stack index and create a reference to it // in the wxLuaReferences registy table wxLuaObject(const wxLuaState& wxlState, int stack_idx = 1); *************** *** 223,227 **** // on failure and nothing is pushed on the stack. bool GetObject(); ! // Remove any existing reference and allocate another void SetObject(int stack_idx = 1); --- 232,238 ---- // on failure and nothing is pushed on the stack. bool GetObject(); ! // Remove any existing reference and allocate another. ! // You cannot call this after calling GetXXXPtr() however only if this wraps a ! // stack item. void SetObject(int stack_idx = 1); *************** *** 231,234 **** --- 242,246 ---- // and return a pointer to member variable to a function that wants // a pointer to read/write from/to. + // You may only call only one of these per instance of a wxLuaObject class. bool *GetBoolPtr(); int *GetIntPtr(); *************** *** 237,245 **** // Return a flag value that indicated whether the ! // object is being used by a wxValidator class (else 0). ! int GetAllocationFlags() const { return m_alloc_flags; } ! bool HasAllocationFlag(wxLuaObject_Type flag) const { return (m_alloc_flags & flag) != 0; } ! // Set or remove the single or ored allocation flag(s) ! int SetAllocationFlag(wxLuaObject_Type flag, bool set); wxLuaState GetwxLuaState() const; --- 249,254 ---- // Return a flag value that indicated whether the ! // object is being used by a wxValidator class (else wxLUAOBJECT_NONE). ! wxLuaObject_Type GetAllocationFlag() const { return m_alloc_flag; } wxLuaState GetwxLuaState() const; *************** *** 248,256 **** wxLuaState* m_wxlState; // a pointer due to include recursion. int m_reference; ! bool m_bool; ! int m_int; ! wxString m_string; ! wxArrayInt m_arrayInt; ! int m_alloc_flags; DECLARE_ABSTRACT_CLASS(wxLuaObject) --- 257,269 ---- wxLuaState* m_wxlState; // a pointer due to include recursion. int m_reference; ! wxLuaObject_Type m_alloc_flag; ! ! union ! { ! bool m_bool; ! int m_int; ! wxString* m_string; ! wxArrayInt* m_arrayInt; ! }; DECLARE_ABSTRACT_CLASS(wxLuaObject) Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** wxlstate.h 14 Jun 2007 05:02:48 -0000 1.78 --- wxlstate.h 14 Jun 2007 23:59:48 -0000 1.79 *************** *** 88,110 **** // ---------------------------------------------------------------------------- ! // Push a special string into lua, defines to make sure it's always done the same // ---------------------------------------------------------------------------- ! // Push the "wxLuaReferences" string onto the stack. This is the name of an ! // index in the LUA_REGISTRYINDEX table that is a table indexed on the "tags" and each item ! // is a metatable for classes or a reference to an object we want to keep a handle to. ! #define wxlua_pushstring_wxLuaReferences(L) lua_pushlstring(L, "wxLuaReferences", 15) ! // Push the "wxLuaClasses" string onto the stack. This is the name of an ! // index in the LUA_REGISTRYINDEX table that is a table // t[wxLuaBindClass.name] = wxLuaBindClass, where the wxLuaBindClass is a lightuserdata. ! #define wxlua_pushstring_wxLuaClasses(L) lua_pushlstring(L, "wxLuaClasses", 12) ! // Push the "wxLuaDerivedMethods" string onto the stack. This is the name of an ! // index in the LUA_REGISTRYINDEX table that is a table // t[lightuserdata object] = {["derived func/value name"] = wxLuaObject(lua function/value), ...} ! #define wxlua_pushstring_wxLuaDerivedMethods(L) lua_pushlstring(L, "wxLuaDerivedMethods", 19) ! // Push the "wxLuaStateRefData" string onto the stack. This is the name of an ! // index of the LUA_REGISTRYINDEX table that is a lightuserdata of the // wxLuaStateRefData for this lua_State. ! #define wxlua_pushstring_wxLuaStateRefData(L) lua_pushlstring(L, "wxLuaStateRefData", 17) //---------------------------------------------------------------------------- --- 88,125 ---- // ---------------------------------------------------------------------------- ! // Push a special number into lua, defines to make sure it's always done the same. ! // ! // Note we do not push a human readable string for these because lua always makes ! // a copy of the string and the copying takes a considerable amount of time ! // when benchmarked using valgrind. // ---------------------------------------------------------------------------- ! #define WXLUA_LREG_REFERENCES -100000 ! #define WXLUA_LREG_CLASSES -100001 ! #define WXLUA_LREG_DERIVED_METHODS -100002 ! #define WXLUA_LREG_WXLUASTATEREFDATA -100003 ! #define WXLUA_METATABLE_TAG 0 ! #define WXLUA_METATABLE_CLASS 1 ! ! // Push a key that is index in the LUA_REGISTRYINDEX table that is a table indexed ! // on the "tags" and each item is a metatable for classes ! // or a reference to an object we want to keep a handle to. ! #define wxlua_pushkey_wxLuaReferences(L) lua_pushnumber(L, WXLUA_LREG_REFERENCES) ! // Push a key that is an index in the LUA_REGISTRYINDEX table that is a table // t[wxLuaBindClass.name] = wxLuaBindClass, where the wxLuaBindClass is a lightuserdata. ! #define wxlua_pushkey_wxLuaClasses(L) lua_pushnumber(L, WXLUA_LREG_CLASSES) ! // Push a key that is an index in the LUA_REGISTRYINDEX table that is a table // t[lightuserdata object] = {["derived func/value name"] = wxLuaObject(lua function/value), ...} ! #define wxlua_pushkey_wxLuaDerivedMethods(L) lua_pushnumber(L, WXLUA_LREG_DERIVED_METHODS) ! // Push a key of an index of the LUA_REGISTRYINDEX table that is a lightuserdata of the // wxLuaStateRefData for this lua_State. ! #define wxlua_pushkey_wxLuaStateRefData(L) lua_pushnumber(L, WXLUA_LREG_WXLUASTATEREFDATA) ! ! // Push a key of an index into the metatable of a wxLua userdata for the "tag" ! // in the wxLuaReferences table. ! #define wxlua_pushkey_metatableTag(L) lua_pushnumber(L, WXLUA_METATABLE_TAG) ! // Push a key of an index into the metatable of a wxLua userdata for the wxLuaBindClass ! // in the wxLuaReferences table. ! #define wxlua_pushkey_metatableClass(L) lua_pushnumber(L, WXLUA_METATABLE_CLASS) //---------------------------------------------------------------------------- *************** *** 280,290 **** bool m_bindings_registered; // Are the bindings registered into the lua_State - int m_wxluatag_wxLuaFunction; // The lua tag for wxLuaFunctions. - int m_wxluatag_NULL; // The lua tag for NULL pointer - int m_wxluatag_wxWinDestroyTable; // The lua tag for the wxWindow destroy tracking table - int m_wxluatag_wxEvent; // The lua tag for wxEvents - int m_wxluatag_wxWindow; // The lua tag for wxWindows - int m_wxluatag_wxString; // The lua tag for wxStrings - bool m_callbase_func; // call the base class function instead of derived func --- 295,298 ---- *************** *** 568,578 **** bool GetBindingsRegistered() const; // Are the binding registered - int GetwxLuaFunctionTag() const; // The lua tag for wxLuaFunction objects. - int GetLuaNULLTag() const; // The lua tag for NULL pointer - int GetLuaWinDestroyTableTag() const; // The lua tag for the wxWindow destroy tracking table - int GetwxEventTag() const; // The lua tag for wxEvents - int GetwxWindowTag() const; // The lua tag for wxWindows - int GetwxStringTag() const; // The lua tag for wxStrings - // When looking up a function to call, should the base class function // be called or the wxlua dervived method (internal use) --- 576,579 ---- |