1eda14cbcSMatt Macy /* 2eda14cbcSMatt Macy ** $Id: lstring.h,v 1.49.1.1 2013/04/12 18:48:47 roberto Exp $ 3eda14cbcSMatt Macy ** String table (keep all strings handled by Lua) 4eda14cbcSMatt Macy ** See Copyright Notice in lua.h 5eda14cbcSMatt Macy */ 6eda14cbcSMatt Macy 7eda14cbcSMatt Macy #ifndef lstring_h 8eda14cbcSMatt Macy #define lstring_h 9eda14cbcSMatt Macy 10eda14cbcSMatt Macy #include "lgc.h" 11eda14cbcSMatt Macy #include "lobject.h" 12eda14cbcSMatt Macy #include "lstate.h" 13eda14cbcSMatt Macy 14eda14cbcSMatt Macy 15*7a7741afSMartin Matuska #define sizestring(s) (sizeof(struct TString)+((s)->len+1)*sizeof(char)) 16eda14cbcSMatt Macy 17eda14cbcSMatt Macy #define sizeudata(u) (sizeof(union Udata)+(u)->len) 18eda14cbcSMatt Macy 19eda14cbcSMatt Macy #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 20eda14cbcSMatt Macy (sizeof(s)/sizeof(char))-1)) 21eda14cbcSMatt Macy 22eda14cbcSMatt Macy #define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) 23eda14cbcSMatt Macy 24eda14cbcSMatt Macy 25eda14cbcSMatt Macy /* 26eda14cbcSMatt Macy ** test whether a string is a reserved word 27eda14cbcSMatt Macy */ 28eda14cbcSMatt Macy #define isreserved(s) ((s)->tsv.tt == LUA_TSHRSTR && (s)->tsv.extra > 0) 29eda14cbcSMatt Macy 30eda14cbcSMatt Macy 31eda14cbcSMatt Macy /* 32eda14cbcSMatt Macy ** equality for short strings, which are always internalized 33eda14cbcSMatt Macy */ 34eda14cbcSMatt Macy #define eqshrstr(a,b) check_exp((a)->tsv.tt == LUA_TSHRSTR, (a) == (b)) 35eda14cbcSMatt Macy 36eda14cbcSMatt Macy 37eda14cbcSMatt Macy LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); 38eda14cbcSMatt Macy LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); 39eda14cbcSMatt Macy LUAI_FUNC int luaS_eqstr (TString *a, TString *b); 40eda14cbcSMatt Macy LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 41eda14cbcSMatt Macy LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); 42eda14cbcSMatt Macy LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 43eda14cbcSMatt Macy LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); 44eda14cbcSMatt Macy 45eda14cbcSMatt Macy 46eda14cbcSMatt Macy #endif 47