48
48
functions = [ ]
49
49
50
50
Dir [ "src/main/c/cext/*.c" ] . sort . each do |file |
51
- next if %w[ cext_constants.c wrappers.c ruby.c st.c strlcpy.c ] . include? ( File . basename ( file ) )
51
+ next if %w[ cext_constants.c ruby.c st.c strlcpy.c ] . include? ( File . basename ( file ) )
52
52
53
53
contents = File . read ( file )
54
54
found_functions = contents . scan ( function_regexp )
@@ -128,37 +128,31 @@ def struct_by_value?(type)
128
128
129
129
C
130
130
131
- File . open ( "src/main/c/cext/wrappers.c" , "w" ) do |sulong |
132
- sulong . puts <<C
133
- #include <ruby.h>
134
-
135
- C
136
-
137
- signatures = [
138
- [ 'rb_tr_setjmp_wrapper_void_to_void' , '(void):void' ] ,
139
- [ 'rb_tr_setjmp_wrapper_pointer1_to_void' , '(VALUE arg):void' ] ,
140
- [ 'rb_tr_setjmp_wrapper_pointer2_to_void' , '(VALUE tracepoint, void *data):void' ] ,
141
- [ 'rb_tr_setjmp_wrapper_pointer3_to_void' , '(VALUE val, ID id, VALUE *data):void' ] ,
142
- [ 'rb_tr_setjmp_wrapper_pointer3_to_int' , '(VALUE key, VALUE val, VALUE arg):int' ] ,
143
- [ 'rb_tr_setjmp_wrapper_pointer1_to_size_t' , '(const void *arg):size_t' ] ,
144
- [ 'rb_tr_setjmp_wrapper_int_pointer2_to_pointer' , '(int argc, VALUE *argv, VALUE obj):VALUE' ] ,
145
- [ 'rb_tr_setjmp_wrapper_pointer2_int_to_pointer' , '(VALUE g, VALUE h, int r):VALUE' ] ,
146
- [ 'rb_tr_setjmp_wrapper_pointer2_int_pointer2_to_pointer' , '(VALUE yielded_arg, VALUE callback_arg, int argc, const VALUE *argv, VALUE blockarg):VALUE' ] ,
131
+ signatures = [
132
+ [ 'rb_tr_setjmp_wrapper_void_to_void' , '(void):void' ] ,
133
+ [ 'rb_tr_setjmp_wrapper_pointer1_to_void' , '(VALUE arg):void' ] ,
134
+ [ 'rb_tr_setjmp_wrapper_pointer2_to_void' , '(VALUE tracepoint, void *data):void' ] ,
135
+ [ 'rb_tr_setjmp_wrapper_pointer3_to_void' , '(VALUE val, ID id, VALUE *data):void' ] ,
136
+ [ 'rb_tr_setjmp_wrapper_pointer3_to_int' , '(VALUE key, VALUE val, VALUE arg):int' ] ,
137
+ [ 'rb_tr_setjmp_wrapper_pointer1_to_size_t' , '(const void *arg):size_t' ] ,
138
+ [ 'rb_tr_setjmp_wrapper_int_pointer2_to_pointer' , '(int argc, VALUE *argv, VALUE obj):VALUE' ] ,
139
+ [ 'rb_tr_setjmp_wrapper_pointer2_int_to_pointer' , '(VALUE g, VALUE h, int r):VALUE' ] ,
140
+ [ 'rb_tr_setjmp_wrapper_pointer2_int_pointer2_to_pointer' , '(VALUE yielded_arg, VALUE callback_arg, int argc, const VALUE *argv, VALUE blockarg):VALUE' ] ,
141
+ ]
142
+ ( 1 ..16 ) . each do |arity |
143
+ signatures << [
144
+ "rb_tr_setjmp_wrapper_pointer#{ arity } _to_pointer" ,
145
+ "(#{ ( 1 ..arity ) . map { |i | "VALUE arg#{ i } " } . join ( ', ' ) } ):VALUE"
147
146
]
148
- ( 1 ..16 ) . each do |arity |
149
- signatures << [
150
- "rb_tr_setjmp_wrapper_pointer#{ arity } _to_pointer" ,
151
- "(#{ ( 1 ..arity ) . map { |i | "VALUE arg#{ i } " } . join ( ', ' ) } ):VALUE"
152
- ]
153
- end
147
+ end
154
148
155
- signatures . each do |function_name , signature |
156
- argument_types , return_type = signature . split ( ':' )
157
- argument_types = argument_types . delete_prefix ( '(' ) . delete_suffix ( ')' )
158
- original_argument_types = argument_types
159
- argument_types = '' if argument_types == 'void'
160
- void = return_type == 'void'
161
- f . puts <<C
149
+ signatures . each do |function_name , signature |
150
+ argument_types , return_type = signature . split ( ':' )
151
+ argument_types = argument_types . delete_prefix ( '(' ) . delete_suffix ( ')' )
152
+ original_argument_types = argument_types
153
+ argument_types = '' if argument_types == 'void'
154
+ void = return_type == 'void'
155
+ f . puts <<C
162
156
#{ return_type } #{ function_name } (#{ return_type } (*func)(#{ original_argument_types } )#{ ', ' unless argument_types . empty? } #{ argument_types } ) {
163
157
#{ "#{ return_type } result;" unless void }
164
158
@@ -179,13 +173,6 @@ def struct_by_value?(type)
179
173
}
180
174
181
175
C
182
- sulong . puts <<C
183
- #{ return_type } #{ function_name } (#{ return_type } (*func)(#{ original_argument_types } )#{ ', ' unless argument_types . empty? } #{ argument_types } ) {
184
- #{ 'return ' unless void } func(#{ argument_types . split ( ', ' ) . map { |param | param [ /\w +$/ ] } . join ( ', ' ) } );
185
- }
186
-
187
- C
188
- end
189
176
end
190
177
191
178
f . puts "\n // Functions\n \n "
0 commit comments