-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2048 from mhammond/async-ctors
Add async constructor support.
- Loading branch information
Showing
27 changed files
with
347 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 1 addition & 52 deletions
53
uniffi_bindgen/src/bindings/kotlin/templates/TopLevelFunctionTemplate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1 @@ | ||
{%- call kt::docstring(func, 8) %} | ||
{%- if func.is_async() %} | ||
{%- match func.throws_type() -%} | ||
{%- when Some with (throwable) %} | ||
@Throws({{ throwable|type_name(ci) }}::class) | ||
{%- else -%} | ||
{%- endmatch %} | ||
|
||
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") | ||
suspend fun {{ func.name()|fn_name }}({%- call kt::arg_list_decl(func) -%}){% match func.return_type() %}{% when Some with (return_type) %} : {{ return_type|type_name(ci) }}{% when None %}{%- endmatch %} { | ||
return uniffiRustCallAsync( | ||
UniffiLib.INSTANCE.{{ func.ffi_func().name() }}({% call kt::arg_list_lowered(func) %}), | ||
{{ func|async_poll(ci) }}, | ||
{{ func|async_complete(ci) }}, | ||
{{ func|async_free(ci) }}, | ||
// lift function | ||
{%- match func.return_type() %} | ||
{%- when Some(return_type) %} | ||
{ {{ return_type|lift_fn }}(it) }, | ||
{%- when None %} | ||
{ Unit }, | ||
{% endmatch %} | ||
// Error FFI converter | ||
{%- match func.throws_type() %} | ||
{%- when Some(e) %} | ||
{{ e|type_name(ci) }}.ErrorHandler, | ||
{%- when None %} | ||
UniffiNullRustCallStatusErrorHandler, | ||
{%- endmatch %} | ||
) | ||
} | ||
|
||
{%- else %} | ||
{%- match func.throws_type() -%} | ||
{%- when Some with (throwable) %} | ||
@Throws({{ throwable|type_name(ci) }}::class) | ||
{%- else -%} | ||
{%- endmatch -%} | ||
|
||
{%- match func.return_type() -%} | ||
{%- when Some with (return_type) %} | ||
|
||
fun {{ func.name()|fn_name }}({%- call kt::arg_list_decl(func) -%}): {{ return_type|type_name(ci) }} { | ||
return {{ return_type|lift_fn }}({% call kt::to_ffi_call(func) %}) | ||
} | ||
{% when None %} | ||
|
||
fun {{ func.name()|fn_name }}({% call kt::arg_list_decl(func) %}) = | ||
{% call kt::to_ffi_call(func) %} | ||
|
||
{% endmatch %} | ||
{%- endif %} | ||
{%- call kt::func_decl("", func, 8) %} |
Oops, something went wrong.