GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
defun-int.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1994-2017 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 the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 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 <http://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 "symtab.h"
33 #include "version.h"
34 
35 class octave_value;
36 
37 extern OCTINTERP_API void print_usage (void);
38 extern OCTINTERP_API void print_usage (const std::string&);
39 
40 extern OCTINTERP_API void check_version (const std::string& version,
41  const std::string& fcn);
42 
43 extern OCTINTERP_API void
45  const std::string& file, const std::string& doc,
46  bool can_hide_function = true);
47 
48 extern OCTINTERP_API void
50  const octave::dynamic_library& shl, const std::string& doc,
51  bool relative = false);
52 
53 extern OCTINTERP_API void
54 install_mex_function (void *fptr, bool fmex, const std::string& name,
55  const octave::dynamic_library& shl, bool relative = false);
56 
57 extern OCTINTERP_API void
58 alias_builtin (const std::string& alias, const std::string& name);
59 
60 // Gets the shlib of the currently executing DLD function, if any.
62 get_current_shlib (void);
63 
64 // This is a convenience class that calls the above function automatically at
65 // construction time. When deriving new classes, you can either use it as a
66 // field or as a parent (with multiple inheritance).
67 
69 {
70 public:
74  : octave::dynamic_library (shl) { }
75 };
76 
77 extern OCTINTERP_API bool
78 defun_isargout (int, int);
79 
80 extern OCTINTERP_API void
81 defun_isargout (int, int, bool *);
82 
83 #define FORWARD_DECLARE_FUNX(name) \
84  extern OCTAVE_EXPORT octave_value_list \
85  name (const octave_value_list&, int)
86 
87 #define FORWARD_DECLARE_FUN(name) \
88  FORWARD_DECLARE_FUNX (F ## name)
89 
90 #define DECLARE_FUNX(name, args_name, nargout_name) \
91  OCTAVE_EXPORT octave_value_list \
92  name (const octave_value_list& args_name, int nargout_name)
93 
94 #define DECLARE_FUN(name, args_name, nargout_name) \
95  DECLARE_FUNX (F ## name, args_name, nargout_name)
96 
97 // Define the code that will be used to insert the new function into
98 // the symbol table. We look for this name instead of the actual
99 // function so that we can easily install the doc std::string too.
100 
101 typedef bool (*octave_dld_fcn_installer) (const octave::dynamic_library&, bool relative);
102 
103 typedef octave_function *
104  (*octave_dld_fcn_getter) (const octave::dynamic_library&, bool relative);
105 
106 #if defined (OCTAVE_SOURCE)
107 # define DEFINE_FUN_INSTALLER_FUN(name, doc) \
108  DEFINE_FUNX_INSTALLER_FUN(#name, F ## name, G ## name, "external-doc")
109 #else
110 # define DEFINE_FUN_INSTALLER_FUN(name, doc) \
111  DEFINE_FUNX_INSTALLER_FUN(#name, F ## name, G ## name, doc)
112 #endif
113 
114 #define DEFINE_FUNX_INSTALLER_FUN(name, fname, gname, doc) \
115  extern "C" \
116  OCTAVE_EXPORT \
117  octave_function * \
118  gname (const octave::dynamic_library& shl, bool relative) \
119  { \
120  check_version (OCTAVE_API_VERSION, name); \
121  \
122  octave_dld_function *fcn \
123  = octave_dld_function::create (fname, shl, name, doc); \
124  \
125  if (relative) \
126  fcn->mark_relative (); \
127  \
128  return fcn; \
129  }
130 
131 #endif
Octave interface to the compression and uncompression libraries.
Definition: aepbalance.cc:47
For example cd octave end example noindent changes the current working directory to file
Definition: dirfns.cc:120
octave_value_list(* fcn)(const octave_value_list &, int)
Definition: ov-builtin.h:47
OCTINTERP_API void install_builtin_function(octave_builtin::fcn f, const std::string &name, const std::string &file, const std::string &doc, bool can_hide_function=true)
Definition: defun.cc:83
OCTINTERP_API void print_usage(void)
Definition: defun.cc:52
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &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 F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE * f
OCTINTERP_API void alias_builtin(const std::string &alias, const std::string &name)
Definition: defun.cc:122
octave_auto_shlib(void)
Definition: defun-int.h:71
octave_function * fcn
Definition: ov-class.cc:1743
octave_auto_shlib(const octave::dynamic_library &shl)
Definition: defun-int.h:73
OCTAVE_EXPORT octave_value_list any number nd example oindent prints the prompt xample Pick a any number!nd example oindent and waits for the user to enter a value The string entered by the user is evaluated as an so it may be a literal a variable name
Definition: input.cc:871
#define OCTINTERP_API
Definition: mexproto.h:69
OCTINTERP_API void check_version(const std::string &version, const std::string &fcn)
Definition: defun.cc:68
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:108
bool(* octave_dld_fcn_installer)(const octave::dynamic_library &, bool relative)
Definition: defun-int.h:101
FloatComplex(* fptr)(const FloatComplex &, float, int, octave_idx_type &)
Definition: lo-specfun.cc:1724
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:854
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:93
OCTINTERP_API bool defun_isargout(int, int)
Definition: defun.cc:152
OCTINTERP_API octave::dynamic_library get_current_shlib(void)
Definition: defun.cc:128