Skip to content

feat(client/codegen): C++ wire-contract header from the Python registry#270

Open
ryanontheinside wants to merge 1 commit into
refactor/client-sdk-configfrom
feat/client-sdk-cpp-wire-emitter
Open

feat(client/codegen): C++ wire-contract header from the Python registry#270
ryanontheinside wants to merge 1 commit into
refactor/client-sdk-configfrom
feat/client-sdk-cpp-wire-emitter

Conversation

@ryanontheinside

Copy link
Copy Markdown
Collaborator

Step 04 (DEMON side) of the wire-contract onboarding: project a C++ header from the same demos/realtime_motion_graph_web/protocol.py registry that already generates the TypeScript wireContract.gen.ts, so the JUCE/C++ rtmg-vst plugin can share one source of truth for the wire contract instead of hand-copying message strings.

What it adds

  • render_wire_types_hpp(contract, knob_schema_version) in scripts/gen_wire_types.py (parallel to render_wire_types_ts), plus _cpp_comment / _cpp_str_lit / _cpp_const_name / _indent / _emit_cpp_message / _emit_cpp_group helpers. main() now writes both .ts and .hpp.
  • packages/demon-client/types/wireContract.gen.hpp — committed beside the .ts.
  • A byte-for-byte drift guard test_generated_wire_types_hpp_match_contract mirroring the .ts one.

Design: constants + enums only, JSON-library-agnostic

The header declares no structs and pulls in no JSON dependency. It emits string constants only — message "type" names, per-field JSON keys, and enum option values — under demon::wire::{command,event,config,handshake}, plus kProtocolVersion / kKnobSchemaVersion / kTypeKey. The VST parses with juce::var and has no nlohmann, so a struct-typed header wouldn't compile there; this keeps the emitter framework-neutral and the VST keeps its own (de)serialization.

Relationship to other PRs

Sibling of #269 — both branch off refactor/client-sdk-config. #269 never touches protocol.py / gen_wire_types.py, so there is no overlap; this reads the registry only. Merges as part of the #266#267 stack.

Verification

  • tests/unit/test_wire_contract.py: 16 passed (was 15); drift guard confirmed non-hollow (fails on a stale header, passes after regenerate).
  • Generated header compiles clean under MSVC C++17 with /WX.

…egistry

Add render_wire_types_hpp to gen_wire_types.py — a JSON-library-agnostic C++
projection of the same wire_contract() registry that backs the TypeScript
types. It emits string constants only (message "type" names, per-field JSON
keys, enum option values) under demon::wire::{command,event,config,handshake},
plus kProtocolVersion / kKnobSchemaVersion / kTypeKey. No structs, no JSON
dependency: a C++ client keeps its own (de)serialization and just references
the generated names.

main() now writes both the .ts and the new
packages/demon-client/types/wireContract.gen.hpp; a byte-for-byte drift guard
(test_generated_wire_types_hpp_match_contract) mirrors the existing .ts one.

The rtmg-vst JUCE plugin vendors this header so the C++ client shares one
source of truth for the wire contract instead of hand-copying message strings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant