lstring.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. ** $Id: lstring.h,v 1.63 2017/11/23 19:29:04 roberto Exp roberto $
  3. ** String table (keep all strings handled by Lua)
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef lstring_h
  7. #define lstring_h
  8. #include "lgc.h"
  9. #include "lobject.h"
  10. #include "lstate.h"
  11. /*
  12. ** Memory-allocation error message must be preallocated (it cannot
  13. ** be created after memory is exhausted)
  14. */
  15. #define MEMERRMSG "not enough memory"
  16. #define sizelstring(l) (sizeof(union UTString) + ((l) + 1) * sizeof(char))
  17. #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \
  18. (sizeof(s)/sizeof(char))-1))
  19. /*
  20. ** test whether a string is a reserved word
  21. */
  22. #define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0)
  23. /*
  24. ** equality for short strings, which are always internalized
  25. */
  26. #define eqshrstr(a,b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b))
  27. LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed);
  28. LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts);
  29. LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b);
  30. LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
  31. LUAI_FUNC void luaS_clearcache (global_State *g);
  32. LUAI_FUNC void luaS_init (lua_State *L);
  33. LUAI_FUNC void luaS_remove (lua_State *L, TString *ts);
  34. LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, int nuvalue);
  35. LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
  36. LUAI_FUNC TString *luaS_new (lua_State *L, const char *str);
  37. LUAI_FUNC TString *luaS_createlngstrobj (lua_State *L, size_t l);
  38. #endif