Mercurial > octave
comparison mk-opts.pl @ 12174:db1f49eaba6b
whitespace fixes
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 26 Jan 2011 23:49:42 -0500 |
parents | fd0a3ac60b0e |
children | d1758f03a2ec |
comparison
equal
deleted
inserted
replaced
12173:dd2af7b8dafe | 12174:db1f49eaba6b |
---|---|
1 #! /usr/bin/perl | 1 #! /usr/bin/perl |
2 # | 2 # |
3 # Copyright (C) 2002-2011 John W. Eaton | 3 # Copyright (C) 2002-2011 John W. Eaton |
4 # | 4 # |
5 # This file is part of Octave. | 5 # This file is part of Octave. |
6 # | 6 # |
7 # Octave is free software; you can redistribute it and/or modify it | 7 # Octave is free software; you can redistribute it and/or modify it |
8 # under the terms of the GNU General Public License as published by the | 8 # under the terms of the GNU General Public License as published by the |
9 # Free Software Foundation; either version 3 of the License, or (at | 9 # Free Software Foundation; either version 3 of the License, or (at |
10 # your option) any later version. | 10 # your option) any later version. |
11 # | 11 # |
12 # Octave is distributed in the hope that it will be useful, but WITHOUT | 12 # Octave is distributed in the hope that it will be useful, but WITHOUT |
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | 14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
15 # for more details. | 15 # for more details. |
16 # | 16 # |
17 # You should have received a copy of the GNU General Public License | 17 # You should have received a copy of the GNU General Public License |
18 # along with Octave; see the file COPYING. If not, see | 18 # along with Octave; see the file COPYING. If not, see |
19 # <http://www.gnu.org/licenses/>. | 19 # <http://www.gnu.org/licenses/>. |
20 | 20 |
21 # Generate option handling code from a simpler input files for | 21 # Generate option handling code from a simpler input files for |
22 # Octave's functions like lsode, dassl, etc. | 22 # Octave's functions like lsode, dassl, etc. |
23 | 23 |
24 # FIXME: | 24 # FIXME: |
25 # | 25 # |
26 # * Improve default documentation and/or individual documentation | 26 # * Improve default documentation and/or individual documentation |
27 # in data files. | 27 # in data files. |
28 # | 28 # |
29 # * Fix print/show code to display/return something more informative | 29 # * Fix print/show code to display/return something more informative |
30 # for special values (for example, -1 ==> infinite in some cases). | 30 # for special values (for example, -1 ==> infinite in some cases). |
31 # Probably need more information in the data files for this. | 31 # Probably need more information in the data files for this. |
32 | 32 |
109 $fcn_name = $1; | 109 $fcn_name = $1; |
110 } | 110 } |
111 elsif (/^\s*INCLUDE\s*=\s*"(\S+)"\s*$/) | 111 elsif (/^\s*INCLUDE\s*=\s*"(\S+)"\s*$/) |
112 { | 112 { |
113 $include = "${include}#include <$1>\n"; | 113 $include = "${include}#include <$1>\n"; |
114 } | 114 } |
115 elsif (/^\s*DOC_STRING\s*$/) | 115 elsif (/^\s*DOC_STRING\s*$/) |
116 { | 116 { |
117 die "duplicate DOC_STRING" if ($have_doc_string); | 117 die "duplicate DOC_STRING" if ($have_doc_string); |
118 &parse_doc_string; | 118 &parse_doc_string; |
119 $have_doc_string = 1; | 119 $have_doc_string = 1; |
120 } | 120 } |
121 else | 121 else |
122 { | 122 { |
123 die "mk-opts.pl: unknown command: $_\n" | 123 die "mk-opts.pl: unknown command: $_\n" |
124 } | 124 } |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 sub parse_option_block | 128 sub parse_option_block |
129 { | 129 { |
211 $max_tokens = &max (@n_toks); | 211 $max_tokens = &max (@n_toks); |
212 | 212 |
213 &get_min_match_len_info ($max_tokens); | 213 &get_min_match_len_info ($max_tokens); |
214 | 214 |
215 $fcn_name = lc ($CLASS) if ($fcn_name eq ""); | 215 $fcn_name = lc ($CLASS) if ($fcn_name eq ""); |
216 | 216 |
217 $opt_fcn_name = "${fcn_name}_options" if ($opt_fcn_name eq ""); | 217 $opt_fcn_name = "${fcn_name}_options" if ($opt_fcn_name eq ""); |
218 | 218 |
219 $static_object_name = "${fcn_name}_opts"; | 219 $static_object_name = "${fcn_name}_opts"; |
220 | 220 |
221 if ($doc_string eq "") | 221 if ($doc_string eq "") |
236 | 236 |
237 for ($i = 0; $i < $opt_num; $i++) | 237 for ($i = 0; $i < $opt_num; $i++) |
238 { | 238 { |
239 for ($j = 0; $j < $max_tokens; $j++) | 239 for ($j = 0; $j < $max_tokens; $j++) |
240 { | 240 { |
241 $min_tok_len_to_match[$i][$j] = 0; | 241 $min_tok_len_to_match[$i][$j] = 0; |
242 } | 242 } |
243 | 243 |
244 $min_toks_to_match[$i] = 1; | 244 $min_toks_to_match[$i] = 1; |
245 | 245 |
246 L1: for ($k = 0; $k < $opt_num; $k++) | 246 L1: for ($k = 0; $k < $opt_num; $k++) |
247 { | 247 { |
248 local ($duplicate) = 1; | 248 local ($duplicate) = 1; |
249 | 249 |
250 if ($i != $k) | 250 if ($i != $k) |
251 { | 251 { |
252 L2: for ($j = 0; $j < $max_tokens; $j++) | 252 L2: for ($j = 0; $j < $max_tokens; $j++) |
253 { | 253 { |
262 | 262 |
263 $min_toks_to_match[$i]++; | 263 $min_toks_to_match[$i]++; |
264 } | 264 } |
265 else | 265 else |
266 { | 266 { |
267 $duplicate = 0; | 267 $duplicate = 0; |
268 | 268 |
269 if ($min_tok_len_to_match[$i][$j] == 0) | 269 if ($min_tok_len_to_match[$i][$j] == 0) |
270 { | 270 { |
271 $min_tok_len_to_match[$i][$j] = 1; | 271 $min_tok_len_to_match[$i][$j] = 1; |
272 } | 272 } |
273 | 273 |
274 local (@s) = split (//, $kw_tok[$i][$j]); | 274 local (@s) = split (//, $kw_tok[$i][$j]); |
275 local (@t) = split (//, $kw_tok[$k][$j]); | 275 local (@t) = split (//, $kw_tok[$k][$j]); |
276 | 276 |
277 local ($n, $ii); | 277 local ($n, $ii); |
280 | 280 |
281 for ($ii = 0; $ii < $n; $ii++) | 281 for ($ii = 0; $ii < $n; $ii++) |
282 { | 282 { |
283 if ("$s[$ii]" eq "$t[$ii]") | 283 if ("$s[$ii]" eq "$t[$ii]") |
284 { | 284 { |
285 if ($ii + 2 > $min_tok_len_to_match[$i][$j]) | 285 if ($ii + 2 > $min_tok_len_to_match[$i][$j]) |
286 { | 286 { |
287 $min_tok_len_to_match[$i][$j]++; | 287 $min_tok_len_to_match[$i][$j]++; |
288 } | 288 } |
289 } | 289 } |
290 else | 290 else |
291 { | 291 { |
292 last L2; | 292 last L2; |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
296 last L1; | 296 last L1; |
297 } | 297 } |
298 } | 298 } |
299 else | 299 else |
300 { | 300 { |
301 die "ambiguous options \"$name[$i]\" and \"$name[$k]\"" if ($duplicate); | 301 die "ambiguous options \"$name[$i]\" and \"$name[$k]\"" if ($duplicate); |
302 } | 302 } |
303 } | 303 } |
304 } | 304 } |
305 } | 305 } |
306 } | 306 } |
307 } | 307 } |
616 for ($i = 0; $i < $opt_num; $i++) | 616 for ($i = 0; $i < $opt_num; $i++) |
617 { | 617 { |
618 &emit_option_table_entry ($i, 0); | 618 &emit_option_table_entry ($i, 0); |
619 | 619 |
620 if ($i < $opt_num - 1) | 620 if ($i < $opt_num - 1) |
621 { | 621 { |
622 print "\n"; | 622 print "\n"; |
623 } | 623 } |
624 } | 624 } |
625 | 625 |
626 print "};\n\n"; | 626 print "};\n\n"; |
627 } | 627 } |
628 | 628 |
718 { | 718 { |
719 print " os << $static_object_name.$opt[$i] () << \"\\n\";\n"; | 719 print " os << $static_object_name.$opt[$i] () << \"\\n\";\n"; |
720 } | 720 } |
721 elsif ($type[$i] eq "Array<int>" || $type[$i] eq "Array<octave_idx_type>") | 721 elsif ($type[$i] eq "Array<int>" || $type[$i] eq "Array<octave_idx_type>") |
722 { | 722 { |
723 if ($type[$i] eq "Array<int>") | 723 if ($type[$i] eq "Array<int>") |
724 { | 724 { |
725 $elt_type = "int"; | 725 $elt_type = "int"; |
726 } | 726 } |
727 else | 727 else |
728 { | 728 { |
734 os << val(0) << \"\\n\"; | 734 os << val(0) << \"\\n\"; |
735 } | 735 } |
736 else | 736 else |
737 { | 737 { |
738 os << \"\\n\\n\"; | 738 os << \"\\n\\n\"; |
739 octave_idx_type len = val.length (); | 739 octave_idx_type len = val.length (); |
740 Matrix tmp (len, 1); | 740 Matrix tmp (len, 1); |
741 for (octave_idx_type i = 0; i < len; i++) | 741 for (octave_idx_type i = 0; i < len; i++) |
742 tmp(i,0) = val(i); | 742 tmp(i,0) = val(i); |
743 octave_print_internal (os, tmp, false, 2); | 743 octave_print_internal (os, tmp, false, 2); |
744 os << \"\\n\\n\"; | 744 os << \"\\n\\n\"; |
745 }\n"; | 745 }\n"; |
746 } | 746 } |
747 elsif ($type[$i] eq "Array<double>") | 747 elsif ($type[$i] eq "Array<double>") |
899 { | 899 { |
900 print " retval = $static_object_name.$opt[$i] ();\n"; | 900 print " retval = $static_object_name.$opt[$i] ();\n"; |
901 } | 901 } |
902 elsif ($type[$i] eq "Array<int>" || $type[$i] eq "Array<octave_idx_type>") | 902 elsif ($type[$i] eq "Array<int>" || $type[$i] eq "Array<octave_idx_type>") |
903 { | 903 { |
904 if ($type[$i] eq "Array<int>") | 904 if ($type[$i] eq "Array<int>") |
905 { | 905 { |
906 $elt_type = "int"; | 906 $elt_type = "int"; |
907 } | 907 } |
908 else | 908 else |
909 { | 909 { |
914 { | 914 { |
915 retval = static_cast<double> (val(0)); | 915 retval = static_cast<double> (val(0)); |
916 } | 916 } |
917 else | 917 else |
918 { | 918 { |
919 octave_idx_type len = val.length (); | 919 octave_idx_type len = val.length (); |
920 ColumnVector tmp (len); | 920 ColumnVector tmp (len); |
921 for (octave_idx_type i = 0; i < len; i++) | 921 for (octave_idx_type i = 0; i < len; i++) |
922 tmp(i) = val(i); | 922 tmp(i) = val(i); |
923 retval = tmp; | 923 retval = tmp; |
924 }\n"; | 924 }\n"; |
925 } | 925 } |
926 elsif ($type[$i] eq "Array<double>") | 926 elsif ($type[$i] eq "Array<double>") |
927 { | 927 { |
975 | 975 |
976 for ($i = 0; $i < $opt_num; $i++) | 976 for ($i = 0; $i < $opt_num; $i++) |
977 { | 977 { |
978 print "\@item \\\"$name[$i]\\\"\\n\\\n"; | 978 print "\@item \\\"$name[$i]\\\"\\n\\\n"; |
979 if ($doc_item[$i] ne "") | 979 if ($doc_item[$i] ne "") |
980 { | 980 { |
981 print "$doc_item[$i]"; | 981 print "$doc_item[$i]"; |
982 } | 982 } |
983 } | 983 } |
984 | 984 |
985 print "\@end table\\n\\\n\@end deftypefn\") | 985 print "\@end table\\n\\\n\@end deftypefn\") |
986 { | 986 { |
987 octave_value_list retval; | 987 octave_value_list retval; |
1008 } | 1008 } |
1009 else | 1009 else |
1010 print_usage (); | 1010 print_usage (); |
1011 | 1011 |
1012 return retval; | 1012 return retval; |
1013 }\n"; | 1013 }\n"; |
1014 } | 1014 } |
1015 | 1015 |
1016 sub emit_options_debug | 1016 sub emit_options_debug |
1017 { | 1017 { |
1018 print "CLASS = \"$class\"\n"; | 1018 print "CLASS = \"$class\"\n"; |