mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-25 06:24:27 +08:00
Library exports and callbacks passed text only as a pointer and length. profile_format 2 adds the cstring class, a NUL-terminated `const char *` (an i32 pointer in Wasm reactors), for export parameters, export results and callback parameters. Parameters are copied in and decoded as UTF-8, with U+FFFD for malformed bytes; a NULL pointer is the SC4012 host-contract trap. Results live in the result arena like string results. A result or callback argument containing U+0000 traps instead of being truncated. Closes #615 Co-authored-by: ailuoku6 <23209876+ailuoku6@users.noreply.github.com>
23 lines
892 B
JSON
23 lines
892 B
JSON
{
|
|
"profile_format": 2,
|
|
"name": "conformance-cstrings",
|
|
"entry": "lib.ts",
|
|
"emission": "llvm",
|
|
"abi": {
|
|
"prefix": "kc_",
|
|
"init_symbol": "kc_init",
|
|
"sink_register_symbol": "kc_set_panic_sink",
|
|
"collect_symbol": "kc_collect",
|
|
"result_reset_symbol": null,
|
|
"callback_register_symbol": "kc_set_callback"
|
|
},
|
|
"callbacks": [{ "name": "log", "params": ["cstring", "f64"], "returns": "void" }],
|
|
"exports": [
|
|
{ "export": "greet", "symbol": "kc_greet", "params": ["cstring"], "returns": "cstring" },
|
|
{ "export": "length", "symbol": "kc_length", "params": ["cstring"], "returns": "f64" },
|
|
{ "export": "echo", "symbol": "kc_echo", "params": ["cstring"], "returns": "f64" },
|
|
{ "export": "withNul", "symbol": "kc_with_nul", "params": [], "returns": "cstring" },
|
|
{ "export": "echoNul", "symbol": "kc_echo_nul", "params": [], "returns": "f64" }
|
|
]
|
|
}
|