This repository was archived by the owner on Feb 2, 2023. It is now read-only.
File tree 5 files changed +66
-4
lines changed
5 files changed +66
-4
lines changed Original file line number Diff line number Diff line change 82
82
hello world
83
83
=> nil
84
84
` ` `
85
+
86
+ To run all tests in the repository, run
87
+
88
+ ` ` ` shell
89
+ rake install
90
+ rake
91
+ ` ` `
Original file line number Diff line number Diff line change @@ -100,6 +100,9 @@ def cargo_build
100
100
if ENV [ 'VERBOSE' ]
101
101
cargo_args << " --verbose"
102
102
end
103
+ if ENV [ 'CARGO_EXTRA_ARGS' ]
104
+ cargo_args << ENV [ 'CARGO_EXTRA_ARGS' ]
105
+ end
103
106
if link_args
104
107
rustc_args << "-C link-args=#{ link_args } "
105
108
end
Original file line number Diff line number Diff line change @@ -49,3 +49,7 @@ pub type ToRubyResult = Result<VALUE, Error>;
49
49
pub trait ToRuby {
50
50
fn to_ruby ( self ) -> ToRubyResult ;
51
51
}
52
+
53
+ pub trait InitRuby {
54
+ fn init_ruby ( ) ;
55
+ }
Original file line number Diff line number Diff line change @@ -222,10 +222,44 @@ macro_rules! codegen_method {
222
222
} ;
223
223
}
224
224
225
+ #[ macro_export]
226
+ macro_rules! codegen_ruby_init {
227
+ ( {
228
+ type : class,
229
+ rust_name: $rust_name: tt,
230
+ ruby_name: $ruby_name: tt,
231
+ meta: { pub : $pub: tt, reopen: $reopen: tt } ,
232
+ struct : $struct: tt,
233
+ methods: $methods: tt
234
+ } ) => (
235
+ impl $crate:: InitRuby for $rust_name {
236
+ fn init_ruby( ) {
237
+ codegen_class_binding!( {
238
+ type : class,
239
+ rust_name: $rust_name,
240
+ ruby_name: $ruby_name,
241
+ meta: { pub : $pub, reopen: $reopen } ,
242
+ struct : $struct,
243
+ methods: $methods
244
+ } , {
245
+ type : class,
246
+ rust_name: $rust_name,
247
+ ruby_name: $ruby_name,
248
+ meta: { pub : $pub, reopen: $reopen } ,
249
+ struct : $struct,
250
+ methods: $methods
251
+ } ) ;
252
+ }
253
+ }
254
+ ) ;
255
+ }
256
+
257
+
225
258
#[ macro_export]
226
259
macro_rules! codegen_extra_impls {
227
260
( $class: tt) => (
228
261
codegen_allocator!( $class) ;
229
262
codegen_coercions!( $class) ;
263
+ codegen_ruby_init!( $class) ;
230
264
)
231
- }
265
+ }
Original file line number Diff line number Diff line change 1
1
#[ macro_export]
2
2
macro_rules! codegen_init {
3
- { [ $( $class: tt) * ] } => {
3
+ // Extracts the list of rust class names and calls the actual codegen_init with that
4
+ { [ $( {
5
+ type : class,
6
+ rust_name: $rust_name: tt,
7
+ ruby_name: { $( $ruby_name: tt) * } ,
8
+ meta: { pub : $pub: tt, reopen: $reopen: tt } ,
9
+ struct : $struct: tt,
10
+ methods: [ $( $method: tt) * ]
11
+ } ) * ] } => (
12
+ codegen_init!{ [ $( $rust_name) * ] }
13
+ ) ;
14
+
15
+ { [ $( $rust_name: tt) * ] } => {
4
16
#[ allow( non_snake_case) ]
5
17
#[ no_mangle]
6
18
pub extern "C" fn Init_native ( ) {
19
+ use $crate:: InitRuby ;
7
20
$crate:: sys:: check_version( ) ;
8
21
9
22
$(
10
- codegen_class_binding! ( $class , $class ) ;
23
+ $rust_name :: init_ruby ( ) ;
11
24
) *
12
25
}
13
- }
26
+ } ;
14
27
}
15
28
29
+
16
30
#[ macro_export]
17
31
macro_rules! codegen_class_binding {
18
32
{ $class: tt, {
You can’t perform that action at this time.
0 commit comments