From: John L. <jr...@us...> - 2007-03-23 00:09:56
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv18290/wxLua/modules/wxlua/include Modified Files: wxlstate.h Log Message: change tget to not push nil on the stack if it fails since we'd never use it store the WXLUACLASS in our wxLuaReferences LUA_REGISTRY table to allow lookup by tag store the WXLUACLASS in our wxLuaClasses LUA_REGISTRY table to allow lookup by name use lua_createtable for pushing wxArrayInt/String to preallocate them don't call lua_objlen on the tables for getting wxArrayInt/String since objlen traverses it so why do it twice. Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** wxlstate.h 21 Mar 2007 23:43:12 -0000 1.63 --- wxlstate.h 23 Mar 2007 00:09:35 -0000 1.64 *************** *** 116,122 **** // Remove a reference to the object at the index in the // wxLuaReferences registry table, returns success. ! WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_tremove(lua_State* L, int iReference); // Push onto the top of the stack the object at the index in the ! // wxLuaReferences registry table, returns success. WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_tget(lua_State* L, int wxlref_index); // Push the errorMsg on the stack and call lua_error --- 116,123 ---- // Remove a reference to the object at the index in the // wxLuaReferences registry table, returns success. ! WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_tremove(lua_State* L, int wxlref_index); // Push onto the top of the stack the object at the index in the ! // wxLuaReferences registry table, if the index is LUA_REFNIL or the ! // value is nil return false and don't leave anything on the stack. WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_tget(lua_State* L, int wxlref_index); // Push the errorMsg on the stack and call lua_error *************** *** 125,129 **** // and set the metatable to the object at tget(tag) WXDLLIMPEXP_WXLUA void LUACALL wxLua_lua_tpushusertag(lua_State* L, const void* u, int tag); ! // Get the tag of the object at the stack index, returns TLUA_NOTAG if no tag WXDLLIMPEXP_WXLUA int LUACALL wxLua_lua_ttag(lua_State* L, int stack_idx); // Get the userdata at the stack index, if null_ptr then set the userdata pointer --- 126,131 ---- // and set the metatable to the object at tget(tag) WXDLLIMPEXP_WXLUA void LUACALL wxLua_lua_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_lua_ttag(lua_State* L, int stack_idx); // Get the userdata at the stack index, if null_ptr then set the userdata pointer *************** *** 141,158 **** // 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 ! WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_tsettagmethod(lua_State* L, int tag, const char* method, lua_CFunction func, void* pClass = NULL); ! // Push the "wxLuaReferences" string onto the stack ! WXDLLIMPEXP_WXLUA void LUACALL wxLua_lua_push_wxLuaReferences(lua_State* L); ! // Helper functions to get numbers, booleans and strings safer ! // Validate that the object at the stack index specified is a string, bool, // enum, or double number object or that the object can be converted to it. WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_isstringtype(lua_State* L, int stack_idx); WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_isbooleantype(lua_State* L, int stack_idx); WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_isenumerationtype(lua_State* L, int stack_idx); WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_isnumbertype(lua_State* L, int stack_idx); ! // After verifying using wxLua_lua_isXXXtype return the value, else calls ! // WXDLLIMPEXP_WXLUA const char* LUACALL wxLua_lua_getstringtype(lua_State* L, int stack_idx); WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_getbooleantype(lua_State* L, int stack_idx); --- 143,172 ---- // 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 ! WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_tsettagmethod(lua_State* L, int tag, const char* method, ! lua_CFunction func, void* pClass = NULL); ! // Push the "wxLuaReferences" string onto the stack. This is the name of a ! // table in the LUA_REGISTRYINDEX that is 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_lua_push_wxLuaReferences(L) lua_pushlstring(L, "wxLuaReferences", 15) ! // Push the "wxLuaClasses" string onto the stack. This is the name of a ! // table in the LUA_REGISTRYINDEX that is t[WXLUACLASS.name] = WXLUACLASS ! // where the WXLUACLASS is a lightuserdata. ! #define wxLua_lua_push_wxLuaClasses(L) lua_pushlstring(L, "wxLuaClasses", 12) ! ! ! // Helper functions to get numbers, booleans and strings safer. ! // These validate that the object at the stack index specified is a string, bool, // enum, or double number object or that the object can be converted to it. + // 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 LUACALL wxLua_lua_isstringtype(lua_State* L, int stack_idx); WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_isbooleantype(lua_State* L, int stack_idx); WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_isenumerationtype(lua_State* L, int stack_idx); WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_isnumbertype(lua_State* L, int stack_idx); ! // After verifying using wxLua_lua_isXXXtype return the value, else call ! // wxLua_lua_terror with a message that's appropriate for stack_idx to be a ! // parameter to a function call. (These are used in the bindings) WXDLLIMPEXP_WXLUA const char* LUACALL wxLua_lua_getstringtype(lua_State* L, int stack_idx); WXDLLIMPEXP_WXLUA bool LUACALL wxLua_lua_getbooleantype(lua_State* L, int stack_idx); *************** *** 163,173 **** // Validate that the object at the stack index specified is a table object // This assumes that each numeric entry in the table is a string or number ! // object or can be converted to a string or number. // Convert the table at stack index to a "new" array of wxStrings. ! // Return a pointer to the array of wxStrings (you need to delete them) // and returns the number of strings in the array in count. WXDLLIMPEXP_WXLUA wxString* LUACALL wxLua_lua_getwxStringarray(lua_State* L, int stack_idx, int& count); ! // Adds the table at stack index to the wxArrayString // Return the number of strings added to the array in count. WXDLLIMPEXP_WXLUA int LUACALL wxLua_lua_getwxArrayString(lua_State* L, int stack_idx, wxArrayString& strArray); --- 177,188 ---- // Validate that the object at the stack index specified is a table object // This assumes that each numeric entry in the table is a string or number ! // object or can be converted to a string or number using the ! // wxLua_lua_isstring/numbertype definitions of what is a string or number. // Convert the table at stack index to a "new" array of wxStrings. ! // Returns a pointer to the array of wxStrings (you need to delete them) // and returns the number of strings in the array in count. WXDLLIMPEXP_WXLUA wxString* LUACALL wxLua_lua_getwxStringarray(lua_State* L, int stack_idx, int& count); ! // Adds the table of number indexed strings at stack index to the wxArrayString // Return the number of strings added to the array in count. WXDLLIMPEXP_WXLUA int LUACALL wxLua_lua_getwxArrayString(lua_State* L, int stack_idx, wxArrayString& strArray); *************** *** 181,185 **** WXDLLIMPEXP_WXLUA int* LUACALL wxLua_lua_getintarray(lua_State* L, int stack_idx, int& count); // Adds the table at stack index to the wxArrayInt ! // Return the number of strings added to the array in count. WXDLLIMPEXP_WXLUA int LUACALL wxLua_lua_getwxArrayInt(lua_State* L, int stack_idx, wxArrayInt& intArray); --- 196,200 ---- WXDLLIMPEXP_WXLUA int* LUACALL wxLua_lua_getintarray(lua_State* L, int stack_idx, int& count); // Adds the table at stack index to the wxArrayInt ! // Return the number of ints added to the array in count. WXDLLIMPEXP_WXLUA int LUACALL wxLua_lua_getwxArrayInt(lua_State* L, int stack_idx, wxArrayInt& intArray); *************** *** 545,549 **** bool tremove(int wxlref_index); // Push onto the top of the stack the object at the index in the ! // wxLuaReferences registry table, returns success. bool tget(int wxlref_index); // Push the errorMsg on the stack and call lua_error --- 560,565 ---- bool tremove(int wxlref_index); // Push onto the top of the stack the object at the index in the ! // wxLuaReferences registry table, if the index is LUA_REFNIL or the ! // value is nil return false and don't leave anything on the stack. bool tget(int wxlref_index); // Push the errorMsg on the stack and call lua_error |