Skip to main content

Module c_mode

Module c_mode 

Source
Expand description

IDL → C99 codegen mode (vendor spec zerodds-xcdr2-c-1.0).

For each IDL specification, this module emits:

  • C99 typedef struct definitions per struct (with a module prefix in the type name, because C99 has no namespaces).
  • Static zerodds_typesupport_t tables with XCDR2 encoder/ decoder/key-hash/free function pointers.
  • Inline body implementations of the encoders/decoders that produce the XCDR2 wire format (XTypes 1.3 §7.4) byte-exactly.

§Scope (rc1)

Supported:

  • Structs with @final/@appendable/@mutable extensibility.
  • Primitive types (boolean, octet, short/long/long long + unsigned, float, double).
  • string (unbounded).
  • sequence<T> (unbounded; nested sequences allowed).
  • Nested modules → type-name prefix with :: (cross-language convention) and identifier prefix with _ (C99-conformant).
  • @key members → key-hash routine via PlainCdr2BeKeyHolder.
  • @id(N) for @mutable.

Out of scope (errors at the codegen level):

  • Unions, enums, bitsets/bitmasks, typedefs, arrays, maps.
  • wstring, fixed, any.
  • @optional/@external/@bit_bound.

§Invocation

use zerodds_idl::config::ParserConfig;
use zerodds_idl_cpp::{generate_c_header, CGenOptions};

let ast = zerodds_idl::parse("@final struct Point { long x; long y; };",
                             &ParserConfig::default()).unwrap();
let header = generate_c_header(&ast, &CGenOptions::default()).unwrap();
assert!(header.contains("typedef struct Point_s"));
assert!(header.contains("Point_typesupport"));

Structs§

CGenOptions
Codegen options (parallel to CppGenOptions).

Functions§

generate_c_header
Produces a complete C99 header from an IDL specification.