From: John L. <jr...@us...> - 2008-01-25 23:51:32
|
Update of /cvsroot/wxlua/wxLua/modules/lua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv1159/wxLua/modules/lua/src Modified Files: Makefile lauxlib.c lbaselib.c ldblib.c ldo.c liolib.c loslib.c lundump.c Log Message: - Removed the wxLuaBinding::PreRegister() and PostRegister() functions and made RegisterBinding() virtual Note: wxLuaBinding::RegisterBinding() now leaves the Lua table that the binding objects were installed into on the stack. You must pop it. * The rules.lua for genwxbind.lua now uses wxLuaBinding_class_declaration and wxLuaBinding_class_implementation to replace wxLuaBinding_preregister and wxLuaBinding_postregister. You may now add whatever you like to the class declaration and implementation source code. Updated to Lua 5.1.3 official Index: liolib.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/liolib.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** liolib.c 18 Jan 2008 03:43:00 -0000 1.3 --- liolib.c 25 Jan 2008 23:50:51 -0000 1.4 *************** *** 52,56 **** ! #define topfile(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE)) --- 52,56 ---- ! #define tofilep(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE)) *************** *** 71,75 **** static FILE *tofile (lua_State *L) { ! FILE **f = topfile(L); if (*f == NULL) luaL_error(L, "attempt to use a closed file"); --- 71,75 ---- static FILE *tofile (lua_State *L) { ! FILE **f = tofilep(L); if (*f == NULL) luaL_error(L, "attempt to use a closed file"); *************** *** 94,102 **** /* ! ** this function has a separated environment, which defines the ! ** correct __close for 'popen' files */ static int io_pclose (lua_State *L) { ! FILE **p = topfile(L); int ok = lua_pclose(L, *p); *p = NULL; --- 94,111 ---- /* ! ** function to (not) close the standard files stdin, stdout, and stderr ! */ ! static int io_noclose (lua_State *L) { ! lua_pushnil(L); ! lua_pushliteral(L, "cannot close standard file"); ! return 2; ! } ! ! ! /* ! ** function to close 'popen' files */ static int io_pclose (lua_State *L) { ! FILE **p = tofilep(L); int ok = lua_pclose(L, *p); *p = NULL; *************** *** 105,115 **** static int io_fclose (lua_State *L) { ! FILE **p = topfile(L); ! int ok = 0; ! if (*p != stdin && *p != stdout && *p != stderr) { ! ok = (fclose(*p) == 0); ! *p = NULL; ! } return pushresult(L, ok, NULL); } --- 114,124 ---- + /* + ** function to close regular files + */ static int io_fclose (lua_State *L) { ! FILE **p = tofilep(L); ! int ok = (fclose(*p) == 0); ! *p = NULL; return pushresult(L, ok, NULL); } *************** *** 132,137 **** static int io_gc (lua_State *L) { ! FILE *f = *topfile(L); ! if (f != NULL) /* ignore closed files */ aux_close(L); return 0; --- 141,147 ---- static int io_gc (lua_State *L) { ! FILE *f = *tofilep(L); ! /* ignore closed files */ ! if (f != NULL) aux_close(L); return 0; *************** *** 140,146 **** static int io_tostring (lua_State *L) { ! FILE *f = *topfile(L); if (f == NULL) ! lua_pushstring(L, "file (closed)"); else lua_pushfstring(L, "file (%p)", f); --- 150,156 ---- static int io_tostring (lua_State *L) { ! FILE *f = *tofilep(L); if (f == NULL) ! lua_pushliteral(L, "file (closed)"); else lua_pushfstring(L, "file (%p)", f); *************** *** 158,161 **** --- 168,175 ---- + /* + ** this function has a separated environment, which defines the + ** correct __close for 'popen' files + */ static int io_popen (lua_State *L) { const char *filename = luaL_checkstring(L, 1); *************** *** 283,287 **** if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */ luaL_pushresult(&b); /* close buffer */ ! return (lua_strlen(L, -1) > 0); /* check whether read something */ } l = strlen(p); --- 297,301 ---- if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */ luaL_pushresult(&b); /* close buffer */ ! return (lua_objlen(L, -1) > 0); /* check whether read something */ } l = strlen(p); *************** *** 311,315 **** } while (n > 0 && nr == rlen); /* until end of count or eof */ luaL_pushresult(&b); /* close buffer */ ! return (n == 0 || lua_strlen(L, -1) > 0); } --- 325,329 ---- } while (n > 0 && nr == rlen); /* until end of count or eof */ luaL_pushresult(&b); /* close buffer */ ! return (n == 0 || lua_objlen(L, -1) > 0); } *************** *** 505,509 **** lua_rawseti(L, LUA_ENVIRONINDEX, k); } ! lua_setfield(L, -2, fname); } --- 519,532 ---- lua_rawseti(L, LUA_ENVIRONINDEX, k); } ! lua_pushvalue(L, -2); /* copy environment */ ! lua_setfenv(L, -2); /* set it */ ! lua_setfield(L, -3, fname); ! } ! ! ! static void newfenv (lua_State *L, lua_CFunction cls) { ! lua_createtable(L, 0, 1); ! lua_pushcfunction(L, cls); ! lua_setfield(L, -2, "__close"); } *************** *** 512,533 **** createmeta(L); /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */ ! lua_createtable(L, 2, 1); lua_replace(L, LUA_ENVIRONINDEX); /* open library */ luaL_register(L, LUA_IOLIBNAME, iolib); /* create (and set) default files */ createstdfile(L, stdin, IO_INPUT, "stdin"); createstdfile(L, stdout, IO_OUTPUT, "stdout"); createstdfile(L, stderr, 0, "stderr"); ! /* create environment for 'popen' */ lua_getfield(L, -1, "popen"); ! lua_createtable(L, 0, 1); ! lua_pushcfunction(L, io_pclose); ! lua_setfield(L, -2, "__close"); ! lua_setfenv(L, -2); lua_pop(L, 1); /* pop 'popen' */ - /* set default close function */ - lua_pushcfunction(L, io_fclose); - lua_setfield(L, LUA_ENVIRONINDEX, "__close"); return 1; } --- 535,552 ---- createmeta(L); /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */ ! newfenv(L, io_fclose); lua_replace(L, LUA_ENVIRONINDEX); /* open library */ luaL_register(L, LUA_IOLIBNAME, iolib); /* create (and set) default files */ + newfenv(L, io_noclose); /* close function for default files */ createstdfile(L, stdin, IO_INPUT, "stdin"); createstdfile(L, stdout, IO_OUTPUT, "stdout"); createstdfile(L, stderr, 0, "stderr"); ! lua_pop(L, 1); /* pop environment for default files */ lua_getfield(L, -1, "popen"); ! newfenv(L, io_pclose); /* create environment for 'popen' */ ! lua_setfenv(L, -2); /* set fenv for 'popen' */ lua_pop(L, 1); /* pop 'popen' */ return 1; } Index: lundump.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/lundump.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** lundump.c 29 Mar 2006 05:48:11 -0000 1.2 --- lundump.c 25 Jan 2008 23:50:51 -0000 1.3 *************** *** 30,33 **** --- 30,34 ---- #ifdef LUAC_TRUST_BINARIES #define IF(c,s) + #define error(S,s) #else #define IF(c,s) if (c) error(S,s) *************** *** 48,51 **** --- 49,53 ---- { size_t r=luaZ_read(S->Z,b,size); + UNUSED(r); IF (r!=0, "unexpected end"); } *************** *** 123,127 **** break; default: ! IF (1, "bad constant"); break; } --- 125,129 ---- break; default: ! error(S,"bad constant"); break; } Index: loslib.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/loslib.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** loslib.c 25 Apr 2007 02:52:20 -0000 1.3 --- loslib.c 25 Jan 2008 23:50:51 -0000 1.4 *************** *** 216,220 **** static int os_exit (lua_State *L) { exit(luaL_optint(L, 1, EXIT_SUCCESS)); - return 0; /* to avoid warnings */ } --- 216,219 ---- Index: lauxlib.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/lauxlib.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** lauxlib.c 18 Jan 2008 03:43:00 -0000 1.3 --- lauxlib.c 25 Jan 2008 23:50:51 -0000 1.4 *************** *** 536,540 **** } if (feof(lf->f)) return NULL; ! *size = fread(lf->buff, 1, LUAL_BUFFERSIZE, lf->f); return (*size > 0) ? lf->buff : NULL; } --- 536,540 ---- } if (feof(lf->f)) return NULL; ! *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); return (*size > 0) ? lf->buff : NULL; } *************** *** 571,577 **** if (c == '\n') c = getc(lf.f); } ! if (c == LUA_SIGNATURE[0] && lf.f != stdin) { /* binary file? */ ! fclose(lf.f); ! lf.f = fopen(filename, "rb"); /* reopen in binary mode */ if (lf.f == NULL) return errfile(L, "reopen", fnameindex); /* skip eventual `#!...' */ --- 571,576 ---- if (c == '\n') c = getc(lf.f); } ! if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */ ! lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */ if (lf.f == NULL) return errfile(L, "reopen", fnameindex); /* skip eventual `#!...' */ *************** *** 582,586 **** status = lua_load(L, getF, &lf, lua_tostring(L, -1)); readstatus = ferror(lf.f); ! if (lf.f != stdin) fclose(lf.f); /* close file (even in case of errors) */ if (readstatus) { lua_settop(L, fnameindex); /* ignore results from `lua_load' */ --- 581,585 ---- status = lua_load(L, getF, &lf, lua_tostring(L, -1)); readstatus = ferror(lf.f); ! if (filename) fclose(lf.f); /* close file (even in case of errors) */ if (readstatus) { lua_settop(L, fnameindex); /* ignore results from `lua_load' */ Index: Makefile =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/Makefile,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Makefile 18 Jan 2008 03:43:00 -0000 1.8 --- Makefile 25 Jan 2008 23:50:51 -0000 1.9 *************** *** 100,106 **** macosx: ! $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX ! # use this on Mac OS X 10.4 ! # $(MAKE) all MYCFLAGS="-DLUA_USE_MACOSX -DLUA_USE_READLINE" MYLIBS="-lreadline" mingw: --- 100,106 ---- macosx: ! $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline" ! # use this on Mac OS X 10.3- ! # $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX mingw: Index: ldo.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/ldo.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ldo.c 18 Jan 2008 03:43:00 -0000 1.4 --- ldo.c 25 Jan 2008 23:50:51 -0000 1.5 *************** *** 333,337 **** luaD_callhook(L, LUA_HOOKRET, -1); if (f_isLua(L->ci)) { /* Lua function? */ ! while (L->ci->tailcalls--) /* call hook for eventual tail calls */ luaD_callhook(L, LUA_HOOKTAILRET, -1); } --- 333,337 ---- luaD_callhook(L, LUA_HOOKRET, -1); if (f_isLua(L->ci)) { /* Lua function? */ ! while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */ luaD_callhook(L, LUA_HOOKTAILRET, -1); } Index: ldblib.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/ldblib.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ldblib.c 29 Mar 2006 06:00:00 -0000 1.1 --- ldblib.c 25 Jan 2008 23:50:51 -0000 1.2 *************** *** 139,143 **** return 1; /* return table */ } ! static int db_getlocal (lua_State *L) { --- 139,143 ---- return 1; /* return table */ } ! static int db_getlocal (lua_State *L) { *************** *** 256,277 **** static int db_sethook (lua_State *L) { ! int arg; lua_State *L1 = getthread(L, &arg); if (lua_isnoneornil(L, arg+1)) { lua_settop(L, arg+1); ! lua_sethook(L1, NULL, 0, 0); /* turn off hooks */ } else { const char *smask = luaL_checkstring(L, arg+2); - int count = luaL_optint(L, arg+3, 0); luaL_checktype(L, arg+1, LUA_TFUNCTION); ! lua_sethook(L1, hookf, makemask(smask, count), count); } ! gethooktable(L1); ! lua_pushlightuserdata(L1, L1); lua_pushvalue(L, arg+1); ! lua_xmove(L, L1, 1); ! lua_rawset(L1, -3); /* set new hook */ ! lua_pop(L1, 1); /* remove hook table */ return 0; } --- 256,278 ---- static int db_sethook (lua_State *L) { ! int arg, mask, count; ! lua_Hook func; lua_State *L1 = getthread(L, &arg); if (lua_isnoneornil(L, arg+1)) { lua_settop(L, arg+1); ! func = NULL; mask = 0; count = 0; /* turn off hooks */ } else { const char *smask = luaL_checkstring(L, arg+2); luaL_checktype(L, arg+1, LUA_TFUNCTION); ! count = luaL_optint(L, arg+3, 0); ! func = hookf; mask = makemask(smask, count); } ! gethooktable(L); ! lua_pushlightuserdata(L, L1); lua_pushvalue(L, arg+1); ! lua_rawset(L, -3); /* set new hook */ ! lua_pop(L, 1); /* remove hook table */ ! lua_sethook(L1, func, mask, count); /* set hooks */ return 0; } *************** *** 287,295 **** lua_pushliteral(L, "external hook"); else { ! gethooktable(L1); ! lua_pushlightuserdata(L1, L1); ! lua_rawget(L1, -2); /* get hook */ ! lua_remove(L1, -2); /* remove hook table */ ! lua_xmove(L1, L, 1); } lua_pushstring(L, unmakemask(mask, buff)); --- 288,295 ---- lua_pushliteral(L, "external hook"); else { ! gethooktable(L); ! lua_pushlightuserdata(L, L1); ! lua_rawget(L, -2); /* get hook */ ! lua_remove(L, -2); /* remove hook table */ } lua_pushstring(L, unmakemask(mask, buff)); Index: lbaselib.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/lbaselib.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** lbaselib.c 18 Jan 2008 03:43:00 -0000 1.4 --- lbaselib.c 25 Jan 2008 23:50:51 -0000 1.5 *************** *** 595,601 **** static int luaB_corunning (lua_State *L) { if (lua_pushthread(L)) ! return 0; /* main thread is not a coroutine */ ! else ! return 1; } --- 595,600 ---- static int luaB_corunning (lua_State *L) { if (lua_pushthread(L)) ! lua_pushnil(L); /* main thread is not a coroutine */ ! return 1; } |