thrift_generator_loader (thrift_generator v0.7.0)
View SourceLoads an IDL compilation unit: the root file plus every transitively included file.
Include paths resolve relative to the directory of the including file.
Circular includes are an error; diamond includes deduplicate. Each file
becomes one entry with its module name — taken from namespace erl
(or namespace *), falling back to the file base name without the
.thrift extension. Entries come back in pre-order (root first); paths
are absolute binaries.
Summary
Functions
The qualification prefix other files' references use for this file's
definitions: the file base name without the .thrift extension. Apache
Thrift spells cross-module references with the include's base name
(include "foo.thrift" makes foo.Type references), which is a
different key than the module name the file's erl namespace produces.
Loads Path and its transitive includes, or fails on parse errors,
missing files, circular includes or two files claiming the same module
name.
Types
-type ast_node() :: #thrift_generator_node{line :: non_neg_integer(), col :: non_neg_integer(), doc :: doc(), annotations :: erl_annotations(), payload :: term(), type_module :: module()}.
-type base_type() :: bool | i8 | i16 | i32 | i64 | double | string | binary | uuid.
-type const_value() :: {ref, Name :: binary()} | boolean() | integer() | float() | binary() | {list, [const_value()]} | {map, [{const_value(), const_value()}]}.
-type constant() :: #thrift_generator_constant{name :: constant_name(), type :: thrift_type(), value :: const_value()}.
-nominal constant_name() :: binary().
-type cpp_include() :: #thrift_generator_cpp_include{path :: include_path()}.
-type doc() :: binary() | undefined.
-type enum_() :: #thrift_generator_enum{name :: enum_name(), values :: [enum_value()]}.
-nominal enum_name() :: binary().
-type enum_value() :: {Name :: binary(), Value :: integer() | undefined, annotations(), doc()}.
-type exception_() :: #thrift_generator_exception{name :: exception_name(), fields :: [ast_node()]}.
-nominal exception_name() :: binary().
-type field_() :: #thrift_generator_field{id :: integer() | undefined, required :: requiredness(), type :: thrift_type(), name :: field_name(), default :: const_value() | undefined}.
-nominal field_name() :: binary().
-type function_() :: #thrift_generator_function{oneway :: boolean(), return_type :: thrift_type() | void, name :: function_name(), fields :: [ast_node()], throws :: [ast_node()]}.
-nominal function_name() :: binary().
-type include_() :: #thrift_generator_include{path :: include_path()}.
-nominal include_path() :: binary().
-type namespace_() :: #thrift_generator_namespace{scope :: namespace_scope(), name :: namespace_name()}.
-nominal namespace_name() :: binary().
-nominal namespace_scope() :: binary().
-type node_payload() :: document() | include_() | cpp_include() | namespace_() | constant() | typedef() | enum_() | struct_() | union_def() | exception_() | service() | function_() | field_().
-type requiredness() :: required | optional | default.
-type service() :: #thrift_generator_service{name :: service_name(), extends :: service_parent() | undefined, functions :: [ast_node()]}.
-nominal service_name() :: binary().
-nominal service_parent() :: binary().
-type struct_() :: #thrift_generator_struct{name :: struct_name(), fields :: [ast_node()]}.
-nominal struct_name() :: binary().
-type thrift_type() :: {base, base_type(), annotations()} | type_ref() | {list, Element :: thrift_type(), annotations()} | {set, Element :: thrift_type(), annotations()} | {map, Key :: thrift_type(), Value :: thrift_type(), annotations()}.
-type type_ref() :: {ref, Name :: binary(), annotations()}.
-type typedef() :: #thrift_generator_typedef{name :: typedef_name(), type :: thrift_type()}.
-nominal typedef_name() :: binary().
-type union_def() :: #thrift_generator_union{name :: union_name(), fields :: [ast_node()]}.
-nominal union_name() :: binary().
Functions
-spec include_qualifier(file:filename_all()) -> binary().
The qualification prefix other files' references use for this file's
definitions: the file base name without the .thrift extension. Apache
Thrift spells cross-module references with the include's base name
(include "foo.thrift" makes foo.Type references), which is a
different key than the module name the file's erl namespace produces.
-spec load(file:filename_all()) -> {ok, [#tg_loaded{name :: binary(), prefix :: binary(), path :: binary(), includes :: [binary()], doc :: ast_node()}]} | {error, term()}.
Loads Path and its transitive includes, or fails on parse errors,
missing files, circular includes or two files claiming the same module
name.