From: John L. <jr...@us...> - 2007-06-14 01:23:12
|
Update of /cvsroot/wxlua/wxLua/bindings/wxlua In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv14159/wxLua/bindings/wxlua Added Files: Makefile override.hpp wxlua.i wxlua_rules.lua Log Message: Changed the Delete() function from the %delete tag for classes to just delete() to avoid any future name clashes since delete() is never allowed to be a function name in C++. Moved the wxStyledTextCtrl class and it's 1268 defines into the wxstc table. Moved wxLuaObject, wxLuaDebugger (and friends) into the wxlua table and added more functions for inspecting userdata and the bindings. Fix mismatches between the bindings base classes and what they really are. --- NEW FILE: Makefile --- # # File: makefile.unx # Author: John Labenski, J Winwood # Created: 2002 # Updated: # Copyright: (c) 2002. J Winwood # # # Makefile for generating the bindings WXLUA_DIR = ../.. all: genwxbind genwxbind: @(cd $(WXLUA_DIR)/bindings && ../bin/lua -e"rulesFilename=\"wxlua/wxlua_rules.lua\"" genwxbind.lua > wxlua/error.txt) # do nothing to clean clean: --- NEW FILE: override.hpp --- // ---------------------------------------------------------------------------- // Overridden functions for the wxLua binding for wxLua // // Please keep these functions in the same order as the .i file and in the // same order as the listing of the functions in that file. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Overrides for wxlua.i // ---------------------------------------------------------------------------- %override wxLua_function_CompileLuaScript // %function int CompileLuaScript(const wxString& luaScript, const wxString& fileName) static int LUACALL wxLua_function_CompileLuaScript(lua_State *L) { wxLuaState wxlState(L); int returns; // const wxString fileName const wxString fileName = wxlState.GetwxStringType(2); // const wxString luaScript const wxString luaScript = wxlState.GetwxStringType(1); wxString errMsg; int line_num = -1; wxLuaState wxlState2(true); // create a brand new empty lua state to compile in returns = wxlState2.CompileString(luaScript, fileName, &errMsg, &line_num); // push the result number lua_pushnumber(L, returns); wxlState.lua_PushString(errMsg); lua_pushnumber(L, line_num); return 3; } %end %override wxLua_function_wxlua_typename // %function wxString wxlua_getwxluatypename(int wxluaarg_tag) static int LUACALL wxLua_function_wxlua_typename(lua_State *L) { wxLuaState wxlState(L); wxString returns; // int wxluaarg_tag int wxluaarg_tag = (int)wxlua_getnumbertype(L, 1); // call wxlua_getwxluatypename returns = wxlState.GetLuaTagName(wxluaarg_tag); //wxlua_getwxluatypename(wxluaarg_tag); // push the result string wxlState.lua_PushString(returns); return 1; } %end %override wxLua_function_wxlua_type // %function int wxlua_wxluatype(int wxluaarg_tag) static int LUACALL wxLua_function_wxlua_type(lua_State *L) { wxLuaState wxlState(L); wxString returns; // int wxluaarg_tag int wxluaarg_tag = wxlua_ttag(L, 1); if (wxluaarg_tag == TLUA_NOTAG) { int ltype = lua_type(L, 1); wxluaarg_tag = wxlua_getwxluatype(ltype); } // push the result number lua_pushnumber(L, wxluaarg_tag); return 1; } %end %override wxLua_wxLuaObject_constructor // wxLuaObject(void *object) static int LUACALL wxLua_wxLuaObject_constructor(lua_State *L) { wxluabind_removetableforcall(L); wxLuaState wxlState(L); wxLuaObject *returns; // call constructor returns = new wxLuaObject(wxlState, 1); // add to tracked memory list wxlState.AddTrackedObject(returns); // push the constructed class pointer wxlState.PushUserDataType(s_wxluatag_wxLuaObject, returns); // return the number of parameters return 1; } %end %override wxLua_wxLuaObject_SetObject // void SetObject(void *object) static int LUACALL wxLua_wxLuaObject_SetObject(lua_State *L) { wxLuaState wxlState(L); // get this wxLuaObject *self = (wxLuaObject *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaObject); // call SetObject self->SetObject(1); // return the number of parameters return 0; } %end %override wxLua_wxLuaObject_GetObject // void *GetObject() const static int LUACALL wxLua_wxLuaObject_GetObject(lua_State *L) { wxLuaState wxlState(L); // get this wxLuaObject *self = (wxLuaObject *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaObject); // call GetObject that push the item onto the stack, or nil if (self->GetObject()) return 1; return 0; } %end --- NEW FILE: wxlua.i --- // ============================================================================ // Purpose: wxLua specific wrappers // Author: J Winwood, John Labenski // Created: 14/11/2001 // Copyright: (c) 2001-2002 Lomtick Software. All rights reserved. // Licence: wxWidgets licence // wxWidgets: Updated to 2.6.3 // ============================================================================ // Compile the luaScript of the given name and return the lua error code, a message // and the line number (or -1) of the error. // %override [int return, lua_string err_msg, int line_number] CompileLuaScript(const wxString& luaScript, const wxString& fileName) %function int CompileLuaScript(const wxString& luaScript, const wxString& fileName) //----------------------------------------------------------------------------- // Type information about the bindings or current userdata %enum wxLuaMethod_Type // The type of a Lua method WXLUAMETHOD_CONSTRUCTOR // constructor WXLUAMETHOD_METHOD // class member function WXLUAMETHOD_CFUNCTION // global C function (not part of a class) WXLUAMETHOD_GETPROP // Get %property funcName, read WXLUAMETHOD_SETPROP // Set %property funcName, write WXLUAMETHOD_STATIC // Class member function is static WXLUAMETHOD_OVERLOAD // This is an overload function that will call others // and the min/maxargs for it are not valid, // but are the min and max of all functions WXLUAMETHOD_DELETE // This is the delete function that wxLua has generated // to delete this class and is not part of the // original class. WXLUAMETHOD_OVERLOAD_BASE // Class method has been checked to see if it is // overloaded from the base class. // Check WXLUAMETHOD::basemethod and if !NULL // this method is an overload from the base class %endenum %define WXLUAARG_None %define WXLUAARG_Nil %define WXLUAARG_Boolean %define WXLUAARG_LightUserData %define WXLUAARG_Number %define WXLUAARG_String %define WXLUAARG_LuaTable %define WXLUAARG_LuaFunction %define WXLUAARG_UserData %define WXLUAARG_LuaThread %define WXLUAARG_Integer %define LUA_TNONE // (-1) %define LUA_TNIL // 0 %define LUA_TBOOLEAN // 1 %define LUA_TLIGHTUSERDATA // 2 %define LUA_TNUMBER // 3 %define LUA_TSTRING // 4 %define LUA_TTABLE // 5 %define LUA_TFUNCTION // 6 %define LUA_TUSERDATA // 7 %define LUA_TTHREAD // 8 // Is this lua_type() (or in lua type()) considered %function int wxlua_iswxluatype(int luatype, int wxluaarg_tag) // %override wxString wxlua_typename(int wxluaarg_tag) // C++ Func: wxString wxlua_getwxluatypename(int wxluaarg_tag) // Returns the tag name for both the predefined (negative) as well as the // binding class tags. (C function only does predefined tags) %function wxString wxlua_typename(int wxluaarg_tag) // %override int wxlua_type(void* object) // Get the wxlua type (tag) of the object, this is the arg tags number %function int wxlua_type(void* object) //----------------------------------------------------------------------------- // wxLuaBinding - This is NOT wrapped, but implemented in wxlbind.cpp // These items follow the structure below and ALL items are called as if they // were table members. // Example : wxLuaBinding_wx.GetClassCount // Example : print(wxLuaBinding_wx.GetClassArray[1].methods[1].name) // Note: Use only '.' and NO () to make it a function call, also check to see // if the item exists first (unlike the example above)! /* %class wxLuaBinding_XXX - where XXX is the name of the binding // No constructor as this is read only wxString GetBindingName wxString GetLuaNamespace int GetClassCount int GetDefineCount int GetStringCount int GetEventCount int GetObjectCount int GetFunctionCount {wxLuaBindClass*} GetClassArray {wxLuaBindMethod*} GetFunctionArray {name, value} GetDefineArray {name, value} GetStringArray {name, eventType, class_tag} GetEventArray {name, object, class_tag} GetObjectArray %endclass %class wxLuaBindClass // No constructor as this is read only wxString name {wxLuaBindMethod*} methods int methods_n wxClassInfo* classInfo int class_tag wxString baseclassName wxLuaBindClass* baseclass {name, value} enums int enums_n %endclass %class wxLuaBindMethod // No constructor as this is read only wxString name int type {wxLuaBindCFunc*} funcs int funcs_n wxLuaBindMethod* basemethod wxLuaBindClass* class // class this is part of (not in struct) wxString class_name // class name this is part of (not in struct) %endclass %class wxLuaBindCFunc // No constructor as this is read only cfunction func int type int minargs int maxargs {int} argtags wxString class_name // added, not in struct %endclass */ //----------------------------------------------------------------------------- // wxLuaState %include "wxlua/include/wxlstate.h" %class %delete wxLuaState, wxObject /* wxLuaState(bool create = false) wxLuaState(wxEvtHandler *handler, wxWindowID id = wxID_ANY) bool Ok() const void Destroy() bool CloseLuaState(bool force) bool IsClosing() const wxEventType GetInEventType() const void SetEventHandler(wxEvtHandler *evtHandler) wxEvtHandler *GetEventHandler() const void SetId(wxWindowID id) wxWindowID GetId() const void SendEvent( wxLuaEvent &event ) const int RunFile(const wxString &fileName) int RunString(const wxString &script, const wxString& name = "") bool IsRunning() const wxString GetLuaTagName(int tag) const */ %endclass //----------------------------------------------------------------------------- // wxLuaObject - Allows Lua data items to be used for client data. %enum wxLuaObject_Type wxLUAOBJECT_NONE wxLUAOBJECT_BOOL wxLUAOBJECT_INT wxLUAOBJECT_STRING wxLUAOBJECT_ARRAYINT %endenum %class %delete wxLuaObject, wxObject // %override wxLuaObject(any value type) // C++ Func: wxLuaObject(const wxLuaState& wxlState, int stack_idx = 1) // Wrap the single value passed in with a wxLuaObject wxLuaObject() // %override void wxLuaObject::SetObject(any value type) // C++ Func: void SetObject(int stack_idx = 1) // Discard the old reference and create a new one for the item passed in void SetObject() // %override [any value type] wxLuaObject::GetObject() // C++ Func: bool GetObject() // get the object, note C++ returns bool, in lua it "returns" the referenced object void GetObject() const // These are not useful in lua //bool *GetBoolPtr(); //int *GetIntPtr(); //wxString *GetStringPtr(); //wxArrayInt *GetArrayPtr(); int GetAllocationFlags() const bool HasAllocationFlag(wxLuaObject_Type flag) //int SetAllocationFlag(wxLuaObject_Type flag, bool set) // NOT for use in lua %endclass --- NEW FILE: wxlua_rules.lua --- ------------------------------------------------------------------------------- -- Rules to build the wxLua binding for wxLua -- load using : $lua -e"rulesFilename=\"rules.lua\"" genwxbind.lua ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- Set the root directory of the wxLua distribution, used only in this file wxlua_dir = "../" --============================================================================= -- Set the lua namespace (lua table) that the bindings will be placed into. -- eg. wx.wxWindow(...) hook_lua_namespace = "wxlua" -- Set the C++ "namespace" that the bindings will be placed. -- eg. cpp function names contain this to prevent duplicate function names hook_cpp_namespace = "wxlua" --============================================================================= -- Set the directory to output the bindings to, both C++ header and source files output_cpp_header_filepath = wxlua_dir.."modules/wxlua/include" output_cpp_filepath = wxlua_dir.."modules/wxlua/src" --============================================================================= -- Set the DLLIMPEXP macros for compiling these bindings into a DLL -- Use "WXLUA_NO_DLLIMPEXP" and "WXLUA_NO_DLLIMPEXP_DATA" for no IMPEXP macros output_cpp_impexpsymbol = "WXDLLIMPEXP_WXLUA" output_cpp_impexpdatasymbol = "WXDLLIMPEXP_DATA_WXLUA" ------------------------------------------------------------------------------- -- Set the name of the header file that will have the #includes from the -- bindings in it. This will be used as #include "hook_cpp_header_filename" in -- the C++ wrapper files, so it must include the proper #include path. hook_cpp_header_filename = "wxlua/include/wxlua_bind.h" ------------------------------------------------------------------------------- -- Set the name of the main binding file that will have the glue code for the -- bindings in it. This file along with the output from the *.i files will be -- placed in the "output_cpp_filepath". hook_cpp_binding_filename = hook_cpp_namespace.."_bind.cpp" ------------------------------------------------------------------------------- -- Set the name of the subclassed wxLuaBinding class hook_cpp_binding_classname = "wxLuaBinding_"..hook_cpp_namespace ------------------------------------------------------------------------------- -- Set the function names that wrap the output structs of defined values, -- objects, events, functions, and classes. hook_cpp_define_funcname = "wxLuaGetDefineList_"..hook_cpp_namespace hook_cpp_string_funcname = "wxLuaGetStringList_"..hook_cpp_namespace hook_cpp_object_funcname = "wxLuaGetObjectList_"..hook_cpp_namespace hook_cpp_event_funcname = "wxLuaGetEventList_"..hook_cpp_namespace hook_cpp_function_funcname = "wxLuaGetFunctionList_"..hook_cpp_namespace hook_cpp_class_funcname = "wxLuaGetClassList_"..hook_cpp_namespace ------------------------------------------------------------------------------- -- Set any #includes or other C++ code to be placed verbatim at the top of -- every generated cpp file or "" for none hook_cpp_binding_includes = "" ------------------------------------------------------------------------------- -- Set any #includes or other C++ code to be placed verbatim below the -- #includes of every generated cpp file or "" for none -- X.h defines Above and Below as numbers, undef them for wx/layout.h hook_cpp_binding_post_includes = "#ifdef Above\n #undef Above\n#endif\n".. "#ifdef Below\n #undef Below\n#endif\n" ------------------------------------------------------------------------------- -- Add additional include information or C++ code for the binding header file, -- hook_cpp_header_filename. -- This code will be place directly after any #includes at the top of the file --hook_cpp_binding_header_includes = ------------------------------------------------------------------------------- -- Set any #includes or other C++ code to be placed verbatim at the top of -- the single hook_cpp_binding_filename generated cpp file or "" for none hook_cpp_binding_source_includes = nil --============================================================================= -- Set the bindings directory that contains the *.i interface files interface_filepath = wxlua_dir.."bindings/wxlua" ------------------------------------------------------------------------------- -- A list of interface files to use to make the bindings. These files will be -- converted into *.cpp and placed in the output_cpp_filepath directory. -- The files are loaded from the interface_filepath. interface_fileTable = { "wxlua.i", } ------------------------------------------------------------------------------- -- A list of files that contain bindings that need to be overridden or empty -- table {} for none. -- The files are loaded from the interface_filepath. override_fileTable = { "override.hpp" } --============================================================================= -- A table containing filenames of XXX_datatype.lua from other wrappers to -- to define classes and data types used in this wrapper -- NOTE: for the base wxWidgets wrappers we don't load the cache since they -- don't depend on other wrappers and can cause problems when interface -- files are updated. Make sure you delete or have updated any cache file -- that changes any data types used by this binding. datatype_cache_input_fileTable = { wxlua_dir.."bindings/wxwidgets/wx_datatypes.lua" } ------------------------------------------------------------------------------- -- The file to output the data type cache for later use with a binding that -- makes use of data types (classes, enums, etc) that are declared in this -- binding. The file will be generated in the interface_filepath. datatypes_cache_output_filename = hook_cpp_namespace.."_datatypes.lua" --============================================================================= -- virtual void wxLuaBinding::PreRegister function body for the -- hook_cpp_binding_classname. You can initialize data here. -- Typically this is not necessary and you can rem this out. --wxLuaBinding_PreRegister = --============================================================================= -- virtual void wxLuaBinding::PostRegister function body for the -- hook_cpp_binding_classname. You can load any other custom bindings here. -- Typically this is not necessary and you can rem this out. --wxLuaBinding_PostRegister = --============================================================================= -- Add additional conditions here -- example: conditions["DOXYGEN_INCLUDE"] = "defined(DOXYGEN_INCLUDE)" ------------------------------------------------------------------------------- -- Add additional data types here -- example: AllocDataType("wxArrayInt", "class",false) --============================================================================= -- Generate comments into binding C++ code comment_cpp_binding_code = true |