Mercurial > octave
annotate libinterp/mk-builtins.pl @ 31211:8340137bb190
maint: Merge stable to default.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Mon, 29 Aug 2022 13:58:00 +0200 |
parents | ac74380e9d46 |
children | fcbbb498d4af e88a07dec498 |
rev | line source |
---|---|
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
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:
29972
diff
changeset
|
5 ## Copyright (C) 1996-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 ######################################################################## |
2335 | 27 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
28 $make_header = 0; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
29 $make_source = 0; |
4299 | 30 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
31 $have_options = 1; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
32 |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
33 while ($have_options) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
34 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
35 $opt = shift (@ARGV); |
15418
60090630cb76
generate declarations for all built-in DEFUN functions
John W. Eaton <jwe@octave.org>
parents:
15268
diff
changeset
|
36 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
37 if ($opt eq "--header") |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
38 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
39 die "mk-builtins.pl: only one of --header or --source may be specified" if ($make_source); |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
40 |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
41 $make_header = 1; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
42 } |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
43 elsif ($opt eq "--source") |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
44 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
45 die "mk-builtins.pl: only one of --header or --source may be specified" if ($make_header); |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
46 |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
47 $make_source = 1; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
48 } |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
49 else |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
50 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
51 $srcdir = "$opt"; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
52 $opt = shift (@ARGV); |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
53 die "mk-builtins.pl: '--' must separate SRCDIR from other file names" if ($opt ne "--"); |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
54 $have_options = 0; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
55 } |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
56 } |
22002
40e9cb6bd95c
avoid macros in generated built-in function files
John W. Eaton <jwe@octave.org>
parents:
22001
diff
changeset
|
57 |
25882
22ee68edcf3a
require dynamic loading capabilities to build Octave
John W. Eaton <jwe@octave.org>
parents:
25637
diff
changeset
|
58 die "usage: mk-builtins.pl --header|--source SRCDIR -- f1 f2 ..." if (! @ARGV); |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
59 |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
60 die "mk-builtins.pl: one of --header or --source must be specified" if (! $make_header && ! $make_source); |
22095
6119019d42f6
move find-defun-files.sh and mkbuiltins to build-aux directory
John W. Eaton <jwe@octave.org>
parents:
22002
diff
changeset
|
61 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
62 if ($make_header) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
63 { |
29952
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
64 @method_names = (); |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
65 @fcn_names = (); |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
66 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
67 while ($file = shift (@ARGV)) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
68 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
69 if (! -f $file) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
70 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
71 $file = "$srcdir/$file"; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
72 } |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
73 |
22002
40e9cb6bd95c
avoid macros in generated built-in function files
John W. Eaton <jwe@octave.org>
parents:
22001
diff
changeset
|
74 ## Generate a list of function names to declare. We could do |
40e9cb6bd95c
avoid macros in generated built-in function files
John W. Eaton <jwe@octave.org>
parents:
22001
diff
changeset
|
75 ## this in one step, but this way keeps the sed patterns a |
40e9cb6bd95c
avoid macros in generated built-in function files
John W. Eaton <jwe@octave.org>
parents:
22001
diff
changeset
|
76 ## bit smaller. |
40e9cb6bd95c
avoid macros in generated built-in function files
John W. Eaton <jwe@octave.org>
parents:
22001
diff
changeset
|
77 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
78 open($fh, "<", $file) || die "mk-builtins.pl: failed to open file $file\n"; |
22002
40e9cb6bd95c
avoid macros in generated built-in function files
John W. Eaton <jwe@octave.org>
parents:
22001
diff
changeset
|
79 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
80 while (<$fh>) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
81 { |
29968
7aa4d8c049e5
eliminate obsolete DEFCONSTFUN and DEFCONSTMETHOD macros
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
82 if (/^[ \t]*DEF(METHOD|UN)[ \t]*\( *([^ ,]*).*$/) |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
83 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
84 $name = "F$2"; |
29968
7aa4d8c049e5
eliminate obsolete DEFCONSTFUN and DEFCONSTMETHOD macros
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
85 $is_method = ($1 eq "METHOD"); |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
86 } |
23518 | 87 elsif (/^[ \t]*DEF(METHOD|UN)X[ \t]*\( *"[^"]*" *, *([^ ,]*).*$/) |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
88 { |
23518 | 89 $name = $2; |
90 $is_method = ($1 eq "METHOD"); | |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
91 } |
15418
60090630cb76
generate declarations for all built-in DEFUN functions
John W. Eaton <jwe@octave.org>
parents:
15268
diff
changeset
|
92 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
93 if ($name) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
94 { |
23518 | 95 if ($is_method) |
96 { | |
29952
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
97 push (@method_names, $name); |
23518 | 98 } |
99 else | |
100 { | |
29952
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
101 push (@fcn_names, $name); |
23518 | 102 } |
15418
60090630cb76
generate declarations for all built-in DEFUN functions
John W. Eaton <jwe@octave.org>
parents:
15268
diff
changeset
|
103 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
104 $name = ""; |
23518 | 105 $is_method = 0; |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
106 } |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
107 } |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
108 } |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
109 |
29952
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
110 print "// DO NOT EDIT! Generated automatically by mk-builtins.pl. |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
111 |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
112 #if ! defined (octave_builtin_defun_decls_h) |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
113 #define octave_builtin_defun_decls_h 1 |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
114 |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
115 #include \"octave-config.h\" |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
116 |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
117 #include \"ovl.h\" |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
118 |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
119 OCTAVE_NAMESPACE_BEGIN |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
120 |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
121 class interpreter; |
29952
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
122 |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
123 "; |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
124 |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
125 if ($#method_names) |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
126 { |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
127 print "// Methods\n\n"; |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
128 } |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
129 |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
130 foreach $name (sort (@method_names)) |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
131 { |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
132 print "extern OCTINTERP_API octave_value_list |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
133 $name (octave::interpreter&, const octave_value_list& = octave_value_list (), int = 0); |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
134 |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
135 "; |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
136 } |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
137 |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
138 if ($#fcn_names) |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
139 { |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
140 print "// Functions\n\n"; |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
141 } |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
142 |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
143 foreach $name (sort (@fcn_names)) |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
144 { |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
145 print "extern OCTINTERP_API octave_value_list |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
146 $name (const octave_value_list& = octave_value_list (), int = 0); |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
147 |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
148 "; |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
149 } |
f2eaf14ff6c3
mk-builtins.pl: Separate fcn name collection and code generation steps.
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
150 |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
151 print "\nOCTAVE_NAMESPACE_END\n"; |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
152 |
29972
febddcd0f227
fix macro name in generated builtin-defun-decls.h file
John W. Eaton <jwe@octave.org>
parents:
29968
diff
changeset
|
153 print "\n#if defined (OCTAVE_PROVIDE_DEPRECATED_SYMBOLS)\n\n"; |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
154 |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
155 foreach $name (sort (@fcn_names)) |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
156 { |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
157 print "OCTAVE_DEPRECATED (7, \"use 'octave::$name' instead\") |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
158 inline octave_value_list |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
159 $name (const octave_value_list& args = octave_value_list (), int nargout = 0) |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
160 { |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
161 return octave::$name (args, nargout); |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
162 } |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
163 |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
164 "; |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
165 } |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
166 |
29972
febddcd0f227
fix macro name in generated builtin-defun-decls.h file
John W. Eaton <jwe@octave.org>
parents:
29968
diff
changeset
|
167 ## end OCTAVE_PROVIDE_DEPRECATED_SYMBOLS block |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
168 print "\n\n#endif\n"; |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
169 |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29952
diff
changeset
|
170 print "\n#endif\n"; |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
171 } |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
172 elsif ($make_source) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
173 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
174 print "// DO NOT EDIT! Generated automatically by mk-builtins.pl. |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
175 |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
176 #if defined (HAVE_CONFIG_H) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
177 # include \"config.h\" |
15418
60090630cb76
generate declarations for all built-in DEFUN functions
John W. Eaton <jwe@octave.org>
parents:
15268
diff
changeset
|
178 #endif |
60090630cb76
generate declarations for all built-in DEFUN functions
John W. Eaton <jwe@octave.org>
parents:
15268
diff
changeset
|
179 |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
180 #include \"builtin-defun-decls.h\" |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
181 #include \"help.h\" |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
182 #include \"ovl.h\" |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
183 #include \"symtab.h\" |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
184 #include \"variables.h\" |
2335 | 185 |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
186 namespace octave |
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
187 {"; |
3399 | 188 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
189 @installer_functions = (); |
5796 | 190 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
191 foreach $arg (@ARGV) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
192 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
193 $file = $arg; |
3295 | 194 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
195 if (! -f $file) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
196 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
197 $file = "$srcdir/$file"; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
198 } |
2373 | 199 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
200 ($fcn = $arg) =~ s,.*/,,; |
25637
e1c3d1c6e896
don't substitute api.prefix style in bison input files
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
201 $fcn =~ s/\.(cc|cpp|in\.cc|yy|ll)$//; |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
202 $fcn =~ s/-/_/g; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
203 $fcn = "install_${fcn}_fcns"; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
204 |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
205 $fcn_header = "\n static void |
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
206 $fcn (symbol_table& symtab) |
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
207 { |
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
208 std::string file = \"$arg\";"; |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
209 |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
210 open($fh, "<", $file) || die "mk-builtins.pl: failed to open file $file\n"; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
211 |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
212 ## Find DEFUN or DEFALIAS macros and generate the function calls that |
22002
40e9cb6bd95c
avoid macros in generated built-in function files
John W. Eaton <jwe@octave.org>
parents:
22001
diff
changeset
|
213 ## install the built-in functions or function aliases. |
40e9cb6bd95c
avoid macros in generated built-in function files
John W. Eaton <jwe@octave.org>
parents:
22001
diff
changeset
|
214 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
215 $type = ""; |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
216 $const_param = ""; |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
217 $fname = ""; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
218 $name = ""; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
219 $alias = ""; |
24726
10c7e236a567
* mk-builtins.pl: Don't generate functions that do nothing.
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
220 $fcn_body = ""; |
22002
40e9cb6bd95c
avoid macros in generated built-in function files
John W. Eaton <jwe@octave.org>
parents:
22001
diff
changeset
|
221 |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
222 %dispatch_map = (); |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
223 |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
224 while ($line = <$fh>) |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
225 { |
23518 | 226 if ($line =~ /^ *DEF(METHOD|UN) *\( *([^ ,]*) *,.*$/) |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
227 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
228 $type = "fun"; |
23518 | 229 $fname = "F$2"; |
230 $name = "$2"; | |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
231 } |
23518 | 232 elsif ($line =~ /^ *DEF(METHOD|UN)X *\( *"([^"]*)" *, *([^ ,]*) *,.*$/) |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
233 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
234 $type = "fun"; |
23518 | 235 $fname = "$3"; |
236 $name = "$2"; | |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
237 } |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
238 elsif ($line =~ /^ *DEFALIAS *\( *([^ ,]*) *, *([^ )]*) *\).*$/) |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
239 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
240 $type = "alias"; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
241 $alias = "$1"; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
242 $name = "$2"; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
243 } |
22002
40e9cb6bd95c
avoid macros in generated built-in function files
John W. Eaton <jwe@octave.org>
parents:
22001
diff
changeset
|
244 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
245 if ($type eq "fun") |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
246 { |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
247 if (($line = <$fh>) =~ /^ *classes:/) |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
248 { |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
249 $line =~ s/\s*classes:\s*//; |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
250 $line =~ s/\s*$//; |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
251 @classes = split (/\s+/, $line); |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
252 |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
253 $dispatch_map{$name} = [@classes]; |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
254 } |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
255 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
256 ## We use the name appended to the "external-doc" tag to find |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
257 ## the docstring for aliases to this function. |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
258 |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
259 $fcn_body .= "\n symtab.install_built_in_function (\"$name\", octave_value (new octave_builtin ($fname, \"$name\", file, \"external-doc:$name\")));"; |
2907 | 260 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
261 $type = ""; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
262 $fname = ""; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
263 $name = ""; |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
264 $const_param = ""; |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
265 } |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
266 elsif ($type eq "alias") |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
267 { |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
268 $fcn_body .= "\n symtab.alias_built_in_function (\"$alias\", \"$name\");"; |
2907 | 269 |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
270 ## Preserve dispatch info (if any) that we have for the |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
271 ## original function. |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
272 |
22896
8fb46f48c548
eliminate warnings from mk-builtins.pl
John W. Eaton <jwe@octave.org>
parents:
22893
diff
changeset
|
273 if (exists $dispatch_map{$name}) |
8fb46f48c548
eliminate warnings from mk-builtins.pl
John W. Eaton <jwe@octave.org>
parents:
22893
diff
changeset
|
274 { |
8fb46f48c548
eliminate warnings from mk-builtins.pl
John W. Eaton <jwe@octave.org>
parents:
22893
diff
changeset
|
275 @classes = @{$dispatch_map{$name}}; |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
276 |
22896
8fb46f48c548
eliminate warnings from mk-builtins.pl
John W. Eaton <jwe@octave.org>
parents:
22893
diff
changeset
|
277 if (@classes) |
8fb46f48c548
eliminate warnings from mk-builtins.pl
John W. Eaton <jwe@octave.org>
parents:
22893
diff
changeset
|
278 { |
8fb46f48c548
eliminate warnings from mk-builtins.pl
John W. Eaton <jwe@octave.org>
parents:
22893
diff
changeset
|
279 $dispatch_map{$alias} = [@classes]; |
8fb46f48c548
eliminate warnings from mk-builtins.pl
John W. Eaton <jwe@octave.org>
parents:
22893
diff
changeset
|
280 } |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
281 } |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
282 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
283 $type = ""; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
284 $name = ""; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
285 $alias = ""; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
286 } |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
287 } |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
288 |
23419
75a4b9a34999
Ensure generated source files are deterministic and reproducible
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
289 foreach $fcn (sort (keys (%dispatch_map))) |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
290 { |
24726
10c7e236a567
* mk-builtins.pl: Don't generate functions that do nothing.
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
291 $dispatch_code = ""; |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
292 |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
293 @classes = @{$dispatch_map{$fcn}}; |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
294 |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
295 foreach $class (@classes) |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
296 { |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
297 $dispatch_code .= "\n symtab.install_built_in_dispatch (\"$fcn\", \"$class\");"; |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
298 } |
24726
10c7e236a567
* mk-builtins.pl: Don't generate functions that do nothing.
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
299 |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
300 if ($dispatch_code) |
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
301 { |
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
302 $fcn_body .= "\n$dispatch_code"; |
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
303 } |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
304 } |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
305 |
24726
10c7e236a567
* mk-builtins.pl: Don't generate functions that do nothing.
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
306 if ($fcn_body) |
10c7e236a567
* mk-builtins.pl: Don't generate functions that do nothing.
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
307 { |
10c7e236a567
* mk-builtins.pl: Don't generate functions that do nothing.
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
308 push (@installer_functions, $fcn); |
10c7e236a567
* mk-builtins.pl: Don't generate functions that do nothing.
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
309 |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
310 print "$fcn_header\n$fcn_body\n }\n"; |
24726
10c7e236a567
* mk-builtins.pl: Don't generate functions that do nothing.
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
311 } |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
312 } |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
313 |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
314 print " |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
315 void |
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
316 symbol_table::install_builtins (void) |
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
317 { |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
318 "; |
2335 | 319 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
320 foreach $fcn (@installer_functions) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
321 { |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
322 print " $fcn (*this);\n" |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
323 } |
2335 | 324 |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
325 print " }\n}\n"; |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
326 } |