Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
350 changes: 160 additions & 190 deletions ipc-codegen/SCHEMA_SPEC.md

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion ipc-codegen/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ function test_cmds {
echo "$prefix $script golden ts"
echo "$prefix $script golden cpp"
echo "$prefix $script golden zig"
echo "$prefix ipc-codegen/echo_example/cpp/build/bin/schema_reflection_test --schema ipc-codegen/echo_example/schema/schema.json"
echo "$prefix ipc-codegen/echo_example/ts_package/test.sh uds"
echo "$prefix ipc-codegen/echo_example/ts_package/test.sh shm"

Expand Down
3 changes: 0 additions & 3 deletions ipc-codegen/echo_example/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,5 @@ add_executable(echo_client
)
target_link_libraries(echo_client PRIVATE echo_common ipc_runtime)

add_executable(schema_reflection_test src/schema_reflection_test.cpp)
target_link_libraries(schema_reflection_test PRIVATE echo_common)

add_executable(golden_test src/golden_test.cpp)
target_link_libraries(golden_test PRIVATE echo_common)
6 changes: 2 additions & 4 deletions ipc-codegen/echo_example/cpp/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ CODEGEN="$(cd "$DIR/../.." && pwd)"
NODE="node --experimental-strip-types --experimental-transform-types --no-warnings"

$NODE "$CODEGEN/src/generate.ts" \
--schema "$DIR/../schema/schema.json" \
--schema "$DIR/../schema/schema.jsonc" \
--lang cpp \
--server \
--client \
--strip-method-prefix \
--out "$DIR/src/generated" \
--prefix Echo \
--cpp-namespace echo

cmake -S "$DIR" -B "$DIR/build"
cmake --build "$DIR/build" --target echo_server echo_client schema_reflection_test golden_test
cmake --build "$DIR/build" --target echo_server echo_client golden_test
79 changes: 0 additions & 79 deletions ipc-codegen/echo_example/cpp/src/schema_reflection_test.cpp

This file was deleted.

6 changes: 2 additions & 4 deletions ipc-codegen/echo_example/rust/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ CODEGEN="$(cd "$DIR/../.." && pwd)"
NODE="node --experimental-strip-types --experimental-transform-types --no-warnings"

$NODE "$CODEGEN/src/generate.ts" \
--schema "$DIR/../schema/schema.json" \
--schema "$DIR/../schema/schema.jsonc" \
--lang rust \
--server \
--client \
--strip-method-prefix \
--uds \
--ffi \
--out "$DIR/src/generated" \
--prefix Echo
--out "$DIR/src/generated"

(cd "$DIR" && cargo build --locked --quiet)
# Compile-check the generated FFI backend (not linked into the binaries).
Expand Down
118 changes: 0 additions & 118 deletions ipc-codegen/echo_example/schema/schema.json

This file was deleted.

44 changes: 44 additions & 0 deletions ipc-codegen/echo_example/schema/schema.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// echo.schema.jsonc — the entire echo service, human-authored.
{
"service": "Echo",

// Named byte aliases (nominal 32-byte types). Only bin32 today.
"aliases": {
"Fr": "bin32"
},

// Shared struct types, referenced by name from commands.
"types": {
"EchoInner": {
"values": "bytes[]",
"flag": "bool?"
}
},

// Error variant shared by every command.
"error": { "message": "string" },

// command -> { request, response }. Names are unprefixed; generated type
// names get the service prefix (EchoBytes), method names do not (bytes).
"commands": {
"Bytes": { "request": { "data": "bytes" },
"response": { "data": "bytes" } },

"Fields": { "request": { "a": "u32", "b": "u64", "name": "string" },
"response": { "a": "u32", "b": "u64", "name": "string" } },

"Nested": { "request": { "inner": "EchoInner" },
"response": { "inner": "EchoInner" } },

"Aliases": { "request": { "treeId": "u32", "hash": "Fr",
"maybeHash": "Fr?", "hashes": "Fr[]" },
"response": { "treeId": "u32", "hash": "Fr",
"maybeHash": "Fr?", "hashes": "Fr[]" } },

"Blobs": { "request": { "maybeData": "bytes?", "parts": "bytes[2]" },
"response": { "maybeData": "bytes?", "parts": "bytes[2]" } },

"Fail": { "request": { "message": "string" },
"response": {} }
}
}
5 changes: 2 additions & 3 deletions ipc-codegen/echo_example/ts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ REPO_ROOT="$(cd "$CODEGEN/.." && pwd)"
NODE="node --experimental-strip-types --experimental-transform-types --no-warnings"

$NODE "$CODEGEN/src/generate.ts" \
--schema "$DIR/../schema/schema.json" \
--schema "$DIR/../schema/schema.jsonc" \
--lang ts \
--server \
--client \
--out "$DIR/src/generated" \
--prefix Echo
--out "$DIR/src/generated"

(cd "$REPO_ROOT/ipc-runtime" && ./bootstrap.sh)
(cd "$REPO_ROOT/ipc-runtime/ts" && yarn install --immutable && yarn build)
Expand Down
20 changes: 10 additions & 10 deletions ipc-codegen/echo_example/ts/src/echo_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ async function run() {

// Test 1: EchoBytes
const testData = Uint8Array.from([0xde, 0xad, 0xbe, 0xef, 0x42]);
const resp1 = await api.echoBytes({ data: testData });
const resp1 = await api.bytes({ data: testData });
assertBytes(resp1.data, testData, "EchoBytes data");
console.error("echo_client(ts): EchoBytes OK");

// Test 2: EchoFields
const resp2 = await api.echoFields({
const resp2 = await api.fields({
a: 42,
b: 999999,
name: "hello wire compat",
Expand All @@ -78,7 +78,7 @@ async function run() {
values: [Uint8Array.from([1, 2, 3]), Uint8Array.from([4, 5])],
flag: true,
};
const resp3 = await api.echoNested({ inner });
const resp3 = await api.nested({ inner });
assertEqual(resp3.inner.flag, true, "EchoNested flag");
assertEqual(resp3.inner.values.length, 2, "EchoNested values length");
assertBytes(resp3.inner.values[0]!, inner.values[0]!, "EchoNested values[0]");
Expand All @@ -87,7 +87,7 @@ async function run() {
// Test 4: EchoAliases
const hash = testHash(0x10);
const second = testHash(0x40);
const resp4 = await api.echoAliases({
const resp4 = await api.aliases({
treeId: 7,
hash,
maybeHash: second,
Expand All @@ -102,7 +102,7 @@ async function run() {
console.error("echo_client(ts): EchoAliases OK");

// Test 5: EchoAliases with maybeHash absent (optional over live IPC)
const resp5 = await api.echoAliases({
const resp5 = await api.aliases({
treeId: 7,
hash,
maybeHash: null,
Expand All @@ -113,20 +113,20 @@ async function run() {

// Test 6: EchoFields with b > 2^32 (uint64 wire encoding over live IPC)
const big = Number.MAX_SAFE_INTEGER;
const resp6 = await api.echoFields({ a: 42, b: big, name: "big" });
const resp6 = await api.fields({ a: 42, b: big, name: "big" });
assertEqual(resp6.b, big, "EchoFields u64");
// Values past 2^53 must throw client-side rather than silently lose precision.
let threw = false;
try {
await api.echoFields({ a: 42, b: 2 ** 60, name: "too big" });
await api.fields({ a: 42, b: 2 ** 60, name: "too big" });
} catch {
threw = true;
}
assertEqual(threw, true, "EchoFields u64 guard");
console.error("echo_client(ts): EchoFields u64 OK");

// Test 7: EchoBlobs — optional bytes Some/None and fixed [bytes; 2]
const resp7 = await api.echoBlobs({
const resp7 = await api.blobs({
maybeData: Uint8Array.from([0xaa, 0xbb]),
parts: [Uint8Array.from([1, 2, 3]), Uint8Array.from([4])],
});
Expand All @@ -141,7 +141,7 @@ async function run() {
"EchoBlobs parts[0]",
);
assertBytes(resp7.parts[1]!, Uint8Array.from([4]), "EchoBlobs parts[1]");
const resp7b = await api.echoBlobs({
const resp7b = await api.blobs({
maybeData: null,
parts: [Uint8Array.from([]), Uint8Array.from([9])],
});
Expand All @@ -151,7 +151,7 @@ async function run() {
// Test 8: EchoFail — server error surfaces with its message
let failMessage = "";
try {
await api.echoFail({ message: "deliberate failure" });
await api.fail({ message: "deliberate failure" });
} catch (e: any) {
failMessage = e.message;
}
Expand Down
Loading
Loading