Skip to main content

Crate alef_backend_kotlin

Crate alef_backend_kotlin 

Source
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§

KotlinBackend
KotlinJvmBridgeGenerator
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 object block.
emit_jni_bridge_object
Emit <PascalCrateName>Bridge.kt — a Kotlin object containing:
emit_jni_client_class
Emit DefaultClient.kt for 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_class that lets callers override the emitted Kotlin package. The kotlin/android backend uses this to thread [crates.kotlin_android] package through instead of falling back to the generic [crates.kotlin] package accessor (which would derive a com.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-codegen directly.
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 both emit_jni_bridge_object (for the Bridge object body) and from tests. exception_class is the simple name of the exception class emitted alongside the Bridge object (e.g. "DemoBridgeException"). Start and Next are annotated with @Throws because 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_classes but also threads the set of non-enum data class type names that have a Rust Default impl 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 raising MissingKotlinParameterException when the wire JSON omits the nested struct.
emit_type_pub_with_enum_defaults
Like emit_type_pub but 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 raises MissingKotlinParameterException when 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_defaults but also threads the set of sealed-class names (Rust enums with serde_tag or serde_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_case or kebab-case name to lowerCamelCase.
to_pascal_case
Convert a snake_case or kebab-case name to PascalCase.