Big renaming of string buffer/formatting/conversion functions.
This commit is contained in:
@@ -65,6 +65,15 @@ typedef enum FormatType {
|
||||
#define STRFMT_U (STRFMT_UINT)
|
||||
#define STRFMT_X (STRFMT_UINT|STRFMT_T_HEX)
|
||||
|
||||
/* Maximum buffer sizes for conversions. */
|
||||
#define STRFMT_MAXBUF_XINT (1+22) /* '0' prefix + uint64_t in octal. */
|
||||
#define STRFMT_MAXBUF_INT (1+10) /* Sign + int32_t in decimal. */
|
||||
#define STRFMT_MAXBUF_NUM LUAI_MAXNUMBER2STR
|
||||
#define STRFMT_MAXBUF_PTR (2+2*sizeof(ptrdiff_t)) /* "0x" + hex ptr. */
|
||||
|
||||
/* Format parser. */
|
||||
LJ_FUNC SFormat LJ_FASTCALL lj_strfmt_parse(FormatState *fs);
|
||||
|
||||
static LJ_AINLINE void lj_strfmt_init(FormatState *fs, const char *p, MSize len)
|
||||
{
|
||||
fs->p = (const uint8_t *)p;
|
||||
@@ -72,18 +81,38 @@ static LJ_AINLINE void lj_strfmt_init(FormatState *fs, const char *p, MSize len)
|
||||
lua_assert(*fs->e == 0); /* Must be NUL-terminated (may have NULs inside). */
|
||||
}
|
||||
|
||||
LJ_FUNC SFormat LJ_FASTCALL lj_strfmt_parse(FormatState *fs);
|
||||
/* Raw conversions. */
|
||||
LJ_FUNC char * LJ_FASTCALL lj_strfmt_wint(char *p, int32_t k);
|
||||
LJ_FUNC char * LJ_FASTCALL lj_strfmt_wnum(char *p, cTValue *o);
|
||||
LJ_FUNC char * LJ_FASTCALL lj_strfmt_wptr(char *p, const void *v);
|
||||
LJ_FUNC char * LJ_FASTCALL lj_strfmt_wuleb128(char *p, uint32_t v);
|
||||
LJ_FUNC const char *lj_strfmt_wstrnum(char *buf, cTValue *o, MSize *lenp);
|
||||
|
||||
LJ_FUNC SBuf *lj_strfmt_putchar(SBuf *sb, SFormat, int32_t c);
|
||||
LJ_FUNC SBuf *lj_strfmt_putstr(SBuf *sb, SFormat, GCstr *str);
|
||||
LJ_FUNC SBuf *lj_strfmt_putquoted(SBuf *sb, GCstr *str);
|
||||
LJ_FUNC SBuf *lj_strfmt_putxint(SBuf *sb, SFormat sf, uint64_t k);
|
||||
LJ_FUNC SBuf *lj_strfmt_putnum_int(SBuf *sb, SFormat sf, lua_Number n);
|
||||
LJ_FUNC SBuf *lj_strfmt_putnum_uint(SBuf *sb, SFormat sf, lua_Number n);
|
||||
LJ_FUNC SBuf *lj_strfmt_putnum(SBuf *sb, SFormat, lua_Number n);
|
||||
/* Unformatted conversions to buffer. */
|
||||
LJ_FUNC SBuf * LJ_FASTCALL lj_strfmt_putint(SBuf *sb, int32_t k);
|
||||
#if LJ_HASJIT
|
||||
LJ_FUNC SBuf * LJ_FASTCALL lj_strfmt_putnum(SBuf *sb, cTValue *o);
|
||||
#endif
|
||||
LJ_FUNC SBuf * LJ_FASTCALL lj_strfmt_putquoted(SBuf *sb, GCstr *str);
|
||||
|
||||
LJ_FUNC GCstr *lj_strfmt_obj(lua_State *L, cTValue *o);
|
||||
/* Formatted conversions to buffer. */
|
||||
LJ_FUNC SBuf *lj_strfmt_putfxint(SBuf *sb, SFormat sf, uint64_t k);
|
||||
LJ_FUNC SBuf *lj_strfmt_putfnum_int(SBuf *sb, SFormat sf, lua_Number n);
|
||||
LJ_FUNC SBuf *lj_strfmt_putfnum_uint(SBuf *sb, SFormat sf, lua_Number n);
|
||||
LJ_FUNC SBuf *lj_strfmt_putfnum(SBuf *sb, SFormat, lua_Number n);
|
||||
LJ_FUNC SBuf *lj_strfmt_putfchar(SBuf *sb, SFormat, int32_t c);
|
||||
LJ_FUNC SBuf *lj_strfmt_putfstr(SBuf *sb, SFormat, GCstr *str);
|
||||
|
||||
/* Conversions to strings. */
|
||||
LJ_FUNC GCstr * LJ_FASTCALL lj_strfmt_int(lua_State *L, int32_t k);
|
||||
LJ_FUNCA GCstr * LJ_FASTCALL lj_strfmt_num(lua_State *L, cTValue *o);
|
||||
LJ_FUNCA GCstr * LJ_FASTCALL lj_strfmt_number(lua_State *L, cTValue *o);
|
||||
#if LJ_HASJIT
|
||||
LJ_FUNC GCstr * LJ_FASTCALL lj_strfmt_char(lua_State *L, int c);
|
||||
#endif
|
||||
LJ_FUNC GCstr * LJ_FASTCALL lj_strfmt_obj(lua_State *L, cTValue *o);
|
||||
|
||||
/* Internal string formatting. */
|
||||
LJ_FUNC const char *lj_strfmt_pushvf(lua_State *L, const char *fmt,
|
||||
va_list argp);
|
||||
LJ_FUNC const char *lj_strfmt_pushf(lua_State *L, const char *fmt, ...)
|
||||
|
||||
Reference in New Issue
Block a user