lua.h 2.6 KB

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