Fledex.Utils.Dsl (fledex v0.7.0)
View SourceThe module is only inteded to be used by the Fledex module.
It's a set of helper functions to create the DSL. A lot of functions are workign on the AST (abstract syntax tree) level.
Summary
Functions
This function applies an effect to some configurations
This function takes an ast function block and adds an argument
to the function. This is different from ast_add_argument_to_func_if_missing/1
that it does not expect there to be an arugment and therefore will raise an
ArgumentError if it does find one.
This function takes an AST block of a function, checks whether
the required parameter (trigger) is present, and if not will
add one.
This function is to decide on whether ast_create_anonymous_func/1
or ast_create_anonymous_func/2 should be called
This function takes an AST of a function body and wraps it into an anonymous function. It does expect that the arguments are handled as part of the function body, e.g. the function body should look something like this
This function is similar to ast_create_anonymous_func/1, except that no
argument was specified in the block (because the user does not want to use it),
even though the function should have one.
The function will make sure to add the argument to the block before wrapping
it into an anonymous function.
This function extracts teh configs from an AST
This function creates the configuration for an led strip
This function creates the configuration for a component
This function creates a configuration for an animator
This function creates the configuration for a coordinator
This function creates the confguration for a job
This initializes our animation system, except if we don't want this
Functions
@spec apply_effect( atom(), keyword(), Fledex.Animation.Manager.config_t() | [Fledex.Animation.Manager.config_t()] ) :: Fledex.Animation.Manager.config_t()
This function applies an effect to some configurations
This function takes an ast function block and adds an argument
to the function. This is different from ast_add_argument_to_func_if_missing/1
that it does not expect there to be an arugment and therefore will raise an
ArgumentError if it does find one.
This function takes an AST block of a function, checks whether
the required parameter (trigger) is present, and if not will
add one.
This function is to decide on whether ast_create_anonymous_func/1
or ast_create_anonymous_func/2 should be called
Note
This function makes the assumption that a single argument is required.
@spec ast_create_anonymous_func([{:->, list(), [[atom()] | any()]}]) :: {:fn, [], [{:->, list(), [[atom()] | any()]}]}
This function takes an AST of a function body and wraps it into an anonymous function. It does expect that the arguments are handled as part of the function body, e.g. the function body should look something like this:
arg1 -> :ok
arg1, arg2 -> :ok
This function is similar to ast_create_anonymous_func/1, except that no
argument was specified in the block (because the user does not want to use it),
even though the function should have one.
The function will make sure to add the argument to the block before wrapping
it into an anonymous function.
This function extracts teh configs from an AST
@spec configure_strip( atom(), :config | Fledex.LedStrip.drivers_config_t(), keyword(), [Fledex.Animation.Manager.config_t()] | Fledex.Animation.Manager.config_t() ) :: :ok | Fledex.Animation.Manager.config_t()
This function creates the configuration for an led strip
@spec create_config(atom(), atom(), keyword() | nil) :: Fledex.Animation.Manager.config_t()
This function creates the configuration for a component
@spec create_config( atom(), :animation | :static, (map() -> Fledex.Leds.t()), keyword() | nil ) :: Fledex.Animation.Manager.config_t()
This function creates a configuration for an animator
@spec create_coordinator(atom(), keyword(), (-> any())) :: %{ required(atom()) => Fledex.Animation.Coordinator.config_t() }
This function creates the configuration for a coordinator
@spec create_job(atom(), Fledex.Scheduler.Job.schedule(), keyword(), (-> any())) :: %{ required(atom()) => Fledex.Animation.JobScheduler.config_t() }
This function creates the confguration for a job
This initializes our animation system, except if we don't want this