lua.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.5 1994/11/08 19:56:39 roberto Exp roberto $
  6. */
  7. #ifndef lua_h
  8. #define lua_h
  9. /* Private Part */
  10. typedef enum
  11. {
  12. LUA_T_MARK,
  13. LUA_T_NIL,
  14. LUA_T_NUMBER,
  15. LUA_T_STRING,
  16. LUA_T_ARRAY,
  17. LUA_T_FUNCTION,
  18. LUA_T_CFUNCTION,
  19. LUA_T_USERDATA
  20. } lua_Type;
  21. /* Public Part */
  22. typedef void (*lua_CFunction) (void);
  23. typedef unsigned int lua_Object;
  24. lua_Object lua_setfallback (char *name, lua_CFunction fallback);
  25. void lua_error (char *s);
  26. int lua_dofile (char *filename);
  27. int lua_dostring (char *string);
  28. int lua_callfunction (lua_Object function);
  29. int lua_call (char *funcname);
  30. lua_Object lua_getparam (int number);
  31. #define lua_getresult lua_getparam
  32. float lua_getnumber (lua_Object object);
  33. char *lua_getstring (lua_Object object);
  34. char *lua_copystring (lua_Object object);
  35. lua_CFunction lua_getcfunction (lua_Object object);
  36. void *lua_getuserdata (lua_Object object);
  37. int lua_pushnil (void);
  38. int lua_pushnumber (float n);
  39. int lua_pushstring (char *s);
  40. int lua_pushcfunction (lua_CFunction fn);
  41. int lua_pushuserdata (void *u);
  42. int lua_pushobject (lua_Object object);
  43. lua_Object lua_getglobal (char *name);
  44. int lua_storeglobal (char *name);
  45. int lua_storesubscript (void);
  46. lua_Object lua_getsubscript (void);
  47. int lua_type (lua_Object object);
  48. int lua_lock (lua_Object object);
  49. lua_Object lua_getlocked (int ref);
  50. void lua_unlock (int ref);
  51. /* for lua 1.1 */
  52. #define lua_register(n,f) (lua_pushcfunction(f), lua_storeglobal(n))
  53. #define lua_getindexed(o,n) (lua_pushobject(o), lua_pushnumber(n), lua_getsubscript())
  54. #define lua_getfield(o,f) (lua_pushobject(o), lua_pushstring(f), lua_getsubscript())
  55. #define lua_isnil(_) (lua_type(_)==LUA_T_NIL)
  56. #define lua_isnumber(_) (lua_type(_)==LUA_T_NUMBER)
  57. #define lua_isstring(_) (lua_type(_)==LUA_T_STRING)
  58. #define lua_istable(_) (lua_type(_)==LUA_T_ARRAY)
  59. #define lua_isfunction(_) (lua_type(_)==LUA_T_FUNCTION)
  60. #define lua_iscfunction(_) (lua_type(_)==LUA_T_CFUNCTION)
  61. #define lua_isuserdata(_) (lua_type(_)>=LUA_T_USERDATA)
  62. #endif