@@ -8,8 +8,8 @@ use rutie::{
8
8
rubysys:: { class, value:: ValueType } ,
9
9
types:: { Argc , Value } ,
10
10
util:: str_to_cstring,
11
- wrappable_struct, AnyException , AnyObject , Array , Exception , Fixnum , Float , Module , NilClass ,
12
- Object , RString , Symbol ,
11
+ wrappable_struct, AnyException , AnyObject , Array , Boolean , Exception , Fixnum , Float , Module ,
12
+ NilClass , Object , RString , Symbol ,
13
13
} ;
14
14
use std:: { mem, rc:: Rc } ;
15
15
use wasmer_runtime:: { self as runtime, imports, Export } ;
@@ -27,6 +27,10 @@ impl ExportedFunctions {
27
27
Self { instance }
28
28
}
29
29
30
+ pub fn respond_to_missing ( & self , method_name : & str ) -> bool {
31
+ self . instance . dyn_func ( method_name) . is_ok ( )
32
+ }
33
+
30
34
/// Call an exported function on the given WebAssembly instance.
31
35
pub fn method_missing (
32
36
& self ,
@@ -164,6 +168,20 @@ wrappable_struct!(
164
168
165
169
class ! ( RubyExportedFunctions ) ;
166
170
171
+ #[ rustfmt:: skip]
172
+ methods ! (
173
+ RubyExportedFunctions ,
174
+ itself,
175
+
176
+ fn ruby_exported_functions_method_exists( symbol: Symbol , _include_private: Boolean ) -> Boolean {
177
+ unwrap_or_raise( || {
178
+ let symbol = symbol?;
179
+ let instance = itself. get_data( & * EXPORTED_FUNCTIONS_WRAPPER ) ;
180
+ Ok ( Boolean :: new( instance. respond_to_missing( symbol. to_str( ) ) ) )
181
+ } )
182
+ }
183
+ ) ;
184
+
167
185
/// Glue code to call the `ExportedFunctions.method_missing` method.
168
186
pub extern "C" fn ruby_exported_functions_method_missing (
169
187
argc : Argc ,
0 commit comments