Skip to content

Commit

Permalink
Also use type casts for callbacks
Browse files Browse the repository at this point in the history
Signed-off-by: Kegan Dougal <[email protected]>
  • Loading branch information
kegsay committed Mar 14, 2024
1 parent 2d69843 commit 435c7e3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bindgen/templates/CallbackInterfaceTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func ({{ foreign_callback }}) {{ method_name }} (callback {{ type_name }}, args
{%- endmatch -%}
callback.{{ meth.name()|fn_name }}(
{%- for arg in meth.arguments() -%}
{{ arg|read_fn }}(reader)
{{ arg|read_fn }}(reader){{arg|error_type_cast}}
{%- if !loop.last %}, {% endif -%}
{%- endfor -%}
);
Expand Down
4 changes: 4 additions & 0 deletions fixtures/errors/src/errors.udl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ dictionary Vec2 {
double y;
};

callback interface Callback {
void do_something(BoobyTrapError error);
};

namespace errors {

[Throws=BoobyTrapError]
Expand Down
4 changes: 4 additions & 0 deletions fixtures/errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ pub struct Vec2 {
y: f64,
}

pub trait Callback {
fn do_something(&self, error: BoobyTrapError);
}

impl Vec2 {
pub fn new(x: f64, y: f64) -> Vec2 {
Vec2 { x, y }
Expand Down

0 comments on commit 435c7e3

Please sign in to comment.