Flatbuf.Codegen (flatbuf v0.1.0)

Copy Markdown View Source

Entry point for code generation.

Given a resolved %Flatbuf.Schema{} and options, produces a list of {module_name, source} pairs covering the Wire helper plus one module per enum, struct, and table.

Summary

Functions

Generate all artifacts for the schema.

Types

artifact()

@type artifact() :: {module(), String.t()}

nicety()

@type nicety() :: :behaviour | :jason

options()

@type options() :: [
  wire_module: module(),
  namespace: String.t() | nil,
  niceties: [nicety()]
]

Functions

generate(schema, opts)

@spec generate(Flatbuf.Schema.t(), options()) :: [artifact()]

Generate all artifacts for the schema.

Options:

  • :wire_module (required) — module name for the emitted wire helper. Every generated table aliases this module.
  • :namespace (optional) — string like "Arrow.Ipc.Flatbuf". When set, every generated module's name uses the override as its root, with the schema type's short name appended. The original namespace in the .fbs file is ignored.
  • :niceties (optional, default []) — list of atoms enabling opt-in protocols/behaviours on generated root tables:
    • :behaviour@behaviour Flatbuf.Table.
    • :jason@derive Jason.Encoder on the table struct.