GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
defun.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1994-2018 John W. Eaton
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
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License 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, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_defun_h)
24 #define octave_defun_h 1
25 
26 #include "octave-config.h"
27 
28 #if defined (octave_defun_dld_h)
29 # error defun.h and defun-dld.h both included in same file!
30 #endif
31 
32 #include "defun-int.h"
33 
34 //! Macro to define a builtin function.
35 //!
36 //! For detailed information, see \ref Macros.
37 //!
38 //! @param name The **unqouted** name of the function that should be installed
39 //! on the `octave::symbol_table` and can be called by the
40 //! interpreter. Internally, the function name is prepended by an
41 //! `F`.
42 //! @param args_name The name of the octave_value_list variable used to pass
43 //! the argument list to this function. If this value is
44 //! omitted, the function cannot access the argument list.
45 //! @param nargout_name The name of the `int` variable used to pass the number
46 //! of output arguments this function is expected to
47 //! produce from the caller. If this value is
48 //! omitted, the function cannot access this number.
49 //! @param doc Texinfo help text (docstring) for the function.
50 //!
51 //! @see DEFUNX, DEFCONSTFUN
52 
53 #define DEFUN(name, args_name, nargout_name, doc) \
54  DECLARE_FUN (name, args_name, nargout_name)
55 
56 //! Macro to define a builtin function with certain internal name.
57 //!
58 //! @warning Consider to use #DEFUN, unless you have good reason.
59 //!
60 //! For detailed information, see \ref Macros.
61 //!
62 //! This macro can be used when @p name cannot be used directly (for example if
63 //! it is already defined as a macro). In that case, @p name is already a
64 //! quoted string (thus unaffected by macros), and the internal name of the
65 //! function is given by @p fname.
66 //!
67 //! @param name The **qouted** name of the function that should be callable
68 //! by the interpreter.
69 //! @param fname The internal **unqouted** name of the function. This internal
70 //! name is by convention prepended by an `F`.
71 //! @param args_name The name of the octave_value_list variable used to pass
72 //! the argument list to this function. If this value is
73 //! omitted, the function cannot access the argument list.
74 //! @param nargout_name The name of the `int` variable used to pass the number
75 //! of output arguments this function is expected to
76 //! produce from the caller. If this value is
77 //! omitted, the function cannot access this number.
78 //! @param doc Texinfo help text (docstring) for the function.
79 //!
80 //! @see DEFUN, DEFCONSTFUN
81 
82 #define DEFUNX(name, fname, args_name, nargout_name, doc) \
83  DECLARE_FUNX (fname, args_name, nargout_name)
84 
85 //! Macro to define a builtin function that cannot be hidden by a variable.
86 //!
87 //! @warning Consider to use #DEFUN, unless you have good reason.
88 //!
89 //! For detailed information, see \ref Macros.
90 //!
91 //! The function gets installed to the `octave::symbol_table` in a way, such
92 //! that no variable is allowed to hide this function name.
93 //!
94 //! @param name The **unqouted** name of the function that should be installed
95 //! on the `octave::symbol_table` and can be called by the
96 //! interpreter. Internally, the function name is prepended by an
97 //! `F`.
98 //! @param args_name The name of the octave_value_list variable used to pass
99 //! the argument list to this function. If this value is
100 //! omitted, the function cannot access the argument list.
101 //! @param nargout_name The name of the `int` variable used to pass the number
102 //! of output arguments this function is expected to
103 //! produce from the caller. If this value is
104 //! omitted, the function cannot access this number.
105 //! @param doc Texinfo help text (docstring) for the function.
106 //!
107 //! @see DEFUN, DEFUNX
108 
109 #define DEFCONSTFUN(name, args_name, nargout_name, doc) \
110  DECLARE_FUN (name, args_name, nargout_name)
111 
112 //! Macro to define a builtin method.
113 //!
114 //! For detailed information, see \ref Macros.
115 //!
116 //! @param name The **unqouted** name of the method that should be installed
117 //! on the `octave::symbol_table` and can be called by the
118 //! interpreter. Internally, the method name is prepended by an
119 //! `F`.
120 //! @param interp_name The name of the `octave::interpreter` reference that can
121 //! be used by this method. If this value is omitted,
122 //! there is no access to the interpreter and one should
123 //! use #DEFUN to define a function instead.
124 //! @param args_name The name of the octave_value_list variable used to pass
125 //! the argument list to this method. If this value is
126 //! omitted, the method cannot access the argument list.
127 //! @param nargout_name The name of the `int` variable used to pass the number
128 //! of output arguments this method is expected to
129 //! produce from the caller. If this value is
130 //! omitted, the method cannot access this number.
131 //! @param doc Texinfo help text (docstring) for the method.
132 //!
133 //! @see DEFMETHODX, DEFCONSTMETHOD
134 
135 #define DEFMETHOD(name, interp_name, args_name, nargout_name, doc) \
136  DECLARE_METHOD (name, interp_name, args_name, nargout_name)
137 
138 //! Macro to define a builtin method with certain internal name.
139 //!
140 //! @warning Consider to use #DEFMETHOD, unless you have good reason.
141 //!
142 //! For detailed information, see \ref Macros.
143 //!
144 //! This macro can be used when @p name cannot be used directly (for example if
145 //! it is already defined as a macro). In that case, @p name is already a
146 //! quoted string (thus unaffected by macros), and the internal name of the
147 //! method is given by @p fname.
148 //!
149 //! @param name The **qouted** name of the method that should be callable
150 //! by the interpreter.
151 //! @param fname The internal **unqouted** name of the method. This internal
152 //! name is by convention prepended by an `F`.
153 //! @param interp_name The name of the `octave::interpreter` reference that can
154 //! be used by this method. If this value is omitted,
155 //! there is no access to the interpreter and one should
156 //! use #DEFUNX to define a function instead.
157 //! @param args_name The name of the octave_value_list variable used to pass
158 //! the argument list to this method. If this value is
159 //! omitted, the method cannot access the argument list.
160 //! @param nargout_name The name of the `int` variable used to pass the number
161 //! of output arguments this method is expected to
162 //! produce from the caller. If this value is
163 //! omitted, the method cannot access this number.
164 //! @param doc Texinfo help text (docstring) for the method.
165 //!
166 //! @see DEFMETHOD, DEFCONSTMETHOD
167 
168 #define DEFMETHODX(name, fname, interp_name, args_name, nargout_name, doc) \
169  DECLARE_METHODX (fname, interp_name, args_name, nargout_name)
170 
171 //! Macro to define a builtin method that cannot be hidden by a variable.
172 //!
173 //! @warning Consider to use #DEFMETHOD, unless you have good reason.
174 //!
175 //! For detailed information, see \ref Macros.
176 //!
177 //! The method gets installed to the `octave::symbol_table` in a way, such
178 //! that no variable is allowed to hide this method name.
179 //!
180 //! @param name The **unqouted** name of the method that should be installed
181 //! on the `octave::symbol_table` and can be called by the
182 //! interpreter. Internally, the method name is prepended by an
183 //! `F`.
184 //! @param interp_name The name of the `octave::interpreter` reference that can
185 //! be used by this method. If this value is omitted,
186 //! there is no access to the interpreter and one should
187 //! use #DEFCONSTFUN to define a function instead.
188 //! @param args_name The name of the octave_value_list variable used to pass
189 //! the argument list to this method. If this value is
190 //! omitted, the method cannot access the argument list.
191 //! @param nargout_name The name of the `int` variable used to pass the number
192 //! of output arguments this method is expected to
193 //! produce from the caller. If this value is
194 //! omitted, the method cannot access this number.
195 //! @param doc Texinfo help text (docstring) for the method.
196 //!
197 //! @see DEFMETHOD, DEFMETHODX
198 
199 #define DEFCONSTMETHOD(name, interp_name, args_name, nargout_name, doc) \
200  DECLARE_METHOD (name, interp_name, args_name, nargout_name)
201 
202 //! Macro to define an alias for another existing function name.
203 //!
204 //! For detailed information, see \ref Macros.
205 //!
206 //! @param alias For another existing function name.
207 //! @param name The name of the other existing function.
208 //!
209 //! @see DEFUN
210 
211 #define DEFALIAS(alias, name)
212 
213 #endif