mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 23:08:31 +00:00
Add pretty printing to redbean serializers
This commit is contained in:
parent
6bb8b26d70
commit
516b68606f
11 changed files with 327 additions and 91 deletions
33
third_party/lua/cosmo.h
vendored
33
third_party/lua/cosmo.h
vendored
|
@ -3,13 +3,39 @@
|
|||
#include "net/http/http.h"
|
||||
#include "net/http/url.h"
|
||||
#include "third_party/lua/lauxlib.h"
|
||||
#include "third_party/lua/visitor.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
struct EncoderConfig {
|
||||
short maxdepth;
|
||||
bool sorted;
|
||||
bool pretty;
|
||||
const char *indent;
|
||||
};
|
||||
|
||||
struct Serializer {
|
||||
struct LuaVisited visited;
|
||||
struct EncoderConfig conf;
|
||||
const char *reason;
|
||||
char *strbuf;
|
||||
size_t strbuflen;
|
||||
};
|
||||
|
||||
struct SerializerJoin {
|
||||
struct Serializer *z;
|
||||
char **buf;
|
||||
bool multi;
|
||||
int depth;
|
||||
int i;
|
||||
const char *indent;
|
||||
};
|
||||
|
||||
bool LuaHasMultipleItems(lua_State *);
|
||||
char *LuaFormatStack(lua_State *) dontdiscard;
|
||||
int LuaCallWithTrace(lua_State *, int, int, lua_State *);
|
||||
int LuaEncodeJsonData(lua_State *, char **, int, bool);
|
||||
int LuaEncodeLuaData(lua_State *, char **, int, bool);
|
||||
int LuaEncodeJsonData(lua_State *, char **, int, struct EncoderConfig);
|
||||
int LuaEncodeLuaData(lua_State *, char **, int, struct EncoderConfig);
|
||||
int LuaEncodeUrl(lua_State *);
|
||||
int LuaParseUrl(lua_State *);
|
||||
int LuaPushHeader(lua_State *, struct HttpMessage *, char *, int);
|
||||
|
@ -17,6 +43,9 @@ int LuaPushHeaders(lua_State *, struct HttpMessage *, const char *);
|
|||
void LuaPrintStack(lua_State *);
|
||||
void LuaPushLatin1(lua_State *, const char *, size_t);
|
||||
void LuaPushUrlParams(lua_State *, struct UrlParams *);
|
||||
int SerializeObjectStart(char **, struct Serializer *, int, bool);
|
||||
int SerializeObjectEnd(char **, struct Serializer *, int, bool);
|
||||
int SerializeObjectIndent(char **, struct Serializer *, int);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue