From: John L. <jr...@us...> - 2008-01-23 06:43:43
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv692/wxLua/modules/wxlua/include Modified Files: wxlbind.h wxldefs.h wxlstate.h wxlua_bind.h Log Message: Use positive values for WXLUA_TXXX types not negative. Initialize the wxLua types when the bindings are initialized not when installed into Lua so we can install the bindings in any order or number for multiple wxLuaStates. Index: wxldefs.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxldefs.h,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** wxldefs.h 4 Jan 2008 00:21:08 -0000 1.41 --- wxldefs.h 23 Jan 2008 06:43:38 -0000 1.42 *************** *** 65,69 **** //----------------------------------------------------------------------------- ! #define WXLUA_BINDING_VERSION 21 // ---------------------------------------------------------------------------- --- 65,69 ---- //----------------------------------------------------------------------------- ! #define WXLUA_BINDING_VERSION 22 // ---------------------------------------------------------------------------- Index: wxlbind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlbind.h,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** wxlbind.h 17 Jan 2008 22:37:30 -0000 1.79 --- wxlbind.h 23 Jan 2008 06:43:38 -0000 1.80 *************** *** 24,30 **** // ---------------------------------------------------------------------------- ! // Binding wxLua types are positive integers generated automatically when initialized ! // and the inbuilt wxLua types (WXLUA_TXXX) corresponding to Lua types ! // (LUA_TXXX) are negative values. // *Use the function bool wxlua_iswxuserdatatype(wxl_type) if you want to // differentiate between the two. --- 24,31 ---- // ---------------------------------------------------------------------------- ! // The inbuilt wxLua types (WXLUA_TXXX) corresponding to Lua types (LUA_TXXX) ! // are shifted to be positive values. ! // The Binding wxLua types are positive integers generated automatically when ! // initialized and start at WXLUA_T_MAX+1. // *Use the function bool wxlua_iswxuserdatatype(wxl_type) if you want to // differentiate between the two. *************** *** 32,85 **** // Note that WXLUA_TUNKNOWN is used as an initialiser for class types // and is used as an end marker for the wxLuaArgType array that ! // represents function prototype argument types in the wxLuaBindCFunc struct. // wxLua types for Lua types #define WXLUA_TUNKNOWN 0 // unset and invalid, not a LUA_TXXX ! #define WXLUA_TNONE -1 // LUA_TNONE -1 ! #define WXLUA_TNIL -2 // LUA_TNIL 0 ! #define WXLUA_TBOOLEAN -3 // LUA_TBOOLEAN 1 ! #define WXLUA_TLIGHTUSERDATA -4 // LUA_TLIGHTUSERDATA 2 ! #define WXLUA_TNUMBER -5 // LUA_TNUMBER 3 ! #define WXLUA_TSTRING -6 // LUA_TSTRING 4 ! #define WXLUA_TTABLE -7 // LUA_TTABLE 5 ! #define WXLUA_TFUNCTION -8 // LUA_TFUNCTION 6 ! #define WXLUA_TUSERDATA -9 // LUA_TUSERDATA 7 ! #define WXLUA_TTHREAD -10 // LUA_TTHREAD 8 ! #define WXLUA_TINTEGER -11 // LUA_TNUMBER but integer only, not a LUA_TXXX ! #define WXLUA_TCFUNCTION -12 // LUA_TFUNCTION & lua_iscfunction(), not a LUA_TXXX ! #define WXLUA_T_MAX 0 // Max of the WXLUA_TXXX values ! #define WXLUA_T_MIN -12 // Min of the WXLUA_TXXX values ! // Blindly convert the lua_type to the wxlua_type. Note: WXLUA_TXXX = -1*LUA_TXXX - 2 // *** See wxlua_luatowxluatype() for a better function *** ! #define LUAT_TO_WXLUAT(luatype) (-1*(luatype) - 2) // Variables used in the wxLuaArgType member of the wxLuaBindCFunc for // Lua types. The binding generator uses these and generates new ones for // classes and structs as specified in the bindings. ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TNONE; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TNIL; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TBOOLEAN; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TLIGHTUSERDATA; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TNUMBER; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TSTRING; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TTABLE; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TFUNCTION; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TUSERDATA; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TTHREAD; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TINTEGER; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TCFUNCTION; // Copies of wxLua types that are used very often. // Note that we do not use the original since we may not be linked // to the binding library that defines them. ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_NULL; // wxLua type for NULL pointer ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxEvent; // wxLua type for wxEvents ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxWindow; // wxLua type for wxWindows ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxString; // wxLua type for wxStrings ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxArrayString; // wxLua type for wxArrayString ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxSortedArrayString; // wxLua type for wxSortedArrayString ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxArrayInt; // wxLua type for wxArrayInt // ---------------------------------------------------------------------------- --- 33,95 ---- // Note that WXLUA_TUNKNOWN is used as an initialiser for class types // and is used as an end marker for the wxLuaArgType array that ! // represents function prototype argument types in the wxLuaBindCFunc struct ! // and it must always be 0. // wxLua types for Lua types #define WXLUA_TUNKNOWN 0 // unset and invalid, not a LUA_TXXX ! #define WXLUA_TNONE 1 // LUA_TNONE -1 ! #define WXLUA_TNIL 2 // LUA_TNIL 0 ! #define WXLUA_TBOOLEAN 3 // LUA_TBOOLEAN 1 ! #define WXLUA_TLIGHTUSERDATA 4 // LUA_TLIGHTUSERDATA 2 ! #define WXLUA_TNUMBER 5 // LUA_TNUMBER 3 ! #define WXLUA_TSTRING 6 // LUA_TSTRING 4 ! #define WXLUA_TTABLE 7 // LUA_TTABLE 5 ! #define WXLUA_TFUNCTION 8 // LUA_TFUNCTION 6 ! #define WXLUA_TUSERDATA 9 // LUA_TUSERDATA 7 ! #define WXLUA_TTHREAD 10 // LUA_TTHREAD 8 ! #define WXLUA_TINTEGER 11 // LUA_TNUMBER but integer only, not a LUA_TXXX ! #define WXLUA_TCFUNCTION 12 // LUA_TFUNCTION & lua_iscfunction(), not a LUA_TXXX ! #define WXLUA_TNULL 13 // C++ NULL ! #define WXLUA_T_MAX 13 // Max of the WXLUA_TXXX values ! #define WXLUA_T_MIN 0 // Min of the WXLUA_TXXX values ! ! // Blindly convert the lua_type to the wxlua_type. Note: WXLUA_TXXX = LUA_TXXX - 2 // *** See wxlua_luatowxluatype() for a better function *** ! #define LUAT_TO_WXLUAT(luatype) ((luatype) - 2) ! ! // Returns true if the wxLua type is for a wxLua binding type and not a ! // generic WXLUA_TXXX type. This means that there might be a metatable for ! // this type in the wxlua_lreg_types_key of the LUA_REGISTRYINDEX table. ! #define wxlua_iswxuserdatatype(wxl_type) ((wxl_type) >= WXLUA_TNULL) // Variables used in the wxLuaArgType member of the wxLuaBindCFunc for // Lua types. The binding generator uses these and generates new ones for // classes and structs as specified in the bindings. ! extern WXDLLIMPEXP_DATA_WXLUA(int) wxluatype_TNONE; ! extern WXDLLIMPEXP_DATA_WXLUA(int) wxluatype_TNIL; ! extern WXDLLIMPEXP_DATA_WXLUA(int) wxluatype_TBOOLEAN; ! extern WXDLLIMPEXP_DATA_WXLUA(int) wxluatype_TLIGHTUSERDATA; ! extern WXDLLIMPEXP_DATA_WXLUA(int) wxluatype_TNUMBER; ! extern WXDLLIMPEXP_DATA_WXLUA(int) wxluatype_TSTRING; ! extern WXDLLIMPEXP_DATA_WXLUA(int) wxluatype_TTABLE; ! extern WXDLLIMPEXP_DATA_WXLUA(int) wxluatype_TFUNCTION; ! extern WXDLLIMPEXP_DATA_WXLUA(int) wxluatype_TUSERDATA; ! extern WXDLLIMPEXP_DATA_WXLUA(int) wxluatype_TTHREAD; ! extern WXDLLIMPEXP_DATA_WXLUA(int) wxluatype_TINTEGER; ! extern WXDLLIMPEXP_DATA_WXLUA(int) wxluatype_TCFUNCTION; ! ! extern WXDLLIMPEXP_DATA_WXLUA(int) wxluatype_NULL; // wxLua type for NULL pointer // Copies of wxLua types that are used very often. // Note that we do not use the original since we may not be linked // to the binding library that defines them. ! extern WXDLLIMPEXP_DATA_WXLUA(int*) p_wxluatype_wxEvent; // wxLua type for wxEvents ! extern WXDLLIMPEXP_DATA_WXLUA(int*) p_wxluatype_wxWindow; // wxLua type for wxWindows ! extern WXDLLIMPEXP_DATA_WXLUA(int*) p_wxluatype_wxString; // wxLua type for wxStrings ! extern WXDLLIMPEXP_DATA_WXLUA(int*) p_wxluatype_wxArrayString; // wxLua type for wxArrayString ! extern WXDLLIMPEXP_DATA_WXLUA(int*) p_wxluatype_wxSortedArrayString; // wxLua type for wxSortedArrayString ! extern WXDLLIMPEXP_DATA_WXLUA(int*) p_wxluatype_wxArrayInt; // wxLua type for wxArrayInt // ---------------------------------------------------------------------------- *************** *** 176,180 **** const wxEventType* eventType; // wxWidgets event type, e.g. &wxEVT_COMMAND_MENU_SELECTED int* wxluatype; // wxLua class type that wxWidgets uses for this wxEventType, ! // e.g. &g_wxluatype_wxCommandEvent }; --- 186,190 ---- const wxEventType* eventType; // wxWidgets event type, e.g. &wxEVT_COMMAND_MENU_SELECTED int* wxluatype; // wxLua class type that wxWidgets uses for this wxEventType, ! // e.g. &wxluatype_wxCommandEvent }; *************** *** 625,628 **** --- 635,639 ---- static wxLuaBindingList sm_bindingList; static bool sm_bindingList_initialized; + static int sm_wxluatype_counter; DECLARE_ABSTRACT_CLASS(wxLuaBinding) Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.116 retrieving revision 1.117 diff -C2 -d -r1.116 -r1.117 *** wxlstate.h 20 Jan 2008 19:23:01 -0000 1.116 --- wxlstate.h 23 Jan 2008 06:43:38 -0000 1.117 *************** *** 199,204 **** // 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. --- 199,204 ---- // 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. *************** *** 315,319 **** WXDLLIMPEXP_WXLUA bool LUACALL wxluaO_istrackedweakobject(lua_State *L, void *obj_ptr, int wxl_type, bool push_on_stack); // Get a wxArrayString of the info in the wxlua_lreg_weakobjects_key LUA_REGISTRYINDEX table. ! // Strings are of the form "&obj_ptr = wxLuaTypeName1(&udata, type=wxLuaType), ..." // If the object is casted to multiple types there will be wxLuaTypeName2(...) and so on. WXDLLIMPEXP_WXLUA wxArrayString LUACALL wxluaO_gettrackedweakobjectinfo(lua_State *L); --- 315,319 ---- WXDLLIMPEXP_WXLUA bool LUACALL wxluaO_istrackedweakobject(lua_State *L, void *obj_ptr, int wxl_type, bool push_on_stack); // Get a wxArrayString of the info in the wxlua_lreg_weakobjects_key LUA_REGISTRYINDEX table. ! // Strings are of the form "&obj_ptr = wxLuaTypeName1(&udata, type=wxLuaType), ..." // If the object is casted to multiple types there will be wxLuaTypeName2(...) and so on. WXDLLIMPEXP_WXLUA wxArrayString LUACALL wxluaO_gettrackedweakobjectinfo(lua_State *L); *************** *** 350,354 **** // Returns the index into the wxLua types table which is a new wxLua type. // Leaves the new table on the top of the stack. ! WXDLLIMPEXP_WXLUA int LUACALL wxluaT_newmetatable(lua_State* L); // Set the metatable of the userdata at top of stack to the table stored in the // wxlua_lreg_types_key LUA_REGISTRYINDEX table. --- 350,359 ---- // Returns the index into the wxLua types table which is a new wxLua type. // Leaves the new table on the top of the stack. ! WXDLLIMPEXP_WXLUA int LUACALL wxluaT_newmetatable(lua_State* L, int wxl_type); ! // Get the metatable for the wxLua type stored in the ! // wxlua_lreg_types_key LUA_REGISTRYINDEX table. ! // Returns true if the type's metatable was found and is on the stack, nothing ! // is left on the stack on failure. ! WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_getmetatable(lua_State* L, int wxl_type); // Set the metatable of the userdata at top of stack to the table stored in the // wxlua_lreg_types_key LUA_REGISTRYINDEX table. *************** *** 365,375 **** WXDLLIMPEXP_WXLUA int LUACALL wxluaT_type(lua_State* L, int stack_idx); - // Returns true if the wxLua type is for a wxLua binding type and not a - // generic WXLUA_TXXX type. This means that there is a metatable for this - // type in the wxlua_lreg_types_key of the LUA_REGISTRYINDEX table. - #define wxlua_iswxuserdatatype(wxl_type) ((wxl_type) > 0) - // Get a human readable name for the predefined WXLUA_TXXX or binding ! // g_wxluatype_XXX wxLua types stored in the wxlua_lreg_types_key // of the LUA_REGISTRYINDEX table. // This is the wxLua equivalent of lua_typename(L, luatype). --- 370,375 ---- WXDLLIMPEXP_WXLUA int LUACALL wxluaT_type(lua_State* L, int stack_idx); // Get a human readable name for the predefined WXLUA_TXXX or binding ! // wxluatype_XXX wxLua types stored in the wxlua_lreg_types_key // of the LUA_REGISTRYINDEX table. // This is the wxLua equivalent of lua_typename(L, luatype). *************** *** 654,658 **** // enum wxLuaState_Type is for the function // wxLuaState::Create(lua_State* L, int state_type = wxLUASTATE_GETSTATE); ! enum wxLuaState_Type { wxLUASTATE_GETSTATE = 1, // Attach to a previously created wxLuaState's --- 654,658 ---- // enum wxLuaState_Type is for the function // wxLuaState::Create(lua_State* L, int state_type = wxLUASTATE_GETSTATE); ! enum wxLuaState_Type { wxLUASTATE_GETSTATE = 1, // Attach to a previously created wxLuaState's *************** *** 666,671 **** wxLUASTATE_STATICSTATE = 0x10, // The lua_State is static and the wxLuaState // will not lua_close() it when Destroy()ed. ! wxLUASTATE_OPENBINDINGS = 0x20, // Install all the bindings in ! // wxLuaBinding::GetBindingList() into the // lua_State. }; --- 666,671 ---- wxLUASTATE_STATICSTATE = 0x10, // The lua_State is static and the wxLuaState // will not lua_close() it when Destroy()ed. ! wxLUASTATE_OPENBINDINGS = 0x20, // Install all the bindings in ! // wxLuaBinding::GetBindingList() into the // lua_State. }; *************** *** 677,681 **** { public: ! // Default constructor or if create=true then // call the function Create(wxEvtHandler=NULL, id=wxID_ANY). wxLuaState(bool create = false) { if (create) Create(); } --- 677,681 ---- { public: ! // Default constructor or if create=true then // call the function Create(wxEvtHandler=NULL, id=wxID_ANY). wxLuaState(bool create = false) { if (create) Create(); } *************** *** 755,768 **** // ----------------------------------------------------------------------- ! // In order for wxLua scripts to work from a C++ program's wxApp::OnInit() // and the Lua module you may have to set this variable to force the wxLua // code "wx.wxGetApp:MainLoop()" to not call wxApp::MainLoop(). ! // The issue is that within the function wxApp::OnInit() wxApp::IsMainLoopRunning() // returns false, but it will be running after OnInit() returns so we should // silently ignore the Lua code wanting to prematurely start the MainLoop. // Initialized to false, meaning not set. ! // Set to true for the Lua code "wx.wxGetApp:MainLoop()" to not call // the app's MainLoop() function. ! // // See the wxLua apps for usage. static bool sm_wxAppMainLoop_will_run; --- 755,768 ---- // ----------------------------------------------------------------------- ! // In order for wxLua scripts to work from a C++ program's wxApp::OnInit() // and the Lua module you may have to set this variable to force the wxLua // code "wx.wxGetApp:MainLoop()" to not call wxApp::MainLoop(). ! // The issue is that within the function wxApp::OnInit() wxApp::IsMainLoopRunning() // returns false, but it will be running after OnInit() returns so we should // silently ignore the Lua code wanting to prematurely start the MainLoop. // Initialized to false, meaning not set. ! // Set to true for the Lua code "wx.wxGetApp:MainLoop()" to not call // the app's MainLoop() function. ! // // See the wxLua apps for usage. static bool sm_wxAppMainLoop_will_run; *************** *** 810,819 **** // Sends a wxEVT_LUA_ERROR wxLuaEvent on error. // narg is the number of args to the function to call. ! // nresults is the number of values expected to be returned and Lua ! // will adjust the stack to match. // Use LUA_MULTRET for a variable number of returns. int LuaPCall(int narg, int nresults); ! // bool SendLuaErrorEvent(int status, int top); --- 810,819 ---- // Sends a wxEVT_LUA_ERROR wxLuaEvent on error. // narg is the number of args to the function to call. ! // nresults is the number of values expected to be returned and Lua ! // will adjust the stack to match. // Use LUA_MULTRET for a variable number of returns. int LuaPCall(int narg, int nresults); ! // bool SendLuaErrorEvent(int status, int top); *************** *** 974,978 **** bool wxluaR_GetRef(int wxlref_index, void* lightuserdata_reg_key); ! int wxluaT_NewMetatable(); bool wxluaT_SetMetatable(int wxl_type); int wxluaT_Type(int stack_idx) const; --- 974,978 ---- bool wxluaR_GetRef(int wxlref_index, void* lightuserdata_reg_key); ! int wxluaT_NewMetatable(int wxl_type); bool wxluaT_SetMetatable(int wxl_type); int wxluaT_Type(int stack_idx) const; Index: wxlua_bind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlua_bind.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** wxlua_bind.h 22 Dec 2007 06:07:15 -0000 1.10 --- wxlua_bind.h 23 Jan 2008 06:43:38 -0000 1.11 *************** *** 17,27 **** // the current version of the bindings. // See 'bindings/genwxbind.lua' and 'modules/wxlua/include/wxldefs.h' ! #if WXLUA_BINDING_VERSION > 21 # error "The WXLUA_BINDING_VERSION in the bindings is too old, regenerate bindings." ! #endif //WXLUA_BINDING_VERSION > 21 // --------------------------------------------------------------------------- // binding class ! class wxLuaBinding_wxlua : public wxLuaBinding { public: --- 17,27 ---- // 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 // --------------------------------------------------------------------------- // binding class ! class WXDLLIMPEXP_WXLUA wxLuaBinding_wxlua : public wxLuaBinding { public: *************** *** 48,71 **** #include "wxlua/include/wxlstate.h" - - // --------------------------------------------------------------------------- - // Functions to access wxLuaBindXXX structs - // --------------------------------------------------------------------------- - - extern wxLuaBindClass *wxLuaGetClassList_wxlua(size_t &count); - extern wxLuaBindNumber *wxLuaGetDefineList_wxlua(size_t &count); - extern wxLuaBindString *wxLuaGetStringList_wxlua(size_t &count); - extern wxLuaBindEvent *wxLuaGetEventList_wxlua(size_t &count); - extern wxLuaBindObject *wxLuaGetObjectList_wxlua(size_t &count); - extern wxLuaBindMethod *wxLuaGetFunctionList_wxlua(size_t &count); - // --------------------------------------------------------------------------- // Lua Tag Method Values and Tables for each Class // --------------------------------------------------------------------------- ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_wxLuaObject; extern WXDLLIMPEXP_WXLUA wxLuaBindMethod wxLuaObject_methods[]; extern WXDLLIMPEXP_DATA_WXLUA(int) wxLuaObject_methodCount; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_wxLuaState; extern WXDLLIMPEXP_WXLUA wxLuaBindMethod wxLuaState_methods[]; extern WXDLLIMPEXP_DATA_WXLUA(int) wxLuaState_methodCount; --- 48,59 ---- #include "wxlua/include/wxlstate.h" // --------------------------------------------------------------------------- // Lua Tag Method Values and Tables for each Class // --------------------------------------------------------------------------- ! extern WXDLLIMPEXP_DATA_WXLUA(int) wxluatype_wxLuaObject; extern WXDLLIMPEXP_WXLUA wxLuaBindMethod wxLuaObject_methods[]; extern WXDLLIMPEXP_DATA_WXLUA(int) wxLuaObject_methodCount; ! extern WXDLLIMPEXP_DATA_WXLUA(int) wxluatype_wxLuaState; extern WXDLLIMPEXP_WXLUA wxLuaBindMethod wxLuaState_methods[]; extern WXDLLIMPEXP_DATA_WXLUA(int) wxLuaState_methodCount; |