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
46LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed);
47LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts);
48LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b);
49LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
50LUAI_FUNC void luaS_clearcache (global_State *g);
51LUAI_FUNC void luaS_init (lua_State *L);
52LUAI_FUNC void luaS_remove (lua_State *L, TString *ts);
53LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, int nuvalue);
54LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
55LUAI_FUNC TString *luaS_new (lua_State *L, const char *str);
56LUAI_FUNC TString *luaS_createlngstrobj (lua_State *L, size_t l);
57
58
59#endif
60