@@ -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,11 @@ impl ExportedFunctions {
27
27
Self { instance }
28
28
}
29
29
30
+ /// Check that an exported function exists.
31
+ pub fn respond_to_missing ( & self , method_name : & str ) -> bool {
32
+ self . instance . dyn_func ( method_name) . is_ok ( )
33
+ }
34
+
30
35
/// Call an exported function on the given WebAssembly instance.
31
36
pub fn method_missing (
32
37
& self ,
@@ -164,6 +169,22 @@ wrappable_struct!(
164
169
165
170
class ! ( RubyExportedFunctions ) ;
166
171
172
+ #[ rustfmt:: skip]
173
+ methods ! (
174
+ RubyExportedFunctions ,
175
+ itself,
176
+
177
+ // Glue code to call the `ExportedFunctions.respond_to` method.
178
+ fn ruby_exported_functions_method_exists( symbol: Symbol , _include_private: Boolean ) -> Boolean {
179
+ unwrap_or_raise( || {
180
+ let symbol = symbol?;
181
+ let instance = itself. get_data( & * EXPORTED_FUNCTIONS_WRAPPER ) ;
182
+
183
+ Ok ( Boolean :: new( instance. respond_to_missing( symbol. to_str( ) ) ) )
184
+ } )
185
+ }
186
+ ) ;
187
+
167
188
/// Glue code to call the `ExportedFunctions.method_missing` method.
168
189
pub extern "C" fn ruby_exported_functions_method_missing (
169
190
argc : Argc ,
0 commit comments