GNU Octave  8.1.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-2023 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
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
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 method.
89 //!
90 //! For detailed information, see \ref Macros.
91 //!
92 //! @param name The **unquoted** name of the method that should be installed
93 //! on the 'octave::symbol_table' and can be called by the
94 //! interpreter. Internally, the method name is prepended by an
95 //! 'F'.
96 //! @param interp_name The name of the 'octave::interpreter' reference that can
97 //! be used by this method. If this value is omitted,
98 //! there is no access to the interpreter and one should
99 //! use #DEFUN to define a function instead.
100 //! @param args_name The name of the octave_value_list variable used to pass
101 //! the argument list to this method. If this value is
102 //! omitted, the method cannot access the argument list.
103 //! @param nargout_name The name of the 'int' variable used to pass the number
104 //! of output arguments this method is expected to
105 //! produce from the caller. If this value is
106 //! omitted, the method cannot access this number.
107 //! @param doc Texinfo help text (docstring) for the method.
108 //!
109 //! @see DEFMETHODX
110 
111 #define DEFMETHOD(name, interp_name, args_name, nargout_name, doc) \
112  DECLARE_METHOD (name, interp_name, args_name, nargout_name)
113 
114 //! Macro to define a builtin method with certain internal name.
115 //!
116 //! @warning Consider to use #DEFMETHOD, unless you have good reason.
117 //!
118 //! For detailed information, see \ref Macros.
119 //!
120 //! This macro can be used when @p name cannot be used directly (for example if
121 //! it is already defined as a macro). In that case, @p name is already a
122 //! quoted string (thus unaffected by macros), and the internal name of the
123 //! method is given by @p fname.
124 //!
125 //! @param name The **quoted** name of the method that should be callable
126 //! by the interpreter.
127 //! @param fname The internal **unquoted** name of the method. This internal
128 //! name is by convention prepended by an 'F'.
129 //! @param interp_name The name of the 'octave::interpreter' reference that can
130 //! be used by this method. If this value is omitted,
131 //! there is no access to the interpreter and one should
132 //! use #DEFUNX to define a function instead.
133 //! @param args_name The name of the octave_value_list variable used to pass
134 //! the argument list to this method. If this value is
135 //! omitted, the method cannot access the argument list.
136 //! @param nargout_name The name of the 'int' variable used to pass the number
137 //! of output arguments this method is expected to
138 //! produce from the caller. If this value is
139 //! omitted, the method cannot access this number.
140 //! @param doc Texinfo help text (docstring) for the method.
141 //!
142 //! @see DEFMETHOD
143 
144 #define DEFMETHODX(name, fname, interp_name, args_name, nargout_name, doc) \
145  DECLARE_METHODX (fname, interp_name, args_name, nargout_name)
146 
147 // These macros are obsolete but provided for backward compatibility.
148 #define DEFCONSTFUN DEFUN
149 #define DEFCONSTMETHOD DEFMETHOD
150 
151 //! Macro to define an alias for another existing function name.
152 //!
153 //! For detailed information, see \ref Macros.
154 //!
155 //! @param alias For another existing function name.
156 //! @param name The name of the other existing function.
157 //!
158 //! @see DEFUN
159 
160 #define DEFALIAS(alias, name)
161 
162 #endif