Skip to main content

Module encode_c

Module encode_c 

Source
Expand description

The C column’s encoder: crate::emit::encode bound to the C backend.

The walk moved to emit/encode.rs when it stopped being C’s alone. What is left here is the binding, and it is a module rather than four turbofishes at each call site because the C generator asks for these by name in twenty places and a ::<C> at each is twenty chances to reach for the wrong backend.

What C forces that the walk does not decide:

  • A pointer parameter. A codec takes const T *v and reaches its members with ->. Every target spells that its own way, and crate::emit::CodecTarget::member is where.
  • An array parameter decays. An array codec takes the array itself, not its address: C adjusts an array parameter to a pointer to its first element, and (*v)[i][j] would otherwise need parentheses the tree has no node for. So a call site passes v->grid for an array and &v->x for everything else.
  • Prototypes ahead of bodies, so a recursive or mutually recursive type does not depend on the order the walk visited its types in.

Re-exports§

pub use crate::emit::encode::CodecOptions as CCodecOptions;

Functions§

c_codec
Build the C encoder for every type in the model, under one plan.
c_codec_from
The C encoder for the types one root reaches, and no others.
c_key_holder
The C key holder for a keyed type, and nothing for one with no @key.
codec_name
The name of the C encoder function for a type.
maybe_unused
Whether the C codec generated for id may legitimately have no caller. See encode::maybe_unused.