lua.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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.17 1995/10/06 14:11:10 roberto 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_MARK = -7,
  22. LUA_T_CMARK = -8,
  23. LUA_T_USERDATA = 0
  24. } lua_Type;
  25. /* Public Part */
  26. #define LUA_NOOBJECT 0
  27. typedef void (*lua_CFunction) (void);
  28. typedef unsigned int lua_Object;
  29. lua_Object lua_setfallback (char *name, lua_CFunction fallback);
  30. void lua_error (char *s);
  31. int lua_dofile (char *filename);
  32. int lua_dostring (char *string);
  33. int lua_callfunction (lua_Object function);
  34. int lua_call (char *funcname);
  35. void lua_beginblock (void);
  36. void lua_endblock (void);
  37. lua_Object lua_getparam (int number);
  38. #define lua_getresult(_) lua_getparam(_)
  39. float lua_getnumber (lua_Object object);
  40. char *lua_getstring (lua_Object object);
  41. lua_CFunction lua_getcfunction (lua_Object object);
  42. void *lua_getuserdata (lua_Object object);
  43. void lua_pushnil (void);
  44. void lua_pushnumber (float n);
  45. void lua_pushstring (char *s);
  46. void lua_pushliteral (char *s);
  47. void lua_pushcfunction (lua_CFunction fn);
  48. void lua_pushusertag (void *u, int tag);
  49. void lua_pushobject (lua_Object object);
  50. lua_Object lua_getglobal (char *name);
  51. void lua_storeglobal (char *name);
  52. void lua_storesubscript (void);
  53. lua_Object lua_getsubscript (void);
  54. int lua_type (lua_Object object);
  55. int lua_lock (void);
  56. lua_Object lua_getlocked (int ref);
  57. void lua_pushlocked (int ref);
  58. void lua_unlock (int ref);
  59. lua_Object lua_createtable (void);
  60. /* some useful macros */
  61. #define lua_lockobject(o) (lua_pushobject(o), lua_lock())
  62. #define lua_register(n,f) (lua_pushcfunction(f), lua_storeglobal(n))
  63. #define lua_pushuserdata(u) lua_pushusertag(u, LUA_T_USERDATA)
  64. #define lua_isnil(_) (lua_type(_)==LUA_T_NIL)
  65. #define lua_isnumber(_) (lua_type(_)==LUA_T_NUMBER)
  66. #define lua_isstring(_) (lua_type(_)==LUA_T_STRING)
  67. #define lua_istable(_) (lua_type(_)==LUA_T_ARRAY)
  68. #define lua_isfunction(_) (lua_type(_)==LUA_T_FUNCTION)
  69. #define lua_iscfunction(_) (lua_type(_)==LUA_T_CFUNCTION)
  70. #define lua_isuserdata(_) (lua_type(_)>=LUA_T_USERDATA)
  71. /* for lua 1.1 compatibility. Avoid using these macros */
  72. #define lua_getindexed(o,n) (lua_pushobject(o), lua_pushnumber(n), lua_getsubscript())
  73. #define lua_getfield(o,f) (lua_pushobject(o), lua_pushliteral(f), lua_getsubscript())
  74. #define lua_copystring(o) (strdup(lua_getstring(o)))
  75. #endif