lauxlib.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. ** $Id: lauxlib.h,v 1.21 2000/08/29 20:43:28 roberto Exp roberto $
  3. ** Auxiliary functions for building Lua libraries
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef lauxlib_h
  7. #define lauxlib_h
  8. #include <stddef.h>
  9. #include "lua.h"
  10. struct luaL_reg {
  11. const char *name;
  12. lua_CFunction func;
  13. };
  14. void luaL_openlib (lua_State *L, const struct luaL_reg *l, int n);
  15. void luaL_argerror (lua_State *L, int numarg, const char *extramsg);
  16. const char *luaL_check_lstr (lua_State *L, int numArg, size_t *len);
  17. const char *luaL_opt_lstr (lua_State *L, int numArg, const char *def,
  18. size_t *len);
  19. double luaL_check_number (lua_State *L, int numArg);
  20. double luaL_opt_number (lua_State *L, int numArg, double def);
  21. void luaL_checkstack (lua_State *L, int space, const char *msg);
  22. void luaL_checktype (lua_State *L, int narg, const char *tname);
  23. void luaL_verror (lua_State *L, const char *fmt, ...);
  24. int luaL_findstring (const char *name, const char *const list[]);
  25. void luaL_chunkid (char *out, const char *source, int len);
  26. void luaL_filesource (char *out, const char *filename, int len);
  27. char *luaL_openspace (lua_State *L, size_t size);
  28. void luaL_resetbuffer (lua_State *L);
  29. void luaL_addchar (lua_State *L, int c);
  30. size_t luaL_getsize (lua_State *L);
  31. void luaL_addsize (lua_State *L, size_t n);
  32. size_t luaL_newbuffer (lua_State *L, size_t size);
  33. void luaL_oldbuffer (lua_State *L, size_t old);
  34. char *luaL_buffer (lua_State *L);
  35. /*
  36. ** ===============================================================
  37. ** some useful macros
  38. ** ===============================================================
  39. */
  40. #define luaL_arg_check(L, cond,numarg,extramsg) if (!(cond)) \
  41. luaL_argerror(L, numarg,extramsg)
  42. #define luaL_check_string(L,n) (luaL_check_lstr(L, (n), NULL))
  43. #define luaL_opt_string(L,n,d) (luaL_opt_lstr(L, (n), (d), NULL))
  44. #define luaL_check_int(L,n) ((int)luaL_check_number(L, n))
  45. #define luaL_check_long(L,n) ((long)luaL_check_number(L, n))
  46. #define luaL_opt_int(L,n,d) ((int)luaL_opt_number(L, n,d))
  47. #define luaL_opt_long(L,n,d) ((long)luaL_opt_number(L, n,d))
  48. #define luaL_openl(L,a) luaL_openlib(L, a, (sizeof(a)/sizeof(a[0])))
  49. #endif