API Reference thrift_generator v#0.7.0
View SourceModules
Front end of the Thrift IDL generator: turns IDL files into tokens and
an AST of #thrift_generator_node{} records.
Command-line front end (escript entry point).
Specialized binary-protocol wire codecs emitted into <mod>_types.erl.
Raw erl_parse vocabulary shared by the specialized wire-codec emitters
(thrift_generator_codec for the binary protocol and its compact/JSON
siblings).
Specialized compact-protocol wire codecs emitted into <mod>_types.erl.
Specialized JSON wire codecs emitted into the types module: per struct
an encode_<X>_json/1 (wire map → {ok, iodata()} | {error, _}), a
decode_<X>_json/1 (binary → {ok, WireMap, Rest} | more | {error, _}, consuming the message envelope's closing ] like the top-level
generic decode) and a json_codec/1 dispatcher ({ok, {Encode, Decode}} | error by wire struct name). The clauses mirror the generic
engine (thrift_runtime_json) byte for byte and error term for error term
— the same discipline as the binary and compact emitters, proven by
the PropEr equivalence properties and the negative battery in
thrift_codec_test.
Error rendering shared by the CLI and the rebar3 plugin.
Turns the semantic model into Erlang modules.
The per-service trio of generated modules: <prefix>_<svc>_handler.erl
(the -callback behaviour), <prefix>_<svc>_server.erl (the
start/stop/port entry points) and <prefix>_<svc>_client.erl (one
typed wrapper per IDL function). The name carries the file's
identifier prefix and the snake-cased service name — Ping in
namespace erl ping.api becomes ping_api_ping_client — so
same-named services of different IDL files cannot collide, exactly
like the record tags.
The erl_syntax helper layer the emitters build forms with: module
headers, attributes, function forms, -doc attributes, literal terms
and the rendering to source text.
Loads an IDL compilation unit: the root file plus every transitively included file.
Identifier derivation shared by the semantic checks and the emitters.
Builds the payload record of an AST node from its kind atom and constructor arguments.
Semantic analysis: turns documents loaded by thrift_generator_loader
into the validated #tg_model{} IR consumed by the code emitter.