GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
defun-int.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_int_h)
24 #define octave_defun_int_h 1
25 
26 #include "octave-config.h"
27 
28 #include <string>
29 
30 #include "ov-builtin.h"
31 #include "ov-dld-fcn.h"
32 #include "version.h"
33 
34 namespace octave
35 {
36  class interpreter;
37 }
38 
39 class octave_value;
40 
41 extern OCTINTERP_API void print_usage (void);
42 extern OCTINTERP_API void print_usage (const std::string&);
43 
44 extern OCTINTERP_API void check_version (const std::string& version,
45  const std::string& fcn);
46 
47 extern OCTINTERP_API void
49  const octave::dynamic_library& shl, const std::string& doc,
50  bool relative = false);
51 
52 extern OCTINTERP_API void
54  const octave::dynamic_library& shl, const std::string& doc,
55  bool relative = false);
56 
57 extern OCTINTERP_API void
58 install_mex_function (void *fptr, bool fmex, const std::string& name,
59  const octave::dynamic_library& shl, bool relative = false);
60 // Gets the shlib of the currently executing DLD function, if any.
61 extern OCTINTERP_API octave::dynamic_library
62 get_current_shlib (void);
63 
64 namespace octave
65 {
66  // FIXME: this class doesn't seem to be used in Octave. Is it
67  // really needed?
68 
69  // This is a convenience class that calls the above function automatically at
70  // construction time. When deriving new classes, you can either use it as a
71  // field or as a parent (with multiple inheritance).
72 
73  class auto_shlib : public dynamic_library
74  {
75  public:
76 
78 
79  auto_shlib (const dynamic_library& shl) : dynamic_library (shl) { }
80  };
81 }
82 
83 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
84 
85 OCTAVE_DEPRECATED (4.4, "use 'octave::auto_shlib' instead")
86 typedef octave::auto_shlib octave_auto_shlib;
87 
88 OCTAVE_DEPRECATED (4.4, "use 'tree_evaluator::isargout' instead")
89 extern OCTINTERP_API bool
90 defun_isargout (int, int);
91 
92 OCTAVE_DEPRECATED (4.4, "use 'tree_evaluator::isargout' instead")
93 extern OCTINTERP_API void
94 defun_isargout (int, int, bool *);
95 
96 OCTAVE_DEPRECATED (4.4, "use 'octave::symbol_table::install_built_in_function' instead")
97 extern OCTINTERP_API void
99  const std::string& file, const std::string& doc,
100  bool can_hide_function = true);
101 
102 OCTAVE_DEPRECATED (4.4, "use 'octave::symbol_table::install_built_in_function' instead")
103 extern OCTINTERP_API void
104 install_builtin_function (octave_builtin::meth m, const std::string& name,
105  const std::string& file, const std::string& doc,
106  bool can_hide_function = true);
107 
108 OCTAVE_DEPRECATED (4.4, "use 'octave::symbol_table::alias_built_in_function' instead")
109 extern OCTINTERP_API void
110 alias_builtin (const std::string& alias, const std::string& name);
111 
112 OCTAVE_DEPRECATED (4.4, "use 'octave::symbol_table::install_built_in_dispatch' instead")
113 extern OCTINTERP_API void
114 install_builtin_dispatch (const std::string& name, const std::string& klass);
115 
116 #endif
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 DECLARE_STATIC_FUNX(name, args_name, nargout_name) \
148  static octave_value_list \
149  name (const octave_value_list& args_name, int nargout_name)
150 
151 #define DECLARE_STATIC_METHODX(name, interp_name, args_name, nargout_name) \
152  static octave_value_list \
153  name (octave::interpreter& interp_name, \
154  const octave_value_list& args_name, int nargout_name)
155 
156 #define DECLARE_STATIC_FUN(name, args_name, nargout_name) \
157  DECLARE_STATIC_FUNX (F ## name, args_name, nargout_name)
158 
159 #define DECLARE_STATIC_METHOD(name, interp_name, args_name, nargout_name) \
160  DECLARE_STATIC_METHODX (F ## name, interp_name, args_name, nargout_name)
161 
162 // Define the code that will be used to insert the new function into
163 // the symbol table. We look for this name instead of the actual
164 // function so that we can easily install the doc std::string too.
165 
166 typedef bool (*octave_dld_fcn_installer) (const octave::dynamic_library&, bool relative);
167 
168 typedef octave_function *
169  (*octave_dld_fcn_getter) (const octave::dynamic_library&, bool relative);
170 
171 #if defined (OCTAVE_SOURCE)
172 # define DEFINE_FUN_INSTALLER_FUN(name, doc) \
173  DEFINE_FUNX_INSTALLER_FUN(#name, F ## name, G ## name, "external-doc")
174 #else
175 # define DEFINE_FUN_INSTALLER_FUN(name, doc) \
176  DEFINE_FUNX_INSTALLER_FUN(#name, F ## name, G ## name, doc)
177 #endif
178 
179 #define DEFINE_FUNX_INSTALLER_FUN(name, fname, gname, doc) \
180  extern "C" \
181  OCTAVE_EXPORT \
182  octave_function * \
183  gname (const octave::dynamic_library& shl, bool relative) \
184  { \
185  check_version (OCTAVE_API_VERSION, name); \
186  \
187  octave_dld_function *fcn \
188  = octave_dld_function::create (fname, shl, name, doc); \
189  \
190  if (relative) \
191  fcn->mark_relative (); \
192  \
193  return fcn; \
194  }
195 
196 #endif
For example cd octave end example noindent changes the current working directory to file
Definition: dirfns.cc:124
void install_builtin_function(octave_builtin::fcn f, const std::string &name, const std::string &file, const std::string &doc, bool)
Definition: defun.cc:88
OCTINTERP_API void print_usage(void)
Definition: defun.cc:54
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE * f
octave_value_list(* fcn)(const octave_value_list &, int)
Definition: ov-builtin.h:60
STL namespace.
octave_function * fcn
Definition: ov-class.cc:1754
bool defun_isargout(int nargout, int iout)
Definition: defun.cc:212
nd deftypefn *std::string name
Definition: sysdep.cc:647
OCTINTERP_API void check_version(const std::string &version, const std::string &fcn)
Definition: defun.cc:73
bool(* octave_dld_fcn_installer)(const octave::dynamic_library &, bool relative)
Definition: defun-int.h:166
octave_value_list(* meth)(octave::interpreter &, const octave_value_list &, int)
Definition: ov-builtin.h:57
auto_shlib(const dynamic_library &shl)
Definition: defun-int.h:79
OCTINTERP_API void install_mex_function(void *fptr, bool fmex, const std::string &name, const octave::dynamic_library &shl, bool relative=false)
Definition: defun.cc:150
void alias_builtin(const std::string &alias, const std::string &name)
Definition: defun.cc:167
FloatComplex(* fptr)(const FloatComplex &, float, int, octave_idx_type &)
Definition: lo-specfun.cc:1129
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888
OCTINTERP_API void install_dld_function(octave_dld_function::fcn f, const std::string &name, const octave::dynamic_library &shl, const std::string &doc, bool relative=false)
Definition: defun.cc:114
void install_builtin_dispatch(const std::string &name, const std::string &klass)
Definition: defun.cc:175
OCTINTERP_API octave::dynamic_library get_current_shlib(void)
Definition: defun.cc:184