Pārlūkot izejas kodu

new macro LUA_API

Roberto Ierusalimschy 25 gadi atpakaļ
vecāks
revīzija
64eecc0b82
19 mainītis faili ar 238 papildinājumiem un 232 dzēšanām
  1. 50 49
      lapi.c
  2. 20 20
      lauxlib.c
  3. 21 19
      lauxlib.h
  4. 2 2
      lbaselib.c
  5. 2 2
      ldblib.c
  6. 23 21
      ldebug.c
  7. 6 6
      ldo.c
  8. 2 2
      liolib.c
  9. 2 2
      llex.c
  10. 2 2
      lmathlib.c
  11. 3 3
      lstate.c
  12. 2 2
      lstrlib.c
  13. 2 2
      ltests.c
  14. 5 5
      ltm.c
  15. 66 61
      lua.h
  16. 9 7
      luadebug.h
  17. 6 6
      lualib.h
  18. 14 14
      lundump.c
  19. 1 7
      lundump.h

+ 50 - 49
lapi.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lapi.c,v 1.105 2000/10/05 12:14:08 roberto Exp roberto $
+** $Id: lapi.c,v 1.106 2000/10/06 19:29:26 roberto Exp roberto $
 ** Lua API
 ** See Copyright Notice in lua.h
 */
@@ -54,7 +54,7 @@ void luaA_pushobject (lua_State *L, const TObject *o) {
   incr_top;
 }
 
-int lua_stackspace (lua_State *L) {
+LUA_API int lua_stackspace (lua_State *L) {
   return (L->stack_last - L->top);
 }
 
@@ -65,12 +65,12 @@ int lua_stackspace (lua_State *L) {
 */
 
 
-int lua_gettop (lua_State *L) {
+LUA_API int lua_gettop (lua_State *L) {
   return (L->top - L->Cbase);
 }
 
 
-void lua_settop (lua_State *L, int index) {
+LUA_API void lua_settop (lua_State *L, int index) {
   if (index >= 0)
     luaD_adjusttop(L, L->Cbase, index);
   else
@@ -78,14 +78,14 @@ void lua_settop (lua_State *L, int index) {
 }
 
 
-void lua_remove (lua_State *L, int index) {
+LUA_API void lua_remove (lua_State *L, int index) {
   StkId p = luaA_index(L, index);
   while (++p < L->top) *(p-1) = *p;
   L->top--;
 }
 
 
-void lua_insert (lua_State *L, int index) {
+LUA_API void lua_insert (lua_State *L, int index) {
   StkId p = luaA_index(L, index);
   StkId q;
   for (q = L->top; q>p; q--)
@@ -94,7 +94,7 @@ void lua_insert (lua_State *L, int index) {
 }
 
 
-void lua_pushvalue (lua_State *L, int index) {
+LUA_API void lua_pushvalue (lua_State *L, int index) {
   *L->top = *luaA_index(L, index);
   api_incr_top(L);
 }
@@ -106,50 +106,50 @@ void lua_pushvalue (lua_State *L, int index) {
 */
 
 
-int lua_type (lua_State *L, int index) {
+LUA_API int lua_type (lua_State *L, int index) {
   StkId o = luaA_indexAcceptable(L, index);
   if (o == NULL) return LUA_TNONE;
   else return ttype(o);
 }
 
-const char *lua_typename (lua_State *L, int t) {
+LUA_API const char *lua_typename (lua_State *L, int t) {
   UNUSED(L);
   return luaO_typenames[t];
 }
 
 
-int lua_iscfunction (lua_State *L, int index) {
+LUA_API int lua_iscfunction (lua_State *L, int index) {
   StkId o = luaA_indexAcceptable(L, index);
   if (o == NULL) return 0;
   else return iscfunction(o);
 }
 
-int lua_isnumber (lua_State *L, int index) {
+LUA_API int lua_isnumber (lua_State *L, int index) {
   TObject *o = luaA_indexAcceptable(L, index);
   if (o == NULL) return 0;
   else return (tonumber(o) == 0);
 }
 
-int lua_isstring (lua_State *L, int index) {
+LUA_API int lua_isstring (lua_State *L, int index) {
   int t = lua_type(L, index);
   return (t == LUA_TSTRING || t == LUA_TNUMBER);
 }
 
 
-int lua_tag (lua_State *L, int index) {
+LUA_API int lua_tag (lua_State *L, int index) {
   StkId o = luaA_indexAcceptable(L, index);
   if (o == NULL) return LUA_NOTAG;
   else return luaT_tag(o);
 }
 
-int lua_equal (lua_State *L, int index1, int index2) {
+LUA_API int lua_equal (lua_State *L, int index1, int index2) {
   StkId o1 = luaA_indexAcceptable(L, index1);
   StkId o2 = luaA_indexAcceptable(L, index2);
   if (o1 == NULL || o2 == NULL) return 0;  /* index out-of-range */
   else return luaO_equalObj(o1, o2);
 }
 
-int lua_lessthan (lua_State *L, int index1, int index2) {
+LUA_API int lua_lessthan (lua_State *L, int index1, int index2) {
   StkId o1 = luaA_indexAcceptable(L, index1);
   StkId o2 = luaA_indexAcceptable(L, index2);
   if (o1 == NULL || o2 == NULL) return 0;  /* index out-of-range */
@@ -158,37 +158,37 @@ int lua_lessthan (lua_State *L, int index1, int index2) {
 
 
 
-double lua_tonumber (lua_State *L, int index) {
+LUA_API double lua_tonumber (lua_State *L, int index) {
   StkId o = luaA_indexAcceptable(L, index);
   if (o == NULL || tonumber(o)) return 0;
   else return nvalue(o);
 }
 
-const char *lua_tostring (lua_State *L, int index) {
+LUA_API const char *lua_tostring (lua_State *L, int index) {
   StkId o = luaA_indexAcceptable(L, index);
   if (o == NULL || tostring(L, o)) return NULL;
   else return svalue(o);
 }
 
-size_t lua_strlen (lua_State *L, int index) {
+LUA_API size_t lua_strlen (lua_State *L, int index) {
   StkId o = luaA_indexAcceptable(L, index);
   if (o == NULL || tostring(L, o)) return 0;
   else return tsvalue(o)->u.s.len;
 }
 
-lua_CFunction lua_tocfunction (lua_State *L, int index) {
+LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index) {
   StkId o = luaA_indexAcceptable(L, index);
   if (o == NULL || !iscfunction(o)) return NULL;
   else return clvalue(o)->f.c;
 }
 
-void *lua_touserdata (lua_State *L, int index) {
+LUA_API void *lua_touserdata (lua_State *L, int index) {
   StkId o = luaA_indexAcceptable(L, index);
   if (o == NULL || ttype(o) != LUA_TUSERDATA) return NULL;
   else return tsvalue(o)->u.d.value;
 }
 
-const void *lua_topointer (lua_State *L, int index) {
+LUA_API const void *lua_topointer (lua_State *L, int index) {
   StkId o = luaA_indexAcceptable(L, index);
   if (o == NULL) return NULL;
   switch (ttype(o)) {
@@ -207,27 +207,27 @@ const void *lua_topointer (lua_State *L, int index) {
 */
 
 
-void lua_pushnil (lua_State *L) {
+LUA_API void lua_pushnil (lua_State *L) {
   ttype(L->top) = LUA_TNIL;
   api_incr_top(L);
 }
 
 
-void lua_pushnumber (lua_State *L, double n) {
+LUA_API void lua_pushnumber (lua_State *L, double n) {
   nvalue(L->top) = n;
   ttype(L->top) = LUA_TNUMBER;
   api_incr_top(L);
 }
 
 
-void lua_pushlstring (lua_State *L, const char *s, size_t len) {
+LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) {
   tsvalue(L->top) = luaS_newlstr(L, s, len);
   ttype(L->top) = LUA_TSTRING;
   api_incr_top(L);
 }
 
 
-void lua_pushstring (lua_State *L, const char *s) {
+LUA_API void lua_pushstring (lua_State *L, const char *s) {
   if (s == NULL)
     lua_pushnil(L);
   else
@@ -235,12 +235,13 @@ void lua_pushstring (lua_State *L, const char *s) {
 }
 
 
-void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
+LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
   luaV_Cclosure(L, fn, n);
 }
 
 
-void lua_pushusertag (lua_State *L, void *u, int tag) {  /* ORDER LUA_T */
+LUA_API void lua_pushusertag (lua_State *L, void *u, int tag) {
+  /* ORDER LUA_T */
   if (!(tag == LUA_ANYTAG || tag == LUA_TUSERDATA || validtag(tag)))
     luaO_verror(L, "invalid tag for a userdata (%d)", tag);
   tsvalue(L->top) = luaS_createudata(L, u, tag);
@@ -255,7 +256,7 @@ void lua_pushusertag (lua_State *L, void *u, int tag) {  /* ORDER LUA_T */
 */
 
 
-void lua_getglobal (lua_State *L, const char *name) {
+LUA_API void lua_getglobal (lua_State *L, const char *name) {
   StkId top = L->top;
   *top = *luaV_getglobal(L, luaS_new(L, name));
   L->top = top;
@@ -263,7 +264,7 @@ void lua_getglobal (lua_State *L, const char *name) {
 }
 
 
-void lua_gettable (lua_State *L, int index) {
+LUA_API void lua_gettable (lua_State *L, int index) {
   StkId t = Index(L, index);
   StkId top = L->top;
   *(top-1) = *luaV_gettable(L, t);
@@ -271,14 +272,14 @@ void lua_gettable (lua_State *L, int index) {
 }
 
 
-void lua_rawget (lua_State *L, int index) {
+LUA_API void lua_rawget (lua_State *L, int index) {
   StkId t = Index(L, index);
   LUA_ASSERT(ttype(t) == LUA_TTABLE, "table expected");
   *(L->top - 1) = *luaH_get(L, hvalue(t), L->top - 1);
 }
 
 
-void lua_rawgeti (lua_State *L, int index, int n) {
+LUA_API void lua_rawgeti (lua_State *L, int index, int n) {
   StkId o = Index(L, index);
   LUA_ASSERT(ttype(o) == LUA_TTABLE, "table expected");
   *L->top = *luaH_getnum(hvalue(o), n);
@@ -286,14 +287,14 @@ void lua_rawgeti (lua_State *L, int index, int n) {
 }
 
 
-void lua_getglobals (lua_State *L) {
+LUA_API void lua_getglobals (lua_State *L) {
   hvalue(L->top) = L->gt;
   ttype(L->top) = LUA_TTABLE;
   api_incr_top(L);
 }
 
 
-int lua_getref (lua_State *L, int ref) {
+LUA_API int lua_getref (lua_State *L, int ref) {
   if (ref == LUA_REFNIL)
     ttype(L->top) = LUA_TNIL;
   else if (0 <= ref && ref < L->refSize &&
@@ -306,7 +307,7 @@ int lua_getref (lua_State *L, int ref) {
 }
 
 
-void lua_newtable (lua_State *L) {
+LUA_API void lua_newtable (lua_State *L) {
   hvalue(L->top) = luaH_new(L, 0);
   ttype(L->top) = LUA_TTABLE;
   api_incr_top(L);
@@ -319,14 +320,14 @@ void lua_newtable (lua_State *L) {
 */
 
 
-void lua_setglobal (lua_State *L, const char *name) {
+LUA_API void lua_setglobal (lua_State *L, const char *name) {
   StkId top = L->top;
   luaV_setglobal(L, luaS_new(L, name));
   L->top = top-1;  /* remove element from the top */
 }
 
 
-void lua_settable (lua_State *L, int index) {
+LUA_API void lua_settable (lua_State *L, int index) {
   StkId t = Index(L, index);
   StkId top = L->top;
   luaV_settable(L, t, top-2);
@@ -334,7 +335,7 @@ void lua_settable (lua_State *L, int index) {
 }
 
 
-void lua_rawset (lua_State *L, int index) {
+LUA_API void lua_rawset (lua_State *L, int index) {
   StkId t = Index(L, index);
   LUA_ASSERT(ttype(t) == LUA_TTABLE, "table expected");
   *luaH_set(L, hvalue(t), L->top-2) = *(L->top-1);
@@ -342,7 +343,7 @@ void lua_rawset (lua_State *L, int index) {
 }
 
 
-void lua_rawseti (lua_State *L, int index, int n) {
+LUA_API void lua_rawseti (lua_State *L, int index, int n) {
   StkId o = Index(L, index);
   LUA_ASSERT(ttype(o) == LUA_TTABLE, "table expected");
   *luaH_setint(L, hvalue(o), n) = *(L->top-1);
@@ -350,14 +351,14 @@ void lua_rawseti (lua_State *L, int index, int n) {
 }
 
 
-void lua_setglobals (lua_State *L) {
+LUA_API void lua_setglobals (lua_State *L) {
   StkId newtable = --L->top;
   LUA_ASSERT(ttype(newtable) == LUA_TTABLE, "table expected");
   L->gt = hvalue(newtable);
 }
 
 
-int lua_ref (lua_State *L,  int lock) {
+LUA_API int lua_ref (lua_State *L,  int lock) {
   int ref;
   if (ttype(L->top-1) == LUA_TNIL)
     ref = LUA_REFNIL;
@@ -385,7 +386,7 @@ int lua_ref (lua_State *L,  int lock) {
 ** (most of them are in ldo.c)
 */
 
-void lua_rawcall (lua_State *L, int nargs, int nresults) {
+LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults) {
   luaD_call(L, L->top-(nargs+1), nresults);
 }
 
@@ -398,15 +399,15 @@ void lua_rawcall (lua_State *L, int nargs, int nresults) {
 #define GCscale(x)		((int)((x)>>10))
 #define GCunscale(x)		((unsigned long)(x)<<10)
 
-int lua_getgcthreshold (lua_State *L) {
+LUA_API int lua_getgcthreshold (lua_State *L) {
   return GCscale(L->GCthreshold);
 }
 
-int lua_getgccount (lua_State *L) {
+LUA_API int lua_getgccount (lua_State *L) {
   return GCscale(L->nblocks);
 }
 
-void lua_setgcthreshold (lua_State *L, int newthreshold) {
+LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) {
   if (newthreshold > GCscale(ULONG_MAX))
     L->GCthreshold = ULONG_MAX;
   else
@@ -419,7 +420,7 @@ void lua_setgcthreshold (lua_State *L, int newthreshold) {
 ** miscellaneous functions
 */
 
-void lua_settag (lua_State *L, int tag) {
+LUA_API void lua_settag (lua_State *L, int tag) {
   luaT_realtag(L, tag);
   switch (ttype(L->top-1)) {
     case LUA_TTABLE:
@@ -436,7 +437,7 @@ void lua_settag (lua_State *L, int tag) {
 }
 
 
-void lua_unref (lua_State *L, int ref) {
+LUA_API void lua_unref (lua_State *L, int ref) {
   if (ref >= 0) {
     LUA_ASSERT(ref < L->refSize && L->refArray[ref].st < 0, "invalid ref");
     L->refArray[ref].st = L->refFree;
@@ -445,7 +446,7 @@ void lua_unref (lua_State *L, int ref) {
 }
 
 
-int lua_next (lua_State *L, int index) {
+LUA_API int lua_next (lua_State *L, int index) {
   StkId t = luaA_index(L, index);
   Node *n;
   LUA_ASSERT(ttype(t) == LUA_TTABLE, "table expected");
@@ -463,7 +464,7 @@ int lua_next (lua_State *L, int index) {
 }
 
 
-int lua_getn (lua_State *L, int index) {
+LUA_API int lua_getn (lua_State *L, int index) {
   Hash *h = hvalue(luaA_index(L, index));
   const TObject *value = luaH_getstr(h, luaS_new(L, "n"));  /* value = h.n */
   if (ttype(value) == LUA_TNUMBER)
@@ -484,7 +485,7 @@ int lua_getn (lua_State *L, int index) {
 }
 
 
-void lua_concat (lua_State *L, int n) {
+LUA_API void lua_concat (lua_State *L, int n) {
   StkId top = L->top;
   luaV_strconc(L, n, top);
   L->top = top-(n-1);

+ 20 - 20
lauxlib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lauxlib.c,v 1.38 2000/10/02 20:10:55 roberto Exp roberto $
+** $Id: lauxlib.c,v 1.39 2000/10/05 12:14:08 roberto Exp roberto $
 ** Auxiliary functions for building Lua libraries
 ** See Copyright Notice in lua.h
 */
@@ -21,7 +21,7 @@
 
 
 
-int luaL_findstring (const char *name, const char *const list[]) {
+LUA_API int luaL_findstring (const char *name, const char *const list[]) {
   int i;
   for (i=0; list[i]; i++)
     if (strcmp(list[i], name) == 0)
@@ -29,7 +29,7 @@ int luaL_findstring (const char *name, const char *const list[]) {
   return -1;  /* name not found */
 }
 
-void luaL_argerror (lua_State *L, int narg, const char *extramsg) {
+LUA_API void luaL_argerror (lua_State *L, int narg, const char *extramsg) {
   lua_Debug ar;
   lua_getstack(L, 0, &ar);
   lua_getinfo(L, "n", &ar);
@@ -42,32 +42,32 @@ void luaL_argerror (lua_State *L, int narg, const char *extramsg) {
 
 static void type_error (lua_State *L, int narg, int t) {
   char buff[100];
-  const char *rt = lua_typename(L, lua_type(L, narg));
-  if (*rt == 'N') rt = "no value";
+  int tt = lua_type(L, narg);
+  const char *rt = (tt == LUA_TNONE) ? "no value" : lua_typename(L, tt);
   sprintf(buff, "%.10s expected, got %.10s", lua_typename(L, t), rt);
   luaL_argerror(L, narg, buff);
 }
 
 
-void luaL_checkstack (lua_State *L, int space, const char *mes) {
+LUA_API void luaL_checkstack (lua_State *L, int space, const char *mes) {
   if (space > lua_stackspace(L))
     luaL_verror(L, "stack overflow (%.30s)", mes);
 }
 
 
-void luaL_checktype(lua_State *L, int narg, int t) {
+LUA_API void luaL_checktype(lua_State *L, int narg, int t) {
   if (lua_type(L, narg) != t)
     type_error(L, narg, t);
 }
 
 
-void luaL_checkany (lua_State *L, int narg) {
+LUA_API void luaL_checkany (lua_State *L, int narg) {
   if (lua_type(L, narg) == LUA_TNONE)
     luaL_argerror(L, narg, "value expected");
 }
 
 
-const char *luaL_check_lstr (lua_State *L, int narg, size_t *len) {
+LUA_API const char *luaL_check_lstr (lua_State *L, int narg, size_t *len) {
   const char *s = lua_tostring(L, narg);
   if (!s) type_error(L, narg, LUA_TSTRING);
   if (len) *len = lua_strlen(L, narg);
@@ -75,7 +75,7 @@ const char *luaL_check_lstr (lua_State *L, int narg, size_t *len) {
 }
 
 
-const char *luaL_opt_lstr (lua_State *L, int narg, const char *def,
+LUA_API const char *luaL_opt_lstr (lua_State *L, int narg, const char *def,
                            size_t *len) {
   if (lua_isnull(L, narg)) {
     if (len)
@@ -86,7 +86,7 @@ const char *luaL_opt_lstr (lua_State *L, int narg, const char *def,
 }
 
 
-double luaL_check_number (lua_State *L, int narg) {
+LUA_API double luaL_check_number (lua_State *L, int narg) {
   double d = lua_tonumber(L, narg);
   if (d == 0 && !lua_isnumber(L, narg))  /* avoid extra test when d is not 0 */
     type_error(L, narg, LUA_TNUMBER);
@@ -94,20 +94,20 @@ double luaL_check_number (lua_State *L, int narg) {
 }
 
 
-double luaL_opt_number (lua_State *L, int narg, double def) {
+LUA_API double luaL_opt_number (lua_State *L, int narg, double def) {
   if (lua_isnull(L, narg)) return def;
   else return luaL_check_number(L, narg);
 }
 
 
-void luaL_openlib (lua_State *L, const struct luaL_reg *l, int n) {
+LUA_API void luaL_openlib (lua_State *L, const struct luaL_reg *l, int n) {
   int i;
   for (i=0; i<n; i++)
     lua_register(L, l[i].name, l[i].func);
 }
 
 
-void luaL_verror (lua_State *L, const char *fmt, ...) {
+LUA_API void luaL_verror (lua_State *L, const char *fmt, ...) {
   char buff[500];
   va_list argp;
   va_start(argp, fmt);
@@ -164,25 +164,25 @@ static void adjuststack (luaL_Buffer *B) {
 }
 
 
-char *luaL_prepbuffer (luaL_Buffer *B) {
+LUA_API char *luaL_prepbuffer (luaL_Buffer *B) {
   if (emptybuffer(B))
     adjuststack(B);
   return B->buffer;
 }
 
 
-void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
+LUA_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
   while (l--)
     luaL_putchar(B, *s++);
 }
 
 
-void luaL_addstring (luaL_Buffer *B, const char *s) {
+LUA_API void luaL_addstring (luaL_Buffer *B, const char *s) {
   luaL_addlstring(B, s, strlen(s));
 }
 
 
-void luaL_pushresult (luaL_Buffer *B) {
+LUA_API void luaL_pushresult (luaL_Buffer *B) {
   emptybuffer(B);
   if (B->level == 0)
     lua_pushlstring(B->L, NULL, 0);
@@ -192,7 +192,7 @@ void luaL_pushresult (luaL_Buffer *B) {
 }
 
 
-void luaL_addvalue (luaL_Buffer *B) {
+LUA_API void luaL_addvalue (luaL_Buffer *B) {
   lua_State *L = B->L;
   size_t vl = lua_strlen(L, -1);
   if (vl <= bufffree(B)) {  /* fit into buffer? */
@@ -209,7 +209,7 @@ void luaL_addvalue (luaL_Buffer *B) {
 }
 
 
-void luaL_buffinit (lua_State *L, luaL_Buffer *B) {
+LUA_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) {
   B->L = L;
   B->p = B->buffer;
   B->level = 0;

+ 21 - 19
lauxlib.h

@@ -1,5 +1,5 @@
 /*
-** $Id: lauxlib.h,v 1.26 2000/10/02 20:10:55 roberto Exp roberto $
+** $Id: lauxlib.h,v 1.27 2000/10/05 12:14:08 roberto Exp roberto $
 ** Auxiliary functions for building Lua libraries
 ** See Copyright Notice in lua.h
 */
@@ -21,20 +21,20 @@ struct luaL_reg {
 };
 
 
-void luaL_openlib (lua_State *L, const struct luaL_reg *l, int n);
-void luaL_argerror (lua_State *L, int numarg, const char *extramsg);
-const char *luaL_check_lstr (lua_State *L, int numArg, size_t *len);
-const char *luaL_opt_lstr (lua_State *L, int numArg, const char *def,
-                           size_t *len);
-double luaL_check_number (lua_State *L, int numArg);
-double luaL_opt_number (lua_State *L, int numArg, double def);
+LUA_API void luaL_openlib (lua_State *L, const struct luaL_reg *l, int n);
+LUA_API void luaL_argerror (lua_State *L, int numarg, const char *extramsg);
+LUA_API const char *luaL_check_lstr (lua_State *L, int numArg, size_t *len);
+LUA_API const char *luaL_opt_lstr (lua_State *L, int numArg, const char *def,
+                                   size_t *len);
+LUA_API double luaL_check_number (lua_State *L, int numArg);
+LUA_API double luaL_opt_number (lua_State *L, int numArg, double def);
 
-void luaL_checkstack (lua_State *L, int space, const char *msg);
-void luaL_checktype (lua_State *L, int narg, int t);
-void luaL_checkany (lua_State *L, int narg);
+LUA_API void luaL_checkstack (lua_State *L, int space, const char *msg);
+LUA_API void luaL_checktype (lua_State *L, int narg, int t);
+LUA_API void luaL_checkany (lua_State *L, int narg);
 
-void luaL_verror (lua_State *L, const char *fmt, ...);
-int luaL_findstring (const char *name, const char *const list[]);
+LUA_API void luaL_verror (lua_State *L, const char *fmt, ...);
+LUA_API int luaL_findstring (const char *name, const char *const list[]);
 
 
 
@@ -62,7 +62,9 @@ int luaL_findstring (const char *name, const char *const list[]);
 */
 
 
+#ifndef LUAL_BUFFERSIZE
 #define LUAL_BUFFERSIZE	  BUFSIZ
+#endif
 
 
 typedef struct luaL_Buffer {
@@ -78,12 +80,12 @@ typedef struct luaL_Buffer {
 
 #define luaL_addsize(B,n)	((B)->p += (n))
 
-void luaL_buffinit (lua_State *L, luaL_Buffer *B);
-char *luaL_prepbuffer (luaL_Buffer *B);
-void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);
-void luaL_addstring (luaL_Buffer *B, const char *s);
-void luaL_addvalue (luaL_Buffer *B);
-void luaL_pushresult (luaL_Buffer *B);
+LUA_API void luaL_buffinit (lua_State *L, luaL_Buffer *B);
+LUA_API char *luaL_prepbuffer (luaL_Buffer *B);
+LUA_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);
+LUA_API void luaL_addstring (luaL_Buffer *B, const char *s);
+LUA_API void luaL_addvalue (luaL_Buffer *B);
+LUA_API void luaL_pushresult (luaL_Buffer *B);
 
 
 /* }====================================================== */

+ 2 - 2
lbaselib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lbaselib.c,v 1.10 2000/10/06 19:13:29 roberto Exp roberto $
+** $Id: lbaselib.c,v 1.11 2000/10/09 15:46:43 roberto Exp roberto $
 ** Basic library
 ** See Copyright Notice in lua.h
 */
@@ -636,7 +636,7 @@ static const struct luaL_reg base_funcs[] = {
 
 
 
-void lua_baselibopen (lua_State *L) {
+LUA_API void lua_baselibopen (lua_State *L) {
   luaL_openl(L, base_funcs);
   lua_pushstring(L, LUA_VERSION);
   lua_setglobal(L, "_VERSION");

+ 2 - 2
ldblib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ldblib.c,v 1.21 2000/09/12 18:38:25 roberto Exp roberto $
+** $Id: ldblib.c,v 1.22 2000/10/02 20:10:55 roberto Exp roberto $
 ** Interface from Lua to its debug API
 ** See Copyright Notice in lua.h
 */
@@ -174,7 +174,7 @@ static const struct luaL_reg dblib[] = {
 };
 
 
-void lua_dblibopen (lua_State *L) {
+LUA_API void lua_dblibopen (lua_State *L) {
   luaL_openl(L, dblib);
 }
 

+ 23 - 21
ldebug.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ldebug.c,v 1.46 2000/10/06 12:45:25 roberto Exp roberto $
+** $Id: ldebug.c,v 1.47 2000/10/09 13:47:32 roberto Exp roberto $
 ** Debug Interface
 ** See Copyright Notice in lua.h
 */
@@ -41,14 +41,14 @@ static int isLmark (StkId o) {
 }
 
 
-lua_Hook lua_setcallhook (lua_State *L, lua_Hook func) {
+LUA_API lua_Hook lua_setcallhook (lua_State *L, lua_Hook func) {
   lua_Hook oldhook = L->callhook;
   L->callhook = func;
   return oldhook;
 }
 
 
-lua_Hook lua_setlinehook (lua_State *L, lua_Hook func) {
+LUA_API lua_Hook lua_setlinehook (lua_State *L, lua_Hook func) {
   lua_Hook oldhook = L->linehook;
   L->linehook = func;
   return oldhook;
@@ -68,7 +68,7 @@ static StkId aux_stackedfunction (lua_State *L, int level, StkId top) {
 }
 
 
-int lua_getstack (lua_State *L, int level, lua_Debug *ar) {
+LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) {
   StkId f = aux_stackedfunction(L, level, L->top);
   if (f == NULL) return 0;  /* there is no such level */
   else {
@@ -78,7 +78,7 @@ int lua_getstack (lua_State *L, int level, lua_Debug *ar) {
 }
 
 
-static int lua_nups (StkId f) {
+static int nups (StkId f) {
   switch (ttype(f)) {
     case LUA_TFUNCTION:
       return clvalue(f)->nupvalues;
@@ -121,7 +121,7 @@ int luaG_getline (int *lineinfo, int pc, int refline, int *prefi) {
 }
 
 
-static int lua_currentpc (StkId f) {
+static int currentpc (StkId f) {
   CallInfo *ci = infovalue(f);
   LUA_ASSERT(isLmark(f), "function has no pc");
   if (ci->pc)
@@ -131,13 +131,13 @@ static int lua_currentpc (StkId f) {
 }
 
 
-static int lua_currentline (StkId f) {
+static int currentline (StkId f) {
   if (!isLmark(f))
     return -1;  /* only active lua functions have current-line information */
   else {
     CallInfo *ci = infovalue(f);
     int *lineinfo = ci->func->f.l->lineinfo;
-    return luaG_getline(lineinfo, lua_currentpc(f), 1, NULL);
+    return luaG_getline(lineinfo, currentpc(f), 1, NULL);
   }
 }
 
@@ -148,25 +148,27 @@ static Proto *getluaproto (StkId f) {
 }
 
 
-const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int localnum) {
+LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar,
+                                  int localnum) {
   const char *name;
   StkId f = ar->_func;
   Proto *fp = getluaproto(f);
   if (!fp) return NULL;  /* `f' is not a Lua function? */
-  name = luaF_getlocalname(fp, localnum, lua_currentpc(f));
+  name = luaF_getlocalname(fp, localnum, currentpc(f));
   if (!name) return NULL;
   luaA_pushobject(L, (f+1)+(localnum-1));  /* push value */
   return name;
 }
 
 
-const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int localnum) {
+LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar,
+                                  int localnum) {
   const char *name;
   StkId f = ar->_func;
   Proto *fp = getluaproto(f);
   L->top--;  /* pop new value */
   if (!fp) return NULL;  /* `f' is not a Lua function? */
-  name = luaF_getlocalname(fp, localnum, lua_currentpc(f));
+  name = luaF_getlocalname(fp, localnum, currentpc(f));
   if (!name || name[0] == '*') return NULL;  /* `*' starts private locals */
   *((f+1)+(localnum-1)) = *L->top;
   return name;
@@ -180,7 +182,7 @@ static void infoLproto (lua_Debug *ar, Proto *f) {
 }
 
 
-static void lua_funcinfo (lua_State *L, lua_Debug *ar, StkId func) {
+static void funcinfo (lua_State *L, lua_Debug *ar, StkId func) {
   Closure *cl = NULL;
   switch (ttype(func)) {
     case LUA_TFUNCTION:
@@ -231,7 +233,7 @@ static const char *travglobals (lua_State *L, const TObject *o) {
 }
 
 
-static void lua_getname (lua_State *L, StkId f, lua_Debug *ar) {
+static void getname (lua_State *L, StkId f, lua_Debug *ar) {
   TObject o;
   setnormalized(&o, f);
   /* try to find a name for given function */
@@ -244,7 +246,7 @@ static void lua_getname (lua_State *L, StkId f, lua_Debug *ar) {
 }
 
 
-int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
+LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
   StkId func;
   int isactive = (*what != '>');
   if (isactive)
@@ -256,21 +258,21 @@ int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
   for (; *what; what++) {
     switch (*what) {
       case 'S': {
-        lua_funcinfo(L, ar, func);
+        funcinfo(L, ar, func);
         break;
       }
       case 'l': {
-        ar->currentline = lua_currentline(func);
+        ar->currentline = currentline(func);
         break;
       }
       case 'u': {
-        ar->nups = lua_nups(func);
+        ar->nups = nups(func);
         break;
       }
       case 'n': {
         ar->namewhat = (isactive) ? getfuncname(L, func, &ar->name) : NULL;
         if (ar->namewhat == NULL)
-          lua_getname(L, func, ar);
+          getname(L, func, ar);
         break;
       }
       case 'f': {
@@ -387,7 +389,7 @@ static const char *getobjname (lua_State *L, StkId obj, const char **name) {
     return NULL;  /* not an active Lua function */
   else {
     Proto *p = infovalue(func)->func->f.l;
-    int pc = lua_currentpc(func);
+    int pc = currentpc(func);
     int stackpos = obj - (func+1);  /* func+1 == function base */
     Instruction i = luaG_symbexec(p, pc, stackpos);
     LUA_ASSERT(pc != -1, "function must be active");
@@ -419,7 +421,7 @@ static const char *getfuncname (lua_State *L, StkId f, const char **name) {
     return NULL;  /* not an active Lua function */
   else {
     Proto *p = infovalue(func)->func->f.l;
-    int pc = lua_currentpc(func);
+    int pc = currentpc(func);
     Instruction i;
     if (pc == -1) return NULL;  /* function is not activated */
     i = p->code[pc];

+ 6 - 6
ldo.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ldo.c,v 1.106 2000/10/09 15:46:43 roberto Exp roberto $
+** $Id: ldo.c,v 1.107 2000/10/10 19:51:39 roberto Exp roberto $
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 */
@@ -212,7 +212,7 @@ static void f_call (lua_State *L, void *ud) {
 }
 
 
-int lua_call (lua_State *L, int nargs, int nresults) {
+LUA_API int lua_call (lua_State *L, int nargs, int nresults) {
   StkId func = L->top - (nargs+1);  /* function to be called */
   struct CallS c;
   int status;
@@ -284,7 +284,7 @@ static int parse_file (lua_State *L, const char *filename) {
 }
 
 
-int lua_dofile (lua_State *L, const char *filename) {
+LUA_API int lua_dofile (lua_State *L, const char *filename) {
   int status = parse_file(L, filename);
   if (status == 0)  /* parse OK? */
     status = lua_call(L, 0, LUA_MULTRET);  /* call main */
@@ -301,7 +301,7 @@ static int parse_buffer (lua_State *L, const char *buff, size_t size,
 }
 
 
-int lua_dobuffer (lua_State *L, const char *buff, size_t size,
+LUA_API int lua_dobuffer (lua_State *L, const char *buff, size_t size,
                   const char *name) {
   int status = parse_buffer(L, buff, size, name);
   if (status == 0)  /* parse OK? */
@@ -310,7 +310,7 @@ int lua_dobuffer (lua_State *L, const char *buff, size_t size,
 }
 
 
-int lua_dostring (lua_State *L, const char *str) {
+LUA_API int lua_dostring (lua_State *L, const char *str) {
   return lua_dobuffer(L, str, strlen(str), str);
 }
 
@@ -343,7 +343,7 @@ static void message (lua_State *L, const char *s) {
 /*
 ** Reports an error, and jumps up to the available recovery label
 */
-void lua_error (lua_State *L, const char *s) {
+LUA_API void lua_error (lua_State *L, const char *s) {
   if (s) message(L, s);
   luaD_breakrun(L, LUA_ERRRUN);
 }

+ 2 - 2
liolib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: liolib.c,v 1.85 2000/09/22 18:14:06 roberto Exp roberto $
+** $Id: liolib.c,v 1.86 2000/10/02 20:10:55 roberto Exp roberto $
 ** Standard I/O (and system) library
 ** See Copyright Notice in lua.h
 */
@@ -721,7 +721,7 @@ static void openwithcontrol (lua_State *L) {
 }
 
 
-void lua_iolibopen (lua_State *L) {
+LUA_API void lua_iolibopen (lua_State *L) {
   luaL_openl(L, iolib);
   openwithcontrol(L);
 }

+ 2 - 2
llex.c

@@ -1,5 +1,5 @@
 /*
-** $Id: llex.c,v 1.70 2000/09/11 20:29:27 roberto Exp roberto $
+** $Id: llex.c,v 1.71 2000/09/27 17:41:58 roberto Exp roberto $
 ** Lexical Analyzer
 ** See Copyright Notice in lua.h
 */
@@ -58,7 +58,7 @@ void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) {
 void luaX_syntaxerror (LexState *ls, const char *s, const char *token) {
   char buff[MAXSRC];
   luaO_chunkid(buff, ls->source->str, sizeof(buff));
-  luaO_verror(ls->L, "%.99s;\n  last token read: `%.50s' at line %d in %.80s",
+  luaO_verror(ls->L, "%.99s;\n  last token read: `%.30s' at line %d in %.80s",
               s, token, ls->linenumber, buff);
 }
 

+ 2 - 2
lmathlib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lmathlib.c,v 1.27 2000/08/28 17:57:04 roberto Exp roberto $
+** $Id: lmathlib.c,v 1.28 2000/08/31 20:23:40 roberto Exp roberto $
 ** Standard mathematical library
 ** See Copyright Notice in lua.h
 */
@@ -228,7 +228,7 @@ static const struct luaL_reg mathlib[] = {
 /*
 ** Open math library
 */
-void lua_mathlibopen (lua_State *L) {
+LUA_API void lua_mathlibopen (lua_State *L) {
   luaL_openl(L, mathlib);
   lua_pushnumber(L, 0);  /* to get its tag */
   lua_pushcfunction(L, math_pow);

+ 3 - 3
lstate.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lstate.c,v 1.43 2000/10/05 13:00:17 roberto Exp roberto $
+** $Id: lstate.c,v 1.44 2000/10/06 19:28:47 roberto Exp roberto $
 ** Global State
 ** See Copyright Notice in lua.h
 */
@@ -60,7 +60,7 @@ static void f_luaopen (lua_State *L, void *ud) {
 }
 
 
-lua_State *lua_open (int stacksize) {
+LUA_API lua_State *lua_open (int stacksize) {
   lua_State *L = luaM_new(NULL, lua_State);
   if (L == NULL) return NULL;  /* memory allocation error */
   L->stack = NULL;
@@ -94,7 +94,7 @@ lua_State *lua_open (int stacksize) {
 }
 
 
-void lua_close (lua_State *L) {
+LUA_API void lua_close (lua_State *L) {
   luaC_collect(L, 1);  /* collect all elements */
   LUA_ASSERT(L->rootproto == NULL, "list should be empty");
   LUA_ASSERT(L->rootcl == NULL, "list should be empty");

+ 2 - 2
lstrlib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lstrlib.c,v 1.53 2000/09/14 14:09:31 roberto Exp roberto $
+** $Id: lstrlib.c,v 1.54 2000/10/05 12:14:08 roberto Exp roberto $
 ** Standard library for string operations and pattern-matching
 ** See Copyright Notice in lua.h
 */
@@ -616,6 +616,6 @@ static const struct luaL_reg strlib[] = {
 /*
 ** Open string library
 */
-void lua_strlibopen (lua_State *L) {
+LUA_API void lua_strlibopen (lua_State *L) {
   luaL_openl(L, strlib);
 }

+ 2 - 2
ltests.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ltests.c,v 1.49 2000/10/05 13:00:17 roberto Exp roberto $
+** $Id: ltests.c,v 1.50 2000/10/06 19:29:26 roberto Exp roberto $
 ** Internal Module for Debugging of the Lua Implementation
 ** See Copyright Notice in lua.h
 */
@@ -72,7 +72,7 @@ static int pushop (lua_State *L, Proto *p, int pc) {
   sprintf(buff, "%5d - ", luaG_getline(p->lineinfo, pc, 1, NULL));
   switch ((enum Mode)luaK_opproperties[o].mode) {  
     case iO:
-      sprintf(buff+8, "%s", name);
+      sprintf(buff+8, "%-12s", name);
       break;
     case iU:
       sprintf(buff+8, "%-12s%4u", name, GETARG_U(i));

+ 5 - 5
ltm.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ltm.c,v 1.53 2000/10/05 12:14:08 roberto Exp roberto $
+** $Id: ltm.c,v 1.54 2000/10/05 13:00:17 roberto Exp roberto $
 ** Tag methods
 ** See Copyright Notice in lua.h
 */
@@ -83,7 +83,7 @@ void luaT_init (lua_State *L) {
 }
 
 
-int lua_newtag (lua_State *L) {
+LUA_API int lua_newtag (lua_State *L) {
   luaM_growvector(L, L->TMtable, L->last_tag, 1, struct TM,
                   "tag table overflow", MAX_INT);
   L->nblocks += sizeof(struct TM);
@@ -104,7 +104,7 @@ void luaT_realtag (lua_State *L, int tag) {
 }
 
 
-int lua_copytagmethods (lua_State *L, int tagto, int tagfrom) {
+LUA_API int lua_copytagmethods (lua_State *L, int tagto, int tagfrom) {
   int e;
   checktag(L, tagto);
   checktag(L, tagfrom);
@@ -126,7 +126,7 @@ int luaT_tag (const TObject *o) {
 }
 
 
-void lua_gettagmethod (lua_State *L, int t, const char *event) {
+LUA_API void lua_gettagmethod (lua_State *L, int t, const char *event) {
   int e;
   e = luaI_checkevent(L, event, t);
   checktag(L, t);
@@ -140,7 +140,7 @@ void lua_gettagmethod (lua_State *L, int t, const char *event) {
 }
 
 
-void lua_settagmethod (lua_State *L, int t, const char *event) {
+LUA_API void lua_settagmethod (lua_State *L, int t, const char *event) {
   Closure *oldtm;
   int e = luaI_checkevent(L, event, t);
   checktag(L, t);

+ 66 - 61
lua.h

@@ -1,5 +1,5 @@
 /*
-** $Id: lua.h,v 1.73 2000/10/05 12:14:08 roberto Exp roberto $
+** $Id: lua.h,v 1.74 2000/10/09 15:46:43 roberto Exp roberto $
 ** Lua - An Extensible Extension Language
 ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
 ** e-mail: [email protected]
@@ -16,6 +16,11 @@
 #include <stddef.h>
 
 
+#ifndef LUA_API
+#define LUA_API		extern
+#endif
+
+
 #define LUA_VERSION	"Lua 4.0 (beta)"
 #define LUA_COPYRIGHT	"Copyright (C) 1994-2000 TeCGraf, PUC-Rio"
 #define LUA_AUTHORS 	"W. Celes, R. Ierusalimschy & L. H. de Figueiredo"
@@ -65,113 +70,113 @@ typedef int (*lua_CFunction) (lua_State *L);
 /*
 ** state manipulation
 */
-lua_State     *lua_open (int stacksize);
-void           lua_close (lua_State *L);
+LUA_API lua_State *lua_open (int stacksize);
+LUA_API void       lua_close (lua_State *L);
 
 
 /*
 ** basic stack manipulation
 */
-int            lua_gettop (lua_State *L);
-void           lua_settop (lua_State *L, int index);
-void           lua_pushvalue (lua_State *L, int index);
-void           lua_remove (lua_State *L, int index);
-void           lua_insert (lua_State *L, int index);
-int            lua_stackspace (lua_State *L);
+LUA_API int   lua_gettop (lua_State *L);
+LUA_API void  lua_settop (lua_State *L, int index);
+LUA_API void  lua_pushvalue (lua_State *L, int index);
+LUA_API void  lua_remove (lua_State *L, int index);
+LUA_API void  lua_insert (lua_State *L, int index);
+LUA_API int   lua_stackspace (lua_State *L);
 
 
 /*
 ** access functions (stack -> C)
 */
 
-int            lua_type (lua_State *L, int index);
-const char    *lua_typename (lua_State *L, int t);
-int            lua_isnumber (lua_State *L, int index);
-int            lua_isstring (lua_State *L, int index);
-int            lua_iscfunction (lua_State *L, int index);
-int            lua_tag (lua_State *L, int index);
+LUA_API int            lua_type (lua_State *L, int index);
+LUA_API const char    *lua_typename (lua_State *L, int t);
+LUA_API int            lua_isnumber (lua_State *L, int index);
+LUA_API int            lua_isstring (lua_State *L, int index);
+LUA_API int            lua_iscfunction (lua_State *L, int index);
+LUA_API int            lua_tag (lua_State *L, int index);
 
-int            lua_equal (lua_State *L, int index1, int index2);
-int            lua_lessthan (lua_State *L, int index1, int index2);
+LUA_API int            lua_equal (lua_State *L, int index1, int index2);
+LUA_API int            lua_lessthan (lua_State *L, int index1, int index2);
 
-double         lua_tonumber (lua_State *L, int index);
-const char    *lua_tostring (lua_State *L, int index);
-size_t         lua_strlen (lua_State *L, int index);
-lua_CFunction  lua_tocfunction (lua_State *L, int index);
-void	      *lua_touserdata (lua_State *L, int index);
-const void    *lua_topointer (lua_State *L, int index);
+LUA_API double         lua_tonumber (lua_State *L, int index);
+LUA_API const char    *lua_tostring (lua_State *L, int index);
+LUA_API size_t         lua_strlen (lua_State *L, int index);
+LUA_API lua_CFunction  lua_tocfunction (lua_State *L, int index);
+LUA_API void	      *lua_touserdata (lua_State *L, int index);
+LUA_API const void    *lua_topointer (lua_State *L, int index);
 
 
 /*
 ** push functions (C -> stack)
 */
-void           lua_pushnil (lua_State *L);
-void           lua_pushnumber (lua_State *L, double n);
-void           lua_pushlstring (lua_State *L, const char *s, size_t len);
-void           lua_pushstring (lua_State *L, const char *s);
-void           lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);
-void           lua_pushusertag (lua_State *L, void *u, int tag);
+LUA_API void  lua_pushnil (lua_State *L);
+LUA_API void  lua_pushnumber (lua_State *L, double n);
+LUA_API void  lua_pushlstring (lua_State *L, const char *s, size_t len);
+LUA_API void  lua_pushstring (lua_State *L, const char *s);
+LUA_API void  lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);
+LUA_API void  lua_pushusertag (lua_State *L, void *u, int tag);
 
 
 /*
 ** get functions (Lua -> stack)
 */
-void           lua_getglobal (lua_State *L, const char *name);
-void           lua_gettable (lua_State *L, int index);
-void           lua_rawget (lua_State *L, int index);
-void           lua_rawgeti (lua_State *L, int index, int n);
-void           lua_getglobals (lua_State *L);
-void           lua_gettagmethod (lua_State *L, int tag, const char *event);
+LUA_API void  lua_getglobal (lua_State *L, const char *name);
+LUA_API void  lua_gettable (lua_State *L, int index);
+LUA_API void  lua_rawget (lua_State *L, int index);
+LUA_API void  lua_rawgeti (lua_State *L, int index, int n);
+LUA_API void  lua_getglobals (lua_State *L);
+LUA_API void  lua_gettagmethod (lua_State *L, int tag, const char *event);
 
-int            lua_getref (lua_State *L, int ref);
+LUA_API int   lua_getref (lua_State *L, int ref);
 
-void           lua_newtable (lua_State *L);
+LUA_API void  lua_newtable (lua_State *L);
 
 
 /*
 ** set functions (stack -> Lua)
 */
-void           lua_setglobal (lua_State *L, const char *name);
-void           lua_settable (lua_State *L, int index);
-void           lua_rawset (lua_State *L, int index);
-void           lua_rawseti (lua_State *L, int index, int n);
-void           lua_setglobals (lua_State *L);
-void           lua_settagmethod (lua_State *L, int tag, const char *event);
-int            lua_ref (lua_State *L, int lock);
+LUA_API void  lua_setglobal (lua_State *L, const char *name);
+LUA_API void  lua_settable (lua_State *L, int index);
+LUA_API void  lua_rawset (lua_State *L, int index);
+LUA_API void  lua_rawseti (lua_State *L, int index, int n);
+LUA_API void  lua_setglobals (lua_State *L);
+LUA_API void  lua_settagmethod (lua_State *L, int tag, const char *event);
+LUA_API int   lua_ref (lua_State *L, int lock);
 
 
 /*
 ** "do" functions (run Lua code)
 */
-int            lua_call (lua_State *L, int nargs, int nresults);
-void           lua_rawcall (lua_State *L, int nargs, int nresults);
-int            lua_dofile (lua_State *L, const char *filename);
-int            lua_dostring (lua_State *L, const char *str);
-int            lua_dobuffer (lua_State *L, const char *buff, size_t size,
-                             const char *name);
+LUA_API int   lua_call (lua_State *L, int nargs, int nresults);
+LUA_API void  lua_rawcall (lua_State *L, int nargs, int nresults);
+LUA_API int   lua_dofile (lua_State *L, const char *filename);
+LUA_API int   lua_dostring (lua_State *L, const char *str);
+LUA_API int   lua_dobuffer (lua_State *L, const char *buff, size_t size,
+                            const char *name);
 
 /*
 ** Garbage-collection functions
 */
-int            lua_getgcthreshold (lua_State *L);
-int            lua_getgccount (lua_State *L);
-void           lua_setgcthreshold (lua_State *L, int newthreshold);
+LUA_API int   lua_getgcthreshold (lua_State *L);
+LUA_API int   lua_getgccount (lua_State *L);
+LUA_API void  lua_setgcthreshold (lua_State *L, int newthreshold);
 
 /*
 ** miscellaneous functions
 */
-int            lua_newtag (lua_State *L);
-int            lua_copytagmethods (lua_State *L, int tagto, int tagfrom);
-void           lua_settag (lua_State *L, int tag);
+LUA_API int   lua_newtag (lua_State *L);
+LUA_API int   lua_copytagmethods (lua_State *L, int tagto, int tagfrom);
+LUA_API void  lua_settag (lua_State *L, int tag);
 
-void           lua_error (lua_State *L, const char *s);
+LUA_API void  lua_error (lua_State *L, const char *s);
 
-void	       lua_unref (lua_State *L, int ref);
+LUA_API void  lua_unref (lua_State *L, int ref);
 
-int            lua_next (lua_State *L, int index);
-int            lua_getn (lua_State *L, int index);
+LUA_API int   lua_next (lua_State *L, int index);
+LUA_API int   lua_getn (lua_State *L, int index);
 
-void           lua_concat (lua_State *L, int n);
+LUA_API void  lua_concat (lua_State *L, int n);
 
 
 /* 

+ 9 - 7
luadebug.h

@@ -1,5 +1,5 @@
 /*
-** $Id: luadebug.h,v 1.14 2000/09/11 20:29:27 roberto Exp roberto $
+** $Id: luadebug.h,v 1.15 2000/09/12 18:38:02 roberto Exp roberto $
 ** Debugging API
 ** See Copyright Notice in lua.h
 */
@@ -17,13 +17,15 @@ typedef struct lua_Localvar lua_Localvar;
 typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
 
 
-int lua_getstack (lua_State *L, int level, lua_Debug *ar);
-int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
-const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int localnum);
-const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int localnum);
+LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar);
+LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
+LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar,
+                                  int localnum);
+LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar,
+                                  int localnum);
 
-lua_Hook lua_setcallhook (lua_State *L, lua_Hook func);
-lua_Hook lua_setlinehook (lua_State *L, lua_Hook func);
+LUA_API lua_Hook lua_setcallhook (lua_State *L, lua_Hook func);
+LUA_API lua_Hook lua_setlinehook (lua_State *L, lua_Hook func);
 
 
 #define LUA_IDSIZE	60

+ 6 - 6
lualib.h

@@ -1,5 +1,5 @@
 /*
-** $Id: lualib.h,v 1.11 2000/09/05 19:33:32 roberto Exp roberto $
+** $Id: lualib.h,v 1.12 2000/09/12 13:46:59 roberto Exp roberto $
 ** Lua standard libraries
 ** See Copyright Notice in lua.h
 */
@@ -13,11 +13,11 @@
 
 #define LUA_ALERT               "_ALERT"
 
-void lua_baselibopen (lua_State *L);
-void lua_iolibopen (lua_State *L);
-void lua_strlibopen (lua_State *L);
-void lua_mathlibopen (lua_State *L);
-void lua_dblibopen (lua_State *L);
+LUA_API void lua_baselibopen (lua_State *L);
+LUA_API void lua_iolibopen (lua_State *L);
+LUA_API void lua_strlibopen (lua_State *L);
+LUA_API void lua_mathlibopen (lua_State *L);
+LUA_API void lua_dblibopen (lua_State *L);
 
 
 

+ 14 - 14
lundump.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lundump.c,v 1.32 2000/09/21 03:15:36 lhf Exp $
+** $Id: lundump.c,v 1.32 2000/09/21 03:15:36 lhf Exp lhf $
 ** load bytecodes from files
 ** See Copyright Notice in lua.h
 */
@@ -23,7 +23,7 @@ static const char* ZNAME (ZIO* Z)
 
 static void unexpectedEOZ (lua_State* L, ZIO* Z)
 {
- luaO_verror(L,"unexpected end of file in `%.255s'",ZNAME(Z));
+ luaO_verror(L,"unexpected end of file in `%.99s'",ZNAME(Z));
 }
 
 static int ezgetc (lua_State* L, ZIO* Z)
@@ -107,7 +107,8 @@ static void LoadCode (lua_State* L, Proto* tf, ZIO* Z, int swap)
  int size=LoadInt(L,Z,swap);
  tf->code=luaM_newvector(L,size,Instruction);
  LoadVector(L,tf->code,size,sizeof(*tf->code),Z,swap);
- if (tf->code[size-1]!=OP_END) luaO_verror(L,"bad code in `%.255s'",ZNAME(Z));
+ if (tf->code[size-1]!=OP_END) luaO_verror(L,"bad code in `%.99s'",ZNAME(Z));
+ luaF_protook(L,tf,size);
 }
 
 static void LoadLocals (lua_State* L, Proto* tf, ZIO* Z, int swap)
@@ -125,8 +126,8 @@ static void LoadLocals (lua_State* L, Proto* tf, ZIO* Z, int swap)
 
 static void LoadLines (lua_State* L, Proto* tf, ZIO* Z, int swap)
 {
- int n=LoadInt(L,Z,swap);
- if (n==0) return;
+ int n;
+ tf->nlineinfo=n=LoadInt(L,Z,swap);
  tf->lineinfo=luaM_newvector(L,n,int);
  LoadVector(L,tf->lineinfo,n,sizeof(*tf->lineinfo),Z,swap);
 }
@@ -157,10 +158,10 @@ static Proto* LoadFunction (lua_State* L, ZIO* Z, int swap)
  tf->numparams=LoadInt(L,Z,swap);
  tf->is_vararg=LoadByte(L,Z);
  tf->maxstacksize=LoadInt(L,Z,swap);
- LoadCode(L,tf,Z,swap);
  LoadLocals(L,tf,Z,swap);
  LoadLines(L,tf,Z,swap);
  LoadConstants(L,tf,Z,swap);
+ LoadCode(L,tf,Z,swap);
  return tf;
 }
 
@@ -169,14 +170,14 @@ static void LoadSignature (lua_State* L, ZIO* Z)
  const char* s=SIGNATURE;
  while (*s!=0 && ezgetc(L,Z)==*s)
   ++s;
- if (*s!=0) luaO_verror(L,"bad signature in `%.255s'",ZNAME(Z));
+ if (*s!=0) luaO_verror(L,"bad signature in `%.99s'",ZNAME(Z));
 }
 
 static void TestSize (lua_State* L, int s, const char* what, ZIO* Z)
 {
  int r=ezgetc(L,Z);
  if (r!=s)
-  luaO_verror(L,"virtual machine mismatch in `%.255s':\n"
+  luaO_verror(L,"virtual machine mismatch in `%.99s':\n"
 	"  %s is %d but read %d",ZNAME(Z),what,s,r);
 }
 
@@ -190,11 +191,11 @@ static int LoadHeader (lua_State* L, ZIO* Z)
  LoadSignature(L,Z);
  version=ezgetc(L,Z);
  if (version>VERSION)
-  luaO_verror(L,"`%.255s' too new:\n"
+  luaO_verror(L,"`%.99s' too new:\n"
 	"  read version %d.%d; expected at most %d.%d",
 	ZNAME(Z),V(version),V(VERSION));
  if (version<VERSION0)			/* check last major change */
-  luaO_verror(L,"`%.255s' too old:\n"
+  luaO_verror(L,"`%.99s' too old:\n"
 	"  read version %d.%d; expected at least %d.%d",
 	ZNAME(Z),V(version),V(VERSION));
  swap=(luaU_endianess()!=ezgetc(L,Z));	/* need to swap bytes? */
@@ -207,9 +208,8 @@ static int LoadHeader (lua_State* L, ZIO* Z)
  TESTSIZE(sizeof(Number));
  f=LoadNumber(L,Z,swap);
  if ((long)f!=(long)tf)		/* disregard errors in last bit of fraction */
-  luaO_verror(L,"unknown number format in `%.255s':\n"
-      "  read " NUMBER_FMT "; expected " NUMBER_FMT,
-      ZNAME(Z),f,tf);
+  luaO_verror(L,"unknown number format in `%.99s':\n"
+      "  read " NUMBER_FMT "; expected " NUMBER_FMT, ZNAME(Z),f,tf);
  return swap;
 }
 
@@ -230,7 +230,7 @@ Proto* luaU_undump (lua_State* L, ZIO* Z)
   tf=LoadChunk(L,Z);
  c=zgetc(Z);
  if (c!=EOZ)
-  luaO_verror(L,"`%.255s' apparently contains more than one chunk",ZNAME(Z));
+  luaO_verror(L,"`%.99s' apparently contains more than one chunk",ZNAME(Z));
  return tf;
 }
 

+ 1 - 7
lundump.h

@@ -1,5 +1,5 @@
 /*
-** $Id: lundump.h,v 1.19 2000/04/24 17:32:29 lhf Exp lhf $
+** $Id: lundump.h,v 1.20 2000/09/18 20:03:46 lhf Exp lhf $
 ** load pre-compiled Lua chunks
 ** See Copyright Notice in lua.h
 */
@@ -12,7 +12,6 @@
 
 /* load one chunk */
 Proto* luaU_undump (lua_State* L, ZIO* Z);
-#define luaU_undump1 luaU_undump
 
 /* find byte order */
 int luaU_endianess (void);
@@ -29,11 +28,6 @@ int luaU_endianess (void);
 #define IN		" in %p " SOURCE
 #define INLOC		tf,tf->source->str,tf->lineDefined
 
-/* format for numbers in listings and error messages */
-#ifndef NUMBER_FMT
-#define NUMBER_FMT	"%.16g"		/* LUA_NUMBER */
-#endif
-
 /* a multiple of PI for testing native format */
 /* multiplying by 1E8 gives non-trivial integer values */
 #define	TEST_NUMBER	3.14159265358979323846E8