525
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, |
|
4 2004, 2005, 2006, 2007 John W. Eaton |
525
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
7016
|
10 Free Software Foundation; either version 3 of the License, or (at your |
|
11 option) any later version. |
525
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
7016
|
19 along with Octave; see the file COPYING. If not, see |
|
20 <http://www.gnu.org/licenses/>. |
525
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_defun_h) |
|
25 #define octave_defun_h 1 |
|
26 |
|
27 #if defined (octave_defun_dld_h) |
|
28 #error defun.h and defun-dld.h both included in same file! |
|
29 #endif |
|
30 |
|
31 #include "defun-int.h" |
|
32 |
550
|
33 // Define a builtin function. |
|
34 // |
1957
|
35 // name is the name of the function, unqouted. |
550
|
36 // |
2086
|
37 // args_name is the name of the octave_value_list variable used to pass |
1957
|
38 // the argument list to this function. |
550
|
39 // |
1957
|
40 // nargout_name is the name of the int variable used to pass the |
|
41 // number of output arguments this function is expected to produce. |
550
|
42 // |
|
43 // doc is the simple help text for the function. |
|
44 |
1957
|
45 #define DEFUN(name, args_name, nargout_name, doc) \ |
2890
|
46 DEFUN_INTERNAL (name, args_name, nargout_name, false, doc) |
525
|
47 |
3743
|
48 // This one can be used when `name' cannot be used directly (if it is |
|
49 // already defined as a macro). In that case, name is already a |
|
50 // quoted string, and the internal name of the function must be passed |
5794
|
51 // too (the convention is to use a prefix of "F", so "foo" becomes "Ffoo"). |
3743
|
52 |
|
53 #define DEFUNX(name, fname, args_name, nargout_name, doc) \ |
|
54 DEFUNX_INTERNAL (name, fname, args_name, nargout_name, false, doc) |
|
55 |
4208
|
56 // Define a builtin command-style function. |
550
|
57 // |
|
58 // This is like DEFUN, except that it defines a function that can be |
|
59 // called from the Octave language without using parenthesis to |
|
60 // surround the arguments). |
|
61 |
4208
|
62 #define DEFCMD(name, args_name, nargout_name, doc) \ |
2890
|
63 DEFUN_INTERNAL (name, args_name, nargout_name, true, doc) |
525
|
64 |
4208
|
65 // For backward compatibility. |
|
66 |
|
67 #define DEFUN_TEXT DEFCMD |
|
68 |
4234
|
69 // This is a function with a name that can't be hidden by a variable. |
|
70 #define DEFCONSTFUN(name, args_name, nargout_name, doc) \ |
|
71 DEFCONSTFUN_INTERNAL (name, args_name, nargout_name, true, doc) |
|
72 |
550
|
73 // Define a mapper function. |
|
74 // |
1957
|
75 // name is the name of the function, unquoqted. |
550
|
76 // |
2089
|
77 // ch_map is a pointer to a function that should be called for |
3249
|
78 // integer arguments that are expected to create integer results. |
2089
|
79 // (It's a kluge to handle character mappers like isalpha.) |
550
|
80 // |
3249
|
81 // d_b_map is a pointer to a function that should be called for real |
|
82 // arguments that are expected to create bool results. |
|
83 // |
|
84 // c_b_map is a pointer to a function that should be called for |
|
85 // complex arguments that are expected to create bool results. |
|
86 // |
550
|
87 // d_d_map is a pointer to a function that should be called for real |
|
88 // arguments that are expected to create real results. |
|
89 // |
6989
|
90 // c_d_map is a pointer to a function that should be called for |
6961
|
91 // complex arguments that are expected to create real results. |
550
|
92 // |
|
93 // c_c_map is a pointer to a function that should be called for |
|
94 // complex arguments that are expected to create complex results. |
|
95 // |
4668
|
96 // lo is the lower bound of the range for which real arguments |
|
97 // return real results (e.g., lo == 0 for sqrt). |
2089
|
98 // |
4668
|
99 // hi is the upper bound of the range for which real arguments |
|
100 // return real results (e.g., hi == Inf for sqrt). |
2089
|
101 // |
4100
|
102 // ch_map_flag has the following meanings for the ch_map function: |
|
103 // |
|
104 // 0 => this function returns a matrix of ones and zeros |
|
105 // 1 => this function returns a numeric matrix (any values) |
|
106 // 2 => this function returns a std::string array |
|
107 // |
2089
|
108 // can_ret_cmplx_for_real is a flag that says whether this function |
|
109 // can create a complex number given a real-valued argument |
|
110 // (e.g., sqrt (-1)). |
|
111 // |
550
|
112 // doc is the simple help text for the function. |
|
113 |
4100
|
114 #define DEFUN_MAPPER(name, ch_map, d_b_map, c_b_map, d_d_map, \ |
6989
|
115 c_d_map, c_c_map, lo, hi, ch_map_flag, \ |
4100
|
116 can_ret_cmplx_for_real, doc) \ |
|
117 DEFUN_MAPPER_INTERNAL (name, ch_map, d_b_map, c_b_map, d_d_map, \ |
6989
|
118 c_d_map, c_c_map, lo, hi, ch_map_flag, \ |
4100
|
119 can_ret_cmplx_for_real, doc) |
525
|
120 |
550
|
121 // Make alias another name for the existing function name. This macro |
|
122 // must be used in the same file where name is defined, after the |
|
123 // definition for name. |
525
|
124 |
4699
|
125 #define DEFALIAS(alias, name) \ |
|
126 DEFALIAS_INTERNAL (alias, name) |
525
|
127 |
|
128 #endif |
|
129 |
|
130 /* |
|
131 ;;; Local Variables: *** |
|
132 ;;; mode: C++ *** |
|
133 ;;; End: *** |
|
134 */ |