BCNP 3.2.1
Batched Command Network Protocol
Loading...
Searching...
No Matches
bcnp_codegen Namespace Reference

Functions

int compute_crc32 (bytes data)
 
str canonical_json (dict schema)
 
int compute_schema_hash (dict schema)
 
int compute_message_size (dict msg)
 
None generate_cpp_header (dict schema, Path output_dir)
 
None generate_python_bindings (dict schema, Path output_dir)
 
 main ()
 

Variables

dict TYPE_INFO
 

Detailed Description

BCNP Schema Compiler

Compiles BCNP message schema (JSON) to C++ header and Python bindings.
Generates serialization/deserialization code and computes schema hash (CRC32).

Usage:
    python bcnp_codegen.py schema/messages.json --cpp src/bcnp/generated/
    python bcnp_codegen.py schema/messages.json --python examples/

Function Documentation

◆ canonical_json()

str bcnp_codegen.canonical_json ( dict schema)
Produce a canonical JSON string for schema hashing.
Only includes structurally significant fields (id, name, type, scale).

Definition at line 44 of file bcnp_codegen.py.

Here is the caller graph for this function:

◆ compute_crc32()

int bcnp_codegen.compute_crc32 ( bytes data)
IEEE CRC32 matching BCNP's existing implementation.

Definition at line 31 of file bcnp_codegen.py.

Here is the caller graph for this function:

◆ compute_message_size()

int bcnp_codegen.compute_message_size ( dict msg)
Compute wire size of a message in bytes.

Definition at line 77 of file bcnp_codegen.py.

Here is the caller graph for this function:

◆ compute_schema_hash()

int bcnp_codegen.compute_schema_hash ( dict schema)
Compute CRC32 of canonical JSON schema.

Definition at line 71 of file bcnp_codegen.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_cpp_header()

None bcnp_codegen.generate_cpp_header ( dict schema,
Path output_dir )
Generate C++ header with message types and serialization.

The file is written to output_dir/bcnp/message_types.h so that
users can add output_dir to their include path and use:
    #include <bcnp/message_types.h>

Definition at line 85 of file bcnp_codegen.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_python_bindings()

None bcnp_codegen.generate_python_bindings ( dict schema,
Path output_dir )
Generate Python module with message classes and serialization.

Definition at line 395 of file bcnp_codegen.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

bcnp_codegen.main ( )

Definition at line 556 of file bcnp_codegen.py.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ TYPE_INFO

dict bcnp_codegen.TYPE_INFO
Initial value:
1= {
2 "int8": (1, "int8_t", True, "b"),
3 "uint8": (1, "uint8_t", False, "B"),
4 "int16": (2, "int16_t", True, "h"),
5 "uint16": (2, "uint16_t", False, "H"),
6 "int32": (4, "int32_t", True, "i"),
7 "uint32": (4, "uint32_t", False, "I"),
8 "float32": (4, "float", True, "f"), # Encoded as int32 with scale
9}

Definition at line 20 of file bcnp_codegen.py.