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, |
3145
|
48 bool iaf, bool p, bool e, |
|
49 symbol_record::change_function chg_fcn, |
2968
|
50 const string& h); |
|
51 |
|
52 extern void |
|
53 alias_builtin (const string& alias, const string& name); |
2405
|
54 |
550
|
55 // MAKE_BUILTINS is defined to extract function names and related |
|
56 // information and create the *.def files that are eventually used to |
|
57 // create the buitlins.cc file. |
|
58 |
525
|
59 #ifdef MAKE_BUILTINS |
|
60 |
550
|
61 // Generate code to install name in the symbol table. The script |
|
62 // mkdefs will create a .def file for every .cc file that uses DEFUN, |
|
63 // DEFUN_TEXT, or DEFUN_DLD. |
|
64 |
1957
|
65 #define DEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ |
525
|
66 BEGIN_INSTALL_BUILTIN \ |
1957
|
67 extern DECLARE_FUN (name, args_name, nargout_name); \ |
2968
|
68 install_builtin_function (F ## name, #name, doc, is_text_fcn); \ |
525
|
69 END_INSTALL_BUILTIN |
|
70 |
550
|
71 // Generate code for making another name for an existing function. |
|
72 |
|
73 #define DEFALIAS_INTERNAL(alias, name) \ |
|
74 BEGIN_INSTALL_BUILTIN \ |
|
75 alias_builtin (#alias, #name); \ |
|
76 END_INSTALL_BUILTIN |
525
|
77 |
|
78 #else /* ! MAKE_BUILTINS */ |
|
79 |
550
|
80 // Generate the first line of the function definition. This ensures |
|
81 // that the internal functions all have the same signature. |
|
82 |
1957
|
83 #define DEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ |
|
84 DECLARE_FUN (name, args_name, nargout_name) |
525
|
85 |
550
|
86 // No definition is required for an alias. |
|
87 |
|
88 #define DEFALIAS_INTERNAL(name, alias) |
525
|
89 |
|
90 #endif /* ! MAKE_BUILTINS */ |
|
91 |
3092
|
92 // Define the code that will be used to insert the new function into |
703
|
93 // the symbol table. |
|
94 |
2968
|
95 #define DEFINE_FUN_INSTALLER_FUN(name, doc) \ |
|
96 bool \ |
1957
|
97 FS ## name (void) \ |
703
|
98 { \ |
2968
|
99 static bool installed = false; \ |
|
100 if (! installed) \ |
3015
|
101 { \ |
|
102 check_version (OCTAVE_VERSION, #name); \ |
|
103 install_builtin_function (F ## name, #name, doc); \ |
3096
|
104 installed = true; \ |
3015
|
105 } \ |
2968
|
106 return installed; \ |
703
|
107 } |
|
108 |
1957
|
109 #define DECLARE_FUN(name, args_name, nargout_name) \ |
2968
|
110 octave_value_list \ |
|
111 F ## name (const octave_value_list& args_name, int nargout_name) |
|
112 |
|
113 // How builtin variables are actually installed. |
|
114 |
3005
|
115 #define DEFVAR_INTERNAL(name, sname, defn, inst_as_fcn, protect, \ |
|
116 chg_fcn, doc) \ |
2968
|
117 install_builtin_variable (name, octave_value (defn), inst_as_fcn, \ |
3005
|
118 protect, (chg_fcn != 0), chg_fcn, doc) |
2968
|
119 |
|
120 // How mapper functions are actually installed. |
|
121 |
3249
|
122 #define DEFUN_MAPPER_INTERNAL(name, ch_map, d_b_map, c_b_map, d_d_map, \ |
|
123 d_c_map, c_c_map, lo, hi, \ |
|
124 can_ret_cmplx_for_real, doc) \ |
2968
|
125 install_builtin_mapper \ |
3249
|
126 (new octave_mapper (ch_map, d_b_map, c_b_map, d_d_map, d_c_map, \ |
|
127 c_c_map, lo, hi, \ |
2968
|
128 can_ret_cmplx_for_real, #name)) |
525
|
129 |
|
130 #endif |
|
131 |
|
132 /* |
|
133 ;;; Local Variables: *** |
|
134 ;;; mode: C++ *** |
|
135 ;;; End: *** |
|
136 */ |