Skip to main content

Module decl

Module decl 

Source
Expand description

Language-neutral declaration vocabulary: the decl objects and constructor macros a build script uses to describe boundary expansion (expand_param! / expand_return!), free functions (fun!), and canonical single-value conversions (convert!). Moved down from the JNI adapter (formerly api/lang/jnigen, now the separate prebindgen-jni crate) because none of it is Kotlin/JNI-specific — it only references TypeKey, Origin<syn::Type>, and plain syn types. prebindgen-jni’s own jni/decl.rs keeps the genuinely Kotlin-specific declarations (ptr_class!, enum_class!, sealed_class!, data_class!, constant!, package!) and re-exports these types from here, so the public prebindgen_flat::* surface is unaffected by the split.

Structs§

ConvertDecl
ConvertSourceDecl
One conversion source, accepted by ConvertDecl::input / ConvertDecl::output. Built by fun! — a #[prebindgen] conversion fn (bare ident, signature read from the registry) or a binding-local one (fun!(crate::f) + .sig(sig!(…)), the one vocabulary for locally defined callables; a Result<_, E> return states the error channel) — or by the direction-stating macros from! / try_from! / into! / try_into! (a core::convert trait conversion with a stated representation type).
ExpandParamDecl
Declares a type’s default input boundary: how a parameter of this type may be supplied, as a list of variants — “built from this constructor’s ingredients, OR that one’s, OR passed as an existing handle”. Applies to every function with a parameter of the type; a single function opts out or narrows via FunctionDecl::expand_param.
ExpandReturnDecl
Declares a type’s default output boundary: wherever the type is returned or handed to a callback, it is decomposed into this set of fields, all delivered in one FFI crossing — instead of an opaque handle the caller must then query field by field with more JNI calls. Applies to every function returning the type; a single function opts out or replaces the set via FunctionDecl::expand_return.
FieldsDecl
A value-form expansion: the accessor whose returned struct supplies the fields, plus the per-field adjustments. Built with fields! and handed to ExpandReturnDecl::fields.
FunctionDecl
Declares one #[prebindgen] function to export. The adapter either adds it to a package or attaches it to a class as a method or a factory.

Enums§

ConvertSpec
Declares a type’s canonical single-value conversion: how one value of the type crosses the boundary wherever a single value is needed — as a parameter or return, inside Option<_> / Vec<_> / the Result<T, E> success position, as a data_class field. Each direction takes one ConvertSourceDecl:
ExpandDecl
Unifies the two boundary decls into one type so an adapter’s expand can expose a single entry point — the boundary-decl peer of its class declarator. Deliberately no impl From<syn::Type> for ExpandDecl — a bare syn::Type alone doesn’t say which direction it describes, so every declaration names its direction via the matching constructor macro: .expand(prebindgen_registry::expand_param!(Summary)...), .expand(prebindgen_registry::expand_return!(Sample)...).
LocalField
One arm of an expand_return! .field* list (type-level or per-fn). The name is stored raw (None = derive at replay time: for a class-level field, the class member’s Kotlin name if the accessor is a declared member, else snake_to_camel; for a per-fn field, snake_to_camel).
LocalVariant
One arm of an expand_param! .variant* list (type-level or per-fn).

Functions§

declared_origin
The origin of a type a build script wrote.
local_path_prefix
Bare-ident type __JniErr — the generated file’s alias for the prebindgen-jni crate’s JniBindingError framework type. Built-in converters use this as their Result<…, _> error type so their bodies’ <__JniErr as From<String>>::from(...) calls keep compiling. A Result<T, E> return instead binds its own raw E (see JniGenBuilder::lookup_output); the extern’s Err arm funnels both to the per-call signal_error sink via E: Display. The origin-module prefix of a binding-local fn’s declared path (crate::sub::f"crate::sub"). Paths are validated ≥2 segments at decl time (fun! path arm / FieldDecl::with), so the prefix is always non-empty.