-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add binding docstrings #512
Open
dangeross
wants to merge
5
commits into
main
Choose a base branch
from
savage-rn-codegen-0.25
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
# Generated by pub | ||
# See https://dart.dev/tools/pub/glossary#lockfile | ||
packages: | ||
args: | ||
dependency: "direct main" | ||
description: | ||
name: args | ||
sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a" | ||
url: "https://pub.dev" | ||
source: hosted | ||
version: "2.5.0" | ||
async: | ||
dependency: transitive | ||
description: | ||
name: async | ||
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" | ||
url: "https://pub.dev" | ||
source: hosted | ||
version: "2.11.0" | ||
charcode: | ||
dependency: transitive | ||
description: | ||
name: charcode | ||
sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306 | ||
url: "https://pub.dev" | ||
source: hosted | ||
version: "1.3.1" | ||
cli_script: | ||
dependency: "direct main" | ||
description: | ||
name: cli_script | ||
sha256: "3463c6e8e57271faaf557eee56cb455522f1ab1ebe618bbfb7454f74fc793967" | ||
url: "https://pub.dev" | ||
source: hosted | ||
version: "0.3.1" | ||
collection: | ||
dependency: transitive | ||
description: | ||
name: collection | ||
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf | ||
url: "https://pub.dev" | ||
source: hosted | ||
version: "1.19.0" | ||
file: | ||
dependency: transitive | ||
description: | ||
name: file | ||
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" | ||
url: "https://pub.dev" | ||
source: hosted | ||
version: "7.0.0" | ||
glob: | ||
dependency: "direct main" | ||
description: | ||
name: glob | ||
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" | ||
url: "https://pub.dev" | ||
source: hosted | ||
version: "2.1.2" | ||
meta: | ||
dependency: transitive | ||
description: | ||
name: meta | ||
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c | ||
url: "https://pub.dev" | ||
source: hosted | ||
version: "1.16.0" | ||
path: | ||
dependency: transitive | ||
description: | ||
name: path | ||
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" | ||
url: "https://pub.dev" | ||
source: hosted | ||
version: "1.9.0" | ||
source_span: | ||
dependency: transitive | ||
description: | ||
name: source_span | ||
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" | ||
url: "https://pub.dev" | ||
source: hosted | ||
version: "1.10.0" | ||
stack_trace: | ||
dependency: transitive | ||
description: | ||
name: stack_trace | ||
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377" | ||
url: "https://pub.dev" | ||
source: hosted | ||
version: "1.12.0" | ||
string_scanner: | ||
dependency: transitive | ||
description: | ||
name: string_scanner | ||
sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" | ||
url: "https://pub.dev" | ||
source: hosted | ||
version: "1.3.0" | ||
term_glyph: | ||
dependency: transitive | ||
description: | ||
name: term_glyph | ||
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 | ||
url: "https://pub.dev" | ||
source: hosted | ||
version: "1.2.1" | ||
tuple: | ||
dependency: transitive | ||
description: | ||
name: tuple | ||
sha256: a97ce2013f240b2f3807bcbaf218765b6f301c3eff91092bcfa23a039e7dd151 | ||
url: "https://pub.dev" | ||
source: hosted | ||
version: "2.0.2" | ||
sdks: | ||
dart: ">=3.4.0 <4.0.0" |
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
32 changes: 32 additions & 0 deletions
32
lib/bindings/langs/react-native/src/gen_kotlin/callback_interface.rs
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
use uniffi_bindgen::ComponentInterface; | ||
|
||
use super::CodeType; | ||
|
||
#[derive(Debug)] | ||
pub struct CallbackInterfaceCodeType { | ||
id: String, | ||
} | ||
|
||
impl CallbackInterfaceCodeType { | ||
pub fn new(id: String) -> Self { | ||
Self { id } | ||
} | ||
} | ||
|
||
impl CodeType for CallbackInterfaceCodeType { | ||
fn type_label(&self, ci: &ComponentInterface) -> String { | ||
super::KotlinCodeOracle.class_name(ci, &self.id) | ||
} | ||
|
||
fn canonical_name(&self) -> String { | ||
format!("Type{}", self.id) | ||
} | ||
|
||
fn initialization_fn(&self) -> Option<String> { | ||
Some(format!("{}.register", self.ffi_converter_name())) | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
lib/bindings/langs/react-native/src/gen_kotlin/compounds.rs
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 |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
use super::CodeType; | ||
use paste::paste; | ||
use uniffi_bindgen::{ | ||
backend::{Literal, Type}, | ||
ComponentInterface, | ||
}; | ||
|
||
#[allow(dead_code)] | ||
fn render_literal(literal: &Literal, inner: &Type, ci: &ComponentInterface) -> String { | ||
match literal { | ||
Literal::Null => "null".into(), | ||
Literal::EmptySequence => "listOf()".into(), | ||
Literal::EmptyMap => "mapOf()".into(), | ||
|
||
// For optionals | ||
_ => super::KotlinCodeOracle.find(inner).literal(literal, ci), | ||
} | ||
} | ||
|
||
macro_rules! impl_code_type_for_compound { | ||
($T:ty, $type_label_pattern:literal, $canonical_name_pattern: literal) => { | ||
paste! { | ||
#[derive(Debug)] | ||
pub struct $T { | ||
inner: Type, | ||
} | ||
|
||
impl $T { | ||
pub fn new(inner: Type) -> Self { | ||
Self { inner } | ||
} | ||
fn inner(&self) -> &Type { | ||
&self.inner | ||
} | ||
} | ||
|
||
impl CodeType for $T { | ||
fn type_label(&self, ci: &ComponentInterface) -> String { | ||
format!($type_label_pattern, super::KotlinCodeOracle.find(self.inner()).type_label(ci)) | ||
} | ||
|
||
fn canonical_name(&self) -> String { | ||
format!($canonical_name_pattern, super::KotlinCodeOracle.find(self.inner()).canonical_name()) | ||
} | ||
|
||
fn literal(&self, literal: &Literal, ci: &ComponentInterface) -> String { | ||
render_literal(literal, self.inner(), ci) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
impl_code_type_for_compound!(OptionalCodeType, "{}?", "Optional{}"); | ||
impl_code_type_for_compound!(SequenceCodeType, "List<{}>", "Sequence{}"); | ||
|
||
#[derive(Debug)] | ||
pub struct MapCodeType { | ||
key: Type, | ||
value: Type, | ||
} | ||
|
||
impl MapCodeType { | ||
pub fn new(key: Type, value: Type) -> Self { | ||
Self { key, value } | ||
} | ||
|
||
fn key(&self) -> &Type { | ||
&self.key | ||
} | ||
|
||
fn value(&self) -> &Type { | ||
&self.value | ||
} | ||
} | ||
|
||
impl CodeType for MapCodeType { | ||
fn type_label(&self, ci: &ComponentInterface) -> String { | ||
format!( | ||
"Map<{}, {}>", | ||
super::KotlinCodeOracle.find(self.key()).type_label(ci), | ||
super::KotlinCodeOracle.find(self.value()).type_label(ci), | ||
) | ||
} | ||
|
||
fn canonical_name(&self) -> String { | ||
format!( | ||
"Map{}{}", | ||
super::KotlinCodeOracle.find(self.key()).canonical_name(), | ||
super::KotlinCodeOracle.find(self.value()).canonical_name(), | ||
) | ||
} | ||
|
||
fn literal(&self, literal: &Literal, ci: &ComponentInterface) -> String { | ||
render_literal(literal, &self.value, ci) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
use uniffi_bindgen::ComponentInterface; | ||
|
||
use super::CodeType; | ||
|
||
#[derive(Debug)] | ||
pub struct CustomCodeType { | ||
name: String, | ||
} | ||
|
||
impl CustomCodeType { | ||
pub fn new(name: String) -> Self { | ||
CustomCodeType { name } | ||
} | ||
} | ||
|
||
impl CodeType for CustomCodeType { | ||
fn type_label(&self, _ci: &ComponentInterface) -> String { | ||
self.name.clone() | ||
} | ||
|
||
fn canonical_name(&self) -> String { | ||
format!("Type{}", self.name) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
use uniffi_bindgen::{backend::Literal, ComponentInterface}; | ||
|
||
use super::CodeType; | ||
|
||
#[derive(Debug)] | ||
pub struct EnumCodeType { | ||
id: String, | ||
} | ||
|
||
impl EnumCodeType { | ||
pub fn new(id: String) -> Self { | ||
Self { id } | ||
} | ||
} | ||
|
||
impl CodeType for EnumCodeType { | ||
fn type_label(&self, ci: &ComponentInterface) -> String { | ||
super::KotlinCodeOracle.class_name(ci, &self.id) | ||
} | ||
|
||
fn canonical_name(&self) -> String { | ||
format!("Type{}", self.id) | ||
} | ||
|
||
fn literal(&self, literal: &Literal, ci: &ComponentInterface) -> String { | ||
if let Literal::Enum(v, _) = literal { | ||
format!( | ||
"{}.{}", | ||
self.type_label(ci), | ||
super::KotlinCodeOracle.enum_variant_name(v) | ||
) | ||
} else { | ||
unreachable!(); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the new
uniffi_bindgen_kmp
, is theuniffi_bindgen_kotlin_multiplatform
below still necessary?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to split the use of
uniffi_bindgen
because of compatibility issues, souniffi_bindgen_kmp
isuniffi_bindgen
0.25.2 for use withuniffi_bindgen_kotlin_multiplatform
.I will play around a bit more to see if I can get them to use the same
uniffi_bindgen
.