Jengamon / ruwren

A Rustified binding for Wren
Other
40 stars 9 forks source link

How do I create a foreign static function for a non-foreign class in rust? #14

Closed darmie closed 1 year ago

darmie commented 1 year ago

I have a class like this

class MyClass {
  foreign static api(result);
  static call(){
     api("result data") // call the foreign function
  }
}

Is there an API to do something like this?

fn api_function(vm:&VM){
   // do stuff with data
}

/// macro to generate a wren foreign function 
create_foreign_function!{
  static(fn "MyClass.api", 1) api_function
}