annotate src/mkbuiltins @ 8746:5dd06f19e9be

handle commands in the lexer
author John W. Eaton <jwe@octave.org>
date Sun, 15 Feb 2009 23:49:15 -0500
parents 8c32f95c2639
children eb63fbe60fab
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6218
c1b66b74937d [project @ 2006-12-27 17:43:50 by jwe]
jwe
parents: 5796
diff changeset
1 #! /bin/sh
7019
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6218
diff changeset
2 #
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6218
diff changeset
3 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2005,
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6218
diff changeset
4 # 2006, 2007 John W. Eaton
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6218
diff changeset
5 #
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6218
diff changeset
6 # This file is part of Octave.
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6218
diff changeset
7 #
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6218
diff changeset
8 # Octave is free software; you can redistribute it and/or modify it
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6218
diff changeset
9 # under the terms of the GNU General Public License as published by the
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6218
diff changeset
10 # Free Software Foundation; either version 3 of the License, or (at
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6218
diff changeset
11 # your option) any later version.
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6218
diff changeset
12 #
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6218
diff changeset
13 # Octave is distributed in the hope that it will be useful, but WITHOUT
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6218
diff changeset
14 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6218
diff changeset
15 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6218
diff changeset
16 # for more details.
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6218
diff changeset
17 #
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6218
diff changeset
18 # You should have received a copy of the GNU General Public License
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6218
diff changeset
19 # along with Octave; see the file COPYING. If not, see
4270ded9ddc6 [project @ 2007-10-13 01:42:20 by jwe]
jwe
parents: 6218
diff changeset
20 # <http://www.gnu.org/licenses/>.
2335
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
21
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5307
diff changeset
22 if test $# -ne 1; then
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5307
diff changeset
23 echo "usage: mkbuiltins f1" 1>&2
2907
8bb31a2b480b [project @ 1997-04-30 05:01:46 by jwe]
jwe
parents: 2890
diff changeset
24 exit 1
8bb31a2b480b [project @ 1997-04-30 05:01:46 by jwe]
jwe
parents: 2890
diff changeset
25 fi
8bb31a2b480b [project @ 1997-04-30 05:01:46 by jwe]
jwe
parents: 2890
diff changeset
26
4299
02fcb550f20c [project @ 2003-01-16 20:15:14 by jwe]
jwe
parents: 4234
diff changeset
27 SED=${SED:-'sed'}
02fcb550f20c [project @ 2003-01-16 20:15:14 by jwe]
jwe
parents: 4234
diff changeset
28
2907
8bb31a2b480b [project @ 1997-04-30 05:01:46 by jwe]
jwe
parents: 2890
diff changeset
29 DEF_FILES=`cat $1`
8bb31a2b480b [project @ 1997-04-30 05:01:46 by jwe]
jwe
parents: 2890
diff changeset
30
8bb31a2b480b [project @ 1997-04-30 05:01:46 by jwe]
jwe
parents: 2890
diff changeset
31 if test -z "$DEF_FILES"; then
8bb31a2b480b [project @ 1997-04-30 05:01:46 by jwe]
jwe
parents: 2890
diff changeset
32 echo "mkbuiltins: DEF_FILES is empty!" 1>&2
8bb31a2b480b [project @ 1997-04-30 05:01:46 by jwe]
jwe
parents: 2890
diff changeset
33 exit 1
8bb31a2b480b [project @ 1997-04-30 05:01:46 by jwe]
jwe
parents: 2890
diff changeset
34 fi
8bb31a2b480b [project @ 1997-04-30 05:01:46 by jwe]
jwe
parents: 2890
diff changeset
35
2335
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
36 cat << \EOF
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
37 // DO NOT EDIT! Generated automatically by mkbuiltins.
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
38
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
39 #ifdef HAVE_CONFIG_H
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
40 #include "config.h"
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
41 #endif
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
42
2968
e330cb788508 [project @ 1997-05-15 17:40:29 by jwe]
jwe
parents: 2910
diff changeset
43 #include "defun.h"
2335
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
44 #include "oct-obj.h"
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
45 #include "variables.h"
7210
818b1417bce9 [project @ 2007-11-28 16:43:13 by jwe]
jwe
parents: 7019
diff changeset
46 #include "builtins.h"
2335
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
47
3399
e665633c76af [project @ 1999-12-22 22:11:50 by jwe]
jwe
parents: 3364
diff changeset
48 #if defined (quad)
e665633c76af [project @ 1999-12-22 22:11:50 by jwe]
jwe
parents: 3364
diff changeset
49 #undef quad
e665633c76af [project @ 1999-12-22 22:11:50 by jwe]
jwe
parents: 3364
diff changeset
50 #endif
e665633c76af [project @ 1999-12-22 22:11:50 by jwe]
jwe
parents: 3364
diff changeset
51
4128
919b2f6573ee [project @ 2002-10-25 20:36:14 by jwe]
jwe
parents: 4110
diff changeset
52 #if defined (ENABLE_DYNAMIC_LINKING)
5796
20f4bd627a74 [project @ 2006-05-09 02:04:54 by jwe]
jwe
parents: 5794
diff changeset
53
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 7503
diff changeset
54 #define XDEFUN_DLD_INTERNAL(name, args_name, nargout_name, doc)
5796
20f4bd627a74 [project @ 2006-05-09 02:04:54 by jwe]
jwe
parents: 5794
diff changeset
55
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 7503
diff changeset
56 #define XDEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, doc)
5796
20f4bd627a74 [project @ 2006-05-09 02:04:54 by jwe]
jwe
parents: 5794
diff changeset
57
3364
fac05a83b4c5 [project @ 1999-11-20 03:05:42 by jwe]
jwe
parents: 3321
diff changeset
58 #else
5796
20f4bd627a74 [project @ 2006-05-09 02:04:54 by jwe]
jwe
parents: 5794
diff changeset
59
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 7503
diff changeset
60 #define XDEFUN_DLD_INTERNAL(name, args_name, nargout_name, doc) \
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 7503
diff changeset
61 XDEFUN_INTERNAL(name, args_name, nargout_name, doc)
5796
20f4bd627a74 [project @ 2006-05-09 02:04:54 by jwe]
jwe
parents: 5794
diff changeset
62
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 7503
diff changeset
63 #define XDEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, doc) \
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 7503
diff changeset
64 XDEFUNX_INTERNAL(name, fname, args_name, nargout_name, doc)
5796
20f4bd627a74 [project @ 2006-05-09 02:04:54 by jwe]
jwe
parents: 5794
diff changeset
65
3364
fac05a83b4c5 [project @ 1999-11-20 03:05:42 by jwe]
jwe
parents: 3321
diff changeset
66 #endif
fac05a83b4c5 [project @ 1999-11-20 03:05:42 by jwe]
jwe
parents: 3321
diff changeset
67
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 7503
diff changeset
68 #define XDEFUN_INTERNAL(name, args_name, nargout_name, doc) \
3295
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3225
diff changeset
69 extern DECLARE_FUN (name, args_name, nargout_name); \
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 7503
diff changeset
70 install_builtin_function (F ## name, #name, doc); \
4234
90e44267e8cf [project @ 2002-12-21 17:15:25 by jwe]
jwe
parents: 4128
diff changeset
71
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 7503
diff changeset
72 #define XDEFCONSTFUN_INTERNAL(name, args_name, nargout_name, doc) \
4234
90e44267e8cf [project @ 2002-12-21 17:15:25 by jwe]
jwe
parents: 4128
diff changeset
73 extern DECLARE_FUN (name, args_name, nargout_name); \
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 7503
diff changeset
74 install_builtin_function (F ## name, #name, doc, false); \
3295
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3225
diff changeset
75
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 7503
diff changeset
76 #define XDEFUNX_INTERNAL(name, fname, args_name, nargout_name, doc) \
3744
b0588fc1f3ca [project @ 2000-11-30 00:27:00 by jwe]
jwe
parents: 3399
diff changeset
77 extern DECLARE_FUNX (fname, args_name, nargout_name); \
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 7503
diff changeset
78 install_builtin_function (fname, name, doc); \
3744
b0588fc1f3ca [project @ 2000-11-30 00:27:00 by jwe]
jwe
parents: 3399
diff changeset
79
3295
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3225
diff changeset
80 #define XDEFALIAS_INTERNAL(alias, name) \
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3225
diff changeset
81 alias_builtin (#alias, #name);
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3225
diff changeset
82
3321
6923abb04e16 [project @ 1999-10-26 18:15:30 by jwe]
jwe
parents: 3295
diff changeset
83 #define XDEFCONST_INTERNAL(name, defn, doc)
3295
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3225
diff changeset
84
2373
d423dcc0ac32 [project @ 1996-10-12 00:19:58 by jwe]
jwe
parents: 2335
diff changeset
85 EOF
d423dcc0ac32 [project @ 1996-10-12 00:19:58 by jwe]
jwe
parents: 2335
diff changeset
86
2907
8bb31a2b480b [project @ 1997-04-30 05:01:46 by jwe]
jwe
parents: 2890
diff changeset
87 for file in $DEF_FILES; do
4299
02fcb550f20c [project @ 2003-01-16 20:15:14 by jwe]
jwe
parents: 4234
diff changeset
88 fcn=`echo $file | $SED 's,^\./,,; s/\.df//; s/-/_/g'`
2373
d423dcc0ac32 [project @ 1996-10-12 00:19:58 by jwe]
jwe
parents: 2335
diff changeset
89 echo "static void"
d423dcc0ac32 [project @ 1996-10-12 00:19:58 by jwe]
jwe
parents: 2335
diff changeset
90 echo "install_${fcn}_fcns (void)"
d423dcc0ac32 [project @ 1996-10-12 00:19:58 by jwe]
jwe
parents: 2335
diff changeset
91 echo "{"
d423dcc0ac32 [project @ 1996-10-12 00:19:58 by jwe]
jwe
parents: 2335
diff changeset
92 cat $file
d423dcc0ac32 [project @ 1996-10-12 00:19:58 by jwe]
jwe
parents: 2335
diff changeset
93 echo "}"
2907
8bb31a2b480b [project @ 1997-04-30 05:01:46 by jwe]
jwe
parents: 2890
diff changeset
94 echo ""
8bb31a2b480b [project @ 1997-04-30 05:01:46 by jwe]
jwe
parents: 2890
diff changeset
95 done
8bb31a2b480b [project @ 1997-04-30 05:01:46 by jwe]
jwe
parents: 2890
diff changeset
96
2373
d423dcc0ac32 [project @ 1996-10-12 00:19:58 by jwe]
jwe
parents: 2335
diff changeset
97 cat << \EOF
2907
8bb31a2b480b [project @ 1997-04-30 05:01:46 by jwe]
jwe
parents: 2890
diff changeset
98
7503
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7210
diff changeset
99 void
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7210
diff changeset
100 install_builtins (void)
2335
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
101 {
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
102 EOF
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
103
2907
8bb31a2b480b [project @ 1997-04-30 05:01:46 by jwe]
jwe
parents: 2890
diff changeset
104 for file in $DEF_FILES; do
4299
02fcb550f20c [project @ 2003-01-16 20:15:14 by jwe]
jwe
parents: 4234
diff changeset
105 fcn=`echo $file | $SED 's,^\./,,; s/\.df//; s/-/_/g'`
2373
d423dcc0ac32 [project @ 1996-10-12 00:19:58 by jwe]
jwe
parents: 2335
diff changeset
106 echo " install_${fcn}_fcns ();"
d423dcc0ac32 [project @ 1996-10-12 00:19:58 by jwe]
jwe
parents: 2335
diff changeset
107 done
2335
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
108
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
109 cat << \EOF
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
110 }
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
111
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
112 EOF
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
113
4a9feb849125 [project @ 1996-07-19 02:51:02 by jwe]
jwe
parents:
diff changeset
114 exit 0