lua.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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.27 1996/04/25 14:10:00 roberto Exp roberto $
  6. */
  7. #ifndef lua_h
  8. #define lua_h
  9. #define LUA_VERSION "Lua 2.4"
  10. #define LUA_COPYRIGHT "Copyright (C) 1994, 1995 TeCGraf"
  11. #define LUA_AUTHORS "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_LINE = -9,
  24. LUA_T_USERDATA = 0
  25. } lua_Type;
  26. /* Public Part */
  27. #define LUA_NOOBJECT 0
  28. typedef void (*lua_CFunction) (void);
  29. typedef unsigned int lua_Object;
  30. lua_Object lua_setfallback (char *name, lua_CFunction fallback);
  31. void lua_error (char *s);
  32. int lua_dofile (char *filename);
  33. int lua_dostring (char *string);
  34. int lua_callfunction (lua_Object function);
  35. int lua_call (char *funcname);
  36. void lua_beginblock (void);
  37. void lua_endblock (void);
  38. lua_Object lua_getparam (int number);
  39. #define lua_getresult(_) lua_getparam(_)
  40. #define lua_isnil(_) (lua_type(_)==LUA_T_NIL)
  41. #define lua_istable(_) (lua_type(_)==LUA_T_ARRAY)
  42. #define lua_isuserdata(_) (lua_type(_)>=LUA_T_USERDATA)
  43. #define lua_iscfunction(_) (lua_type(_)==LUA_T_CFUNCTION)
  44. int lua_isnumber (lua_Object object);
  45. int lua_isstring (lua_Object object);
  46. int lua_isfunction (lua_Object object);
  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);
  51. void lua_pushnil (void);
  52. void lua_pushnumber (float n);
  53. void lua_pushstring (char *s);
  54. void lua_pushcfunction (lua_CFunction fn);
  55. void lua_pushusertag (void *u, int tag);
  56. void lua_pushobject (lua_Object object);
  57. lua_Object lua_getglobal (char *name);
  58. void lua_storeglobal (char *name);
  59. void lua_storesubscript (void);
  60. lua_Object lua_getsubscript (void);
  61. int lua_type (lua_Object object);
  62. int lua_ref (int lock);
  63. lua_Object lua_getref (int ref);
  64. void lua_pushref (int ref);
  65. void lua_unref (int ref);
  66. lua_Object lua_createtable (void);
  67. /* some useful macros */
  68. #define lua_refobject(o,l) (lua_pushobject(o), lua_ref(l))
  69. #define lua_register(n,f) (lua_pushcfunction(f), lua_storeglobal(n))
  70. #define lua_pushuserdata(u) lua_pushusertag(u, LUA_T_USERDATA)
  71. /* for compatibility with old versions. Avoid using these macros */
  72. #define lua_lockobject(o) lua_refobject(o,1)
  73. #define lua_lock() lua_ref(1)
  74. #define lua_getlocked lua_getref
  75. #define lua_pushlocked lua_pushref
  76. #define lua_unlock lua_unref
  77. #define lua_pushliteral(o) lua_pushstring(o)
  78. #define lua_getindexed(o,n) (lua_pushobject(o), lua_pushnumber(n), lua_getsubscript())
  79. #define lua_getfield(o,f) (lua_pushobject(o), lua_pushliteral(f), lua_getsubscript())
  80. #define lua_copystring(o) (strdup(lua_getstring(o)))
  81. #endif