Skip to main content

Module c_mode

Module c_mode 

Source
Expand description

IDL → C99 Codegen-Mode (Vendor-Spec zerodds-xcdr2-c-1.0).

Diese Module emittiert pro IDL-Specification:

  • C99 typedef struct-Definitionen pro struct (mit Module-prefix im Type-Namen, weil C99 keine Namespaces hat).
  • Statische zerodds_typesupport_t-Tabellen mit XCDR2-Encoder/ Decoder/KeyHash/Free-Funktionspointern.
  • Inline-Body-Implementationen der Encoder/Decoder, die das XCDR2-Wire-Format (XTypes 1.3 §7.4) byte-genau erzeugen.

§Scope (rc1)

Unterstuetzt:

  • Strukturen mit @final/@appendable/@mutable-Extensibility.
  • Primitive-Typen (boolean, octet, short/long/long long + unsigned, float, double).
  • string (unbounded).
  • sequence<T> (unbounded; nested sequences zulaessig).
  • Geschachtelte Module → Type-Name-Praefix mit :: (Cross-Lang- Konvention) und Identifier-Praefix mit _ (C99-konform).
  • @key-Members → Key-Hash-Routine ueber PlainCdr2BeKeyHolder.
  • @id(N) fuer @mutable.

Ausserhalb (Errors auf der Codegen-Ebene):

  • Unions, Enums, Bitsets/Bitmasks, Typedefs, Arrays, Maps.
  • wstring, fixed, any.
  • @optional/@external/@bit_bound.

§Aufruf

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-Optionen (parallel zu CppGenOptions).

Functions§

generate_c_header
Erzeugt einen vollstaendigen C99-Header aus einer IDL-Specification.