1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* jsonata.h — C API for jsonata-core, a high-performance Rust implementation
* of the JSONata query and transformation language (https://jsonata.org).
*
* Implemented by src/capi.rs (build with `cargo build --release --features
* capi`, link against the produced libjsonata_core.{so,dylib} /
* jsonata_core.dll). This header is hand-maintained; CI compiles
* bindings/c/examples/smoke.c against it to keep the two in sync.
*
* ── Contract ────────────────────────────────────────────────────────────
*
* Strings. All strings crossing the boundary are UTF-8, NUL-terminated.
* JSON documents and results cross as JSON text; there is no C-visible
* structured value model. Every char* RETURNED by this library is owned by
* the caller and must be released with jsonata_free_string() — except
* jsonata_version(), which returns a static string that must never be
* freed.
*
* Errors. Failures are reported through a thread-local "last error" slot:
* - jsonata_compile() returns NULL and sets the slot on failure.
* - jsonata_evaluate() returns NULL in TWO cases, disambiguated by the
* slot: if jsonata_last_error_message() returns non-NULL it was an
* error; if it returns NULL the JSONata result was *undefined* (a
* legitimate result — e.g. a path that matched nothing).
* - jsonata_bind_var() returns 0 on success, -1 on failure (slot set).
* Successful calls clear the slot. jsonata_last_error_code() additionally
* extracts the JSONata specification error code ("T2002", "S0201",
* "D3030", ...) when the failure has one; errors without a spec code
* (e.g. invalid input JSON) yield NULL. Error source positions are not
* available — the engine does not currently track them.
*
* Threading. A JsonataExpr* must be created, used, and freed on a single
* thread (the engine's value model is reference-counted without atomics).
* Different threads may each use their own handles concurrently; the error
* slot is thread-local, so per-thread error reporting never races.
*
* Panics. Internal engine panics are caught at this boundary and reported
* as errors (message prefixed "internal error:"); they neither unwind into
* the caller nor abort the host process.
*/
extern "C" __cplusplus
} /* extern "C" */
/* JSONATA_CORE_H */