Skip to content

Latest commit

 

History

History
47 lines (36 loc) · 2.05 KB

cxx-generated-code-guide.rst

File metadata and controls

47 lines (36 loc) · 2.05 KB

C++ Generated Code Guide

Usage

usage: generate_cxx_backend.py [-h] [--input INPUT] [--output OUTPUT] [--namespace NAMESPACE] [--include-header INCLUDE_HEADER] [--using-namespace USING_NAMESPACE]

options:
  -h, --help            show this help message and exit
  --input INPUT         Input PDL-JSON source
  --output OUTPUT       Output C++ file
  --namespace NAMESPACE
                        Generated module namespace
  --include-header INCLUDE_HEADER
                        Added include directives
  --using-namespace USING_NAMESPACE
                        Added using namespace statements

Example invocation:

cargo run my-protocol.pdl --output-format json | \
    ./pdl-compiler/scripts/generate_cxx_backend.py > my-protocol.h

Language bindings

Enum declarations

enum TestEnum : 8 {
    A = 1,
    B = 2..3,
    C = 4,
    OTHER = ..,
}
enum TestEnum : int8_t {
    A = 1,
    B_MIN = 2,
    B_MAX = 3,
    C = 4,
}

Note

C++ enums are open by construction, default cases in enum declarations are ignored.