Flatbuf.Codegen.Naming (flatbuf v0.1.0)

Copy Markdown View Source

Centralized fully-qualified-name → Elixir-module-name mapping.

Without a :namespace override, the FQN drives the module name directly: org.apache.arrow.flatbuf.Schema becomes Org.Apache.Arrow.Flatbuf.Schema.

When :namespace is set on the codegen (or passed via mix flatbuf.gen --namespace), it replaces whatever namespace the schema declared. Only the type's short name (last dotted segment) is kept; the override becomes the new root. For the Arrow example:

module_name("org.apache.arrow.flatbuf.Schema", nil)
#=> "Org.Apache.Arrow.Flatbuf.Schema"

module_name("org.apache.arrow.flatbuf.Schema", "Arrow.Ipc.Flatbuf")
#=> "Arrow.Ipc.Flatbuf.Schema"

All codegen modules thread the same override through every call, so cross-references inside emitted code resolve consistently.

Summary

Functions

module_name(fqn, prefix)

@spec module_name(String.t(), String.t() | nil) :: String.t()