-
Notifications
You must be signed in to change notification settings - Fork 4
/
bstring.h
28 lines (21 loc) · 907 Bytes
/
bstring.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef BEAN_STRING_H
#define BEAN_STRING_H
#include <string.h>
#include <errno.h>
#include "bstate.h"
#include "bobject.h"
#include "blex.h"
#define MEMERRMSG "not enough memory"
#define HASHLIMIT 5
#define MAXSTRTB cast_int(beanM_limitN(INT_MAX, TString*))
// Size of String is sum of the size of struct TString and the extra char array with the '\0' at the end of the string.
#define sizeofstring(s) (sizeof(TString) + ((s) + 1) * sizeof(char))
#define isreserved(s) ((s)->tt == BEAN_TSTRING && (s)->reserved > 0)
#define getstr(ts) (cast_charp(ts) + sizeof(TString))
#define tslen(ts) (ts -> len)
#define beanS_newliteral(B, s) beanS_newlstr(B, "" s, strlen(s))
TString * beanS_newlstr (bean_State * B, const char *str, size_t l);
bool beanS_equal(TString * ts1, TString * ts2);
TValue * init_String(bean_State * B);
TValue * concat(bean_State * B, TValue * left, TValue * right);
#endif