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