lua.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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.36 1997/03/17 17:01:10 roberto Exp roberto $
  6. */
  7. #ifndef lua_h
  8. #define lua_h
  9. #define LUA_VERSION "Lua 2.?"
  10. #define LUA_COPYRIGHT "Copyright (C) 1994-1996 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_setglobalmethod (char *event, lua_CFunction method);
  18. int lua_newtag (char *t);
  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_getbinarydata (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_pushbinarydata (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_basicgetglobal (char *name);
  53. void lua_storeglobal (char *name); /* In: value */
  54. void lua_basicstoreglobal (char *name); /* In: value */
  55. void lua_storesubscript (void); /* In: table, index, value */
  56. void lua_basicstoreindex (void); /* In: table, index, value */
  57. lua_Object lua_getsubscript (void); /* In: table, index */
  58. lua_Object lua_basicindex (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_storeglobal(n))
  69. #define lua_pushuserdata(u) lua_pushusertag(u, 0)
  70. /* =============================================================== */
  71. /* for compatibility with old versions. Avoid using these macros */
  72. #define lua_type(o) (lua_tag(o))
  73. #define lua_getuserdata(o) (*(void **)lua_getbinarydata(o))
  74. #define lua_lockobject(o) lua_refobject(o,1)
  75. #define lua_lock() lua_ref(1)
  76. #define lua_getlocked lua_getref
  77. #define lua_pushlocked lua_pushref
  78. #define lua_unlock lua_unref
  79. #define lua_pushliteral(o) lua_pushstring(o)
  80. #define lua_getindexed(o,n) (lua_pushobject(o), lua_pushnumber(n), lua_getsubscript())
  81. #define lua_getfield(o,f) (lua_pushobject(o), lua_pushliteral(f), lua_getsubscript())
  82. #define lua_copystring(o) (strdup(lua_getstring(o)))
  83. #endif