Files
Jason Larabie 52b6c66fa1 Add C++ Bindings (#3544)
# Description of Changes

This adds C++ server bindings (/crate/bindings-cpp) to allow writing C++
20 modules.

- Emscripten WASM build system integration with CMake
- Macro-based code generation (SPACETIMEDB_TABLE, SPACETIMEDB_REDUCER,
etc)
- All SpacetimeDB types supported (primitives, Timestamp, Identity,
Uuid, etc)
- Product types via SPACETIMEDB_STRUCT
- Sum types via SPACETIMEDB_ENUM
- Constraints marked with FIELD* macros

# API and ABI breaking changes

None

# Expected complexity level and risk

2 - Doesn't heavily impact any other areas but is complex macro C++
structure to support a similar developer experience, did have a small
impact on init command

# Testing

- [x] modules/module-test-cpp - heavily tested every reducer
- [x] modules/benchmarks-cpp - tested through the standalone (~6x faster
than C#, ~6x slower than Rust)
- [x] modules/sdk-test-cpp
- [x] modules/sdk-test-procedure-cpp
- [x] modules/sdk-test-view-cpp  
- [x] Wrote several test modules myself
- [x] Quickstart smoketest [Currently in progress]
- [ ] Write Blackholio C++ server module

---------

Signed-off-by: Jason Larabie <jason@clockworklabs.io>
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Ryan <r.ekhoff@clockworklabs.io>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
2026-02-07 04:26:45 +00:00

58 lines
1.9 KiB
Python

#!/usr/bin/env python3
import json
from collections import Counter
# Load both schemas
with open('rust-module-schema.json', 'r') as f:
rust_schema = json.load(f)
with open('cpp-module-schema.json', 'r') as f:
cpp_schema = json.load(f)
# Count actual tables
rust_tables = rust_schema.get('tables', [])
cpp_tables = cpp_schema.get('tables', [])
print(f'Actual table counts:')
print(f' Rust: {len(rust_tables)} tables')
print(f' C++: {len(cpp_tables)} tables')
# Count all duplicate table entries (tables can appear multiple times for different accessors)
rust_table_names = [t['name'] for t in rust_tables]
cpp_table_names = [t['name'] for t in cpp_tables]
rust_counts = Counter(rust_table_names)
cpp_counts = Counter(cpp_table_names)
print(f'\nTotal table entries (including duplicates):')
print(f' Rust: {sum(rust_counts.values())} entries')
print(f' C++: {sum(cpp_counts.values())} entries')
# Check for tables that appear different number of times
print(f'\nTables with different occurrence counts:')
all_tables = set(rust_counts.keys()) | set(cpp_counts.keys())
diff_found = False
for table in sorted(all_tables):
rust_count = rust_counts.get(table, 0)
cpp_count = cpp_counts.get(table, 0)
if rust_count != cpp_count:
print(f' {table}: Rust={rust_count}, C++={cpp_count}, diff={cpp_count-rust_count}')
diff_found = True
if not diff_found:
print(' None - all tables appear the same number of times')
# Check unique table names
print(f'\nUnique table names:')
print(f' Rust: {len(set(rust_table_names))} unique tables')
print(f' C++: {len(set(cpp_table_names))} unique tables')
# Check if table counts suggest duplicates
print(f'\nTables appearing more than once:')
for table, count in rust_counts.items():
if count > 1:
print(f' Rust: {table} appears {count} times')
for table, count in cpp_counts.items():
if count > 1:
print(f' C++: {table} appears {count} times')