lua.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.41 1997/04/02 22:52:42 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. lua_Object lua_setfallback (char *event, lua_CFunction fallback);
  16. void lua_setintmethod (int tag, char *event, lua_CFunction method);
  17. void lua_getintmethod (int tag, char *event); /* out: method */
  18. void 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. int lua_call (char *funcname);
  27. /* In: parameters; Out: returns */
  28. void lua_beginblock (void);
  29. void lua_endblock (void);
  30. lua_Object lua_lua2C (int number);
  31. #define lua_getparam(_) lua_lua2C(_)
  32. #define lua_getresult(_) lua_lua2C(_)
  33. int lua_isnil (lua_Object object);
  34. int lua_istable (lua_Object object);
  35. int lua_isuserdata (lua_Object object);
  36. int lua_iscfunction (lua_Object object);
  37. int lua_isnumber (lua_Object object);
  38. int lua_isstring (lua_Object object);
  39. int lua_isfunction (lua_Object object);
  40. float lua_getnumber (lua_Object object);
  41. char *lua_getstring (lua_Object object);
  42. lua_CFunction lua_getcfunction (lua_Object object);
  43. void *lua_getbinarydata (lua_Object object);
  44. int lua_getbindatasize (lua_Object object);
  45. void lua_pushnil (void);
  46. void lua_pushnumber (float n);
  47. void lua_pushstring (char *s);
  48. void lua_pushcfunction (lua_CFunction fn);
  49. void lua_pushbinarydata (void *buff, int size, int tag);
  50. void lua_pushusertag (void *u, int tag);
  51. void lua_pushobject (lua_Object object);
  52. lua_Object lua_getglobal (char *name);
  53. lua_Object lua_basicgetglobal (char *name);
  54. void lua_setglobal (char *name); /* In: value */
  55. void lua_basicsetglobal (char *name); /* In: value */
  56. void lua_storesubscript (void); /* In: table, index, value */
  57. void lua_basicstoreindex (void); /* In: table, index, value */
  58. lua_Object lua_getsubscript (void); /* In: table, index */
  59. lua_Object lua_basicindex (void); /* In: table, index */
  60. int lua_tag (lua_Object object);
  61. int lua_ref (int lock); /* In: value */
  62. lua_Object lua_getref (int ref);
  63. void lua_pushref (int ref);
  64. void lua_unref (int ref);
  65. lua_Object lua_createtable (void);
  66. /* =============================================================== */
  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_setglobal(n))
  70. #define lua_pushuserdata(u) lua_pushusertag(u, 0)
  71. /* =============================================================== */
  72. /* for compatibility with old versions. Avoid using these macros/functions */
  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_getsubscript())
  83. #define lua_getfield(o,f) (lua_pushobject(o), lua_pushliteral(f), lua_getsubscript())
  84. #define lua_copystring(o) (strdup(lua_getstring(o)))
  85. #endif