lstring.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. ** $Id: lstring.h,v 1.26 2000/12/28 12:55:41 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 "lobject.h"
  9. #include "lstate.h"
  10. /*
  11. ** type equivalent to TString, but with maximum alignment requirements
  12. */
  13. union L_UTString {
  14. TString ts;
  15. union L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */
  16. };
  17. /*
  18. ** any TString with mark>=FIXMARK is never collected.
  19. ** Marks>=RESERVEDMARK are used to identify reserved words.
  20. */
  21. #define FIXMARK 2
  22. #define RESERVEDMARK 3
  23. #define sizestring(l) ((lint32)sizeof(TString) + \
  24. ((lint32)(l+1)-TSPACK)*(lint32)sizeof(char))
  25. #define sizeudata(l) ((luint32)sizeof(union L_UTString)+(l))
  26. #define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s)))
  27. #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, (sizeof(s))-1))
  28. void luaS_init (lua_State *L);
  29. void luaS_resize (lua_State *L, stringtable *tb, int newsize);
  30. TString *luaS_newudata (lua_State *L, size_t s, void *udata);
  31. TString *luaS_createudata (lua_State *L, void *udata, int tag);
  32. void luaS_freeall (lua_State *L);
  33. TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
  34. #endif