Ver Fonte

new macro luaL_openl

Roberto Ierusalimschy há 26 anos atrás
pai
commit
7d1499ba88
6 ficheiros alterados com 20 adições e 20 exclusões
  1. 9 7
      lauxlib.h
  2. 2 2
      lbuiltin.c
  3. 2 2
      ldblib.c
  4. 2 3
      liolib.c
  5. 2 2
      lmathlib.c
  6. 3 4
      lstrlib.c

+ 9 - 7
lauxlib.h

@@ -1,5 +1,5 @@
 /*
-** $Id: lauxlib.h,v 1.13 1999/08/16 20:52:00 roberto Exp roberto $
+** $Id: lauxlib.h,v 1.14 1999/11/22 13:12:07 roberto Exp roberto $
 ** Auxiliary functions for building Lua libraries
 ** See Copyright Notice in lua.h
 */
@@ -22,12 +22,13 @@ struct luaL_reg {
 
 #define luaL_arg_check(L, cond,numarg,extramsg) if (!(cond)) \
                                                luaL_argerror(L, numarg,extramsg)
-#define luaL_check_string(L, n)	(luaL_check_lstr(L, (n), NULL))
-#define luaL_opt_string(L, n, d)	(luaL_opt_lstr(L, (n), (d), NULL))
-#define luaL_check_int(L, n)	((int)luaL_check_number(L, n))
-#define luaL_check_long(L, n)	((long)luaL_check_number(L, n))
-#define luaL_opt_int(L, n,d)	((int)luaL_opt_number(L, n,d))
-#define luaL_opt_long(L, n,d)	((long)luaL_opt_number(L, n,d))
+#define luaL_check_string(L,n)	(luaL_check_lstr(L, (n), NULL))
+#define luaL_opt_string(L,n,d)	(luaL_opt_lstr(L, (n), (d), NULL))
+#define luaL_check_int(L,n)	((int)luaL_check_number(L, n))
+#define luaL_check_long(L,n)	((long)luaL_check_number(L, n))
+#define luaL_opt_int(L,n,d)	((int)luaL_opt_number(L, n,d))
+#define luaL_opt_long(L,n,d)	((long)luaL_opt_number(L, n,d))
+#define luaL_openl(L,a)		luaL_openlib(L, a, (sizeof(a)/sizeof(a[0])))
 
 #else
 
@@ -39,6 +40,7 @@ struct luaL_reg {
 #define luaL_check_long(n)	((long)luaL_check_number(n))
 #define luaL_opt_int(n,d)	((int)luaL_opt_number(n,d))
 #define luaL_opt_long(n,d)	((long)luaL_opt_number(n,d))
+#define luaL_openl(a)		luaL_openlib(a, (sizeof(a)/sizeof(a[0])))
 
 #endif
 

+ 2 - 2
lbuiltin.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lbuiltin.c,v 1.73 1999/11/16 12:50:48 roberto Exp roberto $
+** $Id: lbuiltin.c,v 1.74 1999/11/22 13:12:07 roberto Exp roberto $
 ** Built-in functions
 ** See Copyright Notice in lua.h
 */
@@ -810,7 +810,7 @@ void luaB_predefine (lua_State *L) {
   /* pre-register mem error messages, to avoid loop when error arises */
   luaS_newfixedstring(L, tableEM);
   luaS_newfixedstring(L, memEM);
-  luaL_openlib(L, builtin_funcs, (sizeof(builtin_funcs)/sizeof(builtin_funcs[0])));
+  luaL_openl(L, builtin_funcs);
   lua_pushstring(L, LUA_VERSION);
   lua_setglobal(L, "_VERSION");
 }

+ 2 - 2
ldblib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ldblib.c,v 1.6 1999/08/16 20:52:00 roberto Exp roberto $
+** $Id: ldblib.c,v 1.7 1999/11/22 13:12:07 roberto Exp roberto $
 ** Interface from Lua to its debug API
 ** See Copyright Notice in lua.h
 */
@@ -214,6 +214,6 @@ static const struct luaL_reg dblib[] = {
 
 
 void lua_dblibopen (lua_State *L) {
-  luaL_openlib(L, dblib, (sizeof(dblib)/sizeof(dblib[0])));
+  luaL_openl(L, dblib);
 }
 

+ 2 - 3
liolib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: liolib.c,v 1.50 1999/11/09 17:59:35 roberto Exp roberto $
+** $Id: liolib.c,v 1.51 1999/11/22 13:12:07 roberto Exp roberto $
 ** Standard I/O (and system) library
 ** See Copyright Notice in lua.h
 */
@@ -632,8 +632,7 @@ static void openwithtags (lua_State *L) {
 }
 
 void lua_iolibopen (lua_State *L) {
-  /* register lib functions */
-  luaL_openlib(L, iolib, (sizeof(iolib)/sizeof(iolib[0])));
+  luaL_openl(L, iolib);
   openwithtags(L);
 }
 

+ 2 - 2
lmathlib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lmathlib.c,v 1.19 1999/08/18 14:40:51 roberto Exp roberto $
+** $Id: lmathlib.c,v 1.20 1999/11/22 13:12:07 roberto Exp roberto $
 ** Lua standard mathematical library
 ** See Copyright Notice in lua.h
 */
@@ -199,7 +199,7 @@ static const struct luaL_reg mathlib[] = {
 ** Open math library
 */
 void lua_mathlibopen (lua_State *L) {
-  luaL_openlib(L, mathlib, (sizeof(mathlib)/sizeof(mathlib[0])));
+  luaL_openl(L, mathlib);
   lua_pushcfunction(L, math_pow);
   lua_pushnumber(L, 0);  /* to get its tag */
   lua_settagmethod(L, lua_tag(L, lua_pop(L)), "pow");

+ 3 - 4
lstrlib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lstrlib.c,v 1.36 1999/11/11 16:45:04 roberto Exp roberto $
+** $Id: lstrlib.c,v 1.37 1999/11/22 13:12:07 roberto Exp roberto $
 ** Standard library for strings and pattern-matching
 ** See Copyright Notice in lua.h
 */
@@ -614,7 +614,6 @@ static const struct luaL_reg strlib[] = {
 /*
 ** Open string library
 */
-void lua_strlibopen (lua_State *L)
-{
-  luaL_openlib(L, strlib, (sizeof(strlib)/sizeof(strlib[0])));
+void lua_strlibopen (lua_State *L) {
+  luaL_openl(L, strlib);
 }