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 variable. |
|
33 // |
1957
|
34 // name is the name of the variable, unquoted. |
1340
|
35 // |
|
36 // defn is the initial value for the variable. |
550
|
37 // |
1340
|
38 // protect is a flag that says whether it should be possible to give |
|
39 // the variable a new value. |
|
40 // |
550
|
41 // eternal is a flag that says whether it should be possible to |
|
42 // clear the variable. Most builtin variables are eternal, and |
|
43 // cannot be cleared. |
|
44 // |
3005
|
45 // chg_fcn is a pointer to a function that should be called whenever |
550
|
46 // this variable is given a new value. It can be 0 if there is no |
|
47 // function to call. See also the code in user-prefs.cc. |
|
48 // |
|
49 // doc is the simple help text for this variable. |
|
50 |
3258
|
51 #define DEFVAR(name, defn, chg_fcn, doc) \ |
|
52 DEFVAR_INTERNAL (#name, SBV_ ## name, defn, false, chg_fcn, doc) |
1957
|
53 |
3258
|
54 // Define a builtin constant `name' (which may be redefined, but will |
|
55 // retain its original value when cleared) and also an alias to it |
|
56 // called `__name__' (which may not be redefined). |
1957
|
57 |
3141
|
58 #define DEFCONST(name, defn, doc) \ |
3321
|
59 DEFCONST_INTERNAL (name, defn, doc) |
1957
|
60 |
|
61 // This one can be used when `name' cannot be used directly (if it is |
|
62 // already defined as a macro). In that case, name is already a |
3523
|
63 // quoted std::string, and the name of the structure has to be passed too. |
1957
|
64 |
3141
|
65 #define DEFCONSTX(name, sname, defn, doc) \ |
3321
|
66 DEFCONSTX_INTERNAL (name, sname, defn, doc) |
525
|
67 |
550
|
68 // Define a builtin function. |
|
69 // |
1957
|
70 // name is the name of the function, unqouted. |
550
|
71 // |
2086
|
72 // args_name is the name of the octave_value_list variable used to pass |
1957
|
73 // the argument list to this function. |
550
|
74 // |
1957
|
75 // nargout_name is the name of the int variable used to pass the |
|
76 // number of output arguments this function is expected to produce. |
550
|
77 // |
|
78 // doc is the simple help text for the function. |
|
79 |
1957
|
80 #define DEFUN(name, args_name, nargout_name, doc) \ |
2890
|
81 DEFUN_INTERNAL (name, args_name, nargout_name, false, doc) |
525
|
82 |
550
|
83 // Define a builtin text-style function. |
|
84 // |
|
85 // This is like DEFUN, except that it defines a function that can be |
|
86 // called from the Octave language without using parenthesis to |
|
87 // surround the arguments). |
|
88 |
1957
|
89 #define DEFUN_TEXT(name, args_name, nargout_name, doc) \ |
2890
|
90 DEFUN_INTERNAL (name, args_name, nargout_name, true, doc) |
525
|
91 |
550
|
92 // Define a mapper function. |
|
93 // |
1957
|
94 // name is the name of the function, unquoqted. |
550
|
95 // |
2089
|
96 // ch_map is a pointer to a function that should be called for |
3249
|
97 // integer arguments that are expected to create integer results. |
2089
|
98 // (It's a kluge to handle character mappers like isalpha.) |
550
|
99 // |
3249
|
100 // d_b_map is a pointer to a function that should be called for real |
|
101 // arguments that are expected to create bool results. |
|
102 // |
|
103 // c_b_map is a pointer to a function that should be called for |
|
104 // complex arguments that are expected to create bool results. |
|
105 // |
550
|
106 // d_d_map is a pointer to a function that should be called for real |
|
107 // arguments that are expected to create real results. |
|
108 // |
|
109 // d_c_map is a pointer to a function that should be called for real |
|
110 // arguments that are expected to create complex results. |
|
111 // |
|
112 // c_c_map is a pointer to a function that should be called for |
|
113 // complex arguments that are expected to create complex results. |
|
114 // |
2089
|
115 // lo is the lower bound of the range for which real arguments can |
|
116 // become complex. (e.g., lo == -Inf for sqrt). |
|
117 // |
|
118 // hi is the upper bound of the range for which real arguments can |
|
119 // become complex. (e.g., hi == 0 for sqrt). |
|
120 // |
|
121 // can_ret_cmplx_for_real is a flag that says whether this function |
|
122 // can create a complex number given a real-valued argument |
|
123 // (e.g., sqrt (-1)). |
|
124 // |
550
|
125 // doc is the simple help text for the function. |
|
126 |
3249
|
127 #define DEFUN_MAPPER(name, ch_map, d_b_map, c_b_map, d_d_map, d_c_map, \ |
|
128 c_c_map, lo, hi, can_ret_cmplx_for_real, doc) \ |
|
129 DEFUN_MAPPER_INTERNAL(name, ch_map, d_b_map, c_b_map, d_d_map, d_c_map, \ |
|
130 c_c_map, lo, hi, can_ret_cmplx_for_real, doc) |
525
|
131 |
550
|
132 // Make alias another name for the existing function name. This macro |
|
133 // must be used in the same file where name is defined, after the |
|
134 // definition for name. |
525
|
135 |
2374
|
136 #define DEFALIAS(name, alias) \ |
|
137 DEFALIAS_INTERNAL (name, alias) |
525
|
138 |
|
139 #endif |
|
140 |
|
141 /* |
|
142 ;;; Local Variables: *** |
|
143 ;;; mode: C++ *** |
|
144 ;;; End: *** |
|
145 */ |