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 |
|
28 class octave_value; |
|
29 |
|
30 // XXX FIXME XXX -- change to use actual pointer types instead of void* |
|
31 // when things are not changing as rapidly. |
|
32 |
|
33 extern void |
|
34 install_builtin_mapper (void *mf); |
|
35 |
|
36 extern void |
|
37 install_builtin_function (void *f, const string& name, const string& doc, |
|
38 bool is_text_fcn = false); |
|
39 |
|
40 extern void |
|
41 install_builtin_variable (const string& n, const octave_value& v, |
|
42 bool iaf, bool p, bool e, void *svf, |
|
43 const string& h); |
|
44 |
|
45 extern void |
|
46 alias_builtin (const string& alias, const string& name); |
2405
|
47 |
550
|
48 // MAKE_BUILTINS is defined to extract function names and related |
|
49 // information and create the *.def files that are eventually used to |
|
50 // create the buitlins.cc file. |
|
51 |
525
|
52 #ifdef MAKE_BUILTINS |
|
53 |
550
|
54 // Generate code to install name in the symbol table. The script |
|
55 // mkdefs will create a .def file for every .cc file that uses DEFUN, |
|
56 // DEFUN_TEXT, or DEFUN_DLD. |
|
57 |
1957
|
58 #define DEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ |
525
|
59 BEGIN_INSTALL_BUILTIN \ |
1957
|
60 extern DECLARE_FUN (name, args_name, nargout_name); \ |
2968
|
61 install_builtin_function (F ## name, #name, doc, is_text_fcn); \ |
525
|
62 END_INSTALL_BUILTIN |
|
63 |
550
|
64 // Generate code for making another name for an existing function. |
|
65 |
|
66 #define DEFALIAS_INTERNAL(alias, name) \ |
|
67 BEGIN_INSTALL_BUILTIN \ |
|
68 alias_builtin (#alias, #name); \ |
|
69 END_INSTALL_BUILTIN |
525
|
70 |
|
71 #else /* ! MAKE_BUILTINS */ |
|
72 |
550
|
73 // Generate the first line of the function definition. This ensures |
|
74 // that the internal functions all have the same signature. |
|
75 |
1957
|
76 #define DEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ |
|
77 DECLARE_FUN (name, args_name, nargout_name) |
525
|
78 |
550
|
79 // No definition is required for an alias. |
|
80 |
|
81 #define DEFALIAS_INTERNAL(name, alias) |
525
|
82 |
|
83 #endif /* ! MAKE_BUILTINS */ |
|
84 |
703
|
85 // Define the structure that will be used to insert this function into |
|
86 // the symbol table. |
|
87 |
2968
|
88 #define DEFINE_FUN_INSTALLER_FUN(name, doc) \ |
|
89 bool \ |
1957
|
90 FS ## name (void) \ |
703
|
91 { \ |
2968
|
92 static bool installed = false; \ |
|
93 if (! installed) \ |
|
94 install_builtin_function (F ## name, #name, doc); \ |
|
95 return installed; \ |
703
|
96 } |
|
97 |
1957
|
98 #define DECLARE_FUN(name, args_name, nargout_name) \ |
2968
|
99 octave_value_list \ |
|
100 F ## name (const octave_value_list& args_name, int nargout_name) |
|
101 |
|
102 // How builtin variables are actually installed. |
|
103 |
3005
|
104 #define DEFVAR_INTERNAL(name, sname, defn, inst_as_fcn, protect, \ |
|
105 chg_fcn, doc) \ |
2968
|
106 install_builtin_variable (name, octave_value (defn), inst_as_fcn, \ |
3005
|
107 protect, (chg_fcn != 0), chg_fcn, doc) |
2968
|
108 |
|
109 // How mapper functions are actually installed. |
|
110 |
|
111 #define DEFUN_MAPPER_INTERNAL(name, ch_map, d_d_map, d_c_map, c_c_map, \ |
|
112 lo, hi, can_ret_cmplx_for_real, doc) \ |
|
113 install_builtin_mapper \ |
|
114 (new octave_mapper (ch_map, d_d_map, d_c_map, c_c_map, lo, hi, \ |
|
115 can_ret_cmplx_for_real, #name)) |
525
|
116 |
|
117 #endif |
|
118 |
|
119 /* |
|
120 ;;; Local Variables: *** |
|
121 ;;; mode: C++ *** |
|
122 ;;; End: *** |
|
123 */ |