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_h) |
|
24 #define octave_defun_h 1 |
|
25 |
|
26 #if defined (octave_defun_dld_h) |
|
27 #error defun.h and defun-dld.h both included in same file! |
|
28 #endif |
|
29 |
|
30 #include "defun-int.h" |
|
31 |
550
|
32 // Define a builtin function. |
|
33 // |
1957
|
34 // name is the name of the function, unqouted. |
550
|
35 // |
2086
|
36 // args_name is the name of the octave_value_list variable used to pass |
1957
|
37 // the argument list to this function. |
550
|
38 // |
1957
|
39 // nargout_name is the name of the int variable used to pass the |
|
40 // number of output arguments this function is expected to produce. |
550
|
41 // |
|
42 // doc is the simple help text for the function. |
|
43 |
1957
|
44 #define DEFUN(name, args_name, nargout_name, doc) \ |
2890
|
45 DEFUN_INTERNAL (name, args_name, nargout_name, false, doc) |
525
|
46 |
3743
|
47 // This one can be used when `name' cannot be used directly (if it is |
|
48 // already defined as a macro). In that case, name is already a |
|
49 // quoted string, and the internal name of the function must be passed |
|
50 // too (the convetion is to use a prefix of "F", so "foo" becomes "Ffoo"). |
|
51 |
|
52 #define DEFUNX(name, fname, args_name, nargout_name, doc) \ |
|
53 DEFUNX_INTERNAL (name, fname, args_name, nargout_name, false, doc) |
|
54 |
4208
|
55 // Define a builtin command-style function. |
550
|
56 // |
|
57 // This is like DEFUN, except that it defines a function that can be |
|
58 // called from the Octave language without using parenthesis to |
|
59 // surround the arguments). |
|
60 |
4208
|
61 #define DEFCMD(name, args_name, nargout_name, doc) \ |
2890
|
62 DEFUN_INTERNAL (name, args_name, nargout_name, true, doc) |
525
|
63 |
4208
|
64 // For backward compatibility. |
|
65 |
|
66 #define DEFUN_TEXT DEFCMD |
|
67 |
4234
|
68 // This is a function with a name that can't be hidden by a variable. |
|
69 #define DEFCONSTFUN(name, args_name, nargout_name, doc) \ |
|
70 DEFCONSTFUN_INTERNAL (name, args_name, nargout_name, true, doc) |
|
71 |
550
|
72 // Define a mapper function. |
|
73 // |
1957
|
74 // name is the name of the function, unquoqted. |
550
|
75 // |
2089
|
76 // ch_map is a pointer to a function that should be called for |
3249
|
77 // integer arguments that are expected to create integer results. |
2089
|
78 // (It's a kluge to handle character mappers like isalpha.) |
550
|
79 // |
3249
|
80 // d_b_map is a pointer to a function that should be called for real |
|
81 // arguments that are expected to create bool results. |
|
82 // |
|
83 // c_b_map is a pointer to a function that should be called for |
|
84 // complex arguments that are expected to create bool results. |
|
85 // |
550
|
86 // d_d_map is a pointer to a function that should be called for real |
|
87 // arguments that are expected to create real results. |
|
88 // |
|
89 // d_c_map is a pointer to a function that should be called for real |
|
90 // arguments that are expected to create complex results. |
|
91 // |
|
92 // c_c_map is a pointer to a function that should be called for |
|
93 // complex arguments that are expected to create complex results. |
|
94 // |
4668
|
95 // lo is the lower bound of the range for which real arguments |
|
96 // return real results (e.g., lo == 0 for sqrt). |
2089
|
97 // |
4668
|
98 // hi is the upper bound of the range for which real arguments |
|
99 // return real results (e.g., hi == Inf for sqrt). |
2089
|
100 // |
4100
|
101 // ch_map_flag has the following meanings for the ch_map function: |
|
102 // |
|
103 // 0 => this function returns a matrix of ones and zeros |
|
104 // 1 => this function returns a numeric matrix (any values) |
|
105 // 2 => this function returns a std::string array |
|
106 // |
2089
|
107 // can_ret_cmplx_for_real is a flag that says whether this function |
|
108 // can create a complex number given a real-valued argument |
|
109 // (e.g., sqrt (-1)). |
|
110 // |
550
|
111 // doc is the simple help text for the function. |
|
112 |
4100
|
113 #define DEFUN_MAPPER(name, ch_map, d_b_map, c_b_map, d_d_map, \ |
|
114 d_c_map, c_c_map, lo, hi, ch_map_flag, \ |
|
115 can_ret_cmplx_for_real, doc) \ |
|
116 DEFUN_MAPPER_INTERNAL (name, ch_map, d_b_map, c_b_map, d_d_map, \ |
|
117 d_c_map, c_c_map, lo, hi, ch_map_flag, \ |
|
118 can_ret_cmplx_for_real, doc) |
525
|
119 |
550
|
120 // Make alias another name for the existing function name. This macro |
|
121 // must be used in the same file where name is defined, after the |
|
122 // definition for name. |
525
|
123 |
4699
|
124 #define DEFALIAS(alias, name) \ |
|
125 DEFALIAS_INTERNAL (alias, name) |
525
|
126 |
|
127 #endif |
|
128 |
|
129 /* |
|
130 ;;; Local Variables: *** |
|
131 ;;; mode: C++ *** |
|
132 ;;; End: *** |
|
133 */ |