diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-08-30 17:00:59 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-08-30 17:00:59 -0300 |
commit | 2c670baf24115d9c59b5869b89873b93af8b779d (patch) | |
tree | 30ec1b85988ea36bd74403bd32a29a362def36d4 | |
parent | fdafd4f4a88d1584dea900517445a17d87f8b82f (diff) | |
download | lua-2c670baf24115d9c59b5869b89873b93af8b779d.tar.gz lua-2c670baf24115d9c59b5869b89873b93af8b779d.tar.bz2 lua-2c670baf24115d9c59b5869b89873b93af8b779d.zip |
avoid the use of "obvious" names in header files to avoid conflicts
-rw-r--r-- | lauxlib.c | 20 | ||||
-rw-r--r-- | lauxlib.h | 24 | ||||
-rw-r--r-- | lua.h | 78 |
3 files changed, 60 insertions, 62 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.82 2002/08/06 18:01:50 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.83 2002/08/08 20:08:41 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 | */ |
@@ -208,27 +208,27 @@ static int emptybuffer (luaL_Buffer *B) { | |||
208 | else { | 208 | else { |
209 | lua_pushlstring(B->L, B->buffer, l); | 209 | lua_pushlstring(B->L, B->buffer, l); |
210 | B->p = B->buffer; | 210 | B->p = B->buffer; |
211 | B->level++; | 211 | B->lvl++; |
212 | return 1; | 212 | return 1; |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | static void adjuststack (luaL_Buffer *B) { | 217 | static void adjuststack (luaL_Buffer *B) { |
218 | if (B->level > 1) { | 218 | if (B->lvl > 1) { |
219 | lua_State *L = B->L; | 219 | lua_State *L = B->L; |
220 | int toget = 1; /* number of levels to concat */ | 220 | int toget = 1; /* number of levels to concat */ |
221 | size_t toplen = lua_strlen(L, -1); | 221 | size_t toplen = lua_strlen(L, -1); |
222 | do { | 222 | do { |
223 | size_t l = lua_strlen(L, -(toget+1)); | 223 | size_t l = lua_strlen(L, -(toget+1)); |
224 | if (B->level - toget + 1 >= LIMIT || toplen > l) { | 224 | if (B->lvl - toget + 1 >= LIMIT || toplen > l) { |
225 | toplen += l; | 225 | toplen += l; |
226 | toget++; | 226 | toget++; |
227 | } | 227 | } |
228 | else break; | 228 | else break; |
229 | } while (toget < B->level); | 229 | } while (toget < B->lvl); |
230 | lua_concat(L, toget); | 230 | lua_concat(L, toget); |
231 | B->level = B->level - toget + 1; | 231 | B->lvl = B->lvl - toget + 1; |
232 | } | 232 | } |
233 | } | 233 | } |
234 | 234 | ||
@@ -253,8 +253,8 @@ LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { | |||
253 | 253 | ||
254 | LUALIB_API void luaL_pushresult (luaL_Buffer *B) { | 254 | LUALIB_API void luaL_pushresult (luaL_Buffer *B) { |
255 | emptybuffer(B); | 255 | emptybuffer(B); |
256 | lua_concat(B->L, B->level); | 256 | lua_concat(B->L, B->lvl); |
257 | B->level = 1; | 257 | B->lvl = 1; |
258 | } | 258 | } |
259 | 259 | ||
260 | 260 | ||
@@ -269,7 +269,7 @@ LUALIB_API void luaL_addvalue (luaL_Buffer *B) { | |||
269 | else { | 269 | else { |
270 | if (emptybuffer(B)) | 270 | if (emptybuffer(B)) |
271 | lua_insert(L, -2); /* put buffer before new value */ | 271 | lua_insert(L, -2); /* put buffer before new value */ |
272 | B->level++; /* add new value into B stack */ | 272 | B->lvl++; /* add new value into B stack */ |
273 | adjuststack(B); | 273 | adjuststack(B); |
274 | } | 274 | } |
275 | } | 275 | } |
@@ -278,7 +278,7 @@ LUALIB_API void luaL_addvalue (luaL_Buffer *B) { | |||
278 | LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { | 278 | LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { |
279 | B->L = L; | 279 | B->L = L; |
280 | B->p = B->buffer; | 280 | B->p = B->buffer; |
281 | B->level = 0; | 281 | B->lvl = 0; |
282 | } | 282 | } |
283 | 283 | ||
284 | /* }====================================================== */ | 284 | /* }====================================================== */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.h,v 1.51 2002/07/01 19:23:58 roberto Exp roberto $ | 2 | ** $Id: lauxlib.h,v 1.52 2002/08/08 20:08:41 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 | */ |
@@ -30,31 +30,29 @@ typedef struct luaL_reg { | |||
30 | LUALIB_API void luaL_openlib (lua_State *L, const luaL_reg *l, int nup); | 30 | LUALIB_API void luaL_openlib (lua_State *L, const luaL_reg *l, int nup); |
31 | LUALIB_API void luaL_opennamedlib (lua_State *L, const char *libname, | 31 | LUALIB_API void luaL_opennamedlib (lua_State *L, const char *libname, |
32 | const luaL_reg *l, int nup); | 32 | const luaL_reg *l, int nup); |
33 | LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event); | 33 | LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *e); |
34 | LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname); | 34 | LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname); |
35 | LUALIB_API int luaL_argerror (lua_State *L, int numarg, const char *extramsg); | 35 | LUALIB_API int luaL_argerror (lua_State *L, int numarg, const char *extramsg); |
36 | LUALIB_API const char *luaL_check_lstr (lua_State *L, int numArg, | 36 | LUALIB_API const char *luaL_check_lstr (lua_State *L, int numArg, size_t *l); |
37 | size_t *len); | ||
38 | LUALIB_API const char *luaL_opt_lstr (lua_State *L, int numArg, | 37 | LUALIB_API const char *luaL_opt_lstr (lua_State *L, int numArg, |
39 | const char *def, size_t *len); | 38 | const char *def, size_t *l); |
40 | LUALIB_API lua_Number luaL_check_number (lua_State *L, int numArg); | 39 | LUALIB_API lua_Number luaL_check_number (lua_State *L, int numArg); |
41 | LUALIB_API lua_Number luaL_opt_number (lua_State *L, int nArg, lua_Number def); | 40 | LUALIB_API lua_Number luaL_opt_number (lua_State *L, int nArg, lua_Number def); |
42 | 41 | ||
43 | LUALIB_API void luaL_check_stack (lua_State *L, int space, const char *msg); | 42 | LUALIB_API void luaL_check_stack (lua_State *L, int sz, const char *msg); |
44 | LUALIB_API void luaL_check_type (lua_State *L, int narg, int t); | 43 | LUALIB_API void luaL_check_type (lua_State *L, int narg, int t); |
45 | LUALIB_API void luaL_check_any (lua_State *L, int narg); | 44 | LUALIB_API void luaL_check_any (lua_State *L, int narg); |
46 | 45 | ||
47 | LUALIB_API void luaL_where (lua_State *L, int level); | 46 | LUALIB_API void luaL_where (lua_State *L, int lvl); |
48 | LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...); | 47 | LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...); |
49 | 48 | ||
50 | LUALIB_API int luaL_findstring (const char *name, | 49 | LUALIB_API int luaL_findstring (const char *st, const char *const lst[]); |
51 | const char *const list[]); | ||
52 | 50 | ||
53 | LUALIB_API int luaL_ref (lua_State *L, int t); | 51 | LUALIB_API int luaL_ref (lua_State *L, int t); |
54 | LUALIB_API void luaL_unref (lua_State *L, int t, int ref); | 52 | LUALIB_API void luaL_unref (lua_State *L, int t, int ref); |
55 | 53 | ||
56 | LUALIB_API int luaL_loadfile (lua_State *L, const char *filename); | 54 | LUALIB_API int luaL_loadfile (lua_State *L, const char *filename); |
57 | LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, | 55 | LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t sz, |
58 | const char *name); | 56 | const char *name); |
59 | 57 | ||
60 | 58 | ||
@@ -89,7 +87,7 @@ LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, | |||
89 | 87 | ||
90 | typedef struct luaL_Buffer { | 88 | typedef struct luaL_Buffer { |
91 | char *p; /* current position in buffer */ | 89 | char *p; /* current position in buffer */ |
92 | int level; | 90 | int lvl; /* number of strings in the stack (level) */ |
93 | lua_State *L; | 91 | lua_State *L; |
94 | char buffer[LUAL_BUFFERSIZE]; | 92 | char buffer[LUAL_BUFFERSIZE]; |
95 | } luaL_Buffer; | 93 | } luaL_Buffer; |
@@ -121,8 +119,8 @@ LUALIB_API void luaL_pushresult (luaL_Buffer *B); | |||
121 | 119 | ||
122 | LUALIB_API int lua_dofile (lua_State *L, const char *filename); | 120 | LUALIB_API int lua_dofile (lua_State *L, const char *filename); |
123 | LUALIB_API int lua_dostring (lua_State *L, const char *str); | 121 | LUALIB_API int lua_dostring (lua_State *L, const char *str); |
124 | LUALIB_API int lua_dobuffer (lua_State *L, const char *buff, size_t size, | 122 | LUALIB_API int lua_dobuffer (lua_State *L, const char *buff, size_t sz, |
125 | const char *name); | 123 | const char *n); |
126 | 124 | ||
127 | 125 | ||
128 | #endif | 126 | #endif |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.154 2002/08/12 17:23:12 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.155 2002/08/30 19:09:21 roberto Exp roberto $ |
3 | ** Lua - An Extensible Extension Language | 3 | ** Lua - An Extensible Extension Language |
4 | ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil | 4 | ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil |
5 | ** http://www.lua.org mailto:info@lua.org | 5 | ** http://www.lua.org mailto:info@lua.org |
@@ -54,7 +54,7 @@ typedef int (*lua_CFunction) (lua_State *L); | |||
54 | /* | 54 | /* |
55 | ** functions that read blocks when loading Lua chunk | 55 | ** functions that read blocks when loading Lua chunk |
56 | */ | 56 | */ |
57 | typedef const char * (*lua_Chunkreader) (lua_State *L, void *ud, size_t *size); | 57 | typedef const char * (*lua_Chunkreader) (lua_State *L, void *ud, size_t *sz); |
58 | 58 | ||
59 | 59 | ||
60 | /* | 60 | /* |
@@ -103,7 +103,7 @@ typedef LUA_NUMBER lua_Number; | |||
103 | LUA_API lua_State *lua_open (void); | 103 | LUA_API lua_State *lua_open (void); |
104 | LUA_API void lua_close (lua_State *L); | 104 | LUA_API void lua_close (lua_State *L); |
105 | LUA_API lua_State *lua_newthread (lua_State *L); | 105 | LUA_API lua_State *lua_newthread (lua_State *L); |
106 | LUA_API void lua_closethread (lua_State *L, lua_State *thread); | 106 | LUA_API void lua_closethread (lua_State *L, lua_State *t); |
107 | 107 | ||
108 | LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf); | 108 | LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf); |
109 | 109 | ||
@@ -112,36 +112,36 @@ LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf); | |||
112 | ** basic stack manipulation | 112 | ** basic stack manipulation |
113 | */ | 113 | */ |
114 | LUA_API int lua_gettop (lua_State *L); | 114 | LUA_API int lua_gettop (lua_State *L); |
115 | LUA_API void lua_settop (lua_State *L, int index); | 115 | LUA_API void lua_settop (lua_State *L, int idx); |
116 | LUA_API void lua_pushvalue (lua_State *L, int index); | 116 | LUA_API void lua_pushvalue (lua_State *L, int idx); |
117 | LUA_API void lua_remove (lua_State *L, int index); | 117 | LUA_API void lua_remove (lua_State *L, int idx); |
118 | LUA_API void lua_insert (lua_State *L, int index); | 118 | LUA_API void lua_insert (lua_State *L, int idx); |
119 | LUA_API void lua_replace (lua_State *L, int index); | 119 | LUA_API void lua_replace (lua_State *L, int idx); |
120 | LUA_API int lua_checkstack (lua_State *L, int size); | 120 | LUA_API int lua_checkstack (lua_State *L, int sz); |
121 | 121 | ||
122 | 122 | ||
123 | /* | 123 | /* |
124 | ** access functions (stack -> C) | 124 | ** access functions (stack -> C) |
125 | */ | 125 | */ |
126 | 126 | ||
127 | LUA_API int lua_isnumber (lua_State *L, int index); | 127 | LUA_API int lua_isnumber (lua_State *L, int idx); |
128 | LUA_API int lua_isstring (lua_State *L, int index); | 128 | LUA_API int lua_isstring (lua_State *L, int idx); |
129 | LUA_API int lua_iscfunction (lua_State *L, int index); | 129 | LUA_API int lua_iscfunction (lua_State *L, int idx); |
130 | LUA_API int lua_isuserdata (lua_State *L, int index); | 130 | LUA_API int lua_isuserdata (lua_State *L, int idx); |
131 | LUA_API int lua_type (lua_State *L, int index); | 131 | LUA_API int lua_type (lua_State *L, int idx); |
132 | LUA_API const char *lua_typename (lua_State *L, int type); | 132 | LUA_API const char *lua_typename (lua_State *L, int tp); |
133 | 133 | ||
134 | LUA_API int lua_equal (lua_State *L, int index1, int index2); | 134 | LUA_API int lua_equal (lua_State *L, int idx1, int idx2); |
135 | LUA_API int lua_rawequal (lua_State *L, int index1, int index2); | 135 | LUA_API int lua_rawequal (lua_State *L, int idx1, int idx2); |
136 | LUA_API int lua_lessthan (lua_State *L, int index1, int index2); | 136 | LUA_API int lua_lessthan (lua_State *L, int idx1, int idx2); |
137 | 137 | ||
138 | LUA_API lua_Number lua_tonumber (lua_State *L, int index); | 138 | LUA_API lua_Number lua_tonumber (lua_State *L, int idx); |
139 | LUA_API int lua_toboolean (lua_State *L, int index); | 139 | LUA_API int lua_toboolean (lua_State *L, int idx); |
140 | LUA_API const char *lua_tostring (lua_State *L, int index); | 140 | LUA_API const char *lua_tostring (lua_State *L, int idx); |
141 | LUA_API size_t lua_strlen (lua_State *L, int index); | 141 | LUA_API size_t lua_strlen (lua_State *L, int idx); |
142 | LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index); | 142 | LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx); |
143 | LUA_API void *lua_touserdata (lua_State *L, int index); | 143 | LUA_API void *lua_touserdata (lua_State *L, int idx); |
144 | LUA_API const void *lua_topointer (lua_State *L, int index); | 144 | LUA_API const void *lua_topointer (lua_State *L, int idx); |
145 | 145 | ||
146 | 146 | ||
147 | /* | 147 | /* |
@@ -149,7 +149,7 @@ LUA_API const void *lua_topointer (lua_State *L, int index); | |||
149 | */ | 149 | */ |
150 | LUA_API void lua_pushnil (lua_State *L); | 150 | LUA_API void lua_pushnil (lua_State *L); |
151 | LUA_API void lua_pushnumber (lua_State *L, lua_Number n); | 151 | LUA_API void lua_pushnumber (lua_State *L, lua_Number n); |
152 | LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len); | 152 | LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t l); |
153 | LUA_API void lua_pushstring (lua_State *L, const char *s); | 153 | LUA_API void lua_pushstring (lua_State *L, const char *s); |
154 | LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt, | 154 | LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt, |
155 | va_list argp); | 155 | va_list argp); |
@@ -162,24 +162,24 @@ LUA_API void lua_pushlightuserdata (lua_State *L, void *p); | |||
162 | /* | 162 | /* |
163 | ** get functions (Lua -> stack) | 163 | ** get functions (Lua -> stack) |
164 | */ | 164 | */ |
165 | LUA_API void lua_gettable (lua_State *L, int index); | 165 | LUA_API void lua_gettable (lua_State *L, int idx); |
166 | LUA_API void lua_rawget (lua_State *L, int index); | 166 | LUA_API void lua_rawget (lua_State *L, int idx); |
167 | LUA_API void lua_rawgeti (lua_State *L, int index, int n); | 167 | LUA_API void lua_rawgeti (lua_State *L, int idx, int n); |
168 | LUA_API void lua_newtable (lua_State *L); | 168 | LUA_API void lua_newtable (lua_State *L); |
169 | LUA_API int lua_getmetatable (lua_State *L, int objindex); | 169 | LUA_API int lua_getmetatable (lua_State *L, int objindex); |
170 | LUA_API const char *lua_getmode (lua_State *L, int index); | 170 | LUA_API const char *lua_getmode (lua_State *L, int idx); |
171 | LUA_API void lua_getglobals (lua_State *L, int index); | 171 | LUA_API void lua_getglobals (lua_State *L, int idx); |
172 | 172 | ||
173 | 173 | ||
174 | /* | 174 | /* |
175 | ** set functions (stack -> Lua) | 175 | ** set functions (stack -> Lua) |
176 | */ | 176 | */ |
177 | LUA_API void lua_settable (lua_State *L, int index); | 177 | LUA_API void lua_settable (lua_State *L, int idx); |
178 | LUA_API void lua_rawset (lua_State *L, int index); | 178 | LUA_API void lua_rawset (lua_State *L, int idx); |
179 | LUA_API void lua_rawseti (lua_State *L, int index, int n); | 179 | LUA_API void lua_rawseti (lua_State *L, int idx, int n); |
180 | LUA_API void lua_setmode (lua_State *L, int index, const char *mode); | 180 | LUA_API void lua_setmode (lua_State *L, int idx, const char *md); |
181 | LUA_API int lua_setmetatable (lua_State *L, int objindex); | 181 | LUA_API int lua_setmetatable (lua_State *L, int objindex); |
182 | LUA_API int lua_setglobals (lua_State *L, int index); | 182 | LUA_API int lua_setglobals (lua_State *L, int idx); |
183 | 183 | ||
184 | 184 | ||
185 | /* | 185 | /* |
@@ -187,7 +187,7 @@ LUA_API int lua_setglobals (lua_State *L, int index); | |||
187 | */ | 187 | */ |
188 | LUA_API void lua_call (lua_State *L, int nargs, int nresults); | 188 | LUA_API void lua_call (lua_State *L, int nargs, int nresults); |
189 | LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc); | 189 | LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc); |
190 | LUA_API int lua_load (lua_State *L, lua_Chunkreader reader, void *data, | 190 | LUA_API int lua_load (lua_State *L, lua_Chunkreader reader, void *dt, |
191 | const char *chunkname); | 191 | const char *chunkname); |
192 | 192 | ||
193 | 193 | ||
@@ -211,11 +211,11 @@ LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold); | |||
211 | 211 | ||
212 | LUA_API int lua_error (lua_State *L); | 212 | LUA_API int lua_error (lua_State *L); |
213 | 213 | ||
214 | LUA_API int lua_next (lua_State *L, int index); | 214 | LUA_API int lua_next (lua_State *L, int idx); |
215 | 215 | ||
216 | LUA_API void lua_concat (lua_State *L, int n); | 216 | LUA_API void lua_concat (lua_State *L, int n); |
217 | 217 | ||
218 | LUA_API void *lua_newuserdata (lua_State *L, size_t size); | 218 | LUA_API void *lua_newuserdata (lua_State *L, size_t sz); |
219 | 219 | ||
220 | 220 | ||
221 | 221 | ||