View Source Kinda.CodeGen behaviour (kinda v0.11.0)

Behavior and macros for declaration-driven NIF module generation.

use Kinda.CodeGen requires a codec: module. Generated public wrappers call their concrete raw NIF function and pass only its return value to codec.normalize/1.

The default :combined surface keeps public wrappers, native stubs, and a raw proxy module together. Large bindings can compile the :public and :raw surfaces in separate modules to remove the proxy layer and let the compiler process both surfaces independently.

Summary

Types

declaration_manifest()

@type declaration_manifest() :: Kinda.CodeGen.DeclarationManifest.t()

declaration_manifest_source()

@type declaration_manifest_source() :: Kinda.CodeGen.DeclarationManifest.source()

declaration_surfaces()

@type declaration_surfaces() :: Kinda.CodeGen.DeclarationSurfaces.t()

nif_decl_input()

@type nif_decl_input() ::
  Kinda.CodeGen.NIFDecl.t() | {atom(), integer()} | {atom(), [atom()]}

signature_manifest()

@type signature_manifest() :: map() | nil

type_decl()

@type type_decl() :: Kinda.CodeGen.TypeDecl.t()

Callbacks

declaration_manifest()

@callback declaration_manifest() :: declaration_manifest_source()

kinds()

(optional)
@callback kinds() :: [Kinda.CodeGen.KindDecl.t()]

Functions

declaration_manifest(nif_decls, type_decls, signature_manifest \\ nil)

kinds()

nif_ast(kinds, nifs, root_module, codec)

nif_ast_from_decls(decls, root_module, codec)

nif_decls(kinds, nifs, root_module)

public_nif_ast_from_decls(decls, raw_module, codec)

Generates public wrappers that call functions in raw_module directly.

Kind-scoped declarations are omitted because they are an implementation detail of resource modules rather than part of the public wrapper surface.

raw_module(root_module)

raw_nif_ast_from_decls(decls)

Generates native stubs without a public proxy layer.

Public declarations use their wrapper name in the raw module. Kind-scoped declarations retain their fully-qualified function atoms so each resource kind remains unambiguous.

record_types_ast(signature_manifest)

type_decls(declaration_manifest)

type_decls_ast(type_decls)