diff options
Diffstat (limited to 'lua.h')
-rw-r--r-- | lua.h | 85 |
1 files changed, 28 insertions, 57 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.106 2001/10/31 19:40:14 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.107 2001/10/31 19:58:11 roberto Exp $ |
3 | ** Lua - An Extensible Extension Language | 3 | ** Lua - An Extensible Extension Language |
4 | ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil | 4 | ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil |
5 | ** e-mail: info@lua.org | 5 | ** e-mail: info@lua.org |
@@ -91,12 +91,6 @@ typedef int (*lua_CFunction) (lua_State *L); | |||
91 | #endif | 91 | #endif |
92 | typedef LUA_NUMBER lua_Number; | 92 | typedef LUA_NUMBER lua_Number; |
93 | 93 | ||
94 | /* Lua character type */ | ||
95 | #ifndef L_CHAR | ||
96 | #define L_CHAR char | ||
97 | #endif | ||
98 | typedef L_CHAR lua_char; | ||
99 | |||
100 | 94 | ||
101 | /* mark for all API functions */ | 95 | /* mark for all API functions */ |
102 | #ifndef LUA_API | 96 | #ifndef LUA_API |
@@ -126,7 +120,7 @@ LUA_API int lua_stackspace (lua_State *L); | |||
126 | ** access functions (stack -> C) | 120 | ** access functions (stack -> C) |
127 | */ | 121 | */ |
128 | 122 | ||
129 | LUA_API const lua_char *lua_type (lua_State *L, int index); | 123 | LUA_API const char *lua_type (lua_State *L, int index); |
130 | LUA_API int lua_isnumber (lua_State *L, int index); | 124 | LUA_API int lua_isnumber (lua_State *L, int index); |
131 | LUA_API int lua_isstring (lua_State *L, int index); | 125 | LUA_API int lua_isstring (lua_State *L, int index); |
132 | LUA_API int lua_iscfunction (lua_State *L, int index); | 126 | LUA_API int lua_iscfunction (lua_State *L, int index); |
@@ -137,7 +131,7 @@ LUA_API int lua_equal (lua_State *L, int index1, int index2); | |||
137 | LUA_API int lua_lessthan (lua_State *L, int index1, int index2); | 131 | LUA_API int lua_lessthan (lua_State *L, int index1, int index2); |
138 | 132 | ||
139 | LUA_API lua_Number lua_tonumber (lua_State *L, int index); | 133 | LUA_API lua_Number lua_tonumber (lua_State *L, int index); |
140 | LUA_API const lua_char *lua_tostring (lua_State *L, int index); | 134 | LUA_API const char *lua_tostring (lua_State *L, int index); |
141 | LUA_API size_t lua_strlen (lua_State *L, int index); | 135 | LUA_API size_t lua_strlen (lua_State *L, int index); |
142 | LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index); | 136 | LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index); |
143 | LUA_API void *lua_touserdata (lua_State *L, int index); | 137 | LUA_API void *lua_touserdata (lua_State *L, int index); |
@@ -149,19 +143,19 @@ LUA_API const void *lua_topointer (lua_State *L, int index); | |||
149 | */ | 143 | */ |
150 | LUA_API void lua_pushnil (lua_State *L); | 144 | LUA_API void lua_pushnil (lua_State *L); |
151 | LUA_API void lua_pushnumber (lua_State *L, lua_Number n); | 145 | LUA_API void lua_pushnumber (lua_State *L, lua_Number n); |
152 | LUA_API void lua_pushlstring (lua_State *L, const lua_char *s, size_t len); | 146 | LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len); |
153 | LUA_API void lua_pushstring (lua_State *L, const lua_char *s); | 147 | LUA_API void lua_pushstring (lua_State *L, const char *s); |
154 | LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n); | 148 | LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n); |
155 | 149 | ||
156 | 150 | ||
157 | /* | 151 | /* |
158 | ** get functions (Lua -> stack) | 152 | ** get functions (Lua -> stack) |
159 | */ | 153 | */ |
160 | LUA_API void lua_getglobal (lua_State *L, const lua_char *name); | 154 | LUA_API void lua_getglobal (lua_State *L, const char *name); |
161 | LUA_API void lua_gettable (lua_State *L, int index); | 155 | LUA_API void lua_gettable (lua_State *L, int index); |
162 | LUA_API void lua_rawget (lua_State *L, int index); | 156 | LUA_API void lua_rawget (lua_State *L, int index); |
163 | LUA_API void lua_rawgeti (lua_State *L, int index, int n); | 157 | LUA_API void lua_rawgeti (lua_State *L, int index, int n); |
164 | LUA_API void lua_gettagmethod (lua_State *L, int tag, const lua_char *event); | 158 | LUA_API void lua_gettagmethod (lua_State *L, int tag, const char *event); |
165 | LUA_API void lua_newtable (lua_State *L); | 159 | LUA_API void lua_newtable (lua_State *L); |
166 | LUA_API void lua_getweakregistry (lua_State *L); | 160 | LUA_API void lua_getweakregistry (lua_State *L); |
167 | 161 | ||
@@ -169,12 +163,12 @@ LUA_API void lua_getweakregistry (lua_State *L); | |||
169 | /* | 163 | /* |
170 | ** set functions (stack -> Lua) | 164 | ** set functions (stack -> Lua) |
171 | */ | 165 | */ |
172 | LUA_API void lua_setglobal (lua_State *L, const lua_char *name); | 166 | LUA_API void lua_setglobal (lua_State *L, const char *name); |
173 | LUA_API void lua_settable (lua_State *L, int index); | 167 | LUA_API void lua_settable (lua_State *L, int index); |
174 | LUA_API void lua_rawset (lua_State *L, int index); | 168 | LUA_API void lua_rawset (lua_State *L, int index); |
175 | LUA_API void lua_rawseti (lua_State *L, int index, int n); | 169 | LUA_API void lua_rawseti (lua_State *L, int index, int n); |
176 | LUA_API void lua_setglobals (lua_State *L); | 170 | LUA_API void lua_setglobals (lua_State *L); |
177 | LUA_API void lua_settagmethod (lua_State *L, int tag, const lua_char *event); | 171 | LUA_API void lua_settagmethod (lua_State *L, int tag, const char *event); |
178 | 172 | ||
179 | 173 | ||
180 | /* | 174 | /* |
@@ -182,13 +176,13 @@ LUA_API void lua_settagmethod (lua_State *L, int tag, const lua_char *event); | |||
182 | */ | 176 | */ |
183 | LUA_API int lua_call (lua_State *L, int nargs, int nresults); | 177 | LUA_API int lua_call (lua_State *L, int nargs, int nresults); |
184 | LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults); | 178 | LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults); |
185 | LUA_API int lua_loadfile (lua_State *L, const lua_char *filename); | 179 | LUA_API int lua_loadfile (lua_State *L, const char *filename); |
186 | LUA_API int lua_dofile (lua_State *L, const lua_char *filename); | 180 | LUA_API int lua_dofile (lua_State *L, const char *filename); |
187 | LUA_API int lua_dostring (lua_State *L, const lua_char *str); | 181 | LUA_API int lua_dostring (lua_State *L, const char *str); |
188 | LUA_API int lua_loadbuffer (lua_State *L, const lua_char *buff, size_t size, | 182 | LUA_API int lua_loadbuffer (lua_State *L, const char *buff, size_t size, |
189 | const lua_char *name); | 183 | const char *name); |
190 | LUA_API int lua_dobuffer (lua_State *L, const lua_char *buff, size_t size, | 184 | LUA_API int lua_dobuffer (lua_State *L, const char *buff, size_t size, |
191 | const lua_char *name); | 185 | const char *name); |
192 | 186 | ||
193 | /* | 187 | /* |
194 | ** Garbage-collection functions | 188 | ** Garbage-collection functions |
@@ -200,13 +194,13 @@ LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold); | |||
200 | /* | 194 | /* |
201 | ** miscellaneous functions | 195 | ** miscellaneous functions |
202 | */ | 196 | */ |
203 | LUA_API int lua_newtype (lua_State *L, const lua_char *name, int basictype); | 197 | LUA_API int lua_newtype (lua_State *L, const char *name, int basictype); |
204 | LUA_API void lua_settag (lua_State *L, int tag); | 198 | LUA_API void lua_settag (lua_State *L, int tag); |
205 | 199 | ||
206 | LUA_API int lua_name2tag (lua_State *L, const lua_char *name); | 200 | LUA_API int lua_name2tag (lua_State *L, const char *name); |
207 | LUA_API const lua_char *lua_tag2name (lua_State *L, int tag); | 201 | LUA_API const char *lua_tag2name (lua_State *L, int tag); |
208 | 202 | ||
209 | LUA_API void lua_error (lua_State *L, const lua_char *s); | 203 | LUA_API void lua_error (lua_State *L, const char *s); |
210 | 204 | ||
211 | LUA_API int lua_next (lua_State *L, int index); | 205 | LUA_API int lua_next (lua_State *L, int index); |
212 | LUA_API int lua_getn (lua_State *L, int index); | 206 | LUA_API int lua_getn (lua_State *L, int index); |
@@ -240,8 +234,8 @@ LUA_API int lua_getweakmode (lua_State *L, int index); | |||
240 | #define lua_isnil(L,n) (lua_rawtag(L,n) == LUA_TNIL) | 234 | #define lua_isnil(L,n) (lua_rawtag(L,n) == LUA_TNIL) |
241 | #define lua_isnull(L,n) (lua_rawtag(L,n) == LUA_TNONE) | 235 | #define lua_isnull(L,n) (lua_rawtag(L,n) == LUA_TNONE) |
242 | 236 | ||
243 | #define lua_pushliteral(L, s) lua_pushlstring(L, s, \ | 237 | #define lua_pushliteral(L, s) lua_pushlstring(L, "" s, \ |
244 | (sizeof(s)/sizeof(lua_char))-1) | 238 | (sizeof(s)/sizeof(char))-1) |
245 | 239 | ||
246 | #define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX); | 240 | #define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX); |
247 | #define lua_getglobals(L) lua_pushvalue(L, LUA_GLOBALSINDEX); | 241 | #define lua_getglobals(L) lua_pushvalue(L, LUA_GLOBALSINDEX); |
@@ -264,7 +258,7 @@ LUA_API void lua_pushupvalues (lua_State *L); | |||
264 | #define LUA_REFNIL (-1) | 258 | #define LUA_REFNIL (-1) |
265 | 259 | ||
266 | #define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ | 260 | #define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ |
267 | (lua_error(L, l_s("unlocked references are obsolete")), 0)) | 261 | (lua_error(L, "unlocked references are obsolete"), 0)) |
268 | 262 | ||
269 | #define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) | 263 | #define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) |
270 | 264 | ||
@@ -277,43 +271,21 @@ LUA_API void lua_pushupvalues (lua_State *L); | |||
277 | /* | 271 | /* |
278 | ** {====================================================================== | 272 | ** {====================================================================== |
279 | ** useful definitions for Lua kernel and libraries | 273 | ** useful definitions for Lua kernel and libraries |
274 | ** ======================================================================= | ||
280 | */ | 275 | */ |
281 | #ifdef LUA_PRIVATE | ||
282 | |||
283 | #define l_char lua_char | ||
284 | |||
285 | /* macro to control type of literal strings */ | ||
286 | #ifndef l_s | ||
287 | #define l_s(x) x | ||
288 | #endif | ||
289 | |||
290 | /* macro to control type of literal chars */ | ||
291 | #ifndef l_c | ||
292 | #define l_c(x) x | ||
293 | #endif | ||
294 | |||
295 | /* macro to `unsign' a character */ | ||
296 | #ifndef uchar | ||
297 | #define uchar(c) ((unsigned char)(c)) | ||
298 | #endif | ||
299 | |||
300 | /* integer type to hold the result of fgetc */ | ||
301 | #ifndef l_charint | ||
302 | #define l_charint int | ||
303 | #endif | ||
304 | 276 | ||
305 | /* | 277 | /* formats for Lua numbers */ |
306 | ** formats for Lua numbers | ||
307 | */ | ||
308 | #ifndef LUA_NUMBER_SCAN | 278 | #ifndef LUA_NUMBER_SCAN |
309 | #define LUA_NUMBER_SCAN "%lf" | 279 | #define LUA_NUMBER_SCAN "%lf" |
310 | #endif | 280 | #endif |
281 | |||
311 | #ifndef LUA_NUMBER_FMT | 282 | #ifndef LUA_NUMBER_FMT |
312 | #define LUA_NUMBER_FMT "%.16g" | 283 | #define LUA_NUMBER_FMT "%.16g" |
313 | #endif | 284 | #endif |
285 | |||
314 | /* function to convert a lua_Number to a string */ | 286 | /* function to convert a lua_Number to a string */ |
315 | #ifndef lua_number2str | 287 | #ifndef lua_number2str |
316 | #define lua_number2str(s,n) sprintf((s), l_s(LUA_NUMBER_FMT), (n)) | 288 | #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) |
317 | #endif | 289 | #endif |
318 | 290 | ||
319 | /* function to convert a string to a lua_Number */ | 291 | /* function to convert a string to a lua_Number */ |
@@ -321,7 +293,6 @@ LUA_API void lua_pushupvalues (lua_State *L); | |||
321 | #define lua_str2number(s,p) strtod((s), (p)) | 293 | #define lua_str2number(s,p) strtod((s), (p)) |
322 | #endif | 294 | #endif |
323 | 295 | ||
324 | #endif | ||
325 | /* }====================================================================== */ | 296 | /* }====================================================================== */ |
326 | 297 | ||
327 | 298 | ||