]> git.proxmox.com Git - ceph.git/blame - ceph/src/civetweb/src/third_party/duktape-1.3.0/src-separate/duk_json.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / civetweb / src / third_party / duktape-1.3.0 / src-separate / duk_json.h
CommitLineData
7c673cae
FG
1/*
2 * Defines for JSON, especially duk_bi_json.c.
3 */
4
5#ifndef DUK_JSON_H_INCLUDED
6#define DUK_JSON_H_INCLUDED
7
8/* Encoding/decoding flags */
9#define DUK_JSON_FLAG_ASCII_ONLY (1 << 0) /* escape any non-ASCII characters */
10#define DUK_JSON_FLAG_AVOID_KEY_QUOTES (1 << 1) /* avoid key quotes when key is an ASCII Identifier */
11#define DUK_JSON_FLAG_EXT_CUSTOM (1 << 2) /* extended types: custom encoding */
12#define DUK_JSON_FLAG_EXT_COMPATIBLE (1 << 3) /* extended types: compatible encoding */
13
14/* How much stack to require on entry to object/array encode */
15#define DUK_JSON_ENC_REQSTACK 32
16
17/* How much stack to require on entry to object/array decode */
18#define DUK_JSON_DEC_REQSTACK 32
19
20/* How large a loop detection stack to use for fast path */
21#if defined(DUK_USE_JSON_STRINGIFY_FASTPATH)
22#define DUK_JSON_ENC_LOOPARRAY 64
23#endif
24
25/* Encoding state. Heap object references are all borrowed. */
26typedef struct {
27 duk_hthread *thr;
28 duk_bufwriter_ctx bw; /* output bufwriter */
29 duk_hobject *h_replacer; /* replacer function */
30 duk_hstring *h_gap; /* gap (if empty string, NULL) */
31 duk_hstring *h_indent; /* current indent (if gap is NULL, this is NULL) */
32 duk_idx_t idx_proplist; /* explicit PropertyList */
33 duk_idx_t idx_loop; /* valstack index of loop detection object */
34 duk_small_uint_t flags;
35 duk_small_uint_t flag_ascii_only;
36 duk_small_uint_t flag_avoid_key_quotes;
37#if defined(DUK_USE_JX) || defined(DUK_USE_JC)
38 duk_small_uint_t flag_ext_custom;
39 duk_small_uint_t flag_ext_compatible;
40#endif
41 duk_int_t recursion_depth;
42 duk_int_t recursion_limit;
43 duk_uint_t mask_for_undefined; /* type bit mask: types which certainly produce 'undefined' */
44#if defined(DUK_USE_JX) || defined(DUK_USE_JC)
45 duk_small_uint_t stridx_custom_undefined;
46 duk_small_uint_t stridx_custom_nan;
47 duk_small_uint_t stridx_custom_neginf;
48 duk_small_uint_t stridx_custom_posinf;
49 duk_small_uint_t stridx_custom_function;
50#endif
51#if defined(DUK_USE_JSON_STRINGIFY_FASTPATH)
52 duk_hobject *visiting[DUK_JSON_ENC_LOOPARRAY]; /* indexed by recursion_depth */
53#endif
54} duk_json_enc_ctx;
55
56typedef struct {
57 duk_hthread *thr;
58 const duk_uint8_t *p;
59 const duk_uint8_t *p_start;
60 const duk_uint8_t *p_end;
61 duk_idx_t idx_reviver;
62 duk_small_uint_t flags;
63#if defined(DUK_USE_JX) || defined(DUK_USE_JC)
64 duk_small_uint_t flag_ext_custom;
65 duk_small_uint_t flag_ext_compatible;
66#endif
67 duk_int_t recursion_depth;
68 duk_int_t recursion_limit;
69} duk_json_dec_ctx;
70
71#endif /* DUK_JSON_H_INCLUDED */