Meta Programming
For most use cases, the default API @option is sufficient, however, there are some specific cases requires one to use Configurations's advanced API on meta programming.
Custom Option Macro
In some cases, you may not want all the features we defined by default in Configurations.
In this case, you can construct your own macro using the code generation passes defined in Configurations. The code generation passes API starts with codegen_. You combine them as a codegen pipeline.
Configurations uses an intermediate representation defined by Expronicon to represent user defined option types, which is the JLKwStruct struct.
Builtin Code Generators
Configurations.add_field_defaults! — Method
add_field_defaults!(m::Module, def::JLKwStruct)Add default value for Maybe and Reflect type.
Configurations.codegen_convert — Method
codegen_convert(x::JLKwStruct)Generate Base.convert from AbstractDict{String} to the given option type.
Configurations.codegen_create — Method
codegen_create(def::JLKwStruct)Generate Configurations.create overload.
Configurations.codegen_documented_struct — Method
codegen_documented_struct(def::JLKwStruct)Generate the struct definition (with its keyword constructor), with the docstring attached to the struct expression itself, so that field docstrings are collected by the docsystem as for plain structs (#17).
Configurations.codegen_field_default — Method
codegen_field_default(def::JLKwStruct)Generate field_default overload to support the default value reflection.
Configurations.codegen_from_dict_specialize — Method
codegen_from_dict_specialize(def::JLKwStruct)Generate the specialized from_dict for the given definition.
Configurations.codegen_is_option — Method
codegen_is_option(x::JLKwStruct)Generate the is_option method.
Configurations.codegen_isequal — Method
codegen_isequal(x::JLKwStruct)Generate Base.:(==) to overload comparison operator to compare_options for given option type.
Configurations.codegen_option_type — Method
codegen_option_type(mod::Module, def::JLKwStruct)Generate the Configurations option type definition from a given JLKwStruct created by Expronicon.
Configurations.codegen_type_alias — Method
codegen_type_alias(def::JLKwStruct)Generate type alias method type_alias.
Configurations.has_duplicated_reflect_type — Method
has_duplicated_reflect_type(m::Module, def::JLKwStruct)Check if the definition has duplicated reflect type.
Configurations.is_maybe_type_expr — Method
is_maybe_type_expr(m::Module, @nospecialize(ex))Check if the expression ex evaluates to a Maybe{T}.
Configurations.is_reflect_type_expr — Method
is_reflect_type_expr(m::Module, @nospecialize(ex))Check if the expression ex evaluates to a Reflect.
Configurations.validate_option_def — Method
validate_option_def(def::JLKwStruct)Validate the option definition.