feat: implement WASM phase 1 DValue ABI
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
:title
|
||||
ucb_decode
|
||||
|
||||
:sig
|
||||
DValue ucb_decode(String encoded)
|
||||
bool ucb_decode(String encoded, DValue& out, String* error_out = 0)
|
||||
|
||||
:see
|
||||
ucb_encode
|
||||
0_DValue
|
||||
json_decode
|
||||
|
||||
:content
|
||||
Decodes UCEB1 bytes produced by `ucb_encode()` back into a `DValue`.
|
||||
|
||||
The one-argument form returns an empty `DValue` on invalid input. The three-argument form reports whether decoding succeeded and can return a human-readable error string.
|
||||
|
||||
```cpp
|
||||
DValue decoded;
|
||||
String error;
|
||||
if(!ucb_decode(bytes, decoded, &error))
|
||||
{
|
||||
print("decode failed: " + error);
|
||||
return;
|
||||
}
|
||||
|
||||
print(decoded["name"].to_string());
|
||||
```
|
||||
@@ -0,0 +1,23 @@
|
||||
:title
|
||||
ucb_encode
|
||||
|
||||
:sig
|
||||
String ucb_encode(DValue value)
|
||||
|
||||
:see
|
||||
ucb_decode
|
||||
0_DValue
|
||||
json_encode
|
||||
|
||||
:content
|
||||
Serializes a `DValue` to UCEB1, UCE's binary DValue wire format for the WASM membrane and future cross-instance calls.
|
||||
|
||||
UCEB1 is length-prefixed and binary-safe. It preserves nested maps, list-shaped maps, empty lists, and scalar bytes, including embedded NUL bytes. Use JSON/YAML/XML serializers for human-facing formats; use UCEB1 when UCE code needs the native DValue protocol.
|
||||
|
||||
```cpp
|
||||
DValue payload;
|
||||
payload["name"] = "uce";
|
||||
payload["items"].push("first");
|
||||
|
||||
String bytes = ucb_encode(payload);
|
||||
```
|
||||
Reference in New Issue
Block a user