lstring.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. ** $Id: lstring.h,v 1.53 2014/02/19 13:51:09 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. #define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char))
  12. #define sizeudata(u) (sizeof(union Udata)+(u)->len)
  13. #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \
  14. (sizeof(s)/sizeof(char))-1))
  15. /*
  16. ** test whether a string is a reserved word
  17. */
  18. #define isreserved(s) ((s)->tsv.tt == LUA_TSHRSTR && (s)->tsv.extra > 0)
  19. /*
  20. ** equality for short strings, which are always internalized
  21. */
  22. #define eqshrstr(a,b) check_exp((a)->tsv.tt == LUA_TSHRSTR, (a) == (b))
  23. LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed);
  24. LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b);
  25. LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
  26. LUAI_FUNC void luaS_remove (lua_State *L, TString *ts);
  27. LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s);
  28. LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
  29. LUAI_FUNC TString *luaS_new (lua_State *L, const char *str);
  30. #endif