aboutsummaryrefslogtreecommitdiff
path: root/lua.h
diff options
context:
space:
mode:
Diffstat (limited to 'lua.h')
-rw-r--r--lua.h85
1 files changed, 28 insertions, 57 deletions
diff --git a/lua.h b/lua.h
index 9cc3f081..52179b84 100644
--- a/lua.h
+++ b/lua.h
@@ -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
92typedef LUA_NUMBER lua_Number; 92typedef LUA_NUMBER lua_Number;
93 93
94/* Lua character type */
95#ifndef L_CHAR
96#define L_CHAR char
97#endif
98typedef 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
129LUA_API const lua_char *lua_type (lua_State *L, int index); 123LUA_API const char *lua_type (lua_State *L, int index);
130LUA_API int lua_isnumber (lua_State *L, int index); 124LUA_API int lua_isnumber (lua_State *L, int index);
131LUA_API int lua_isstring (lua_State *L, int index); 125LUA_API int lua_isstring (lua_State *L, int index);
132LUA_API int lua_iscfunction (lua_State *L, int index); 126LUA_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);
137LUA_API int lua_lessthan (lua_State *L, int index1, int index2); 131LUA_API int lua_lessthan (lua_State *L, int index1, int index2);
138 132
139LUA_API lua_Number lua_tonumber (lua_State *L, int index); 133LUA_API lua_Number lua_tonumber (lua_State *L, int index);
140LUA_API const lua_char *lua_tostring (lua_State *L, int index); 134LUA_API const char *lua_tostring (lua_State *L, int index);
141LUA_API size_t lua_strlen (lua_State *L, int index); 135LUA_API size_t lua_strlen (lua_State *L, int index);
142LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index); 136LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index);
143LUA_API void *lua_touserdata (lua_State *L, int index); 137LUA_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*/
150LUA_API void lua_pushnil (lua_State *L); 144LUA_API void lua_pushnil (lua_State *L);
151LUA_API void lua_pushnumber (lua_State *L, lua_Number n); 145LUA_API void lua_pushnumber (lua_State *L, lua_Number n);
152LUA_API void lua_pushlstring (lua_State *L, const lua_char *s, size_t len); 146LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len);
153LUA_API void lua_pushstring (lua_State *L, const lua_char *s); 147LUA_API void lua_pushstring (lua_State *L, const char *s);
154LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n); 148LUA_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*/
160LUA_API void lua_getglobal (lua_State *L, const lua_char *name); 154LUA_API void lua_getglobal (lua_State *L, const char *name);
161LUA_API void lua_gettable (lua_State *L, int index); 155LUA_API void lua_gettable (lua_State *L, int index);
162LUA_API void lua_rawget (lua_State *L, int index); 156LUA_API void lua_rawget (lua_State *L, int index);
163LUA_API void lua_rawgeti (lua_State *L, int index, int n); 157LUA_API void lua_rawgeti (lua_State *L, int index, int n);
164LUA_API void lua_gettagmethod (lua_State *L, int tag, const lua_char *event); 158LUA_API void lua_gettagmethod (lua_State *L, int tag, const char *event);
165LUA_API void lua_newtable (lua_State *L); 159LUA_API void lua_newtable (lua_State *L);
166LUA_API void lua_getweakregistry (lua_State *L); 160LUA_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*/
172LUA_API void lua_setglobal (lua_State *L, const lua_char *name); 166LUA_API void lua_setglobal (lua_State *L, const char *name);
173LUA_API void lua_settable (lua_State *L, int index); 167LUA_API void lua_settable (lua_State *L, int index);
174LUA_API void lua_rawset (lua_State *L, int index); 168LUA_API void lua_rawset (lua_State *L, int index);
175LUA_API void lua_rawseti (lua_State *L, int index, int n); 169LUA_API void lua_rawseti (lua_State *L, int index, int n);
176LUA_API void lua_setglobals (lua_State *L); 170LUA_API void lua_setglobals (lua_State *L);
177LUA_API void lua_settagmethod (lua_State *L, int tag, const lua_char *event); 171LUA_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*/
183LUA_API int lua_call (lua_State *L, int nargs, int nresults); 177LUA_API int lua_call (lua_State *L, int nargs, int nresults);
184LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults); 178LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults);
185LUA_API int lua_loadfile (lua_State *L, const lua_char *filename); 179LUA_API int lua_loadfile (lua_State *L, const char *filename);
186LUA_API int lua_dofile (lua_State *L, const lua_char *filename); 180LUA_API int lua_dofile (lua_State *L, const char *filename);
187LUA_API int lua_dostring (lua_State *L, const lua_char *str); 181LUA_API int lua_dostring (lua_State *L, const char *str);
188LUA_API int lua_loadbuffer (lua_State *L, const lua_char *buff, size_t size, 182LUA_API int lua_loadbuffer (lua_State *L, const char *buff, size_t size,
189 const lua_char *name); 183 const char *name);
190LUA_API int lua_dobuffer (lua_State *L, const lua_char *buff, size_t size, 184LUA_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*/
203LUA_API int lua_newtype (lua_State *L, const lua_char *name, int basictype); 197LUA_API int lua_newtype (lua_State *L, const char *name, int basictype);
204LUA_API void lua_settag (lua_State *L, int tag); 198LUA_API void lua_settag (lua_State *L, int tag);
205 199
206LUA_API int lua_name2tag (lua_State *L, const lua_char *name); 200LUA_API int lua_name2tag (lua_State *L, const char *name);
207LUA_API const lua_char *lua_tag2name (lua_State *L, int tag); 201LUA_API const char *lua_tag2name (lua_State *L, int tag);
208 202
209LUA_API void lua_error (lua_State *L, const lua_char *s); 203LUA_API void lua_error (lua_State *L, const char *s);
210 204
211LUA_API int lua_next (lua_State *L, int index); 205LUA_API int lua_next (lua_State *L, int index);
212LUA_API int lua_getn (lua_State *L, int index); 206LUA_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