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