lua.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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.1 1994/11/02 20:30:53 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. } Type;
  21. /* Public Part */
  22. typedef void (*lua_CFunction) (void);
  23. typedef struct Object *lua_Object;
  24. #define lua_register(n,f) (lua_pushcfunction(f), lua_storeglobal(n))
  25. void lua_errorfunction (void (*fn) (char *s));
  26. void lua_error (char *s);
  27. int lua_dofile (char *filename);
  28. int lua_dostring (char *string);
  29. int lua_callfunction (lua_Object function);
  30. lua_Object lua_getparam (int number);
  31. float lua_getnumber (lua_Object object);
  32. char *lua_getstring (lua_Object object);
  33. char *lua_copystring (lua_Object object);
  34. lua_CFunction lua_getcfunction (lua_Object object);
  35. void *lua_getuserdata (lua_Object object);
  36. void *lua_gettable (lua_Object object);
  37. lua_Object lua_getfield (lua_Object object, char *field);
  38. lua_Object lua_getindexed (lua_Object object, float index);
  39. lua_Object lua_getglobal (char *name);
  40. int lua_pushnil (void);
  41. int lua_pushnumber (float n);
  42. int lua_pushstring (char *s);
  43. int lua_pushcfunction (lua_CFunction fn);
  44. int lua_pushuserdata (void *u);
  45. int lua_pushtable (void *t);
  46. int lua_pushsubscript (void);
  47. int lua_pushobject (lua_Object object);
  48. int lua_storeglobal (char *name);
  49. int lua_storefield (lua_Object object, char *field);
  50. int lua_storeindexed (lua_Object object, float index);
  51. int lua_storesubscript (void);
  52. int lua_type (lua_Object object);
  53. /* for lua 1.1 */
  54. #define lua_call(f) lua_callfunction(lua_getglobal(f))
  55. #define lua_getindexed(o,n) (lua_pushnumber(n), lua_getIndex(o))
  56. #define lua_getfield(o,f) (lua_pushstring(f), lua_getIndex(o))
  57. #define lua_isnil(_) (lua_type(_)==LUA_T_NIL)
  58. #define lua_isnumber(_) (lua_type(_)==LUA_T_NUMBER)
  59. #define lua_isstring(_) (lua_type(_)==LUA_T_STRING)
  60. #define lua_istable(_) (lua_type(_)==LUA_T_ARRAY)
  61. #define lua_isfunction(_) (lua_type(_)==LUA_T_FUNCTION)
  62. #define lua_iscfunction(_) (lua_type(_)==LUA_T_CFUNCTION)
  63. #define lua_isuserdata(_) (lua_type(_)>=LUA_T_USERDATA)
  64. #endif