GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
defun-int.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1994-2025 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_int_h)
27#define octave_defun_int_h 1
28
29#include "octave-config.h"
30
31#include <string>
32
33#include "ov-builtin.h"
34#include "ov-dld-fcn.h"
35#include "version.h"
36
37class octave_value;
38
40
41class interpreter;
42
43extern OCTINTERP_API void print_usage ();
44
45extern OCTINTERP_API void print_usage (const std::string&);
46
47extern OCTINTERP_API void check_version (const std::string& version,
48 const std::string& fcn);
49
50extern OCTINTERP_API void
51install_dld_function (octave_dld_function::fcn f, const std::string& name,
52 const dynamic_library& shl, const std::string& doc,
53 bool relative = false);
54
55extern OCTINTERP_API void
56install_dld_function (octave_dld_function::meth m, const std::string& name,
57 const dynamic_library& shl, const std::string& doc,
58 bool relative = false);
59
60extern OCTINTERP_API void
61install_mex_function (void *fptr, bool fmex, const std::string& name,
62 const dynamic_library& shl, bool relative = false);
63
64// Gets the shlib of the currently executing DLD function, if any.
65extern OCTINTERP_API dynamic_library get_current_shlib ();
66
67OCTAVE_END_NAMESPACE(octave)
68
69// Some of these functions are widely used, so maybe we should avoid
70// deprecating them for now?
71
72inline void print_usage ()
73{
74 octave::print_usage ();
75}
76
77inline void print_usage (const std::string& name)
78{
79 octave::print_usage (name);
80}
81
82inline void
83check_version (const std::string& version, const std::string& fcn)
84{
85 octave::check_version (version, fcn);
86}
87
88inline void
90 const octave::dynamic_library& shl,
91 const std::string& doc, bool relative = false)
92{
93 octave::install_dld_function (f, name, shl, doc, relative);
94}
95
96inline void
98 const octave::dynamic_library& shl,
99 const std::string& doc, bool relative = false)
100{
101 octave::install_dld_function (m, name, shl, doc, relative);
102}
103
104inline void
105install_mex_function (void *fptr, bool fmex, const std::string& name,
106 const octave::dynamic_library& shl,
107 bool relative = false)
108{
109 octave::install_mex_function (fptr, fmex, name, shl, relative);
110}
111
112// Gets the shlib of the currently executing DLD function, if any.
113inline octave::dynamic_library get_current_shlib ()
114{
115 return octave::get_current_shlib ();
116}
117
118#define FORWARD_DECLARE_FUNX(name) \
119 extern OCTAVE_EXPORT octave_value_list \
120 name (const octave_value_list&, int)
121
122#define FORWARD_DECLARE_METHODX(name) \
123 extern OCTAVE_EXPORT octave_value_list \
124 name (octave::interpreter&, const octave_value_list&, int)
125
126#define FORWARD_DECLARE_FUN(name) \
127 FORWARD_DECLARE_FUNX (F ## name)
128
129#define FORWARD_DECLARE_METHOD(name) \
130 FORWARD_DECLARE_METHODX (F ## name)
131
132#define DECLARE_FUNX(name, args_name, nargout_name) \
133 OCTAVE_EXPORT octave_value_list \
134 name (const octave_value_list& args_name, int nargout_name)
135
136#define DECLARE_METHODX(name, interp_name, args_name, nargout_name) \
137 OCTAVE_EXPORT octave_value_list \
138 name (octave::interpreter& interp_name, \
139 const octave_value_list& args_name, int nargout_name)
140
141#define DECLARE_FUN(name, args_name, nargout_name) \
142 DECLARE_FUNX (F ## name, args_name, nargout_name)
143
144#define DECLARE_METHOD(name, interp_name, args_name, nargout_name) \
145 DECLARE_METHODX (F ## name, interp_name, args_name, nargout_name)
146
147#define FORWARD_DECLARE_STATIC_FUNX(name) \
148 static octave_value_list \
149 name (const octave_value_list&, int)
150
151#define FORWARD_DECLARE_STATIC_METHODX(name) \
152 static octave_value_list \
153 name (octave::interpreter&, const octave_value_list&, int)
154
155#define FORWARD_DECLARE_STATIC_FUN(name) \
156 FORWARD_DECLARE_STATIC_FUNX (F ## name)
157
158#define FORWARD_DECLARE_STATIC_METHOD(name) \
159 FORWARD_DECLARE_STATIC_METHODX (F ## name)
160
161#define DECLARE_STATIC_FUNX(name, args_name, nargout_name) \
162 static octave_value_list \
163 name (const octave_value_list& args_name, int nargout_name)
164
165#define DECLARE_STATIC_METHODX(name, interp_name, args_name, nargout_name) \
166 static octave_value_list \
167 name (octave::interpreter& interp_name, \
168 const octave_value_list& args_name, int nargout_name)
169
170#define DECLARE_STATIC_FUN(name, args_name, nargout_name) \
171 DECLARE_STATIC_FUNX (F ## name, args_name, nargout_name)
172
173#define DECLARE_STATIC_METHOD(name, interp_name, args_name, nargout_name) \
174 DECLARE_STATIC_METHODX (F ## name, interp_name, args_name, nargout_name)
175
176// Define the code that will be used to insert the new function into
177// the symbol table. We look for this name instead of the actual
178// function so that we can easily install the doc std::string too.
179
180typedef bool (*octave_dld_fcn_installer) (const octave::dynamic_library&, bool relative);
181
183 (*octave_dld_fcn_getter) (const octave::dynamic_library&, bool relative);
184
185#if defined (OCTAVE_SOURCE)
186# define DEFINE_FUN_INSTALLER_FUN(name, doc) \
187 DEFINE_FUNX_INSTALLER_FUN(#name, F ## name, G ## name, "external-doc")
188#else
189# define DEFINE_FUN_INSTALLER_FUN(name, doc) \
190 DEFINE_FUNX_INSTALLER_FUN(#name, F ## name, G ## name, doc)
191#endif
192
193#define DEFINE_FUNX_INSTALLER_FUN(name, fname, gname, doc) \
194 extern "C" \
195 OCTAVE_EXPORT \
196 octave_function * \
197 gname (const octave::dynamic_library& shl, bool relative) \
198 { \
199 check_version (OCTAVE_API_VERSION, name); \
200 \
201 octave_dld_function *fcn \
202 = octave_dld_function::create (fname, shl, name, doc); \
203 \
204 if (relative) \
205 fcn->mark_relative (); \
206 \
207 return fcn; \
208 }
209
210#endif
octave_value_list(* fcn)(const octave_value_list &, int)
Definition ov-builtin.h:61
octave_value_list(* meth)(octave::interpreter &, const octave_value_list &, int)
Definition ov-builtin.h:58
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void install_dld_function(octave_dld_function::fcn f, const std::string &name, const dynamic_library &shl, const std::string &doc, bool relative=false)
Definition defun.cc:90
dynamic_library get_current_shlib()
Definition defun-int.h:113
bool(* octave_dld_fcn_installer)(const octave::dynamic_library &, bool relative)
Definition defun-int.h:180
void install_mex_function(void *fptr, bool fmex, const std::string &name, const dynamic_library &shl, bool relative=false)
Definition defun.cc:124
void check_version(const std::string &version, const std::string &fcn)
Definition defun-int.h:83
void print_usage()
Definition defun-int.h:72
F77_RET_T const F77_DBLE const F77_DBLE * f
FloatComplex(* fptr)(const FloatComplex &, float, int, octave_idx_type &)