diff options
author | Mike Pall <mike> | 2009-12-08 19:46:35 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2009-12-08 19:46:35 +0100 |
commit | 55b16959717084884fd4a0cbae6d19e3786c20c7 (patch) | |
tree | c8a07a43c13679751ed25a9d06796e9e7b2134a6 /src/lj_str.h | |
download | luajit-2.0.0-beta1.tar.gz luajit-2.0.0-beta1.tar.bz2 luajit-2.0.0-beta1.zip |
RELEASE LuaJIT-2.0.0-beta1v2.0.0-beta1
Diffstat (limited to 'src/lj_str.h')
-rw-r--r-- | src/lj_str.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/lj_str.h b/src/lj_str.h new file mode 100644 index 00000000..f7e56d16 --- /dev/null +++ b/src/lj_str.h | |||
@@ -0,0 +1,45 @@ | |||
1 | /* | ||
2 | ** String handling. | ||
3 | ** Copyright (C) 2005-2009 Mike Pall. See Copyright Notice in luajit.h | ||
4 | */ | ||
5 | |||
6 | #ifndef _LJ_STR_H | ||
7 | #define _LJ_STR_H | ||
8 | |||
9 | #include <stdarg.h> | ||
10 | |||
11 | #include "lj_obj.h" | ||
12 | |||
13 | /* String interning. */ | ||
14 | LJ_FUNCA int32_t lj_str_cmp(GCstr *a, GCstr *b); | ||
15 | LJ_FUNC void lj_str_resize(lua_State *L, MSize newmask); | ||
16 | LJ_FUNCA GCstr *lj_str_new(lua_State *L, const char *str, size_t len); | ||
17 | LJ_FUNC void LJ_FASTCALL lj_str_free(global_State *g, GCstr *s); | ||
18 | |||
19 | #define lj_str_newz(L, s) (lj_str_new(L, s, strlen(s))) | ||
20 | #define lj_str_newlit(L, s) (lj_str_new(L, "" s, sizeof(s)-1)) | ||
21 | |||
22 | /* Type conversions. */ | ||
23 | LJ_FUNCA int lj_str_numconv(const char *s, TValue *n); | ||
24 | LJ_FUNCA GCstr *lj_str_fromnum(lua_State *L, const lua_Number *np); | ||
25 | LJ_FUNCA GCstr *lj_str_fromint(lua_State *L, int32_t k); | ||
26 | |||
27 | /* String formatting. */ | ||
28 | LJ_FUNC const char *lj_str_pushvf(lua_State *L, const char *fmt, va_list argp); | ||
29 | LJ_FUNC const char *lj_str_pushf(lua_State *L, const char *fmt, ...) | ||
30 | #if defined(__GNUC__) | ||
31 | __attribute__ ((format (printf, 2, 3))) | ||
32 | #endif | ||
33 | ; | ||
34 | |||
35 | /* Resizable string buffers. Struct definition in lj_obj.h. */ | ||
36 | LJ_FUNC char *lj_str_needbuf(lua_State *L, SBuf *sb, MSize sz); | ||
37 | |||
38 | #define lj_str_initbuf(L, sb) ((sb)->buf = NULL, (sb)->sz = 0) | ||
39 | #define lj_str_resetbuf(sb) ((sb)->n = 0) | ||
40 | #define lj_str_resizebuf(L, sb, size) \ | ||
41 | ((sb)->buf = (char *)lj_mem_realloc(L, (sb)->buf, (sb)->sz, (size)), \ | ||
42 | (sb)->sz = (size)) | ||
43 | #define lj_str_freebuf(g, sb) lj_mem_free(g, (void *)(sb)->buf, (sb)->sz) | ||
44 | |||
45 | #endif | ||