Expand description
Kotlin (JVM) binding generator backend for alef.
Phase 1A skeleton: registers KotlinBackend and exposes BuildConfig
with BuildDependency::Ffi. Kotlin/JVM consumes the same Java/Panama
.so produced by the Java backend; real codegen lands in Phase 1B.
Kotlin/Native and Kotlin Multiplatform paths are deferred to Phase 3.
Modules§
- literal_
normalizer - Post-processing fixes for Kotlin generated code.
- naming
- Kotlin-specific naming helpers for
ResolvedCrateConfig.
Structs§
- Kotlin
Backend - Kotlin
JvmBridge Generator - Kotlin JVM trait-bridge generator.
Functions§
- emit_
enum_ pub - emit_
error_ type_ pub - emit_
function_ jvm - Emit a JVM function body (delegates to Bridge) inside an
objectblock. - emit_
jni_ bridge_ object - Emit
<PascalCrateName>Bridge.kt— a Kotlinobjectcontaining: - emit_
jni_ client_ class - Emit
DefaultClient.ktfor the JNI mode. - emit_
jvm_ client_ class - Emit one Kotlin coroutine-wrapper file per opaque client type.
- emit_
jvm_ client_ class_ with_ package - Variant of
emit_jvm_client_classthat lets callers override the emitted Kotlin package. The kotlin/android backend uses this to thread[crates.kotlin_android] packagethrough instead of falling back to the generic[crates.kotlin] packageaccessor (which would derive acom.github.<org>fallback from the GitHub URL when the JVM-only Kotlin crate config is absent). - emit_
kdoc_ pub - Emit cleaned KDoc for a documentation string. Re-exported for sibling
crates (alef-backend-kotlin-android) so they can attach KDoc to their own
emitted declarations without depending on
alef-codegendirectly. - emit_
streaming_ jni_ external_ funs - Emit
external fun native{Owner}{Adapter}{Start,Next,Free}declarations for every streaming adapter with an owner type. Called from bothemit_jni_bridge_object(for the Bridge object body) and from tests.exception_classis the simple name of the exception class emitted alongside the Bridge object (e.g."DemoBridgeException"). Start and Next are annotated with@Throwsbecause they can propagate Rust errors; Free is infallible. - emit_
type_ pub - emit_
type_ pub_ with_ defaults_ sealed_ and_ constructible - Like
emit_type_pub_with_enum_defaults_and_sealed_classesbut also threads the set of non-enum data class type names that have a RustDefaultimpl AND whose Kotlin emission gives every constructor parameter a default value. Fields whose declared type references such a name receive a constructor default like= PreprocessingOptions()— preventing Jackson’s Kotlin module from raisingMissingKotlinParameterExceptionwhen the wire JSON omits the nested struct. - emit_
type_ pub_ with_ enum_ defaults - Like
emit_type_pubbut also threads an enum-name → default-variant map so that fields whose declared type is a Named enum (e.g.HeadingStyle) receive a constructor default like= HeadingStyle.ATX. The Jackson Kotlin module otherwise raisesMissingKotlinParameterExceptionwhen the wire JSON omits the key, which is the common case for partial-update payloads sent from test fixtures (mapper.readValue("{\"x\":true}", ConversionOptions::class.java)). - emit_
type_ pub_ with_ enum_ defaults_ and_ sealed_ classes - Like
emit_type_pub_with_enum_defaultsbut also threads the set of sealed-class names (Rust enums withserde_tagorserde_untagged). Fields whose declared type references one of these names receive a@field:JsonSerialize(\as` = …)(orcontentAsfor collections) annotation so Jackson dispatches the parent's custom serializer instead of the variant's default POJO serializer. Seeemit_type_with_imports` for the full rationale. - kotlin_
type_ str_ pub - Render a Kotlin type reference, collecting any needed imports.
- to_
lower_ camel - Convert a
snake_caseorkebab-casename tolowerCamelCase. - to_
pascal_ case - Convert a
snake_caseorkebab-casename toPascalCase.