Imported from ../lua-2.1.tar.gz.
[lua.git] / include / lua.h
blob09a0909e11cf9f2e93246d618c26a1efb004604f
1 /*
2 ** LUA - Linguagem para Usuarios de Aplicacao
3 ** Grupo de Tecnologia em Computacao Grafica
4 ** TeCGraf - PUC-Rio
5 ** $Id: lua.h,v 3.16 1995/01/27 17:19:06 celes Exp $
6 */
9 #ifndef lua_h
10 #define lua_h
12 /* Private Part */
14 typedef enum
16 LUA_T_NIL = -1,
17 LUA_T_NUMBER = -2,
18 LUA_T_STRING = -3,
19 LUA_T_ARRAY = -4,
20 LUA_T_FUNCTION = -5,
21 LUA_T_CFUNCTION= -6,
22 LUA_T_USERDATA = 0
23 } lua_Type;
26 /* Public Part */
28 #define LUA_NOOBJECT 0
30 typedef void (*lua_CFunction) (void);
31 typedef unsigned int lua_Object;
33 lua_Object lua_setfallback (char *name, lua_CFunction fallback);
35 void lua_error (char *s);
36 int lua_dofile (char *filename);
37 int lua_dostring (char *string);
38 int lua_callfunction (lua_Object function);
39 int lua_call (char *funcname);
41 void lua_beginblock (void);
42 void lua_endblock (void);
44 lua_Object lua_getparam (int number);
45 #define lua_getresult(_) lua_getparam(_)
47 float lua_getnumber (lua_Object object);
48 char *lua_getstring (lua_Object object);
49 lua_CFunction lua_getcfunction (lua_Object object);
50 void *lua_getuserdata (lua_Object object);
52 void lua_pushnil (void);
53 void lua_pushnumber (float n);
54 void lua_pushstring (char *s);
55 void lua_pushliteral (char *s);
56 void lua_pushcfunction (lua_CFunction fn);
57 void lua_pushusertag (void *u, int tag);
58 void lua_pushobject (lua_Object object);
60 lua_Object lua_getglobal (char *name);
61 void lua_storeglobal (char *name);
63 void lua_storesubscript (void);
64 lua_Object lua_getsubscript (void);
66 int lua_type (lua_Object object);
68 int lua_lock (void);
69 lua_Object lua_getlocked (int ref);
70 void lua_pushlocked (int ref);
71 void lua_unlock (int ref);
73 lua_Object lua_createtable (void);
76 /* some useful macros */
78 #define lua_lockobject(o) (lua_pushobject(o), lua_lock())
80 #define lua_register(n,f) (lua_pushcfunction(f), lua_storeglobal(n))
82 #define lua_pushuserdata(u) lua_pushusertag(u, LUA_T_USERDATA)
84 #define lua_isnil(_) (lua_type(_)==LUA_T_NIL)
85 #define lua_isnumber(_) (lua_type(_)==LUA_T_NUMBER)
86 #define lua_isstring(_) (lua_type(_)==LUA_T_STRING)
87 #define lua_istable(_) (lua_type(_)==LUA_T_ARRAY)
88 #define lua_isfunction(_) (lua_type(_)==LUA_T_FUNCTION)
89 #define lua_iscfunction(_) (lua_type(_)==LUA_T_CFUNCTION)
90 #define lua_isuserdata(_) (lua_type(_)>=LUA_T_USERDATA)
93 /* for lua 1.1 compatibility. Avoid using these macros */
95 #define lua_getindexed(o,n) (lua_pushobject(o), lua_pushnumber(n), lua_getsubscript())
96 #define lua_getfield(o,f) (lua_pushobject(o), lua_pushliteral(f), lua_getsubscript())
98 #define lua_copystring(o) (strdup(lua_getstring(o)))
100 #endif