2
0

lua.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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.1 1997/04/03 18:26:08 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. typedef void (*lua_CFunction) (void);
  14. typedef unsigned int lua_Object;
  15. void lua_settagmethod (int tag, char *event, lua_CFunction method);
  16. void lua_gettagmethod (int tag, char *event); /* out: method */
  17. void lua_seterrormethod (lua_CFunction method);
  18. int lua_newtag (void);
  19. void lua_settag (int tag); /* In: object */
  20. void lua_error (char *s);
  21. int lua_dofile (char *filename); /* Out: returns */
  22. int lua_dostring (char *string); /* Out: returns */
  23. int lua_callfunction (lua_Object f);
  24. /* In: parameters; Out: returns */
  25. int lua_call (char *funcname);
  26. /* In: parameters; Out: returns */
  27. void lua_beginblock (void);
  28. void lua_endblock (void);
  29. lua_Object lua_lua2C (int number);
  30. #define lua_getparam(_) lua_lua2C(_)
  31. #define lua_getresult(_) lua_lua2C(_)
  32. int lua_isnil (lua_Object object);
  33. int lua_istable (lua_Object object);
  34. int lua_isuserdata (lua_Object object);
  35. int lua_iscfunction (lua_Object object);
  36. int lua_isnumber (lua_Object object);
  37. int lua_isstring (lua_Object object);
  38. int lua_isfunction (lua_Object object);
  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_getbindata (lua_Object object);
  43. int lua_getbindatasize (lua_Object object);
  44. void lua_pushnil (void);
  45. void lua_pushnumber (float n);
  46. void lua_pushstring (char *s);
  47. void lua_pushcfunction (lua_CFunction fn);
  48. void lua_pushbindata (void *buff, int size, int tag);
  49. void lua_pushusertag (void *u, int tag);
  50. void lua_pushobject (lua_Object object);
  51. lua_Object lua_getglobal (char *name);
  52. lua_Object lua_rawgetglobal (char *name);
  53. void lua_setglobal (char *name); /* In: value */
  54. void lua_rawsetglobal (char *name); /* In: value */
  55. void lua_settable (void); /* In: table, index, value */
  56. void lua_rawsettable (void); /* In: table, index, value */
  57. lua_Object lua_gettable (void); /* In: table, index */
  58. lua_Object lua_rawgettable (void); /* In: table, index */
  59. int lua_tag (lua_Object object);
  60. int lua_ref (int lock); /* In: value */
  61. lua_Object lua_getref (int ref);
  62. void lua_pushref (int ref);
  63. void lua_unref (int ref);
  64. lua_Object lua_createtable (void);
  65. /* =============================================================== */
  66. /* some useful macros */
  67. #define lua_refobject(o,l) (lua_pushobject(o), lua_ref(l))
  68. #define lua_register(n,f) (lua_pushcfunction(f), lua_setglobal(n))
  69. #define lua_pushuserdata(u) lua_pushusertag(u, 0)
  70. /* =============================================================== */
  71. /* for compatibility with old versions. Avoid using these macros/functions */
  72. lua_Object lua_setfallback (char *event, lua_CFunction fallback);
  73. #define lua_storeglobal(n) lua_setglobal(n)
  74. #define lua_type(o) (lua_tag(o))
  75. void *lua_getuserdata (lua_Object object);
  76. #define lua_lockobject(o) lua_refobject(o,1)
  77. #define lua_lock() lua_ref(1)
  78. #define lua_getlocked lua_getref
  79. #define lua_pushlocked lua_pushref
  80. #define lua_unlock lua_unref
  81. #define lua_pushliteral(o) lua_pushstring(o)
  82. #define lua_getindexed(o,n) (lua_pushobject(o), lua_pushnumber(n), lua_gettable())
  83. #define lua_getfield(o,f) (lua_pushobject(o), lua_pushliteral(f), lua_gettable())
  84. #define lua_copystring(o) (strdup(lua_getstring(o)))
  85. #define lua_getsubscript lua_gettable
  86. #endif