Browse Source

new macro LUA_NUMTAGS

Roberto Ierusalimschy 15 years ago
parent
commit
d20ff60615
6 changed files with 15 additions and 19 deletions
  1. 2 2
      lgc.c
  2. 4 10
      lobject.h
  3. 2 2
      lstate.c
  4. 2 2
      lstate.h
  5. 2 2
      ltests.h
  6. 3 1
      lua.h

+ 2 - 2
lgc.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lgc.c,v 2.76 2010/04/02 14:37:41 roberto Exp roberto $
+** $Id: lgc.c,v 2.77 2010/04/05 14:15:35 roberto Exp roberto $
 ** Garbage Collector
 ** Garbage Collector
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -213,7 +213,7 @@ static void reallymarkobject (global_State *g, GCObject *o) {
 
 
 static void markmt (global_State *g) {
 static void markmt (global_State *g) {
   int i;
   int i;
-  for (i=0; i<NUM_TAGS; i++)
+  for (i=0; i < LUA_NUMTAGS; i++)
     markobject(g, g->mt[i]);
     markobject(g, g->mt[i]);
 }
 }
 
 

+ 4 - 10
lobject.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lobject.h,v 2.35 2010/03/12 19:14:06 roberto Exp roberto $
+** $Id: lobject.h,v 2.36 2010/03/26 20:58:11 roberto Exp roberto $
 ** Type definitions for Lua objects
 ** Type definitions for Lua objects
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -16,18 +16,12 @@
 #include "lua.h"
 #include "lua.h"
 
 
 
 
-/* tags for values visible from Lua */
-#define LAST_TAG	LUA_TTHREAD
-
-#define NUM_TAGS	(LAST_TAG+1)
-
-
 /*
 /*
 ** Extra tags for non-values
 ** Extra tags for non-values
 */
 */
-#define LUA_TPROTO	(LAST_TAG+1)
-#define LUA_TUPVAL	(LAST_TAG+2)
-#define LUA_TDEADKEY	(LAST_TAG+3)
+#define LUA_TPROTO	LUA_NUMTAGS
+#define LUA_TUPVAL	(LUA_NUMTAGS+1)
+#define LUA_TDEADKEY	(LUA_NUMTAGS+2)
 
 
 
 
 /*
 /*

+ 2 - 2
lstate.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lstate.c,v 2.77 2010/04/05 16:35:37 roberto Exp roberto $
+** $Id: lstate.c,v 2.78 2010/04/08 17:16:46 roberto Exp roberto $
 ** Global State
 ** Global State
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -268,7 +268,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
   g->totalbytes = sizeof(LG);
   g->totalbytes = sizeof(LG);
   g->gcpause = LUAI_GCPAUSE;
   g->gcpause = LUAI_GCPAUSE;
   g->gcstepmul = LUAI_GCMUL;
   g->gcstepmul = LUAI_GCMUL;
-  for (i=0; i<NUM_TAGS; i++) g->mt[i] = NULL;
+  for (i=0; i < LUA_NUMTAGS; i++) g->mt[i] = NULL;
   if (luaD_rawrunprotected(L, f_luaopen, NULL) != LUA_OK) {
   if (luaD_rawrunprotected(L, f_luaopen, NULL) != LUA_OK) {
     /* memory allocation error: free partial state */
     /* memory allocation error: free partial state */
     close_state(L);
     close_state(L);

+ 2 - 2
lstate.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lstate.h,v 2.60 2010/04/05 16:35:37 roberto Exp roberto $
+** $Id: lstate.h,v 2.61 2010/04/08 17:16:46 roberto Exp roberto $
 ** Global State
 ** Global State
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -144,7 +144,7 @@ typedef struct global_State {
   const lua_Number *version;  /* pointer to version number */
   const lua_Number *version;  /* pointer to version number */
   TString *memerrmsg;  /* memory-error message */
   TString *memerrmsg;  /* memory-error message */
   TString *tmname[TM_N];  /* array with tag-method names */
   TString *tmname[TM_N];  /* array with tag-method names */
-  struct Table *mt[NUM_TAGS];  /* metatables for basic types */
+  struct Table *mt[LUA_NUMTAGS];  /* metatables for basic types */
 } global_State;
 } global_State;
 
 
 
 

+ 2 - 2
ltests.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltests.h,v 2.29 2009/12/17 12:26:09 roberto Exp roberto $
+** $Id: ltests.h,v 2.30 2010/01/11 17:33:09 roberto Exp roberto $
 ** Internal Header for Debugging of the Lua Implementation
 ** Internal Header for Debugging of the Lua Implementation
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -30,7 +30,7 @@ typedef struct Memcontrol {
   unsigned long total;
   unsigned long total;
   unsigned long maxmem;
   unsigned long maxmem;
   unsigned long memlimit;
   unsigned long memlimit;
-  unsigned long objcount[5];
+  unsigned long objcount[LUA_NUMTAGS];
 } Memcontrol;
 } Memcontrol;
 
 
 extern Memcontrol l_memcontrol;
 extern Memcontrol l_memcontrol;

+ 3 - 1
lua.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lua.h,v 1.265 2010/03/26 20:58:11 roberto Exp roberto $
+** $Id: lua.h,v 1.266 2010/04/02 15:19:19 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
@@ -81,6 +81,8 @@ typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
 #define LUA_TUSERDATA		7
 #define LUA_TUSERDATA		7
 #define LUA_TTHREAD		8
 #define LUA_TTHREAD		8
 
 
+#define LUA_NUMTAGS		9
+
 
 
 
 
 /* minimum Lua stack available to a C function */
 /* minimum Lua stack available to a C function */