lua.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 roberto $
  6. */
  7. #ifndef lua_h
  8. #define lua_h
  9. #define LUA_VERSION "Lua 2.1"
  10. #define LUA_COPYRIGHT "Copyright (C) 1994, 1995 TeCGraf \n\
  11. (written by W. Celes, R. Ierusalimschy & L. H. de Figueiredo)"
  12. /* Private Part */
  13. typedef enum
  14. {
  15. LUA_T_NIL = -1,
  16. LUA_T_NUMBER = -2,
  17. LUA_T_STRING = -3,
  18. LUA_T_ARRAY = -4,
  19. LUA_T_FUNCTION = -5,
  20. LUA_T_CFUNCTION= -6,
  21. LUA_T_USERDATA = 0
  22. } lua_Type;
  23. /* Public Part */
  24. #define LUA_NOOBJECT 0
  25. typedef void (*lua_CFunction) (void);
  26. typedef unsigned int lua_Object;
  27. lua_Object lua_setfallback (char *name, lua_CFunction fallback);
  28. void lua_error (char *s);
  29. int lua_dofile (char *filename);
  30. int lua_dostring (char *string);
  31. int lua_callfunction (lua_Object function);
  32. int lua_call (char *funcname);
  33. void lua_beginblock (void);
  34. void lua_endblock (void);
  35. lua_Object lua_getparam (int number);
  36. #define lua_getresult(_) lua_getparam(_)
  37. float lua_getnumber (lua_Object object);
  38. char *lua_getstring (lua_Object object);
  39. lua_CFunction lua_getcfunction (lua_Object object);
  40. void *lua_getuserdata (lua_Object object);
  41. void lua_pushnil (void);
  42. void lua_pushnumber (float n);
  43. void lua_pushstring (char *s);
  44. void lua_pushliteral (char *s);
  45. void lua_pushcfunction (lua_CFunction fn);
  46. void lua_pushusertag (void *u, int tag);
  47. void lua_pushobject (lua_Object object);
  48. lua_Object lua_getglobal (char *name);
  49. void lua_storeglobal (char *name);
  50. void lua_storesubscript (void);
  51. lua_Object lua_getsubscript (void);
  52. int lua_type (lua_Object object);
  53. int lua_lock (void);
  54. lua_Object lua_getlocked (int ref);
  55. void lua_pushlocked (int ref);
  56. void lua_unlock (int ref);
  57. lua_Object lua_createtable (void);
  58. /* some useful macros */
  59. #define lua_lockobject(o) (lua_pushobject(o), lua_lock())
  60. #define lua_register(n,f) (lua_pushcfunction(f), lua_storeglobal(n))
  61. #define lua_pushuserdata(u) lua_pushusertag(u, LUA_T_USERDATA)
  62. #define lua_isnil(_) (lua_type(_)==LUA_T_NIL)
  63. #define lua_isnumber(_) (lua_type(_)==LUA_T_NUMBER)
  64. #define lua_isstring(_) (lua_type(_)==LUA_T_STRING)
  65. #define lua_istable(_) (lua_type(_)==LUA_T_ARRAY)
  66. #define lua_isfunction(_) (lua_type(_)==LUA_T_FUNCTION)
  67. #define lua_iscfunction(_) (lua_type(_)==LUA_T_CFUNCTION)
  68. #define lua_isuserdata(_) (lua_type(_)>=LUA_T_USERDATA)
  69. /* for lua 1.1 compatibility. Avoid using these macros */
  70. #define lua_getindexed(o,n) (lua_pushobject(o), lua_pushnumber(n), lua_getsubscript())
  71. #define lua_getfield(o,f) (lua_pushobject(o), lua_pushliteral(f), lua_getsubscript())
  72. #define lua_copystring(o) (strdup(lua_getstring(o)))
  73. #endif