Mercurial > octave
annotate libinterp/mk-builtins.pl @ 25882:22ee68edcf3a
require dynamic loading capabilities to build Octave
* configure.ac: Eliminate --disable-dl configure option.
(ENABLE_DYNAMIC_LINKING): Eliminate variable, corresponding automake
conditiona, and all uses. Require dlopen, shl_load, loadlibrary, or
dyld api to build Octave.
* install.txi: Don't document --enable-dl.
* mex_demo.c, oct_demo.cc: Don't mention ENABLE_DYNAMIC_LINKING in
comments.
* toplev.cc (F__octave_config_info__): Remove ENABLE_DYNAMIC_LINKING
and dld from from structs.
* libinterp/module.mk, mk-builtins.pl, config-module.awk:
Always assume dynamic linking is used.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 13 Sep 2018 16:24:18 -0400 |
parents | e1c3d1c6e896 |
children | 00f796120a6d |
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 |
7019 | 2 # |
25054
6652d3823428
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
24728
diff
changeset
|
3 # Copyright (C) 1996-2018 John W. Eaton |
7019 | 4 # |
5 # This file is part of Octave. | |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
6 # |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23714
diff
changeset
|
7 # Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
8 # under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23714
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
10 # (at your option) any later version. |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
11 # |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
12 # Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 # WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
15 # GNU General Public License for more details. |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
16 # |
7019 | 17 # You should have received a copy of the GNU General Public License |
18 # along with Octave; see the file COPYING. If not, see | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23714
diff
changeset
|
19 # <https://www.gnu.org/licenses/>. |
2335 | 20 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
21 $make_header = 0; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
22 $make_source = 0; |
4299 | 23 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
24 $have_options = 1; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
25 |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
26 while ($have_options) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
27 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
28 $opt = shift (@ARGV); |
15418
60090630cb76
generate declarations for all built-in DEFUN functions
John W. Eaton <jwe@octave.org>
parents:
15268
diff
changeset
|
29 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
30 if ($opt eq "--header") |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
31 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
32 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
|
33 |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
34 $make_header = 1; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
35 } |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
36 elsif ($opt eq "--source") |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
37 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
38 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
|
39 |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
40 $make_source = 1; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
41 } |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
42 else |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
43 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
44 $srcdir = "$opt"; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
45 $opt = shift (@ARGV); |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
46 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
|
47 $have_options = 0; |
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 } |
22002
40e9cb6bd95c
avoid macros in generated built-in function files
John W. Eaton <jwe@octave.org>
parents:
22001
diff
changeset
|
50 |
25882
22ee68edcf3a
require dynamic loading capabilities to build Octave
John W. Eaton <jwe@octave.org>
parents:
25637
diff
changeset
|
51 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
|
52 |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
53 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
|
54 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
55 if ($make_header) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
56 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
57 print "// DO NOT EDIT! Generated automatically by mk-builtins.pl. |
15418
60090630cb76
generate declarations for all built-in DEFUN functions
John W. Eaton <jwe@octave.org>
parents:
15268
diff
changeset
|
58 |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
59 #if ! defined (octave_builtin_defun_decls_h) |
15419
2afbe4295682
correct name of include guard in generated builtin-defun-decls.h file
John W. Eaton <jwe@octave.org>
parents:
15418
diff
changeset
|
60 #define octave_builtin_defun_decls_h 1 |
15418
60090630cb76
generate declarations for all built-in DEFUN functions
John W. Eaton <jwe@octave.org>
parents:
15268
diff
changeset
|
61 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
62 #include \"octave-config.h\" |
15422
57e685d135ec
include oct-obj.h in generated builtin-defun-decls.h file
John W. Eaton <jwe@octave.org>
parents:
15419
diff
changeset
|
63 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
64 #include \"ovl.h\" |
22002
40e9cb6bd95c
avoid macros in generated built-in function files
John W. Eaton <jwe@octave.org>
parents:
22001
diff
changeset
|
65 |
23518 | 66 namespace octave |
67 { | |
68 class interpreter; | |
69 } | |
70 | |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
71 "; |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
72 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
73 while ($file = shift (@ARGV)) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
74 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
75 if (! -f $file) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
76 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
77 $file = "$srcdir/$file"; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
78 } |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
79 |
22002
40e9cb6bd95c
avoid macros in generated built-in function files
John W. Eaton <jwe@octave.org>
parents:
22001
diff
changeset
|
80 ## 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
|
81 ## 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
|
82 ## bit smaller. |
40e9cb6bd95c
avoid macros in generated built-in function files
John W. Eaton <jwe@octave.org>
parents:
22001
diff
changeset
|
83 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
84 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
|
85 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
86 while (<$fh>) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
87 { |
23518 | 88 if (/^[ \t]*DEF(CONSTFUN|CONSTMETHOD|METHOD|UN)[ \t]*\( *([^ ,]*).*$/) |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
89 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
90 $name = "F$2"; |
23518 | 91 $is_method = ($1 eq "METHOD" || $1 eq "CONSTMETHOD"); |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
92 } |
23518 | 93 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
|
94 { |
23518 | 95 $name = $2; |
96 $is_method = ($1 eq "METHOD"); | |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
97 } |
15418
60090630cb76
generate declarations for all built-in DEFUN functions
John W. Eaton <jwe@octave.org>
parents:
15268
diff
changeset
|
98 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
99 if ($name) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
100 { |
23518 | 101 if ($is_method) |
102 { | |
103 print "extern OCTINTERP_API octave_value_list | |
104 $name (octave::interpreter&, const octave_value_list& = octave_value_list (), int = 0); | |
105 "; | |
106 } | |
107 else | |
108 { | |
109 print "extern OCTINTERP_API octave_value_list | |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
110 $name (const octave_value_list& = octave_value_list (), int = 0); |
23518 | 111 "; |
112 } | |
15418
60090630cb76
generate declarations for all built-in DEFUN functions
John W. Eaton <jwe@octave.org>
parents:
15268
diff
changeset
|
113 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
114 $name = ""; |
23518 | 115 $is_method = 0; |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
116 } |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
117 } |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
118 } |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
119 |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
120 print "#endif\n"; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
121 } |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
122 elsif ($make_source) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
123 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
124 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
|
125 |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
126 #if defined (HAVE_CONFIG_H) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
127 # include \"config.h\" |
15418
60090630cb76
generate declarations for all built-in DEFUN functions
John W. Eaton <jwe@octave.org>
parents:
15268
diff
changeset
|
128 #endif |
60090630cb76
generate declarations for all built-in DEFUN functions
John W. Eaton <jwe@octave.org>
parents:
15268
diff
changeset
|
129 |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
130 #include \"builtin-defun-decls.h\" |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
131 #include \"help.h\" |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
132 #include \"ovl.h\" |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
133 #include \"symtab.h\" |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
134 #include \"variables.h\" |
2335 | 135 |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
136 namespace octave |
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
137 {"; |
3399 | 138 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
139 @installer_functions = (); |
5796 | 140 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
141 foreach $arg (@ARGV) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
142 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
143 $file = $arg; |
3295 | 144 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
145 if (! -f $file) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
146 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
147 $file = "$srcdir/$file"; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
148 } |
2373 | 149 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
150 ($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
|
151 $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
|
152 $fcn =~ s/-/_/g; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
153 $fcn = "install_${fcn}_fcns"; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
154 |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
155 $fcn_header = "\n static void |
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
156 $fcn (symbol_table& symtab) |
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
157 { |
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
158 std::string file = \"$arg\";"; |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
159 |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
160 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
|
161 |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
162 ## 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
|
163 ## 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
|
164 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
165 $type = ""; |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
166 $const_param = ""; |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
167 $fname = ""; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
168 $name = ""; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
169 $alias = ""; |
24726
10c7e236a567
* mk-builtins.pl: Don't generate functions that do nothing.
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
170 $fcn_body = ""; |
22002
40e9cb6bd95c
avoid macros in generated built-in function files
John W. Eaton <jwe@octave.org>
parents:
22001
diff
changeset
|
171 |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
172 %dispatch_map = (); |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
173 |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
174 while ($line = <$fh>) |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
175 { |
23518 | 176 if ($line =~ /^ *DEF(METHOD|UN) *\( *([^ ,]*) *,.*$/) |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
177 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
178 $type = "fun"; |
23518 | 179 $fname = "F$2"; |
180 $name = "$2"; | |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
181 } |
23518 | 182 elsif ($line =~ /^ *DEF(METHOD|UN)X *\( *"([^"]*)" *, *([^ ,]*) *,.*$/) |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
183 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
184 $type = "fun"; |
23518 | 185 $fname = "$3"; |
186 $name = "$2"; | |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
187 } |
23518 | 188 elsif ($line =~ /^ *DEFCONST(FUN|METHOD) *\( *([^ ,]*) *,.*$/) |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
189 { |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
190 $type = "fun"; |
23518 | 191 $fname = "F$2"; |
192 $name = "$2"; | |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
193 $const_param = ", true"; |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
194 } |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
195 elsif ($line =~ /^ *DEFALIAS *\( *([^ ,]*) *, *([^ )]*) *\).*$/) |
22892
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 $type = "alias"; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
198 $alias = "$1"; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
199 $name = "$2"; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
200 } |
22002
40e9cb6bd95c
avoid macros in generated built-in function files
John W. Eaton <jwe@octave.org>
parents:
22001
diff
changeset
|
201 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
202 if ($type eq "fun") |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
203 { |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
204 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
|
205 { |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
206 $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
|
207 $line =~ s/\s*$//; |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
208 @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
|
209 |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
210 $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
|
211 } |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
212 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
213 ## 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
|
214 ## the docstring for aliases to this function. |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
215 |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
216 $fcn_body .= "\n symtab.install_built_in_function (\"$name\", octave_value (new octave_builtin ($fname, \"$name\", file, \"external-doc:$name\")));"; |
2907 | 217 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
218 $type = ""; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
219 $fname = ""; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
220 $name = ""; |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
221 $const_param = ""; |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
222 } |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
223 elsif ($type eq "alias") |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
224 { |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
225 $fcn_body .= "\n symtab.alias_built_in_function (\"$alias\", \"$name\");"; |
2907 | 226 |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
227 ## 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
|
228 ## original function. |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
229 |
22896
8fb46f48c548
eliminate warnings from mk-builtins.pl
John W. Eaton <jwe@octave.org>
parents:
22893
diff
changeset
|
230 if (exists $dispatch_map{$name}) |
8fb46f48c548
eliminate warnings from mk-builtins.pl
John W. Eaton <jwe@octave.org>
parents:
22893
diff
changeset
|
231 { |
8fb46f48c548
eliminate warnings from mk-builtins.pl
John W. Eaton <jwe@octave.org>
parents:
22893
diff
changeset
|
232 @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
|
233 |
22896
8fb46f48c548
eliminate warnings from mk-builtins.pl
John W. Eaton <jwe@octave.org>
parents:
22893
diff
changeset
|
234 if (@classes) |
8fb46f48c548
eliminate warnings from mk-builtins.pl
John W. Eaton <jwe@octave.org>
parents:
22893
diff
changeset
|
235 { |
8fb46f48c548
eliminate warnings from mk-builtins.pl
John W. Eaton <jwe@octave.org>
parents:
22893
diff
changeset
|
236 $dispatch_map{$alias} = [@classes]; |
8fb46f48c548
eliminate warnings from mk-builtins.pl
John W. Eaton <jwe@octave.org>
parents:
22893
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 } |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
239 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
240 $type = ""; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
241 $name = ""; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
242 $alias = ""; |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
243 } |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
244 } |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
245 |
23419
75a4b9a34999
Ensure generated source files are deterministic and reproducible
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
246 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
|
247 { |
24726
10c7e236a567
* mk-builtins.pl: Don't generate functions that do nothing.
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
248 $dispatch_code = ""; |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
249 |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
250 @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
|
251 |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
252 foreach $class (@classes) |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
253 { |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
254 $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
|
255 } |
24726
10c7e236a567
* mk-builtins.pl: Don't generate functions that do nothing.
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
256 |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
257 if ($dispatch_code) |
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
258 { |
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
259 $fcn_body .= "\n$dispatch_code"; |
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
260 } |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
261 } |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22892
diff
changeset
|
262 |
24726
10c7e236a567
* mk-builtins.pl: Don't generate functions that do nothing.
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
263 if ($fcn_body) |
10c7e236a567
* mk-builtins.pl: Don't generate functions that do nothing.
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
264 { |
10c7e236a567
* mk-builtins.pl: Don't generate functions that do nothing.
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
265 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
|
266 |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
267 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
|
268 } |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
269 } |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
270 |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
271 print " |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
272 void |
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
273 symbol_table::install_builtins (void) |
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
274 { |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
275 "; |
2335 | 276 |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
277 foreach $fcn (@installer_functions) |
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
278 { |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
279 print " $fcn (*this);\n" |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
280 } |
2335 | 281 |
24727
11e359eb63f4
move install_builtins function inside symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24726
diff
changeset
|
282 print " }\n}\n"; |
22892
5521b8a271ae
rewrite mk-builtins script in Perl
John W. Eaton <jwe@octave.org>
parents:
22825
diff
changeset
|
283 } |