525
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
525
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
525
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_defun_int_h) |
|
24 #define octave_defun_int_h 1 |
|
25 |
2968
|
26 #include <string> |
|
27 |
3145
|
28 #include "ov-builtin.h" |
|
29 #include "ov-mapper.h" |
|
30 #include "symtab.h" |
3015
|
31 #include "version.h" |
|
32 |
2968
|
33 class octave_value; |
|
34 |
3014
|
35 extern void print_usage (const string& nm, bool just_usage = false); |
|
36 |
3015
|
37 extern void check_version (const string& version, const string& fcn); |
|
38 |
3145
|
39 extern void |
|
40 install_builtin_mapper (octave_mapper *mf); |
2968
|
41 |
|
42 extern void |
3145
|
43 install_builtin_function (octave_builtin::fcn f, const string& name, |
|
44 const string& doc, bool is_text_fcn = false); |
2968
|
45 |
|
46 extern void |
|
47 install_builtin_variable (const string& n, const octave_value& v, |
3258
|
48 bool p, bool e, |
3145
|
49 symbol_record::change_function chg_fcn, |
2968
|
50 const string& h); |
|
51 |
|
52 extern void |
3258
|
53 install_builtin_constant (const string& n, const octave_value& v, |
|
54 bool p, const string& h); |
|
55 |
|
56 extern void |
2968
|
57 alias_builtin (const string& alias, const string& name); |
2405
|
58 |
550
|
59 // MAKE_BUILTINS is defined to extract function names and related |
|
60 // information and create the *.def files that are eventually used to |
|
61 // create the buitlins.cc file. |
|
62 |
525
|
63 #ifdef MAKE_BUILTINS |
|
64 |
550
|
65 // Generate code to install name in the symbol table. The script |
|
66 // mkdefs will create a .def file for every .cc file that uses DEFUN, |
|
67 // DEFUN_TEXT, or DEFUN_DLD. |
|
68 |
1957
|
69 #define DEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ |
525
|
70 BEGIN_INSTALL_BUILTIN \ |
1957
|
71 extern DECLARE_FUN (name, args_name, nargout_name); \ |
2968
|
72 install_builtin_function (F ## name, #name, doc, is_text_fcn); \ |
525
|
73 END_INSTALL_BUILTIN |
|
74 |
550
|
75 // Generate code for making another name for an existing function. |
|
76 |
|
77 #define DEFALIAS_INTERNAL(alias, name) \ |
|
78 BEGIN_INSTALL_BUILTIN \ |
|
79 alias_builtin (#alias, #name); \ |
|
80 END_INSTALL_BUILTIN |
525
|
81 |
|
82 #else /* ! MAKE_BUILTINS */ |
|
83 |
550
|
84 // Generate the first line of the function definition. This ensures |
|
85 // that the internal functions all have the same signature. |
|
86 |
1957
|
87 #define DEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ |
|
88 DECLARE_FUN (name, args_name, nargout_name) |
525
|
89 |
550
|
90 // No definition is required for an alias. |
|
91 |
|
92 #define DEFALIAS_INTERNAL(name, alias) |
525
|
93 |
|
94 #endif /* ! MAKE_BUILTINS */ |
|
95 |
3092
|
96 // Define the code that will be used to insert the new function into |
703
|
97 // the symbol table. |
|
98 |
2968
|
99 #define DEFINE_FUN_INSTALLER_FUN(name, doc) \ |
|
100 bool \ |
1957
|
101 FS ## name (void) \ |
703
|
102 { \ |
2968
|
103 static bool installed = false; \ |
|
104 if (! installed) \ |
3015
|
105 { \ |
|
106 check_version (OCTAVE_VERSION, #name); \ |
|
107 install_builtin_function (F ## name, #name, doc); \ |
3096
|
108 installed = true; \ |
3015
|
109 } \ |
2968
|
110 return installed; \ |
703
|
111 } |
|
112 |
1957
|
113 #define DECLARE_FUN(name, args_name, nargout_name) \ |
2968
|
114 octave_value_list \ |
|
115 F ## name (const octave_value_list& args_name, int nargout_name) |
|
116 |
|
117 // How builtin variables are actually installed. |
|
118 |
3258
|
119 #define DEFVAR_INTERNAL(name, sname, defn, protect, chg_fcn, doc) \ |
|
120 install_builtin_variable (name, octave_value (defn), protect, \ |
|
121 (chg_fcn != 0), chg_fcn, doc) |
|
122 |
|
123 // How builtin variables are actually installed. |
|
124 |
|
125 #define DEFCONST_INTERNAL(name, sname, defn, protect, doc) \ |
|
126 install_builtin_constant (name, octave_value (defn), protect, doc) |
2968
|
127 |
|
128 // How mapper functions are actually installed. |
|
129 |
3249
|
130 #define DEFUN_MAPPER_INTERNAL(name, ch_map, d_b_map, c_b_map, d_d_map, \ |
|
131 d_c_map, c_c_map, lo, hi, \ |
|
132 can_ret_cmplx_for_real, doc) \ |
2968
|
133 install_builtin_mapper \ |
3249
|
134 (new octave_mapper (ch_map, d_b_map, c_b_map, d_d_map, d_c_map, \ |
|
135 c_c_map, lo, hi, \ |
2968
|
136 can_ret_cmplx_for_real, #name)) |
525
|
137 |
|
138 #endif |
|
139 |
|
140 /* |
|
141 ;;; Local Variables: *** |
|
142 ;;; mode: C++ *** |
|
143 ;;; End: *** |
|
144 */ |