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