Big renaming of string buffer/formatting/conversion functions.
This commit is contained in:
53
src/lj_buf.h
53
src/lj_buf.h
@@ -20,28 +20,10 @@
|
||||
#define setsbufP(sb, q) (setmref((sb)->p, (q)))
|
||||
#define setsbufL(sb, l) (setmref((sb)->L, (l)))
|
||||
|
||||
LJ_FUNC char * LJ_FASTCALL lj_buf_tmp(lua_State *L, MSize sz);
|
||||
/* Buffer management */
|
||||
LJ_FUNC void LJ_FASTCALL lj_buf_grow(SBuf *sb, char *en);
|
||||
LJ_FUNC void LJ_FASTCALL lj_buf_shrink(lua_State *L, SBuf *sb);
|
||||
|
||||
LJ_FUNC char *lj_buf_wmem(char *p, const void *q, MSize len);
|
||||
LJ_FUNC SBuf * lj_buf_putmem(SBuf *sb, const void *q, MSize len);
|
||||
#if LJ_HASJIT
|
||||
LJ_FUNC SBuf * LJ_FASTCALL lj_buf_putstr(SBuf *sb, GCstr *s);
|
||||
LJ_FUNC SBuf * LJ_FASTCALL lj_buf_putchar(SBuf *sb, int c);
|
||||
LJ_FUNC SBuf * LJ_FASTCALL lj_buf_putint(SBuf *sb, int32_t k);
|
||||
LJ_FUNC SBuf * LJ_FASTCALL lj_buf_putnum(SBuf *sb, cTValue *o);
|
||||
#endif
|
||||
LJ_FUNCA SBuf * LJ_FASTCALL lj_buf_putstr_reverse(SBuf *sb, GCstr *s);
|
||||
LJ_FUNCA SBuf * LJ_FASTCALL lj_buf_putstr_lower(SBuf *sb, GCstr *s);
|
||||
LJ_FUNCA SBuf * LJ_FASTCALL lj_buf_putstr_upper(SBuf *sb, GCstr *s);
|
||||
LJ_FUNC SBuf *lj_buf_putstr_rep(SBuf *sb, GCstr *s, int32_t rep);
|
||||
LJ_FUNC SBuf *lj_buf_puttab(SBuf *sb, GCtab *t, GCstr *sep,
|
||||
int32_t i, int32_t e);
|
||||
LJ_FUNCA GCstr * LJ_FASTCALL lj_buf_tostr(SBuf *sb);
|
||||
LJ_FUNC GCstr *lj_buf_cat2str(lua_State *L, GCstr *s1, GCstr *s2);
|
||||
LJ_FUNC uint32_t LJ_FASTCALL lj_buf_ruleb128(const char **pp);
|
||||
LJ_FUNC char * LJ_FASTCALL lj_buf_wuleb128(char *p, uint32_t v);
|
||||
LJ_FUNC char * LJ_FASTCALL lj_buf_tmp(lua_State *L, MSize sz);
|
||||
|
||||
static LJ_AINLINE void lj_buf_init(lua_State *L, SBuf *sb)
|
||||
{
|
||||
@@ -67,11 +49,6 @@ static LJ_AINLINE void lj_buf_free(global_State *g, SBuf *sb)
|
||||
lj_mem_free(g, sbufB(sb), sbufsz(sb));
|
||||
}
|
||||
|
||||
static LJ_AINLINE GCstr *lj_buf_str(lua_State *L, SBuf *sb)
|
||||
{
|
||||
return lj_str_new(L, sbufB(sb), sbuflen(sb));
|
||||
}
|
||||
|
||||
static LJ_AINLINE char *lj_buf_need(SBuf *sb, MSize sz)
|
||||
{
|
||||
char *en = sbufB(sb) + sz;
|
||||
@@ -88,6 +65,14 @@ static LJ_AINLINE char *lj_buf_more(SBuf *sb, MSize sz)
|
||||
return sbufP(sb);
|
||||
}
|
||||
|
||||
/* Low-level buffer put operations */
|
||||
LJ_FUNC char *lj_buf_wmem(char *p, const void *q, MSize len);
|
||||
LJ_FUNC SBuf * lj_buf_putmem(SBuf *sb, const void *q, MSize len);
|
||||
#if LJ_HASJIT
|
||||
LJ_FUNC SBuf * LJ_FASTCALL lj_buf_putchar(SBuf *sb, int c);
|
||||
#endif
|
||||
LJ_FUNC SBuf * LJ_FASTCALL lj_buf_putstr(SBuf *sb, GCstr *s);
|
||||
|
||||
static LJ_AINLINE void lj_buf_putb(SBuf *sb, int c)
|
||||
{
|
||||
char *p = lj_buf_more(sb, 1);
|
||||
@@ -95,4 +80,22 @@ static LJ_AINLINE void lj_buf_putb(SBuf *sb, int c)
|
||||
setsbufP(sb, p);
|
||||
}
|
||||
|
||||
/* High-level buffer put operations */
|
||||
LJ_FUNCA SBuf * LJ_FASTCALL lj_buf_putstr_reverse(SBuf *sb, GCstr *s);
|
||||
LJ_FUNCA SBuf * LJ_FASTCALL lj_buf_putstr_lower(SBuf *sb, GCstr *s);
|
||||
LJ_FUNCA SBuf * LJ_FASTCALL lj_buf_putstr_upper(SBuf *sb, GCstr *s);
|
||||
LJ_FUNC SBuf *lj_buf_putstr_rep(SBuf *sb, GCstr *s, int32_t rep);
|
||||
LJ_FUNC SBuf *lj_buf_puttab(SBuf *sb, GCtab *t, GCstr *sep,
|
||||
int32_t i, int32_t e);
|
||||
|
||||
/* Miscellaneous buffer operations */
|
||||
LJ_FUNCA GCstr * LJ_FASTCALL lj_buf_tostr(SBuf *sb);
|
||||
LJ_FUNC GCstr *lj_buf_cat2str(lua_State *L, GCstr *s1, GCstr *s2);
|
||||
LJ_FUNC uint32_t LJ_FASTCALL lj_buf_ruleb128(const char **pp);
|
||||
|
||||
static LJ_AINLINE GCstr *lj_buf_str(lua_State *L, SBuf *sb)
|
||||
{
|
||||
return lj_str_new(L, sbufB(sb), sbuflen(sb));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user