Mercurial > octave
annotate build-aux/mk-opts.pl @ 30564:796f54d4ddbf stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
In all .txi and .texi files except gpl.txi and gpl.texi in the
doc/liboctave and doc/interpreter directories, change the copyright
to "Octave Project Developers", the same as used for other source
files. Update copyright notices for 2022 (not done since 2019). For
gpl.txi and gpl.texi, change the copyright notice to be "Free Software
Foundation, Inc." and leave the date at 2007 only because this file
only contains the text of the GPL, not anything created by the Octave
Project Developers.
Add Paul Thomas to contributors.in.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 28 Dec 2021 18:22:40 -0500 |
parents | b3717fd85e49 |
children | de6fc38c78c6 |
rev | line source |
---|---|
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1 #! /usr/bin/perl -w |
29357
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2 |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
3 ######################################################################## |
29357
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
4 ## |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30046
diff
changeset
|
5 ## Copyright (C) 2002-2022 The Octave Project Developers |
29357
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
7 ## See the file COPYRIGHT.md in the top-level directory of this |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
8 ## distribution or <https://octave.org/copyright/>. |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
9 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
10 ## This file is part of Octave. |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
11 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
12 ## Octave is free software: you can redistribute it and/or modify it |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
13 ## under the terms of the GNU General Public License as published by |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
14 ## the Free Software Foundation, either version 3 of the License, or |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
15 ## (at your option) any later version. |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
16 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
17 ## Octave is distributed in the hope that it will be useful, but |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
18 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
19 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
20 ## GNU General Public License for more details. |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
21 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
22 ## You should have received a copy of the GNU General Public License |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
23 ## along with Octave; see the file COPYING. If not, see |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
24 ## <https://www.gnu.org/licenses/>. |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
25 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
26 ######################################################################## |
3998 | 27 |
28 # Generate option handling code from a simpler input files for | |
29 # Octave's functions like lsode, dassl, etc. | |
30 | |
8202
cf59d542f33e
replace all TODOs and XXXs with FIXMEs
Jaroslav Hajek <highegg@gmail.com>
parents:
7806
diff
changeset
|
31 # FIXME: |
3999 | 32 # |
33 # * Improve default documentation and/or individual documentation | |
12174 | 34 # in data files. |
3999 | 35 # |
36 # * Fix print/show code to display/return something more informative | |
37 # for special values (for example, -1 ==> infinite in some cases). | |
38 # Probably need more information in the data files for this. | |
39 | |
3998 | 40 # Input file format: |
41 # | |
42 # CLASS = string | |
43 # FCN_NAME = string | |
4044 | 44 # INCLUDE = file |
3998 | 45 # DOC_STRING doc END_DOC_STRING |
46 # OPTION | |
47 # NAME = string | |
4050 | 48 # DOC_ITEM doc END_DOC_ITEM |
3998 | 49 # TYPE = string |
50 # SET_ARG_TYPE = string (optional, defaults to TYPE) | |
51 # INIT_VALUE = string | INIT_BODY code END_INIT_BODY | |
52 # SET_EXPR = string | SET_BODY code END_SET_BODY | SET_CODE code END_SET_CODE | |
53 # END_OPTION | |
54 # | |
55 # END_* must appear at beginning of line (whitespace ignored). | |
56 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
57 ################################################################################ |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
58 # Load packages to |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
59 # 1) process command line options |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
60 ################################################################################ |
3998 | 61 use Getopt::Long; |
62 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
63 ################################################################################ |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
64 # Extract command line arguments |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
65 &parse_options; |
3998 | 66 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
67 $DEFN_FILE = shift @ARGV; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
68 open (DEFN_FILE) or die "unable to open input definition file $DEFN_FILE"; |
3998 | 69 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
70 ################################################################################ |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
71 # Initialize variables |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
72 $BLANK_LINE = qr/^\s*$/; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
73 $COMMENT = qr/^\s*#/; |
3998 | 74 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
75 ################################################################################ |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
76 # Process file |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
77 $OPT_NUM = 0; |
3998 | 78 |
79 &parse_input; | |
80 | |
81 &process_data; | |
82 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
83 # Produce desired style of output |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
84 &emit_opt_class_header if $opt_class_header; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
85 &emit_opt_handler_fcns if $opt_handler_fcns; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
86 &emit_options_debug if $opt_debug; |
3998 | 87 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
88 # End of main code |
3998 | 89 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
90 ################################################################################ |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
91 # Subroutines |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
92 ################################################################################ |
3998 | 93 |
94 sub parse_input | |
95 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
96 LINE: while (<DEFN_FILE>) |
3998 | 97 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
98 next LINE if /$BLANK_LINE/; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
99 next LINE if /$COMMENT/; |
3998 | 100 |
101 if (/^\s*OPTION\s*$/) | |
102 { | |
103 &parse_option_block; | |
104 } | |
105 elsif (/^\s*CLASS\s*=\s*"(\w+)"\s*$/) | |
106 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
107 die "duplicate CLASS" if defined $CLASS; |
3998 | 108 $CLASS = $1; |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
109 $CLASS_NAME = "${CLASS}_options"; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
110 $STRUCT_NAME = "${CLASS_NAME}_struct"; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
111 $STATIC_TABLE_NAME = "${CLASS_NAME}_table"; |
3998 | 112 } |
113 elsif (/^\s*FCN_NAME\s*=\s*"(\w+)"\s*$/) | |
114 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
115 die "duplicate FCN_NAME" if defined $FCN_NAME; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
116 $FCN_NAME = $1; |
3998 | 117 } |
4044 | 118 elsif (/^\s*INCLUDE\s*=\s*"(\S+)"\s*$/) |
119 { | |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23443
diff
changeset
|
120 $INCLUDE .= qq (#include "$1"\n); |
12174 | 121 } |
3998 | 122 elsif (/^\s*DOC_STRING\s*$/) |
123 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
124 die "duplicate DOC_STRING" if defined $DOC_STRING; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
125 while (defined ($_ = <DEFN_FILE>) and not /^\s*END_DOC_STRING\s*$/) |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
126 { |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
127 $DOC_STRING .= $_; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
128 } |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
129 $DOC_STRING =~ s/\n/\\n\\\n/g; |
3998 | 130 } |
4044 | 131 else |
132 { | |
12174 | 133 die "mk-opts.pl: unknown command: $_\n" |
134 } | |
3998 | 135 } |
12612
16cca721117b
doc: Update all documentation for chapter on Numerical Integration
Rik <octave@nomad.inbox5.com>
parents:
12504
diff
changeset
|
136 $INCLUDE = "" if not defined $INCLUDE; # Initialize value if required |
3998 | 137 } |
138 | |
139 sub parse_option_block | |
140 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
141 while (<DEFN_FILE>) |
3998 | 142 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
143 next if /$BLANK_LINE/; |
3998 | 144 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
145 die "missing END_OPTION" if /^\s*OPTION\s*$/; |
3998 | 146 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
147 last if /^\s*END_OPTION\s*$/; |
3998 | 148 |
149 if (/^\s*NAME\s*=\s*"(.*)"\s*$/) | |
150 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
151 die "duplicate NAME" if defined $NAME[$OPT_NUM]; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
152 $NAME[$OPT_NUM] = $1; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
153 ($OPT[$OPT_NUM] = $NAME[$OPT_NUM]) =~ s/\s+/_/g; |
30033
d8ae55260760
maint: use "m_" prefix for member variables generated by mk-opts.pl
Rik <rik@octave.org>
parents:
29958
diff
changeset
|
154 $OPTVAR[$OPT_NUM] = 'm_' . $OPT[$OPT_NUM]; |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
155 $KW_TOK[$OPT_NUM] = [ split (' ', $NAME[$OPT_NUM]) ]; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
156 $N_TOKS[$OPT_NUM] = @{$KW_TOK[$OPT_NUM]}; |
3998 | 157 } |
4050 | 158 elsif (/^\s*DOC_ITEM\s*$/) |
159 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
160 die "duplicate DOC_ITEM" if defined $DOC_ITEM[$OPT_NUM]; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
161 while (defined ($_ = <DEFN_FILE>) and not /^\s*END_DOC_ITEM\s*$/) |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
162 { |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
163 $DOC_ITEM[$OPT_NUM] .= $_; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
164 } |
4050 | 165 } |
3998 | 166 elsif (/^\s*TYPE\s*=\s*"(.*)"\s*$/) |
167 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
168 die "duplicate TYPE" if defined $TYPE[$OPT_NUM]; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
169 $TYPE[$OPT_NUM] = $1; |
3998 | 170 } |
171 elsif (/^\s*SET_ARG_TYPE\s*=\s*"(.*)"\s*$/) | |
172 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
173 die "duplicate SET_ARG_TYPE" if defined $SET_ARG_TYPE[$OPT_NUM]; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
174 $SET_ARG_TYPE[$OPT_NUM] = $1; |
3998 | 175 } |
176 elsif (/^\s*INIT_VALUE\s*=\s*"(.*)"\s*$/) | |
177 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
178 die "duplicate INIT_VALUE" if defined $INIT_VALUE[$OPT_NUM]; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
179 $INIT_VALUE[$OPT_NUM] = $1; |
3998 | 180 } |
181 elsif (/^\s*SET_EXPR\s*=\s*"(.*)"\s*$/) | |
182 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
183 die "duplicate SET_EXPR" if defined $SET_EXPR[$OPT_NUM]; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
184 $SET_EXPR[$OPT_NUM] = $1; |
3998 | 185 } |
186 elsif (/^\s*INIT_BODY\s*$/) | |
187 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
188 die "duplicate INIT_BODY" if defined $INIT_BODY[$OPT_NUM]; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
189 while (defined ($_ = <DEFN_FILE>) and not /^\s*END_INIT_BODY\s*$/) |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
190 { |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
191 $INIT_BODY[$OPT_NUM] .= $_; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
192 } |
3998 | 193 } |
194 elsif (/^\s*SET_BODY\s*$/) | |
195 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
196 die "duplicate SET_BODY" if defined $INIT_BODY[$OPT_NUM]; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
197 while (defined ($_ = <DEFN_FILE>) and not /^\s*END_SET_BODY\s*$/) |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
198 { |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
199 $SET_BODY[$OPT_NUM] .= $_; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
200 } |
3998 | 201 } |
202 elsif (/^\s*SET_CODE\s*$/) | |
203 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
204 die "duplicate SET_CODE" if defined $SET_CODE[$OPT_NUM]; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
205 while (defined ($_ = <DEFN_FILE>) and not /^\s*END_SET_CODE\s*$/) |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
206 { |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
207 $SET_CODE[$OPT_NUM] .= $_; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
208 } |
3998 | 209 } |
210 } | |
211 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
212 if (not defined $SET_ARG_TYPE[$OPT_NUM]) |
3998 | 213 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
214 $SET_ARG_TYPE[$OPT_NUM] = $TYPE[$OPT_NUM]; |
3998 | 215 } |
216 else | |
217 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
218 $SET_ARG_TYPE[$OPT_NUM] |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
219 = substopt ($SET_ARG_TYPE[$OPT_NUM], $OPTVAR[$OPT_NUM], |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
220 $OPT[$OPT_NUM], $TYPE[$OPT_NUM]); |
3998 | 221 } |
222 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
223 $OPT_NUM++; |
3998 | 224 } |
225 | |
226 sub process_data | |
227 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
228 $MAX_TOKENS = max (@N_TOKS); |
3998 | 229 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
230 &get_min_match_len_info; |
3998 | 231 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
232 $FCN_NAME = lc ($CLASS) if not defined $FCN_NAME; |
12174 | 233 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
234 $OPT_FCN_NAME = "${FCN_NAME}_options" if not defined $OPT_FCN_NAME; |
3998 | 235 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
236 $STATIC_OBJECT_NAME = "${FCN_NAME}_opts"; |
3998 | 237 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
238 if (not defined $DOC_STRING) |
3998 | 239 { |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21690
diff
changeset
|
240 $DOC_STRING = "Query or set options for the function \@code{$FCN_NAME}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21690
diff
changeset
|
241 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21690
diff
changeset
|
242 When called with no arguments, the names of all available options and |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21690
diff
changeset
|
243 their current values are displayed. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21690
diff
changeset
|
244 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21690
diff
changeset
|
245 Given one argument, return the value of the option \@var{opt}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21690
diff
changeset
|
246 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21690
diff
changeset
|
247 When called with two arguments, \@code{$OPT_FCN_NAME} sets the option |
12612
16cca721117b
doc: Update all documentation for chapter on Numerical Integration
Rik <octave@nomad.inbox5.com>
parents:
12504
diff
changeset
|
248 \@var{opt} to value \@var{val}."; |
3998 | 249 } |
250 } | |
251 | |
17513
fedcd3717ebc
doc: grammarcheck of documentation before 3.8 release.
Rik <rik@octave.org>
parents:
15039
diff
changeset
|
252 ## FIXME: What does this routine do? And can it be simpler to understand? |
3998 | 253 sub get_min_match_len_info |
254 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
255 my ($i, $j, $k); |
3998 | 256 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
257 for ($i = 0; $i < $OPT_NUM; $i++) |
3998 | 258 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
259 for ($j = 0; $j < $MAX_TOKENS; $j++) |
3998 | 260 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
261 $MIN_TOK_LEN_TO_MATCH[$i][$j] = 0; |
3998 | 262 } |
263 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
264 $MIN_TOKS_TO_MATCH[$i] = 1; |
3998 | 265 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
266 L1: for ($k = 0; $k < $OPT_NUM; $k++) |
3998 | 267 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
268 my $duplicate = 1; |
3998 | 269 |
270 if ($i != $k) | |
271 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
272 L2: for ($j = 0; $j < $MAX_TOKENS; $j++) |
3998 | 273 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
274 if ($j < $N_TOKS[$i]) |
3998 | 275 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
276 if ($KW_TOK[$i][$j] eq $KW_TOK[$k][$j]) |
3998 | 277 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
278 if ($MIN_TOK_LEN_TO_MATCH[$i][$j] == 0) |
3998 | 279 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
280 $MIN_TOK_LEN_TO_MATCH[$i][$j] = 1; |
3998 | 281 } |
282 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
283 $MIN_TOKS_TO_MATCH[$i]++; |
3998 | 284 } |
285 else | |
286 { | |
12174 | 287 $duplicate = 0; |
3998 | 288 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
289 if ($MIN_TOK_LEN_TO_MATCH[$i][$j] == 0) |
12174 | 290 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
291 $MIN_TOK_LEN_TO_MATCH[$i][$j] = 1; |
12174 | 292 } |
3998 | 293 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
294 my @s = split (//, $KW_TOK[$i][$j]); |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
295 my @t = split (//, $KW_TOK[$k][$j]); |
3998 | 296 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
297 my ($n, $ii); |
3998 | 298 $n = scalar (@s); |
299 $n = scalar (@t) if (@t < $n); | |
300 | |
301 for ($ii = 0; $ii < $n; $ii++) | |
302 { | |
303 if ("$s[$ii]" eq "$t[$ii]") | |
304 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
305 if ($ii + 2 > $MIN_TOK_LEN_TO_MATCH[$i][$j]) |
12174 | 306 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
307 $MIN_TOK_LEN_TO_MATCH[$i][$j]++; |
12174 | 308 } |
3998 | 309 } |
310 else | |
311 { | |
312 last L2; | |
313 } | |
314 } | |
315 | |
316 last L1; | |
317 } | |
318 } | |
12174 | 319 else |
320 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
321 die qq|ambiguous options "$NAME[$i]" and "$NAME[$k]"| if $duplicate; |
12174 | 322 } |
3998 | 323 } |
324 } | |
325 } | |
326 } | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
327 } # end of get_min_match_len_info |
4050 | 328 |
3998 | 329 |
11497
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
330 sub emit_copy_body |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
331 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
332 my ($pfx, $var) = @_; |
11497
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
333 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
334 for (my $i = 0; $i < $OPT_NUM; $i++) |
11497
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
335 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
336 print "${pfx}$OPTVAR[$i] = ${var}.$OPTVAR[$i];\n"; |
11497
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
337 } |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
338 |
30046
b3717fd85e49
maint: use "m_" prefix for member variables ODE/DAE classes in liboctave/numeric.
Rik <rik@octave.org>
parents:
30033
diff
changeset
|
339 print "${pfx}m_reset = ${var}.m_reset;\n"; |
11497
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
340 } |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
341 |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
342 ## To silence GCC warnings, we create an initialization list even |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
343 ## though the init function actually does the work of initialization. |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
344 |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
345 sub emit_default_init_list |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
346 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
347 my ($prefix) = @_; |
11497
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
348 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
349 print "$OPTVAR[0] (),\n" unless ($OPT_NUM == 0); |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
350 |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
351 for (my $i = 1; $i < $OPT_NUM; $i++) |
11497
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
352 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
353 print "${prefix}$OPTVAR[$i] (),\n"; |
11497
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
354 } |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
355 |
30046
b3717fd85e49
maint: use "m_" prefix for member variables ODE/DAE classes in liboctave/numeric.
Rik <rik@octave.org>
parents:
30033
diff
changeset
|
356 print "${prefix}m_reset ()\n"; |
11497
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
357 } |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
358 |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
359 sub emit_copy_ctor_init_list |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
360 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
361 my ($prefix, $var) = @_; |
11497
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
362 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
363 print "$OPTVAR[0] ($var.$OPTVAR[0]),\n" unless ($OPT_NUM == 0); |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
364 |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
365 for (my $i = 1; $i < $OPT_NUM; $i++) |
11497
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
366 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
367 print "${prefix}$OPTVAR[$i] ($var.$OPTVAR[$i]),\n"; |
11497
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
368 } |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
369 |
30046
b3717fd85e49
maint: use "m_" prefix for member variables ODE/DAE classes in liboctave/numeric.
Rik <rik@octave.org>
parents:
30033
diff
changeset
|
370 print "${prefix}m_reset ($var.m_reset)\n"; |
11497
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
371 } |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
372 |
3998 | 373 sub emit_opt_class_header |
374 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
375 my ($i, $s); |
3998 | 376 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
377 print <<"_END_EMIT_OPT_CLASS_HEADER_"; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
378 // DO NOT EDIT! |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
379 // Generated automatically from $DEFN_FILE. |
3998 | 380 |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20733
diff
changeset
|
381 #if ! defined (octave_${CLASS_NAME}_h) |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
382 #define octave_${CLASS_NAME}_h 1 |
3998 | 383 |
23662
bd77ab816e43
eliminate obsolete file lo-math.h
John W. Eaton <jwe@octave.org>
parents:
23475
diff
changeset
|
384 #include <cmath> |
bd77ab816e43
eliminate obsolete file lo-math.h
John W. Eaton <jwe@octave.org>
parents:
23475
diff
changeset
|
385 |
23442
53f5f8231c37
allow most header files to be compiled separately
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
386 #include <limits> |
53f5f8231c37
allow most header files to be compiled separately
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
387 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
388 $INCLUDE |
4044 | 389 |
3998 | 390 class |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
391 $CLASS_NAME |
3998 | 392 { |
393 public: | |
394 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
395 $CLASS_NAME (void) |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
396 _END_EMIT_OPT_CLASS_HEADER_ |
11497
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
397 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
398 print ' : '; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
399 emit_default_init_list (" "); |
3998 | 400 |
11497
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
401 print " { |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
402 init (); |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
403 } |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
404 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
405 $CLASS_NAME (const ${CLASS_NAME}& opt) |
11497
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
406 : "; |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
407 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
408 emit_copy_ctor_init_list (" ", "opt"); |
11497
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
409 |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
410 print " { } |
3998 | 411 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
412 ${CLASS_NAME}& operator = (const ${CLASS_NAME}& opt) |
3998 | 413 { |
414 if (this != &opt) | |
11497
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
415 {\n"; |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
416 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
417 emit_copy_body (' ', 'opt'); |
11497
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
418 |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
419 print " } |
3998 | 420 |
421 return *this; | |
422 } | |
423 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
424 ~$CLASS_NAME (void) { }\n"; |
3998 | 425 |
426 print "\n void init (void)\n {\n"; | |
427 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
428 for ($i = 0; $i < $OPT_NUM; $i++) |
3998 | 429 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
430 if ($INIT_VALUE[$i]) |
3998 | 431 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
432 print " $OPTVAR[$i] = $INIT_VALUE[$i];\n"; |
3998 | 433 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
434 elsif ($INIT_BODY[$i]) |
3998 | 435 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
436 $s = substopt ($INIT_BODY[$i], $OPTVAR[$i], $OPT[$i], $TYPE[$i]); |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
437 chomp ($s); |
3998 | 438 $s =~ s/^\s*/ /g; |
439 $s =~ s/\n\s*/\n /g; | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
440 print $s,"\n"; |
3998 | 441 } |
442 } | |
443 | |
30046
b3717fd85e49
maint: use "m_" prefix for member variables ODE/DAE classes in liboctave/numeric.
Rik <rik@octave.org>
parents:
30033
diff
changeset
|
444 print " m_reset = true;\n", |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
445 " }\n"; |
3998 | 446 |
4122 | 447 ## For backward compatibility and because set_options is probably |
448 ## a better name in some contexts: | |
449 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
450 print "\n void set_options (const ${CLASS_NAME}& opt)\n", |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
451 " {\n"; |
4122 | 452 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
453 emit_copy_body (' ', 'opt'); |
11497
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
454 |
7bddd70bc838
mk-opts.pl: generate initialization lists and in-line code for copy method
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
455 print " }\n\n void set_default_options (void) { init (); }\n"; |
3998 | 456 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
457 for ($i = 0; $i < $OPT_NUM; $i++) |
3998 | 458 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
459 if ($SET_EXPR[$i]) |
3998 | 460 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
461 emit_set_decl ($i); |
3998 | 462 |
30046
b3717fd85e49
maint: use "m_" prefix for member variables ODE/DAE classes in liboctave/numeric.
Rik <rik@octave.org>
parents:
30033
diff
changeset
|
463 print "\n { $OPTVAR[$i] = $SET_EXPR[$i]; m_reset = true; }\n"; |
3998 | 464 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
465 elsif ($SET_BODY[$i]) |
3998 | 466 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
467 emit_set_decl ($i); |
3998 | 468 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
469 $s = substopt ($SET_BODY[$i], $OPTVAR[$i], $OPT[$i], $TYPE[$i]); |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
470 chomp ($s); |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
471 $s = ' ' . $s; |
3998 | 472 $s =~ s/\n/\n /g; |
30046
b3717fd85e49
maint: use "m_" prefix for member variables ODE/DAE classes in liboctave/numeric.
Rik <rik@octave.org>
parents:
30033
diff
changeset
|
473 print "\n {\n$s\n m_reset = true;\n }\n"; |
3998 | 474 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
475 elsif ($SET_CODE[$i]) |
3998 | 476 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
477 $s = substopt ($SET_CODE[$i], $OPTVAR[$i], $OPT[$i], $TYPE[$i]); |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
478 chomp ($s); |
3998 | 479 $s =~ s/^ //g; |
480 $s =~ s/\n /\n/g; | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
481 print "\n",$s,"\n"; |
3998 | 482 } |
483 } | |
484 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
485 for ($i = 0; $i < $OPT_NUM; $i++) |
3998 | 486 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
487 print " $TYPE[$i] $OPT[$i] (void) const\n { return $OPTVAR[$i]; }\n\n"; |
3998 | 488 } |
489 | |
490 print "private:\n\n"; | |
491 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
492 for ($i = 0; $i < $OPT_NUM; $i++) |
3998 | 493 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
494 print " $TYPE[$i] $OPTVAR[$i];\n"; |
3998 | 495 } |
496 | |
30046
b3717fd85e49
maint: use "m_" prefix for member variables ODE/DAE classes in liboctave/numeric.
Rik <rik@octave.org>
parents:
30033
diff
changeset
|
497 print "\nprotected:\n\n bool m_reset;\n};\n\n#endif\n"; |
3998 | 498 } |
499 | |
500 sub emit_set_decl | |
501 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
502 my ($i) = @_; |
3998 | 503 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
504 print "\n void set_$OPT[$i] ($SET_ARG_TYPE[$i] val)"; |
3998 | 505 } |
506 | |
507 sub emit_opt_handler_fcns | |
508 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
509 my $header = $DEFN_FILE; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
510 $header =~ s/[.]\w*$/.h/; # replace .in with .h |
4044 | 511 $header =~ s|^.*/([^/]*)$|$1|; # strip directory part |
3998 | 512 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
513 print <<"_END_EMIT_OPT_HANDLER_FCNS_"; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
514 // DO NOT EDIT! |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
515 // Generated automatically from $DEFN_FILE. |
3998 | 516 |
21690
b6a686543080
Only include config.h in files that are compiled separately.
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
517 // This file should not include config.h. It is only included in other |
b6a686543080
Only include config.h in files that are compiled separately.
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
518 // C++ source files that should have included config.h before including |
b6a686543080
Only include config.h in files that are compiled separately.
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
519 // this file. |
3998 | 520 |
521 #include <iomanip> | |
25438
cb1606f78f6b
prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
522 #include <ostream> |
cb1606f78f6b
prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
523 #include <sstream> |
3998 | 524 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
525 #include "$header" |
4044 | 526 |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
527 #include "defun.h" |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
528 #include "pr-output.h" |
3998 | 529 |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20895
diff
changeset
|
530 #include "ovl.h" |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
531 #include "utils.h" |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
532 #include "pager.h" |
4044 | 533 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
534 static $CLASS_NAME $STATIC_OBJECT_NAME; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
535 |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
536 _END_EMIT_OPT_HANDLER_FCNS_ |
3998 | 537 |
538 &emit_struct_decl; | |
539 | |
540 &emit_struct_def; | |
541 | |
542 &emit_print_function; | |
543 | |
544 &emit_set_functions; | |
545 | |
546 &emit_show_function; | |
547 | |
548 &emit_options_function; | |
549 } | |
550 | |
551 sub emit_struct_decl | |
552 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
553 print <<"_END_PRINT_STRUCT_DECL_"; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
554 #define MAX_TOKENS $MAX_TOKENS |
3998 | 555 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
556 struct $STRUCT_NAME |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
557 { |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
558 const char *keyword; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
559 const char *kw_tok[MAX_TOKENS + 1]; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
560 int min_len[MAX_TOKENS + 1]; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
561 int min_toks_to_match; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
562 }; |
3998 | 563 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
564 _END_PRINT_STRUCT_DECL_ |
3998 | 565 } |
566 | |
567 sub emit_struct_def | |
568 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
569 my $i; |
3998 | 570 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
571 print "#define NUM_OPTIONS $OPT_NUM\n\n"; |
3998 | 572 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
573 print "static $STRUCT_NAME $STATIC_TABLE_NAME [] =\n{\n"; |
3998 | 574 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
575 for ($i = 0; $i < ($OPT_NUM - 1); $i++) |
3998 | 576 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
577 emit_option_table_entry ($i, 0); |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
578 print "\n"; |
3998 | 579 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
580 emit_option_table_entry ($i, 0); |
3998 | 581 |
582 print "};\n\n"; | |
583 } | |
584 | |
585 sub emit_option_table_entry | |
586 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
587 my ($i, $empty) = @_; |
3998 | 588 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
589 my $k; |
3998 | 590 |
591 if ($empty) | |
592 { | |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
593 print " { nullptr,\n"; |
3998 | 594 } |
595 else | |
596 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
597 print " { \"$NAME[$i]\",\n"; |
3998 | 598 } |
599 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
600 my $n = scalar $#{$KW_TOK[$i]}; |
3998 | 601 print " {"; |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
602 for $k (0 .. $MAX_TOKENS) |
3998 | 603 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
604 if ($empty or $k > $n) |
3998 | 605 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
606 print " nullptr,"; |
3998 | 607 } |
608 else | |
609 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
610 print " \"$KW_TOK[$i][$k]\","; |
3998 | 611 } |
612 } | |
613 print " },\n"; | |
614 | |
615 print " {"; | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
616 for $k (0 .. $MAX_TOKENS) |
3998 | 617 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
618 if ($empty or $k > $n) |
3998 | 619 { |
620 print " 0,"; | |
621 } | |
622 else | |
623 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
624 print " $MIN_TOK_LEN_TO_MATCH[$i][$k],"; |
3998 | 625 } |
626 } | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
627 print " }, $MIN_TOKS_TO_MATCH[$i], "; |
3998 | 628 |
629 print "},\n"; | |
630 } | |
631 | |
632 sub emit_print_function | |
633 { | |
21092
429f83903400
maint: Use "FIXME:" more places in code base.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
634 ## FIXME: determine the width of the table automatically. |
4047 | 635 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
636 print qq|static void |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
637 print_$CLASS_NAME (std::ostream& os) |
3998 | 638 { |
5765 | 639 std::ostringstream buf; |
3998 | 640 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
641 os << "\\n" |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
642 << "Options for $CLASS include:\\n\\n" |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
643 << " keyword value\\n" |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
644 << " ------- -----\\n"; |
3998 | 645 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
646 $STRUCT_NAME *list = $STATIC_TABLE_NAME;\n\n|; |
3998 | 647 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
648 for (my $i = 0; $i < $OPT_NUM; $i++) |
3998 | 649 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
650 print qq| {\n os << " " |
5667 | 651 << std::setiosflags (std::ios::left) << std::setw (50) |
652 << list[$i].keyword | |
653 << std::resetiosflags (std::ios::left) | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
654 << " ";\n\n|; |
3998 | 655 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
656 if ($TYPE[$i] eq "double") |
3998 | 657 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
658 print qq| double val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n|; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
659 print qq| os << val << "\\n";\n|; |
3998 | 660 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
661 elsif ($TYPE[$i] eq "float") |
7806
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
662 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
663 print qq| float val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n|; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
664 print qq| os << val << "\\n";\n|; |
7806
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
665 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
666 elsif ($TYPE[$i] eq "int" or $TYPE[$i] eq "octave_idx_type") |
3998 | 667 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
668 print qq| int val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n|; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
669 print qq| os << val << "\\n";\n|; |
3998 | 670 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
671 elsif ($TYPE[$i] eq "std::string") |
3998 | 672 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
673 print qq| os << $STATIC_OBJECT_NAME.$OPT[$i] () << "\\n";\n|; |
3998 | 674 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
675 elsif ($TYPE[$i] eq "Array<int>" or $TYPE[$i] eq "Array<octave_idx_type>") |
4044 | 676 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
677 my $elt_type; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
678 if ($TYPE[$i] eq "Array<int>") |
5275 | 679 { |
680 $elt_type = "int"; | |
681 } | |
682 else | |
683 { | |
684 $elt_type = "octave_idx_type"; | |
685 } | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
686 print qq| Array<$elt_type> val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n|; |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20163
diff
changeset
|
687 print qq| if (val.numel () == 1) |
4044 | 688 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
689 os << val(0) << "\\n"; |
4044 | 690 } |
691 else | |
692 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
693 os << "\\n\\n"; |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20163
diff
changeset
|
694 octave_idx_type len = val.numel (); |
12174 | 695 Matrix tmp (len, 1); |
696 for (octave_idx_type i = 0; i < len; i++) | |
697 tmp(i,0) = val(i); | |
6755 | 698 octave_print_internal (os, tmp, false, 2); |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
699 os << "\\n\\n"; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
700 }\n|; |
4044 | 701 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
702 elsif ($TYPE[$i] eq "Array<double>") |
3998 | 703 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
704 print qq| Array<double> val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n|; |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20163
diff
changeset
|
705 print qq| if (val.numel () == 1) |
3998 | 706 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
707 os << val(0) << "\\n"; |
3998 | 708 } |
709 else | |
710 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
711 os << "\\n\\n"; |
3998 | 712 Matrix tmp = Matrix (ColumnVector (val)); |
6755 | 713 octave_print_internal (os, tmp, false, 2); |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
714 os << "\\n\\n"; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
715 }\n|; |
3998 | 716 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
717 elsif ($TYPE[$i] eq "Array<float>") |
7806
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
718 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
719 print qq| Array<float> val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n|; |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20163
diff
changeset
|
720 print qq| if (val.numel () == 1) |
7806
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
721 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
722 os << val(0) << "\\n"; |
7806
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
723 } |
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
724 else |
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
725 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
726 os << "\\n\\n"; |
7806
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
727 FloatMatrix tmp = FloatMatrix (FloatColumnVector (val)); |
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
728 octave_print_internal (os, tmp, false, 2); |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
729 os << "\\n\\n"; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
730 }\n|; |
7806
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
731 } |
3998 | 732 else |
733 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
734 die ("unknown type $TYPE[$i]"); |
3998 | 735 } |
736 | |
737 print " }\n\n"; | |
738 } | |
739 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
740 print qq| os << "\\n";\n}\n\n|; |
3998 | 741 } |
742 | |
743 sub emit_set_functions | |
744 { | |
745 print "static void | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
746 set_$CLASS_NAME (const std::string& keyword, const octave_value& val) |
3998 | 747 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
748 $STRUCT_NAME *list = $STATIC_TABLE_NAME;\n\n"; |
3998 | 749 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
750 my $iftok = "if"; |
3998 | 751 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
752 for (my $i = 0; $i < $OPT_NUM; $i++) |
3998 | 753 { |
754 $iftok = "else if" if ($i > 0); | |
755 | |
25646
4d565baa475e
move libinterp/utils functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25438
diff
changeset
|
756 print " $iftok (octave::keyword_almost_match (list[$i].kw_tok, list[$i].min_len, |
3998 | 757 keyword, list[$i].min_toks_to_match, MAX_TOKENS)) |
758 {\n"; | |
759 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
760 if ($TYPE[$i] eq "double") |
3998 | 761 { |
762 print " double tmp = val.double_value ();\n\n"; | |
20733
c6464d78da69
eliminate error_state from generated code
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
763 print " $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n"; |
3998 | 764 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
765 elsif ($TYPE[$i] eq "float") |
7806
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
766 { |
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
767 print " float tmp = val.float_value ();\n\n"; |
20733
c6464d78da69
eliminate error_state from generated code
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
768 print " $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n"; |
7806
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
769 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
770 elsif ($TYPE[$i] eq "int" or $TYPE[$i] eq "octave_idx_type") |
3998 | 771 { |
772 print " int tmp = val.int_value ();\n\n"; | |
20733
c6464d78da69
eliminate error_state from generated code
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
773 print " $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n"; |
3998 | 774 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
775 elsif ($TYPE[$i] eq "std::string") |
3998 | 776 { |
777 print " std::string tmp = val.string_value ();\n\n"; | |
20733
c6464d78da69
eliminate error_state from generated code
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
778 print " $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n"; |
3998 | 779 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
780 elsif ($TYPE[$i] eq "Array<int>" or $TYPE[$i] eq "Array<octave_idx_type>") |
4044 | 781 { |
782 print " Array<int> tmp = val.int_vector_value ();\n\n"; | |
20733
c6464d78da69
eliminate error_state from generated code
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
783 print " $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n"; |
4044 | 784 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
785 elsif ($TYPE[$i] eq "Array<double>") |
3998 | 786 { |
787 print " Array<double> tmp = val.vector_value ();\n\n"; | |
20733
c6464d78da69
eliminate error_state from generated code
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
788 print " $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n"; |
3998 | 789 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
790 elsif ($TYPE[$i] eq "Array<float>") |
7806
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
791 { |
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
792 print " Array<float> tmp = val.float_vector_value ();\n\n"; |
20733
c6464d78da69
eliminate error_state from generated code
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
793 print " $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n"; |
7806
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
794 } |
3998 | 795 else |
796 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
797 die ("unknown type $TYPE[$i]"); |
3998 | 798 } |
799 | |
800 print " }\n"; | |
801 } | |
802 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
803 print qq| else |
3998 | 804 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
805 warning ("$OPT_FCN_NAME: no match for `%s'", keyword.c_str ()); |
3998 | 806 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
807 }\n\n|; |
3998 | 808 } |
809 | |
810 sub emit_show_function | |
811 { | |
812 print "static octave_value_list | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
813 show_$CLASS_NAME (const std::string& keyword) |
3998 | 814 { |
815 octave_value retval; | |
816 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
817 $STRUCT_NAME *list = $STATIC_TABLE_NAME;\n\n"; |
3998 | 818 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
819 my $iftok = "if"; |
3998 | 820 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
821 for (my $i = 0; $i < $OPT_NUM; $i++) |
3998 | 822 { |
823 $iftok = "else if" if ($i > 0); | |
824 | |
25646
4d565baa475e
move libinterp/utils functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
25438
diff
changeset
|
825 print " $iftok (octave::keyword_almost_match (list[$i].kw_tok, list[$i].min_len, |
3998 | 826 keyword, list[$i].min_toks_to_match, MAX_TOKENS)) |
827 {\n"; | |
828 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
829 if ($TYPE[$i] eq "double") |
3998 | 830 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
831 print " double val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n"; |
3998 | 832 print " retval = val;\n"; |
833 } | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
834 elsif ($TYPE[$i] eq "float") |
7806
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
835 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
836 print " float val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n"; |
7806
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
837 print " retval = val;\n"; |
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
838 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
839 elsif ($TYPE[$i] eq "int" or $TYPE[$i] eq "octave_idx_type") |
3998 | 840 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
841 print " int val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n"; |
3998 | 842 print " retval = static_cast<double> (val);\n"; |
843 } | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
844 elsif ($TYPE[$i] eq "std::string") |
3998 | 845 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
846 print " retval = $STATIC_OBJECT_NAME.$OPT[$i] ();\n"; |
3998 | 847 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
848 elsif ($TYPE[$i] eq "Array<int>" or $TYPE[$i] eq "Array<octave_idx_type>") |
4044 | 849 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
850 my $elt_type; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
851 if ($TYPE[$i] eq "Array<int>") |
5275 | 852 { |
853 $elt_type = "int"; | |
854 } | |
855 else | |
856 { | |
857 $elt_type = "octave_idx_type"; | |
858 } | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
859 print " Array<$elt_type> val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n"; |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20163
diff
changeset
|
860 print " if (val.numel () == 1) |
4044 | 861 { |
862 retval = static_cast<double> (val(0)); | |
863 } | |
864 else | |
865 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20163
diff
changeset
|
866 octave_idx_type len = val.numel (); |
12174 | 867 ColumnVector tmp (len); |
868 for (octave_idx_type i = 0; i < len; i++) | |
869 tmp(i) = val(i); | |
4044 | 870 retval = tmp; |
871 }\n"; | |
872 } | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
873 elsif ($TYPE[$i] eq "Array<double>") |
3998 | 874 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
875 print " Array<double> val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n"; |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20163
diff
changeset
|
876 print " if (val.numel () == 1) |
3998 | 877 { |
878 retval = val(0); | |
879 } | |
880 else | |
881 { | |
882 retval = ColumnVector (val); | |
883 }\n"; | |
884 } | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
885 elsif ($TYPE[$i] eq "Array<float>") |
7806
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
886 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
887 print " Array<float> val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n"; |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20163
diff
changeset
|
888 print " if (val.numel () == 1) |
7806
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
889 { |
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
890 retval = val(0); |
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
891 } |
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
892 else |
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
893 { |
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
894 retval = FloatColumnVector (val); |
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
895 }\n"; |
edc25a3fb2bc
handle floats in mk-opts.pl
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
896 } |
3998 | 897 else |
898 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
899 die ("unknown type $TYPE[$i]"); |
3998 | 900 } |
901 | |
902 print " }\n"; | |
903 } | |
904 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
905 print qq| else |
3998 | 906 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
907 warning ("$OPT_FCN_NAME: no match for `%s'", keyword.c_str ()); |
3998 | 908 } |
909 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
910 return retval;\n}\n\n|; |
3998 | 911 } |
912 | |
913 sub emit_options_function | |
914 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
915 print <<"_END_EMIT_OPTIONS_FUNCTION_HDR_"; |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
916 OCTAVE_NAMESPACE_BEGIN |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
917 |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
918 DEFUN ($OPT_FCN_NAME, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21690
diff
changeset
|
919 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21690
diff
changeset
|
920 \@deftypefn {} {} $OPT_FCN_NAME () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21690
diff
changeset
|
921 \@deftypefnx {} {val =} $OPT_FCN_NAME (\@var{opt}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21690
diff
changeset
|
922 \@deftypefnx {} {} $OPT_FCN_NAME (\@var{opt}, \@var{val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21690
diff
changeset
|
923 $DOC_STRING |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21690
diff
changeset
|
924 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21690
diff
changeset
|
925 Options include |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21690
diff
changeset
|
926 |
22720
766b0163b3b7
doc: Don't create @tables of type @code with @qcode entries.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
927 \@table \@asis |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
928 _END_EMIT_OPTIONS_FUNCTION_HDR_ |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
929 # FIXME: Add extra newline above |
4050 | 930 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
931 for (my $i = 0; $i < $OPT_NUM; $i++) |
4050 | 932 { |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21690
diff
changeset
|
933 print '@item @qcode{"', $NAME[$i], '"}', "\n"; |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
934 print $DOC_ITEM[$i] if $DOC_ITEM[$i]; |
4050 | 935 } |
936 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
937 print <<"_END_EMIT_OPTIONS_FUNCTION_BODY_"; |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21690
diff
changeset
|
938 \@end table |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21690
diff
changeset
|
939 \@end deftypefn */) |
3998 | 940 { |
941 octave_value_list retval; | |
942 | |
943 int nargin = args.length (); | |
944 | |
20812
d9ca869ca124
maint: Clean-up more instances of print_usage().
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
945 if (nargin > 2) |
d9ca869ca124
maint: Clean-up more instances of print_usage().
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
946 print_usage (); |
d9ca869ca124
maint: Clean-up more instances of print_usage().
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
947 |
3998 | 948 if (nargin == 0) |
949 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
950 print_$CLASS_NAME (octave_stdout); |
3998 | 951 } |
20812
d9ca869ca124
maint: Clean-up more instances of print_usage().
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
952 else |
3998 | 953 { |
20733
c6464d78da69
eliminate error_state from generated code
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
954 std::string keyword = args(0).xstring_value ("$OPT_FCN_NAME: expecting keyword as first argument"); |
3998 | 955 |
20733
c6464d78da69
eliminate error_state from generated code
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
956 if (nargin == 1) |
c6464d78da69
eliminate error_state from generated code
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
957 retval = show_$CLASS_NAME (keyword); |
3998 | 958 else |
20733
c6464d78da69
eliminate error_state from generated code
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
959 set_$CLASS_NAME (keyword, args(1)); |
3998 | 960 } |
961 | |
962 return retval; | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
963 } |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
964 |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
965 OCTAVE_NAMESPACE_END |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
966 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
967 _END_EMIT_OPTIONS_FUNCTION_BODY_ |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
968 |
3998 | 969 } |
970 | |
971 sub emit_options_debug | |
972 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
973 print qq|CLASS = "$CLASS"\n|; |
3998 | 974 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
975 for (my $i = 0; $i < $OPT_NUM; $i++) |
3998 | 976 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
977 print "\nOPTION\n"; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
978 print qq| NAME = "$NAME[$i]"\n|; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
979 print qq| TYPE = "$TYPE[$i]"\n|; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
980 if ($SET_ARG_TYPE[$i]) |
3998 | 981 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
982 print eval ("\" SET_ARG_TYPE = \\\"$SET_ARG_TYPE[$i]\\\"\"") . "\n"; |
3998 | 983 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
984 if ($INIT_VALUE[$i]) |
3998 | 985 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
986 print qq| INIT_VALUE = "$INIT_VALUE[$i]"\n|; |
3998 | 987 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
988 if ($INIT_BODY[$i]) |
3998 | 989 { |
990 print " INIT_BODY\n"; | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
991 print &substopt ($INIT_BODY[$i]); |
3998 | 992 print " END_INIT_BODY\n"; |
993 } | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
994 if ($SET_EXPR[$i]) |
3998 | 995 { |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
996 print qq| SET_EXPR = "$SET_EXPR[$i]"\n|; |
3998 | 997 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
998 if ($SET_BODY[$i]) |
3998 | 999 { |
1000 print " SET_BODY\n"; | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1001 print &substopt ($SET_BODY[$i]); |
3998 | 1002 print " END_SET_BODY\n"; |
1003 } | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1004 if ($SET_CODE[$i]) |
3998 | 1005 { |
1006 print " SET_CODE\n"; | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1007 print &substopt ($SET_CODE[$i]); |
3998 | 1008 print " END_SET_CODE\n"; |
1009 } | |
1010 print "END_OPTION\n"; | |
1011 } | |
1012 } | |
1013 | |
1014 sub substopt | |
1015 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1016 my ($string, $optvar, $opt, $type) = @_; |
3998 | 1017 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1018 $string =~ s/\$OPTVAR/$optvar/g; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1019 $string =~ s/\$OPT/$opt/g; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1020 $string =~ s/\$TYPE/$type/g; |
3998 | 1021 |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1022 return $string; |
3998 | 1023 } |
1024 | |
1025 sub max | |
1026 { | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1027 my $max = shift; |
3998 | 1028 |
1029 foreach (@_) | |
1030 { | |
1031 $max = $_ if $max < $_; | |
1032 } | |
1033 | |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1034 return $max; |
3998 | 1035 } |
12504
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1036 |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1037 ################################################################################ |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1038 # Subroutine processes any command line arguments |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1039 ################################################################################ |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1040 sub parse_options |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1041 { |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1042 my $result; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1043 |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1044 $opt_help = 0; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1045 $opt_class_header = 0; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1046 $opt_handler_fcns = 0; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1047 $opt_debug = 0; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1048 |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1049 $result = GetOptions ("opt-class-header" => \$opt_class_header, |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1050 "opt-handler-fcns" => \$opt_handler_fcns, |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1051 "debug" => \$opt_debug, |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1052 "help" => \$opt_help); |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1053 |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1054 # give user info if options incorrect or -h(elp) given |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1055 &usage_info if (!$result or (@ARGV != 1) or $opt_help); |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1056 if ($opt_class_header and $opt_handler_fcns) |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1057 { |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1058 die "Only one of [-opt-class-header | -opt-handler-fcns ] may be specified"; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1059 } |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1060 |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1061 } |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1062 |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1063 ################################################################################ |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1064 # Subroutine displays usage information |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1065 ################################################################################ |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1066 sub usage_info |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1067 { |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1068 warn <<_END_OF_USAGE_; |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1069 ////////////////////////////////////////////////////////////////////////////// |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1070 USAGE : mk-opts.pl -opt-class-header|-opt-handler-fcns [-debug] [-help] DEFN_FILE |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1071 ////////////////////////////////////////////////////////////////////////////// |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1072 |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1073 Automatically generate C++ code for option handling code (DASSL, DASRT, etc.) |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1074 from definition file. |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1075 |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1076 See the head of mk-opts.pl for a description of the format that is parsed. |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1077 _END_OF_USAGE_ |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1078 |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1079 exit(1); # exit with error code |
d1758f03a2ec
Recode mk-opts.pl to use clearer, more modern, Perl syntax.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
1080 } |