lua.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. ** LUA - An Extensible Extension Language
  3. ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
  4. ** e-mail: [email protected]
  5. ** $Id: lua.h,v 4.7 1997/06/12 18:27:29 roberto Exp roberto $
  6. */
  7. #ifndef lua_h
  8. #define lua_h
  9. #define LUA_VERSION "Lua 3.0 (alpha)"
  10. #define LUA_COPYRIGHT "Copyright (C) 1994-1997 TeCGraf"
  11. #define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo"
  12. #define LUA_NOOBJECT 0
  13. #define LUA_ANYTAG (-1)
  14. typedef void (*lua_CFunction) (void);
  15. typedef unsigned int lua_Object;
  16. lua_Object lua_settagmethod (int tag, char *event, lua_CFunction method);
  17. lua_Object lua_gettagmethod (int tag, char *event);
  18. lua_Object lua_seterrormethod (lua_CFunction method);
  19. int lua_newtag (void);
  20. void lua_settag (int tag); /* In: object */
  21. void lua_error (char *s);
  22. int lua_dofile (char *filename); /* Out: returns */
  23. int lua_dostring (char *string); /* Out: returns */
  24. int lua_callfunction (lua_Object f);
  25. /* In: parameters; Out: returns */
  26. void lua_beginblock (void);
  27. void lua_endblock (void);
  28. lua_Object lua_lua2C (int number);
  29. #define lua_getparam(_) lua_lua2C(_)
  30. #define lua_getresult(_) lua_lua2C(_)
  31. int lua_isnil (lua_Object object);
  32. int lua_istable (lua_Object object);
  33. int lua_isuserdata (lua_Object object);
  34. int lua_iscfunction (lua_Object object);
  35. int lua_isnumber (lua_Object object);
  36. int lua_isstring (lua_Object object);
  37. int lua_isfunction (lua_Object object);
  38. float lua_getnumber (lua_Object object);
  39. char *lua_getstring (lua_Object object);
  40. lua_CFunction lua_getcfunction (lua_Object object);
  41. void lua_pushnil (void);
  42. void lua_pushnumber (float n);
  43. void lua_pushstring (char *s);
  44. void lua_pushcfunction (lua_CFunction fn);
  45. void lua_pushusertag (void *u, int tag);
  46. void lua_pushobject (lua_Object object);
  47. lua_Object lua_pop (void);
  48. lua_Object lua_getglobal (char *name);
  49. lua_Object lua_rawgetglobal (char *name);
  50. void lua_setglobal (char *name); /* In: value */
  51. void lua_rawsetglobal (char *name); /* In: value */
  52. void lua_settable (void); /* In: table, index, value */
  53. void lua_rawsettable (void); /* In: table, index, value */
  54. lua_Object lua_gettable (void); /* In: table, index */
  55. lua_Object lua_rawgettable (void); /* In: table, index */
  56. int lua_tag (lua_Object object);
  57. int lua_ref (int lock); /* In: value */
  58. lua_Object lua_getref (int ref);
  59. void lua_unref (int ref);
  60. lua_Object lua_createtable (void);
  61. long lua_collectgarbage (long limit);
  62. /* =============================================================== */
  63. /* some useful macros */
  64. #define lua_call(name) lua_callfunction(lua_getglobal(name))
  65. #define lua_pushref(ref) lua_pushobject(lua_getref(ref))
  66. #define lua_refobject(o,l) (lua_pushobject(o), lua_ref(l))
  67. #define lua_register(n,f) (lua_pushcfunction(f), lua_setglobal(n))
  68. #define lua_pushuserdata(u) lua_pushusertag(u, 0)
  69. /* =============================================================== */
  70. /* for compatibility with old versions. Avoid using these macros/functions */
  71. lua_Object lua_setfallback (char *event, lua_CFunction fallback);
  72. #define lua_storeglobal lua_setglobal
  73. #define lua_type lua_tag
  74. void *lua_getuserdata (lua_Object object);
  75. #define lua_lockobject(o) lua_refobject(o,1)
  76. #define lua_lock() lua_ref(1)
  77. #define lua_getlocked lua_getref
  78. #define lua_pushlocked lua_pushref
  79. #define lua_unlock lua_unref
  80. #define lua_pushliteral(o) lua_pushstring(o)
  81. #define lua_getindexed(o,n) (lua_pushobject(o), lua_pushnumber(n), lua_gettable())
  82. #define lua_getfield(o,f) (lua_pushobject(o), lua_pushliteral(f), lua_gettable())
  83. #define lua_copystring(o) (strdup(lua_getstring(o)))
  84. #define lua_getsubscript lua_gettable
  85. #define lua_storesubscript lua_settable
  86. #endif