-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support builder methods, add ffi integration tests
Signed-off-by: Marin Veršić <marin.versic101@gmail.com>
- Loading branch information
Showing
10 changed files
with
383 additions
and
88 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use iroha_ffi::{ffi_bindgen, FfiResult}; | ||
use std::mem::MaybeUninit; | ||
|
||
struct FfiStruct { | ||
a: u32, | ||
} | ||
|
||
#[ffi_bindgen] | ||
impl FfiStruct { | ||
pub fn from_mutable_input_arg(a: &mut u32) -> Self { | ||
let output = Self { a: a.clone() }; | ||
*a = 42; | ||
output | ||
} | ||
} | ||
|
||
fn main() -> Result<(), ()> { | ||
let s: MaybeUninit<*mut FfiStruct> = MaybeUninit::uninit(); | ||
|
||
if FfiResult::Ok != ffi_struct_from_mutable_input_arg(s.as_mut_ptr()) { | ||
return Err(()); | ||
} | ||
|
||
Ok(()) | ||
} |
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,11 @@ | ||
error: Mutable references not supported | ||
--> tests/ui_fail/mutable_input_arg.rs:10:38 | ||
| | ||
10 | pub fn from_mutable_input_arg(a: &mut u32) -> Self { | ||
| ^^^^^^^^ | ||
|
||
error[E0425]: cannot find function `ffi_struct_from_mutable_input_arg` in this scope | ||
--> tests/ui_fail/mutable_input_arg.rs:20:25 | ||
| | ||
20 | if FfiResult::Ok != ffi_struct_from_mutable_input_arg(s.as_mut_ptr()) { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope |
Oops, something went wrong.