Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Roblox
GitHub Repository: Roblox/luau
Path: blob/master/VM/src/lstring.h
2725 views
1
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2
// This code is based on Lua 5.x implementation licensed under MIT License; see lua_LICENSE.txt for details
3
#pragma once
4
5
#include "lobject.h"
6
#include "lstate.h"
7
8
// string size limit
9
#define MAXSSIZE (1 << 30)
10
11
// string atoms are not defined by default; the storage is 16-bit integer
12
#define ATOM_UNDEF -32768
13
14
#define sizestring(len) (offsetof(TString, data) + len + 1)
15
16
#define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s)))
17
#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, (sizeof(s) / sizeof(char)) - 1))
18
19
#define luaS_fix(s) l_setbit((s)->marked, FIXEDBIT)
20
21
LUAI_FUNC unsigned int luaS_hash(const char* str, size_t len);
22
23
LUAI_FUNC void luaS_resize(lua_State* L, int newsize);
24
25
LUAI_FUNC TString* luaS_newlstr(lua_State* L, const char* str, size_t l);
26
LUAI_FUNC void luaS_free(lua_State* L, TString* ts, struct lua_Page* page);
27
28
LUAI_FUNC TString* luaS_bufstart(lua_State* L, size_t size);
29
LUAI_FUNC TString* luaS_buffinish(lua_State* L, TString* ts);
30
31