sciter-sdk / rust-sciter

Rust bindings for Sciter
https://sciter.com
MIT License
805 stars 75 forks source link

How to execute TIScript callback from Rust? #84

Closed GirkovArpa closed 3 years ago

GirkovArpa commented 3 years ago
view.foo("foo", function(result) {
    stdout.println("result:", result);
  });
impl EventHandler {
    fn foo(&self, filename: String, callback: sciter::Value) -> sciter::Value {
        image_magick_test();
        callback.call(None, &make_args!(1, "2", 3.0), Some(file!())).unwrap();
        sciter::Value::from(bar(filename.as_str()))
    }
}
impl sciter::EventHandler for EventHandler {
    dispatch_script_call! (
        fn foo(String, sciter::Value);
    );
}
fn bar(filename: &str) -> &str {
    return filename;
}

When I do cargo run, I get an error at fn foo(String, sciter::Value) saying that "no rules expected this token in macro call" (referring to sciter::Value).

GirkovArpa commented 3 years ago

I know it's not a minimal reproducible example, but if it's unclear I can simplify it further.

GirkovArpa commented 3 years ago

I found an example at rust-sciter/examples/threads.rs.