Unifex.Specs (Unifex v0.6.0) View Source

Module that handles parsing Unifex specs for native boilerplate code generation.

For information on how to create such specs, see Unifex.Specs.DSL module.

Link to this section Summary

Types

Name of interface generated for the native library. Must be a suffix of code generator module in Unifex.CodeGenerators namespace.

t()

Functions

Parses Unifex specs of native functions.

Link to this section Types

Specs

interface_t() :: atom()

Name of interface generated for the native library. Must be a suffix of code generator module in Unifex.CodeGenerators namespace.

Unifex has built-in generators for NIF and CNode interfaces.

Specs

t() :: %Unifex.Specs{
  callbacks: %{
    required(hook :: :load | :upgrade | :unload | :main_function) =>
      function_name :: String.t()
  },
  dirty_functions: %{
    required({function_name :: atom(), function_arity :: non_neg_integer()}) =>
      :cpu | :io
  },
  enums: [{enum_name :: atom(), [enum_field :: atom()]}],
  functions_args: [
    {function_name :: atom(), [arg_type :: {atom() | {:list, atom()}}]}
  ],
  functions_results: [{function_name :: atom(), return_type :: Macro.t()}],
  interface: [interface_t()] | interface_t() | nil,
  module: module() | nil,
  name: atom(),
  sends: [{send_name :: atom(), send_term_type :: Macro.t()}],
  state_type: String.t() | nil,
  structs: [
    {struct_alias :: atom(), struct_module_name :: atom(),
     [{field_name :: atom(), field_type :: {atom() | {:list, atom()}}}]}
  ]
}

Link to this section Functions

Specs

parse(specs_file :: Path.t(), name :: atom()) :: t()

Parses Unifex specs of native functions.