-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add byte/UInt8/Int8 types, add start of rondpoint Also updates to current main of uniffi, removing `BindingsConfig` struct * Add more numeric primitives, object * Optionals and Sequences * Map and Record (and actually sequence and optional, forgot to add before) Now generating but not compiling on the Java side yet * Add object cleaners, fix broken Java * Generate `record` files * More compiling Maps, Sequences, Enums Still missing Optional FfiConverters from the generation for some reason * Compiling, following test failures * Working minimal rondpoint test! * All tested and passing except optional defaults. Need to settle on how we want to handle default parameters. * Commit to no defaults * Add JNA to flake * Add to testing doc * Clear up a bunch of the TODOs that were decided * Going with immutable records by default * Add geometry example test * Code review change * Add CI * Add JNA to CI * Try to force CI onto Java 21 * Case matters * Testing * Newer Ubuntu version to get newer JNA version
- Loading branch information
Showing
40 changed files
with
1,395 additions
and
244 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Rust CI | ||
'on': | ||
push: | ||
branches: | ||
- main | ||
pull_request: null | ||
workflow_dispatch: null | ||
schedule: | ||
- cron: 0 14 * * 1 | ||
jobs: | ||
rust-ci: | ||
uses: IronCoreLabs/workflows/.github/workflows/rust-ci.yaml@rust-ci-v2 | ||
with: | ||
# enable once initial implementation is done | ||
run_clippy: false | ||
minimum_coverage: "0" | ||
additional_system_deps: "libjna-java" | ||
cargo_command_env_vars: "PATH=$JAVA_HOME_21_X64/bin:$PATH CLASSPATH=/usr/share/java/jna.jar" | ||
secrets: inherit |
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,2 +1,3 @@ | ||
/target | ||
.direnv | ||
*.class |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,129 @@ | ||
/* 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::{AsCodeType, CodeType}; | ||
use uniffi_bindgen::{ | ||
backend::{Literal, Type}, | ||
ComponentInterface, | ||
}; | ||
|
||
#[derive(Debug)] | ||
pub struct OptionalCodeType { | ||
inner: Type, | ||
} | ||
|
||
impl OptionalCodeType { | ||
pub fn new(inner: Type) -> Self { | ||
Self { inner } | ||
} | ||
fn inner(&self) -> &Type { | ||
&self.inner | ||
} | ||
} | ||
|
||
impl CodeType for OptionalCodeType { | ||
fn type_label(&self, ci: &ComponentInterface) -> String { | ||
super::JavaCodeOracle | ||
.find(self.inner()) | ||
.type_label(ci) | ||
.to_string() | ||
} | ||
|
||
fn canonical_name(&self) -> String { | ||
format!( | ||
"Optional{}", | ||
super::JavaCodeOracle.find(self.inner()).canonical_name() | ||
) | ||
} | ||
|
||
fn literal(&self, literal: &Literal, ci: &ComponentInterface) -> String { | ||
match literal { | ||
Literal::None => "null".into(), | ||
Literal::Some { inner } => super::JavaCodeOracle.find(&self.inner).literal(inner, ci), | ||
_ => panic!("Invalid literal for Optional type: {literal:?}"), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct SequenceCodeType { | ||
inner: Type, | ||
} | ||
|
||
impl SequenceCodeType { | ||
pub fn new(inner: Type) -> Self { | ||
Self { inner } | ||
} | ||
fn inner(&self) -> &Type { | ||
&self.inner | ||
} | ||
} | ||
|
||
impl CodeType for SequenceCodeType { | ||
fn type_label(&self, ci: &ComponentInterface) -> String { | ||
format!( | ||
"List<{}>", | ||
super::JavaCodeOracle.find(self.inner()).type_label(ci) | ||
) | ||
} | ||
|
||
fn canonical_name(&self) -> String { | ||
format!( | ||
"Sequence{}", | ||
super::JavaCodeOracle.find(self.inner()).canonical_name() | ||
) | ||
} | ||
|
||
fn literal(&self, literal: &Literal, _ci: &ComponentInterface) -> String { | ||
match literal { | ||
Literal::EmptySequence => "List.of()".into(), | ||
_ => panic!("Invalid literal for List type: {literal:?}"), | ||
} | ||
} | ||
} | ||
|
||
#[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::JavaCodeOracle.find(self.key()).type_label(ci), | ||
super::JavaCodeOracle.find(self.value()).type_label(ci), | ||
) | ||
} | ||
|
||
fn canonical_name(&self) -> String { | ||
format!( | ||
"Map{}{}", | ||
self.key().as_codetype().canonical_name(), | ||
self.value().as_codetype().canonical_name(), | ||
) | ||
} | ||
|
||
fn literal(&self, literal: &Literal, _ci: &ComponentInterface) -> String { | ||
match literal { | ||
Literal::EmptyMap => "Map.of()".into(), | ||
_ => panic!("Invalid literal for Map type: {literal:?}"), | ||
} | ||
} | ||
} |
Oops, something went wrong.