String buffers, part 1: object serialization.

Sponsored by fmad.io.
This commit is contained in:
Mike Pall
2021-03-25 02:21:31 +01:00
parent 836fb5bbd3
commit 4c6b669c41
26 changed files with 797 additions and 18 deletions

View File

@@ -10,7 +10,7 @@
#include "lj_gc.h"
#include "lj_str.h"
/* Resizable string buffers. Struct definition in lj_obj.h. */
/* Resizable string buffers. SBuf struct definition in lj_obj.h. */
#define sbufB(sb) (mref((sb)->b, char))
#define sbufP(sb) (mref((sb)->p, char))
#define sbufE(sb) (mref((sb)->e, char))
@@ -100,4 +100,11 @@ static LJ_AINLINE GCstr *lj_buf_str(lua_State *L, SBuf *sb)
return lj_str_new(L, sbufB(sb), sbuflen(sb));
}
/* Interim user-accessible string buffer. */
typedef struct StrBuf {
SBuf *sb; /* Pointer to system buffer. */
char *r; /* String buffer read pointer. */
int depth; /* Remaining recursion depth. */
} StrBuf;
#endif