diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-04-14 12:14:21 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-04-14 12:14:21 -0300 |
| commit | afdb19ac82bcb7ceabd010a484505105977352ba (patch) | |
| tree | 9771781da1f3bd8021f181f707891b7287140b69 | |
| parent | 7dfa4cd655118faf164427356609fec31906dac2 (diff) | |
| download | lua-afdb19ac82bcb7ceabd010a484505105977352ba.tar.gz lua-afdb19ac82bcb7ceabd010a484505105977352ba.tar.bz2 lua-afdb19ac82bcb7ceabd010a484505105977352ba.zip | |
no more 'ccall' nor 'cpcall' functions. (With light C functions they
are obsolete.)
| -rw-r--r-- | lauxlib.c | 13 | ||||
| -rw-r--r-- | lauxlib.h | 5 | ||||
| -rw-r--r-- | lstate.c | 20 | ||||
| -rw-r--r-- | lua.c | 5 | ||||
| -rw-r--r-- | lua.h | 5 |
5 files changed, 8 insertions, 40 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.c,v 1.206 2010/03/29 17:44:31 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.207 2010/04/09 16:14:46 roberto Exp roberto $ |
| 3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -766,14 +766,3 @@ LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver) { | |||
| 766 | ver, *v); | 766 | ver, *v); |
| 767 | } | 767 | } |
| 768 | 768 | ||
| 769 | |||
| 770 | LUALIB_API int luaL_cpcall (lua_State *L, lua_CFunction f, int nargs, | ||
| 771 | int nresults) { | ||
| 772 | nargs++; /* to include function itself */ | ||
| 773 | lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_CCALL); | ||
| 774 | lua_insert(L, -nargs); /* 'ccall' is real function to be called */ | ||
| 775 | lua_pushlightuserdata(L, &f); | ||
| 776 | lua_insert(L, -nargs); /* 'f' address is its first argument */ | ||
| 777 | return lua_pcall(L, nargs, nresults, 0); | ||
| 778 | } | ||
| 779 | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.h,v 1.101 2010/03/17 21:37:37 roberto Exp roberto $ | 2 | ** $Id: lauxlib.h,v 1.102 2010/04/09 16:14:46 roberto Exp roberto $ |
| 3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -82,9 +82,6 @@ LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, | |||
| 82 | LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1, | 82 | LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1, |
| 83 | const char *msg, int level); | 83 | const char *msg, int level); |
| 84 | 84 | ||
| 85 | LUALIB_API int (luaL_cpcall) (lua_State *L, lua_CFunction f, int nargs, | ||
| 86 | int nresults); | ||
| 87 | |||
| 88 | 85 | ||
| 89 | /* | 86 | /* |
| 90 | ** =============================================================== | 87 | ** =============================================================== |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstate.c,v 2.78 2010/04/08 17:16:46 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 2.79 2010/04/12 16:07:06 roberto Exp roberto $ |
| 3 | ** Global State | 3 | ** Global State |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -114,22 +114,9 @@ static void freestack (lua_State *L) { | |||
| 114 | 114 | ||
| 115 | 115 | ||
| 116 | /* | 116 | /* |
| 117 | ** Calls the function in variable pointed to by userdata in first argument | ||
| 118 | ** (Userdata cannot point directly to the function because pointer to | ||
| 119 | ** function is not compatible with void*.) | ||
| 120 | */ | ||
| 121 | static int ccall (lua_State *L) { | ||
| 122 | lua_CFunction f = *(lua_CFunction *)lua_touserdata(L, 1); | ||
| 123 | lua_remove(L, 1); /* remove f from stack */ | ||
| 124 | return f(L); | ||
| 125 | } | ||
| 126 | |||
| 127 | |||
| 128 | /* | ||
| 129 | ** Create registry table and its predefined values | 117 | ** Create registry table and its predefined values |
| 130 | */ | 118 | */ |
| 131 | static void init_registry (lua_State *L, global_State *g) { | 119 | static void init_registry (lua_State *L, global_State *g) { |
| 132 | Closure *cp; | ||
| 133 | TValue mt; | 120 | TValue mt; |
| 134 | /* create registry */ | 121 | /* create registry */ |
| 135 | Table *registry = luaH_new(L); | 122 | Table *registry = luaH_new(L); |
| @@ -138,11 +125,6 @@ static void init_registry (lua_State *L, global_State *g) { | |||
| 138 | /* registry[LUA_RIDX_MAINTHREAD] = L */ | 125 | /* registry[LUA_RIDX_MAINTHREAD] = L */ |
| 139 | setthvalue(L, &mt, L); | 126 | setthvalue(L, &mt, L); |
| 140 | setobj2t(L, luaH_setint(L, registry, LUA_RIDX_MAINTHREAD), &mt); | 127 | setobj2t(L, luaH_setint(L, registry, LUA_RIDX_MAINTHREAD), &mt); |
| 141 | /* registry[LUA_RIDX_CCALL] = ccall */ | ||
| 142 | cp = luaF_newCclosure(L, 0); | ||
| 143 | cp->c.f = ccall; | ||
| 144 | setclvalue(L, &mt, cp); | ||
| 145 | setobj2t(L, luaH_setint(L, registry, LUA_RIDX_CCALL), &mt); | ||
| 146 | /* registry[LUA_RIDX_GLOBALS] = table of globals */ | 128 | /* registry[LUA_RIDX_GLOBALS] = table of globals */ |
| 147 | sethvalue(L, &mt, luaH_new(L)); | 129 | sethvalue(L, &mt, luaH_new(L)); |
| 148 | setobj2t(L, luaH_setint(L, registry, LUA_RIDX_GLOBALS), &mt); | 130 | setobj2t(L, luaH_setint(L, registry, LUA_RIDX_GLOBALS), &mt); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lua.c,v 1.188 2010/02/27 21:15:36 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.189 2010/03/13 03:57:46 roberto Exp roberto $ |
| 3 | ** Lua stand-alone interpreter | 3 | ** Lua stand-alone interpreter |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -454,9 +454,10 @@ int main (int argc, char **argv) { | |||
| 454 | return EXIT_FAILURE; | 454 | return EXIT_FAILURE; |
| 455 | } | 455 | } |
| 456 | /* call 'pmain' in protected mode */ | 456 | /* call 'pmain' in protected mode */ |
| 457 | lua_pushcfunction(L, &pmain); | ||
| 457 | lua_pushinteger(L, argc); /* 1st argument */ | 458 | lua_pushinteger(L, argc); /* 1st argument */ |
| 458 | lua_pushlightuserdata(L, argv); /* 2nd argument */ | 459 | lua_pushlightuserdata(L, argv); /* 2nd argument */ |
| 459 | status = luaL_cpcall(L, &pmain, 2, 1); | 460 | status = lua_pcall(L, 2, 1, 0); |
| 460 | result = lua_toboolean(L, -1); /* get result */ | 461 | result = lua_toboolean(L, -1); /* get result */ |
| 461 | finalreport(L, status); | 462 | finalreport(L, status); |
| 462 | lua_close(L); | 463 | lua_close(L); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lua.h,v 1.266 2010/04/02 15:19:19 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.267 2010/04/12 16:04:10 roberto Exp roberto $ |
| 3 | ** Lua - A Scripting Language | 3 | ** Lua - A Scripting Language |
| 4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) | 4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) |
| 5 | ** See Copyright Notice at the end of this file | 5 | ** See Copyright Notice at the end of this file |
| @@ -91,8 +91,7 @@ typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); | |||
| 91 | 91 | ||
| 92 | /* predefined values in the registry */ | 92 | /* predefined values in the registry */ |
| 93 | #define LUA_RIDX_MAINTHREAD 1 | 93 | #define LUA_RIDX_MAINTHREAD 1 |
| 94 | #define LUA_RIDX_CCALL 2 | 94 | #define LUA_RIDX_GLOBALS 2 |
| 95 | #define LUA_RIDX_GLOBALS 3 | ||
| 96 | #define LUA_RIDX_LAST LUA_RIDX_GLOBALS | 95 | #define LUA_RIDX_LAST LUA_RIDX_GLOBALS |
| 97 | 96 | ||
| 98 | 97 | ||
