2 ** LUA - An Extensible Extension Language
3 ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
4 ** e-mail: lua@tecgraf.puc-rio.br
5 ** $Id: lua.h,v 4.11 1997/06/23 18:27:53 roberto Exp $
12 #define LUA_VERSION "Lua 3.0"
13 #define LUA_COPYRIGHT "Copyright (C) 1994-1997 TeCGraf"
14 #define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo"
17 #define LUA_NOOBJECT 0
19 #define LUA_ANYTAG (-1)
21 typedef void (*lua_CFunction
) (void);
22 typedef unsigned int lua_Object
;
24 lua_Object
lua_settagmethod (int tag
, char *event
); /* In: new method */
25 lua_Object
lua_gettagmethod (int tag
, char *event
);
26 lua_Object
lua_seterrormethod (void); /* In: new method */
28 int lua_newtag (void);
29 void lua_settag (int tag
); /* In: object */
31 void lua_error (char *s
);
32 int lua_dofile (char *filename
); /* Out: returns */
33 int lua_dostring (char *string
); /* Out: returns */
34 int lua_callfunction (lua_Object f
);
35 /* In: parameters; Out: returns */
37 void lua_beginblock (void);
38 void lua_endblock (void);
40 lua_Object
lua_lua2C (int number
);
41 #define lua_getparam(_) lua_lua2C(_)
42 #define lua_getresult(_) lua_lua2C(_)
44 int lua_isnil (lua_Object object
);
45 int lua_istable (lua_Object object
);
46 int lua_isuserdata (lua_Object object
);
47 int lua_iscfunction (lua_Object object
);
48 int lua_isnumber (lua_Object object
);
49 int lua_isstring (lua_Object object
);
50 int lua_isfunction (lua_Object object
);
52 float lua_getnumber (lua_Object object
);
53 char *lua_getstring (lua_Object object
);
54 lua_CFunction
lua_getcfunction (lua_Object object
);
55 void *lua_getuserdata (lua_Object object
);
58 void lua_pushnil (void);
59 void lua_pushnumber (float n
);
60 void lua_pushstring (char *s
);
61 void lua_pushcfunction (lua_CFunction fn
);
62 void lua_pushusertag (void *u
, int tag
);
63 void lua_pushobject (lua_Object object
);
65 lua_Object
lua_pop (void);
67 lua_Object
lua_getglobal (char *name
);
68 lua_Object
lua_rawgetglobal (char *name
);
69 void lua_setglobal (char *name
); /* In: value */
70 void lua_rawsetglobal (char *name
); /* In: value */
72 void lua_settable (void); /* In: table, index, value */
73 void lua_rawsettable (void); /* In: table, index, value */
74 lua_Object
lua_gettable (void); /* In: table, index */
75 lua_Object
lua_rawgettable (void); /* In: table, index */
77 int lua_tag (lua_Object object
);
80 int lua_ref (int lock
); /* In: value */
81 lua_Object
lua_getref (int ref
);
82 void lua_unref (int ref
);
84 lua_Object
lua_createtable (void);
86 long lua_collectgarbage (long limit
);
89 /* =============================================================== */
90 /* some useful macros */
92 #define lua_call(name) lua_callfunction(lua_getglobal(name))
94 #define lua_pushref(ref) lua_pushobject(lua_getref(ref))
96 #define lua_refobject(o,l) (lua_pushobject(o), lua_ref(l))
98 #define lua_register(n,f) (lua_pushcfunction(f), lua_setglobal(n))
100 #define lua_pushuserdata(u) lua_pushusertag(u, 0)
105 /* ==========================================================================
106 ** for compatibility with old versions. Avoid using these macros/functions
107 ** If your program does not use any of these, define LUA_COMPAT2_5 to 0
110 #ifndef LUA_COMPAT2_5
111 #define LUA_COMPAT2_5 1
118 lua_Object
lua_setfallback (char *event
, lua_CFunction fallback
);
120 #define lua_storeglobal lua_setglobal
121 #define lua_type lua_tag
123 #define lua_lockobject(o) lua_refobject(o,1)
124 #define lua_lock() lua_ref(1)
125 #define lua_getlocked lua_getref
126 #define lua_pushlocked lua_pushref
127 #define lua_unlock lua_unref
129 #define lua_pushliteral(o) lua_pushstring(o)
131 #define lua_getindexed(o,n) (lua_pushobject(o), lua_pushnumber(n), lua_gettable())
132 #define lua_getfield(o,f) (lua_pushobject(o), lua_pushstring(f), lua_gettable())
134 #define lua_copystring(o) (strdup(lua_getstring(o)))
136 #define lua_getsubscript lua_gettable
137 #define lua_storesubscript lua_settable