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§
- Convert
Decl - Convert
Source Decl - One conversion source, accepted by
ConvertDecl::input/ConvertDecl::output. Built byfun!— 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; aResult<_, E>return states the error channel) — or by the direction-stating macrosfrom!/try_from!/into!/try_into!(acore::converttrait conversion with a stated representation type). - Expand
Param Decl - 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. - Expand
Return Decl - 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. - Fields
Decl - A value-form expansion: the accessor whose returned struct supplies the
fields, plus the per-field adjustments. Built with
fields!and handed toExpandReturnDecl::fields. - Function
Decl - 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§
- Convert
Spec - 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<_>/ theResult<T, E>success position, as adata_classfield. Each direction takes oneConvertSourceDecl: - Expand
Decl - Unifies the two boundary decls into one type so an adapter’s
expandcan expose a single entry point — the boundary-decl peer of its class declarator. Deliberately noimpl From<syn::Type> for ExpandDecl— a baresyn::Typealone 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)...). - Local
Field - 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, elsesnake_to_camel; for a per-fn field,snake_to_camel). - Local
Variant - 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 theprebindgen-jnicrate’sJniBindingErrorframework type. Built-in converters use this as theirResult<…, _>error type so their bodies’<__JniErr as From<String>>::from(...)calls keep compiling. AResult<T, E>return instead binds its own rawE(seeJniGenBuilder::lookup_output); the extern’sErrarm funnels both to the per-callsignal_errorsink viaE: 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.