lstring.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. ** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $
  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)+(luaS_isreadonly(s) ? sizeof(char **) : ((s)->len+1)*sizeof(char)))
  12. #define sizeudata(u) (sizeof(union Udata)+(u)->len)
  13. #define luaS_new(L, s) (luaS_newlstr(L, s, c_strlen(s)))
  14. #define luaS_newro(L, s) (luaS_newrolstr(L, s, c_strlen(s)))
  15. #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \
  16. (sizeof(s)/sizeof(char))-1))
  17. #define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT)
  18. #define luaS_readonly(s) l_setbit((s)->tsv.marked, READONLYBIT)
  19. #define luaS_isreadonly(s) testbit((s)->marked, READONLYBIT)
  20. LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
  21. LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e);
  22. LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
  23. LUAI_FUNC TString *luaS_newrolstr (lua_State *L, const char *str, size_t l);
  24. #endif