diff options
| author | eunhhu <[email protected]> | 2026-09-27 13:14:38 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-27 13:14:38 +0100 |
| commit | 37d3a1e152707d2da587440c4cea8601b9ef0fd2 (patch) | |
| tree | 1a4cbea9d8ca636deabd8fc24b0d73cdae2bdaef /serve/message-json.h | |
| parent | 5372d03b5968796515966e2cfc89628d6448f0c1 (diff) | |
| download | pure-37d3a1e152707d2da587440c4cea8601b9ef0fd2.tar.gz pure-37d3a1e152707d2da587440c4cea8601b9ef0fd2.zip | |
Lay Pure out as a core with the parts selected around it
The app model, the tree store and the HTTP host lived in
prototypes/connections among the earlier document runtime, the store was
known only by its format's name, and Vega compiled six Pure sources by path.
Now, as the README's principle has it:
core/ runtime, flow and the app model (module*.c), with what the core
asks of storage (state.h, store.h)
store/ the tree store (PURETRE3, PUREREC1)
serve/ pure-serve: HTTP host, outbound delivery, JSON in place
cli/ pure-run, pure-edit-module
A top-level make builds libpure.a (app model and store, for hosts to link)
and the hosts; make check runs the store's and the app model's tests. The
earlier runtime still builds from prototypes/connections against core/ and
store/ (check, check-tree and check-core pass). Design 009 records the rule:
parts by role behind libraries; git repositories split by coupling, so the
store stays here while its contract moves with the core, and Vega stays apart.
Diffstat (limited to 'serve/message-json.h')
| -rw-r--r-- | serve/message-json.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/serve/message-json.h b/serve/message-json.h new file mode 100644 index 0000000..61211d6 --- /dev/null +++ b/serve/message-json.h @@ -0,0 +1,26 @@ +#ifndef PURE_MESSAGE_JSON_H +#define PURE_MESSAGE_JSON_H +#include "module.h" + +/* A message's fields from a JSON object read in place (docs/research/082-json-in-place.md): + * a u32 or a number for a fixed field (put into the prefix), a string for + * bytes or text (left where it is: an escaped one is unescaped over itself, + * which never makes it longer), a group's fields as an object inside. */ +typedef struct { + const PureModule *module; + const PureInputShape *shape; + unsigned char *payload; /* the prefix; a string's start is counted from here */ + unsigned char *table; /* for each field, its start and size (u32le each) */ + const bool *given; /* fields given elsewhere (a request's query), or NULL */ + bool lenient; /* a member naming no field is skipped, value and all (an API's answer) */ + bool seen[PURE_MODULE_FIELDS]; +} PureJsonMessage; + +/* The object at json[*at] (its opening brace), *at moved past it: NULL, or + * what is wrong ("json", "json_field": unknown or given twice, "json_type"). */ +const char *pure_json_message(PureJsonMessage *, unsigned char *json, size_t size, size_t *at); +size_t pure_json_space(const unsigned char *json, size_t at, size_t size); +/* A fixed field's value from its text (a query value or a JSON number) into + * the prefix: a u32 in range, or a finite number. */ +bool pure_json_fixed(const PureField *field, const unsigned char *text, size_t size, unsigned char *prefix); +#endif |
