lua.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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.2 1994/11/04 10:47:49 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. void lua_error (char *s);
  25. int lua_dofile (char *filename);
  26. int lua_dostring (char *string);
  27. int lua_callfunction (lua_Object function);
  28. lua_Object lua_getparam (int number);
  29. #define lua_getresult lua_getparam
  30. float lua_getnumber (lua_Object object);
  31. char *lua_getstring (lua_Object object);
  32. char *lua_copystring (lua_Object object);
  33. lua_CFunction lua_getcfunction (lua_Object object);
  34. void *lua_getuserdata (lua_Object object);
  35. int lua_pushnil (void);
  36. int lua_pushnumber (float n);
  37. int lua_pushstring (char *s);
  38. int lua_pushcfunction (lua_CFunction fn);
  39. int lua_pushuserdata (void *u);
  40. int lua_pushobject (lua_Object object);
  41. lua_Object lua_getglobal (char *name);
  42. int lua_storeglobal (char *name);
  43. int lua_storesubscript (void);
  44. lua_Object lua_getIndex (void);
  45. int lua_type (lua_Object object);
  46. /* for lua 1.1 */
  47. #define lua_register(n,f) (lua_pushcfunction(f), lua_storeglobal(n))
  48. #define lua_call(f) lua_callfunction(lua_getglobal(f))
  49. #define lua_getindexed(o,n) (lua_pushobject(o), lua_pushnumber(n), lua_getIndex())
  50. #define lua_getfield(o,f) (lua_pushobject(o), lua_pushstring(f), lua_getIndex())
  51. #define lua_isnil(_) (lua_type(_)==LUA_T_NIL)
  52. #define lua_isnumber(_) (lua_type(_)==LUA_T_NUMBER)
  53. #define lua_isstring(_) (lua_type(_)==LUA_T_STRING)
  54. #define lua_istable(_) (lua_type(_)==LUA_T_ARRAY)
  55. #define lua_isfunction(_) (lua_type(_)==LUA_T_FUNCTION)
  56. #define lua_iscfunction(_) (lua_type(_)==LUA_T_CFUNCTION)
  57. #define lua_isuserdata(_) (lua_type(_)>=LUA_T_USERDATA)
  58. #endif