31 'Struct3' => '{?=sc}',
33 'Struct5' => '{?=ic}',
34 'Struct6' => '{?=is}',
35 'Struct7' => '{?=isc}',
57 # The maximum number of arguments a method should have
60 sub generate_methods_file {
62 $file_prologue, $file_epilogue,
63 $method_prefix, $method_code,
69 open(FILE) or die "cannot open file: $!\n";
70 print FILE $file_prologue;
72 # The number of methods generated
73 $methods_generated = 0;
75 gen_method($no_of_args, $method_prefix, $method_code, $initial_acc_args);
76 print FILE $file_epilogue;
78 print "$methods_generated methods generated in file $file.\n";
82 local ($mth_no_of_args,
83 $method_prefix, $method_code,
87 gen_method1(0, $mth_no_of_args, "", $initial_acc_args,
88 $method_prefix, $method_code);
93 $curr_type_no, $curr_arg_no,
94 $acc_mth_name, $acc_args,
95 $method_prefix, $method_code
98 if ($curr_arg_no == 0) {
99 print FILE "$method_prefix";
100 if ($acc_mth_name ne "") {
101 print FILE "${acc_mth_name}${acc_args}";
103 print FILE $method_code;
104 $methods_generated++;
105 print "$methods_generated\r";
109 # Determine the preceding types. We not generate the methods that have more
110 # than 2 identical types in consecutive positions.
111 local $prev_type = "";
112 if ($acc_mth_name =~ /.*_(.*)$/) {
113 $prev_type = $acc_mth_name;
114 $prev_type =~ s/.*_(.*)$/$1/;
117 for (local $curr_type_no = 0; $curr_type_no <= $#types; $curr_type_no++) {
118 local $label = $type_method_name{$types[$curr_type_no]};
120 if(!($label eq $prev_type)) {
121 gen_method1($curr_type_no, $curr_arg_no - 1,
122 "${acc_mth_name}_$label",
123 &$show_acc_args($acc_args, $curr_type_no, $curr_arg_no),
124 $method_prefix, $method_code);
129 $source_file = __FILE__;
131 $show_acc_args = sub {
132 local ($acc_args, $curr_type_no, $curr_arg_no) = @_;
133 local $number = $no_of_args - $curr_arg_no;
134 local $label = $type_method_name{$types[$curr_type_no]};
136 return "$acc_args:($types[$curr_type_no])${label}${number} ";
139 generate_methods_file("SignatureTest.m",
140 "/* Do not modify! Generated automatically from $source_file. */
142 #include <objc/Object.h>
182 \@interface SignatureTest : Object
185 \@implementation SignatureTest
188 \@end /* SignatureTest */
195 $show_acc_args = sub {
196 local ($acc_args, $curr_type_no, $curr_arg_no) = @_;
198 return ":${acc_args}";
201 generate_methods_file("test.m",
202 "/* Do not modify! Generated automatically from $source_file. */
204 #include <objc/objc.h>
205 #include <objc/objc-api.h>
206 #include \"SignatureTest.m\"
210 id signtest = [[SignatureTest alloc] init];
211 struct objc_method* mth;
216 " mth = class_get_instance_method([signtest class], \@selector(method",
218 printf(\"'%s' is '%s'\\n\", sel_get_name(mth->method_name), mth->method_types);