xref: /minix/external/mit/lua/dist/src/lstring.h (revision 0a6a1f1d)
1 /*	$NetBSD: lstring.h,v 1.4 2015/10/08 13:21:00 mbalmer Exp $	*/
2 
3 /*
4 ** Id: lstring.h,v 1.59 2015/03/25 13:42:19 roberto Exp
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 #define sizelstring(l)  (sizeof(union UTString) + ((l) + 1) * sizeof(char))
18 
19 #define sizeludata(l)	(sizeof(union UUdata) + (l))
20 #define sizeudata(u)	sizeludata((u)->len)
21 
22 #define luaS_newliteral(L, s)	(luaS_newlstr(L, "" s, \
23                                  (sizeof(s)/sizeof(char))-1))
24 
25 
26 /*
27 ** test whether a string is a reserved word
28 */
29 #define isreserved(s)	((s)->tt == LUA_TSHRSTR && (s)->extra > 0)
30 
31 
32 /*
33 ** equality for short strings, which are always internalized
34 */
35 #define eqshrstr(a,b)	check_exp((a)->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 void luaS_resize (lua_State *L, int newsize);
41 LUAI_FUNC void luaS_clearcache (global_State *g);
42 LUAI_FUNC void luaS_init (lua_State *L);
43 LUAI_FUNC void luaS_remove (lua_State *L, TString *ts);
44 LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s);
45 LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
46 LUAI_FUNC TString *luaS_new (lua_State *L, const char *str);
47 
48 
49 #endif
50