Selaa lähdekoodia

no more 'ccall' nor 'cpcall' functions. (With light C functions they
are obsolete.)

Roberto Ierusalimschy 15 vuotta sitten
vanhempi
commit
afdb19ac82
5 muutettua tiedostoa jossa 8 lisäystä ja 40 poistoa
  1. 1 12
      lauxlib.c
  2. 1 4
      lauxlib.h
  3. 1 19
      lstate.c
  4. 3 2
      lua.c
  5. 2 3
      lua.h

+ 1 - 12
lauxlib.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lauxlib.c,v 1.206 2010/03/29 17:44:31 roberto Exp roberto $
+** $Id: lauxlib.c,v 1.207 2010/04/09 16:14:46 roberto Exp roberto $
 ** Auxiliary functions for building Lua libraries
 ** Auxiliary functions for building Lua libraries
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -766,14 +766,3 @@ LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver) {
                   ver, *v);
                   ver, *v);
 }
 }
 
 
-
-LUALIB_API int luaL_cpcall (lua_State *L, lua_CFunction f, int nargs,
-                            int nresults) {
-  nargs++;  /* to include function itself */
-  lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_CCALL);
-  lua_insert(L, -nargs);  /* 'ccall' is real function to be called */
-  lua_pushlightuserdata(L, &f);
-  lua_insert(L, -nargs);  /* 'f' address is its first argument */
-  return lua_pcall(L, nargs, nresults, 0);
-}
-

+ 1 - 4
lauxlib.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lauxlib.h,v 1.101 2010/03/17 21:37:37 roberto Exp roberto $
+** $Id: lauxlib.h,v 1.102 2010/04/09 16:14:46 roberto Exp roberto $
 ** Auxiliary functions for building Lua libraries
 ** Auxiliary functions for building Lua libraries
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -82,9 +82,6 @@ LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx,
 LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1,
 LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1,
                                   const char *msg, int level);
                                   const char *msg, int level);
 
 
-LUALIB_API int (luaL_cpcall) (lua_State *L, lua_CFunction f, int nargs,
-                              int nresults);
-
 
 
 /*
 /*
 ** ===============================================================
 ** ===============================================================

+ 1 - 19
lstate.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lstate.c,v 2.78 2010/04/08 17:16:46 roberto Exp roberto $
+** $Id: lstate.c,v 2.79 2010/04/12 16:07:06 roberto Exp roberto $
 ** Global State
 ** Global State
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -113,23 +113,10 @@ static void freestack (lua_State *L) {
 }
 }
 
 
 
 
-/*
-** Calls the function in variable pointed to by userdata in first argument
-** (Userdata cannot point directly to the function because pointer to
-** function is not compatible with void*.)
-*/
-static int ccall (lua_State *L) {
-  lua_CFunction f = *(lua_CFunction *)lua_touserdata(L, 1);
-  lua_remove(L, 1);  /* remove f from stack */
-  return f(L);
-}
-
-
 /*
 /*
 ** Create registry table and its predefined values
 ** Create registry table and its predefined values
 */
 */
 static void init_registry (lua_State *L, global_State *g) {
 static void init_registry (lua_State *L, global_State *g) {
-  Closure *cp;
   TValue mt;
   TValue mt;
   /* create registry */
   /* create registry */
   Table *registry = luaH_new(L);
   Table *registry = luaH_new(L);
@@ -138,11 +125,6 @@ static void init_registry (lua_State *L, global_State *g) {
   /* registry[LUA_RIDX_MAINTHREAD] = L */
   /* registry[LUA_RIDX_MAINTHREAD] = L */
   setthvalue(L, &mt, L);
   setthvalue(L, &mt, L);
   setobj2t(L, luaH_setint(L, registry, LUA_RIDX_MAINTHREAD), &mt);
   setobj2t(L, luaH_setint(L, registry, LUA_RIDX_MAINTHREAD), &mt);
-  /* registry[LUA_RIDX_CCALL] = ccall */
-  cp = luaF_newCclosure(L, 0);
-  cp->c.f = ccall;
-  setclvalue(L, &mt, cp);
-  setobj2t(L, luaH_setint(L, registry, LUA_RIDX_CCALL), &mt);
   /* registry[LUA_RIDX_GLOBALS] = table of globals */
   /* registry[LUA_RIDX_GLOBALS] = table of globals */
   sethvalue(L, &mt, luaH_new(L));
   sethvalue(L, &mt, luaH_new(L));
   setobj2t(L, luaH_setint(L, registry, LUA_RIDX_GLOBALS), &mt);
   setobj2t(L, luaH_setint(L, registry, LUA_RIDX_GLOBALS), &mt);

+ 3 - 2
lua.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lua.c,v 1.188 2010/02/27 21:15:36 roberto Exp roberto $
+** $Id: lua.c,v 1.189 2010/03/13 03:57:46 roberto Exp roberto $
 ** Lua stand-alone interpreter
 ** Lua stand-alone interpreter
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -454,9 +454,10 @@ int main (int argc, char **argv) {
     return EXIT_FAILURE;
     return EXIT_FAILURE;
   }
   }
   /* call 'pmain' in protected mode */
   /* call 'pmain' in protected mode */
+  lua_pushcfunction(L, &pmain);
   lua_pushinteger(L, argc);  /* 1st argument */
   lua_pushinteger(L, argc);  /* 1st argument */
   lua_pushlightuserdata(L, argv); /* 2nd argument */
   lua_pushlightuserdata(L, argv); /* 2nd argument */
-  status = luaL_cpcall(L, &pmain, 2, 1);
+  status = lua_pcall(L, 2, 1, 0);
   result = lua_toboolean(L, -1);  /* get result */
   result = lua_toboolean(L, -1);  /* get result */
   finalreport(L, status);
   finalreport(L, status);
   lua_close(L);
   lua_close(L);

+ 2 - 3
lua.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lua.h,v 1.266 2010/04/02 15:19:19 roberto Exp roberto $
+** $Id: lua.h,v 1.267 2010/04/12 16:04:10 roberto Exp roberto $
 ** Lua - A Scripting Language
 ** Lua - A Scripting Language
 ** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
 ** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
 ** See Copyright Notice at the end of this file
 ** 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);
 
 
 /* predefined values in the registry */
 /* predefined values in the registry */
 #define LUA_RIDX_MAINTHREAD	1
 #define LUA_RIDX_MAINTHREAD	1
-#define LUA_RIDX_CCALL		2
-#define LUA_RIDX_GLOBALS	3
+#define LUA_RIDX_GLOBALS	2
 #define LUA_RIDX_LAST		LUA_RIDX_GLOBALS
 #define LUA_RIDX_LAST		LUA_RIDX_GLOBALS