From: John L. <jr...@us...> - 2007-06-08 22:50:24
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv18758/wxLua/modules/wxlua/include Modified Files: wxlbind.h wxlstate.h Log Message: Add some functions to compare the wxlua tags type to lua_type() within lua also get the tag number for any object in lua Cleanup the bindings.wx.lua to make it more useful Index: wxlbind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlbind.h,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** wxlbind.h 8 Jun 2007 03:40:51 -0000 1.45 --- wxlbind.h 8 Jun 2007 22:50:13 -0000 1.46 *************** *** 361,364 **** --- 361,366 ---- bool SetBaseClass(wxLuaBindClass *pClass); + // These function only look through the binding data of this wxLuaBinding + // Find the wxLuaBindEvent with the wxEventType, returns NULL if not found. const wxLuaBindEvent* GetEvent(wxEventType eventType) const; *************** *** 366,373 **** --- 368,378 ---- // in the wxLuaBindEvent* struct list of this binding. wxString GetEventTypeName(wxEventType eventType) const; + // Get the wxLuaBindClass that has this tag, or NULL if none + const wxLuaBindClass* GetLuaClass(int class_tag) const; // Get the first wxLuaBindClass that has this wxLuaBindMethod const wxLuaBindClass* GetLuaClass(const wxLuaBindMethod* wxlMethod) const; // Get the first wxLuaBindClass that has this wxLuaBindCFunc const wxLuaBindClass* GetLuaClass(const wxLuaBindCFunc* wxlMethod_cfunc) const; + // Get all the bindings that were initialized using the generated binding // function wxLuaBinding_[binding name]_init(). Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** wxlstate.h 8 Jun 2007 03:40:51 -0000 1.73 --- wxlstate.h 8 Jun 2007 22:50:16 -0000 1.74 *************** *** 43,47 **** // ---------------------------------------------------------------------------- ! // Convert a 8-bit Lua String into wxString inline WXDLLIMPEXP_WXLUA wxString lua2wx(const char* luastr) { --- 43,47 ---- // ---------------------------------------------------------------------------- ! // Convert a 8-bit ANSI C Lua String into a wxString inline WXDLLIMPEXP_WXLUA wxString lua2wx(const char* luastr) { *************** *** 62,66 **** } ! // Convert a wxString to 8-bit Lua String inline const WXDLLIMPEXP_WXLUA wxCharBuffer wx2lua(const wxString& wxstr) { --- 62,66 ---- } ! // Convert a wxString to 8-bit ANSI C Lua String inline const WXDLLIMPEXP_WXLUA wxCharBuffer wx2lua(const wxString& wxstr) { *************** *** 73,77 **** } ! // Convert a wxString to 8-bit Lua Buffer and store it class WXDLLIMPEXP_WXLUA wxLuaCharBuffer { --- 73,77 ---- } ! // Convert a wxString to 8-bit ANSI C Lua Buffer and store it class WXDLLIMPEXP_WXLUA wxLuaCharBuffer { *************** *** 82,85 **** --- 82,87 ---- const char *GetData() const { return (const char*)m_buffer; } + operator const char *() const { return m_buffer; } + wxCharBuffer m_buffer; // member since non virtual destructor in wxCharBuffer }; *************** *** 109,123 **** // Push the errorMsg on the stack and call lua_error WXDLLIMPEXP_WXLUA void LUACALL wxlua_terror(lua_State* L, const char* errorMsg); ! // Push the object u onto the top of the stack as a userdata of type tag ! // and set the metatable to the object at tget(tag) ! WXDLLIMPEXP_WXLUA void LUACALL wxlua_tpushusertag(lua_State* L, const void* u, int tag); ! // Get the tag of the object at the stack index using the metatable's "tag" key. ! // returns TLUA_NOTAG if no tag WXDLLIMPEXP_WXLUA int LUACALL wxlua_ttag(lua_State* L, int stack_idx); // Get the userdata at the stack index, if null_ptr then set the userdata pointer // in lua to NULL so that lua won't gc it. WXDLLIMPEXP_WXLUA void* LUACALL wxlua_ttouserdata(lua_State* L, int stack_idx, bool null_ptr = false); ! // Allocate a new table (metatable) tinsert it into the wxLuaReferences registry table ! // and return its index into the ref table. WXDLLIMPEXP_WXLUA int LUACALL wxlua_tnewtag(lua_State* L); // Create a new table and its metatable with weak keys and/or values by setting the --- 111,129 ---- // Push the errorMsg on the stack and call lua_error WXDLLIMPEXP_WXLUA void LUACALL wxlua_terror(lua_State* L, const char* errorMsg); ! // Push the object u onto the top of the stack wrapped in a newuserdata ! // with it's metatable set to the table from tget(tag). Returns true if the ! // tag is known and the metatable was set. ! WXDLLIMPEXP_WXLUA bool LUACALL wxlua_tpushusertag(lua_State* L, const void* u, int tag); ! // Get the numeric tag of the object at the stack index using the metatable's "tag" key. ! // returns TLUA_NOTAG if the metatable of the object doesn't have a "tag" ! // key or it isn't a number. The tag is presumedly the index into the wxLuaReferences ! // registry table and denotes what type of object this is. WXDLLIMPEXP_WXLUA int LUACALL wxlua_ttag(lua_State* L, int stack_idx); // Get the userdata at the stack index, if null_ptr then set the userdata pointer // in lua to NULL so that lua won't gc it. WXDLLIMPEXP_WXLUA void* LUACALL wxlua_ttouserdata(lua_State* L, int stack_idx, bool null_ptr = false); ! // Allocate a new table (metatable) with a "tag" key equal to the number from tinsert ! // and store it in the wxLuaReferences registry table. ! // Returns the index into the ref table, the "tag" from tinsert. WXDLLIMPEXP_WXLUA int LUACALL wxlua_tnewtag(lua_State* L); // Create a new table and its metatable with weak keys and/or values by setting the *************** *** 125,130 **** // registry table and return its index into the ref table. WXDLLIMPEXP_WXLUA int LUACALL wxlua_tnewweaktag(lua_State* L, bool weak_keys, bool weak_values); ! // Set the metatable of the object at top of stack to tget(tag) ! WXDLLIMPEXP_WXLUA void LUACALL wxlua_tsettag(lua_State* L, int tag); // Set a metamethod for the metatable referenced by tag with the supplied name and function. // if pClass is non-null set the upvalue of the function to the supplied class --- 131,137 ---- // registry table and return its index into the ref table. WXDLLIMPEXP_WXLUA int LUACALL wxlua_tnewweaktag(lua_State* L, bool weak_keys, bool weak_values); ! // Set the metatable of the object at top of stack to the table stored in the ! // wxLuaReferences registry table using tget(tag). ! WXDLLIMPEXP_WXLUA bool LUACALL wxlua_tsettag(lua_State* L, int tag); // Set a metamethod for the metatable referenced by tag with the supplied name and function. // if pClass is non-null set the upvalue of the function to the supplied class *************** *** 146,153 **** --- 153,168 ---- // wxluaarg_tag which is one of the predefined WXLUAARG_XXX or s_wxluaarg_XXX types. // Returns 1 if it matches, 0 if it doesn't, -1 if the wxluaarg_tag is not known. + // 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. 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. WXDLLIMPEXP_WXLUA wxString wxlua_getwxluatypename(int wxluaarg_tag); + // Get the wxluaarg_tag for the lua_type(). + // returns -1 if the tag was not one of the predefined types. + WXDLLIMPEXP_WXLUA int wxlua_getwxluatype(int luatype); + // Get the lua_type() for the predefined WXLUAARG_XXX or s_wxluaarg_XXX tags. + // returns -1 (LUA_TNONE) if the tag was not one of the predefined types. + WXDLLIMPEXP_WXLUA int wxlua_getluatype(int wxluatype); // Helper functions to get numbers, booleans and strings safer. *************** *** 561,568 **** void terror(const char *errorMsg) const; wxLUA_UNUSED_NOTUNICODE(void terror(const wxString& errorMsg) const { terror(wx2lua(errorMsg)); }) ! // Push the object u onto the top of the stack as a userdata of type tag ! // and set the metatable to the object at tget(tag) ! void tpushusertag(const void *u, int tag); ! // Get the tag of the object at the stack index, returns TLUA_NOTAG if no tag int ttag(int stack_idx) const; // Get the userdata at the stack index, if null_ptr then set the userdata pointer --- 576,587 ---- void terror(const char *errorMsg) const; wxLUA_UNUSED_NOTUNICODE(void terror(const wxString& errorMsg) const { terror(wx2lua(errorMsg)); }) ! // Push the object u onto the top of the stack wrapped in a newuserdata ! // with it's metatable set to the table from tget(tag). Returns true if the ! // tag is known and the metatable was set. ! bool tpushusertag(const void *u, int tag); ! // Get the numeric tag of the object at the stack index using the metatable's "tag" key. ! // returns TLUA_NOTAG if the metatable of the object doesn't have a "tag" ! // key or it isn't a number. The tag is presumedly the index into the wxLuaReferences ! // registry table and denotes what type of object this is. int ttag(int stack_idx) const; // Get the userdata at the stack index, if null_ptr then set the userdata pointer *************** *** 577,581 **** int tnewweaktag(bool weak_keys, bool weak_values); // Set the metatable of the object at top of stack to tget(tag) ! void tsettag(int tag); // Set a metamethod for the metatable referenced by tag with the supplied name and function. // if pClass is non-null set the upvalue of the function to the supplied class --- 596,600 ---- int tnewweaktag(bool weak_keys, bool weak_values); // Set the metatable of the object at top of stack to tget(tag) ! bool tsettag(int tag); // Set a metamethod for the metatable referenced by tag with the supplied name and function. // if pClass is non-null set the upvalue of the function to the supplied class |