Skip to content

Commit

Permalink
Restore interfaces for exported Kotlin classes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartinesp authored and bendk committed Nov 8, 2023
1 parent 411d767 commit ef2a471
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions uniffi_bindgen/src/bindings/kotlin/templates/ObjectTemplate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
{%- let (interface_name, impl_class_name) = obj|object_names %}
{%- let methods = obj.methods() %}

open class {{ impl_class_name }} : FFIObject{% if obj.is_trait_interface() %}, {{ interface_name }} {% endif %} {
{% include "Interface.kt" %}

open class {{ impl_class_name }} : FFIObject, {{ interface_name }} {

constructor(pointer: Pointer): super(pointer)

Expand Down Expand Up @@ -48,8 +50,8 @@ open class {{ impl_class_name }} : FFIObject{% if obj.is_trait_interface() %}, {
{%- endmatch -%}
{%- if meth.is_async() %}
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
{% if obj.is_trait_interface() %}override {% else %}open {% endif %}suspend fun {{ meth.name()|fn_name }}(
{%- if obj.is_trait_interface() %}{% call kt::arg_list_protocol(meth) %}{% else %}{% call kt::arg_list_decl(meth) %}{% endif -%}
override suspend fun {{ meth.name()|fn_name }}(
{%- call kt::arg_list_decl(meth) -%}
){% match meth.return_type() %}{% when Some with (return_type) %} : {{ return_type|type_name }}{% when None %}{%- endmatch %} {
return uniffiRustCallAsync(
callWithPointer { thisPtr ->
Expand Down Expand Up @@ -80,8 +82,8 @@ open class {{ impl_class_name }} : FFIObject{% if obj.is_trait_interface() %}, {
{%- else -%}
{%- match meth.return_type() -%}
{%- when Some with (return_type) -%}
{% if obj.is_trait_interface() %}override {% else %}open {% endif %}fun {{ meth.name()|fn_name }}(
{%- if obj.is_trait_interface() %}{% call kt::arg_list_protocol(meth) %}{% else %}{% call kt::arg_list_decl(meth) %}{% endif -%}
override fun {{ meth.name()|fn_name }}(
{%- call kt::arg_list_protocol(meth) -%}
): {{ return_type|type_name }} =
callWithPointer {
{%- call kt::to_ffi_call_with_prefix("it", meth) %}
Expand All @@ -90,8 +92,8 @@ open class {{ impl_class_name }} : FFIObject{% if obj.is_trait_interface() %}, {
}

{%- when None -%}
{% if obj.is_trait_interface() %}override {% else %}open {% endif %}fun {{ meth.name()|fn_name }}(
{%- if obj.is_trait_interface() %}{% call kt::arg_list_protocol(meth) %}{% else %}{% call kt::arg_list_decl(meth) %}{% endif -%}
override fun {{ meth.name()|fn_name }}(
{%- call kt::arg_list_protocol(meth) -%}
) =
callWithPointer {
{%- call kt::to_ffi_call_with_prefix("it", meth) %}
Expand Down Expand Up @@ -147,7 +149,6 @@ open class {{ impl_class_name }} : FFIObject{% if obj.is_trait_interface() %}, {
{%- let callback_handler_class = format!("UniffiCallbackInterface{}", name) %}
{%- let callback_handler_obj = format!("uniffiCallbackInterface{}", name) %}
{%- let ffi_init_callback = obj.ffi_init_callback() %}
{% include "Interface.kt" %}
{% include "CallbackInterfaceImpl.kt" %}
{%- endif %}

Expand Down

0 comments on commit ef2a471

Please sign in to comment.