Unifex.Specs (Unifex v1.2.2)

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.

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.

Types

enum_t()

@type enum_t() :: {enum_name :: atom(), [enum_field :: atom()]}

interface_t()

@type 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.

native_name_t()

@type native_name_t() :: atom()

struct_t()

@type struct_t() ::
  {struct_alias :: atom(), struct_module_name :: atom(),
   [{field_name :: atom(), field_type :: {atom() | {:list, atom()}}}]}

t()

@type 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: [],
  functions_args: [
    {function_name :: atom(), [arg_type :: {atom() | {:list, atom()}}]}
  ],
  functions_docs: [
    {function_name :: atom(), documentation :: String.t() | false}
  ],
  functions_results: [{function_name :: atom(), return_type :: Macro.t()}],
  interface: [interface_t()] | interface_t() | nil,
  module: Unifex.CodeGenerator.t() | nil,
  name: native_name_t(),
  sends: [{send_name :: atom(), send_term_type :: Macro.t()}],
  state_type: String.t() | nil,
  structs: [struct_t()]
}

Functions

parse(specs_file, name)

@spec parse(specs_file :: String.t(), native_name_t()) :: t()

Parses Unifex specs of native functions.