Skip to content

Commit

Permalink
Add a simple object with methods
Browse files Browse the repository at this point in the history
This currently fails, because it generates this code:

    uniffi::call_with_output(call_status, || {
        Counter::add(
            &<std::sync::Arc as uniffi::ViaFfi>::try_lift(ptr).unwrap(),
            <u32 as uniffi::ViaFfi>::try_lift(amount).unwrap(),
        )
    })

Precisely this line:

    &<std::sync::Arc as uniffi::ViaFfi>::try_lift(ptr).unwrap(),

Which leads to this error (with hilarious fix suggestions):

    9   | #[uniffi::declare_interface]
        | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 1 type argument
        |
    note: struct defined here, with 1 type parameter: `T`
        = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
    help: use angle brackets to add missing type argument
        |
    9   | #[uniffi::declare_interface]<T>
        |                             ^^^

The `Arc` is missing its type argument.
That code comes from here: `uniffi_bindgen/src/scaffolding/mod.rs#L95`
I'm not sure yet where we lose the type information.
  • Loading branch information
badboy committed Aug 5, 2021
1 parent 9613f96 commit 9a23722
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions examples/geometry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ mod geometry {
pub coord_y: f64,
}

pub struct Counter {
value: u32
}

impl Counter {
fn add(&self, amount: u32) {
println!("amount: {}", amount);
}
}

#[derive(Debug, Clone)]
pub struct Line {
pub start: Point,
Expand Down

0 comments on commit 9a23722

Please sign in to comment.