xref: /netbsd-src/external/mit/lua/dist/src/lstring.h (revision f0dad708b37bd6f5048a66ff2d48c1453845f039)
1 /*	$NetBSD: lstring.h,v 1.10 2023/04/16 20:46:17 nikita Exp $	*/
2 
3 /*
4 ** Id: lstring.h
5 ** String table (keep all strings handled by Lua)
6 ** See Copyright Notice in lua.h
7 */
8 
9 #ifndef lstring_h
10 #define lstring_h
11 
12 #include "lgc.h"
13 #include "lobject.h"
14 #include "lstate.h"
15 
16 
17 /*
18 ** Memory-allocation error message must be preallocated (it cannot
19 ** be created after memory is exhausted)
20 */
21 #define MEMERRMSG       "not enough memory"
22 
23 
24 /*
25 ** Size of a TString: Size of the header plus space for the string
26 ** itself (including final '\0').
27 */
28 #define sizelstring(l)  (offsetof(TString, contents) + ((l) + 1) * sizeof(char))
29 
30 #define luaS_newliteral(L, s)	(luaS_newlstr(L, "" s, \
31                                  (sizeof(s)/sizeof(char))-1))
32 
33 
34 /*
35 ** test whether a string is a reserved word
36 */
37 #define isreserved(s)	((s)->tt == LUA_VSHRSTR && (s)->extra > 0)
38 
39 
40 /*
41 ** equality for short strings, which are always internalized
42 */
43 #define eqshrstr(a,b)	check_exp((a)->tt == LUA_VSHRSTR, (a) == (b))
44 
45 
46 LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed);
47 LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts);
48 LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b);
49 LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
50 LUAI_FUNC void luaS_clearcache (global_State *g);
51 LUAI_FUNC void luaS_init (lua_State *L);
52 LUAI_FUNC void luaS_remove (lua_State *L, TString *ts);
53 LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, int nuvalue);
54 LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
55 LUAI_FUNC TString *luaS_new (lua_State *L, const char *str);
56 LUAI_FUNC TString *luaS_createlngstrobj (lua_State *L, size_t l);
57 
58 
59 #endif
60