-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add proc-macro test fixture with simple function calls
- Loading branch information
Showing
11 changed files
with
106 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[package] | ||
name = "uniffi-fixture-simple-fns" | ||
version = "0.17.0" | ||
authors = ["Firefox Sync Team <sync-team@mozilla.com>"] | ||
edition = "2018" | ||
license = "MPL-2.0" | ||
publish = false | ||
|
||
[lib] | ||
name = "uniffi_simple_fns" | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
uniffi = { path = "../../uniffi", features = ["builtin-bindgen"] } | ||
thiserror = "1.0" | ||
lazy_static = "1.4" | ||
|
||
[build-dependencies] | ||
uniffi_build = { path = "../../uniffi_build", features = ["builtin-bindgen"] } | ||
|
||
[dev-dependencies] | ||
uniffi_macros = { path = "../../uniffi_macros" } |
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,3 @@ | ||
# A basic test for uniffi components | ||
|
||
This test covers basic free-standing functions. |
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,7 @@ | ||
/* 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/. */ | ||
|
||
fn main() { | ||
uniffi_build::generate_scaffolding("./src/simple-fns.udl").unwrap(); | ||
} |
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,25 @@ | ||
/* 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/. */ | ||
|
||
#[uniffi::export] | ||
fn get_string() -> String { | ||
"String created by Rust".to_owned() | ||
} | ||
|
||
#[uniffi::export] | ||
fn get_int() -> i32 { | ||
1289 | ||
} | ||
|
||
#[uniffi::export] | ||
fn string_identity(s: String) -> String { | ||
s | ||
} | ||
|
||
#[uniffi::export] | ||
fn byte_to_u32(byte: u8) -> u32 { | ||
byte.into() | ||
} | ||
|
||
include!(concat!(env!("OUT_DIR"), "/simple-fns.uniffi.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 @@ | ||
namespace uniffi_simple_fns {}; |
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,10 @@ | ||
/* 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/. */ | ||
|
||
import uniffi.fixture.simple_fns.*; | ||
|
||
assert(getString() == "String created by Rust") | ||
assert(getInt() == 1289) | ||
assert(stringIdentity("String created by Kotlin") == "String created by Kotlin") | ||
assert(byteToU32(255U) == 255U) |
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,10 @@ | ||
# 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/. | ||
|
||
from uniffi_simple_fns import * | ||
|
||
assert get_string() == "String created by Rust" | ||
assert get_int() == 1289 | ||
assert string_identity("String created by Python") == "String created by Python" | ||
assert byte_to_u32(255) == 255 |
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,10 @@ | ||
/* 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/. */ | ||
|
||
import uniffi_simple_fns | ||
|
||
assert(getString() == "String created by Rust") | ||
assert(getInt() == 1289) | ||
assert(stringIdentity(s: "String created by Kotlin") == "String created by Kotlin") | ||
assert(byteToU32(byte: 255) == 255) |
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,8 @@ | ||
uniffi_macros::build_foreign_language_testcases!( | ||
["src/simple-fns.udl"], | ||
[ | ||
"tests/bindings/test_simple_fns.kts", | ||
"tests/bindings/test_simple_fns.swift", | ||
"tests/bindings/test_simple_fns.py", | ||
] | ||
); |
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,9 @@ | ||
[bindings.kotlin] | ||
package_name = "uniffi.fixture.simple_fns" | ||
cdylib_name = "uniffi_simple_fns" | ||
|
||
[bindings.python] | ||
cdylib_name = "uniffi_simple_fns" | ||
|
||
[bindings.swift] | ||
cdylib_name = "uniffi_simple_fns" |