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