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