GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ov-builtin.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-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_ov_builtin_h)
24 #define octave_ov_builtin_h 1
25 
26 #include "octave-config.h"
27 
28 #include <list>
29 #include <set>
30 #include <string>
31 
32 #include "ov-fcn.h"
33 #include "ov-typeinfo.h"
34 
35 class octave_value;
36 class octave_value_list;
37 
38 namespace octave
39 {
40  class tree_evaluator;
41  class interpreter;
42  class jit_type;
43 }
44 
45 // Builtin functions.
46 
47 class
48 OCTINTERP_API
50 {
51 public:
52 
53  octave_builtin (void) : octave_function (), f (nullptr), file (),
54  jtype (nullptr)
55  { }
56 
58  const octave_value_list&, int);
59 
60  typedef octave_value_list (*fcn) (const octave_value_list&, int);
61 
62  octave_builtin (fcn ff, const std::string& nm = "",
63  const std::string& ds = "")
64  : octave_function (nm, ds), f (ff), m (nullptr), file (), jtype (nullptr)
65  { }
66 
67  octave_builtin (meth mm, const std::string& nm = "",
68  const std::string& ds = "")
69  : octave_function (nm, ds), f (nullptr), m (mm), file (), jtype (nullptr)
70  { }
71 
72  octave_builtin (fcn ff, const std::string& nm, const std::string& fnm,
73  const std::string& ds)
74  : octave_function (nm, ds), f (ff), m (nullptr), file (fnm), jtype (nullptr)
75  { }
76 
77  octave_builtin (meth mm, const std::string& nm, const std::string& fnm,
78  const std::string& ds)
79  : octave_function (nm, ds), f (nullptr), m (mm), file (fnm), jtype (nullptr)
80  { }
81 
82  // No copying!
83 
84  octave_builtin (const octave_builtin& ob) = delete;
85 
86  octave_builtin& operator = (const octave_builtin& ob) = delete;
87 
88  ~octave_builtin (void) = default;
89 
90  std::string src_file_name (void) const { return file; }
91 
92  octave_function * function_value (bool = false) { return this; }
93 
94  bool is_builtin_function (void) const { return true; }
95 
97  call (octave::tree_evaluator& tw, int nargout = 0,
98  const octave_value_list& args = octave_value_list ());
99 
100  octave::jit_type * to_jit (void) const;
101 
102  void stash_jit (octave::jit_type& type);
103 
104  fcn function (void) const;
105 
106  meth method (void) const;
107 
108  void push_dispatch_class (const std::string& dispatch_type);
109 
110  bool handles_dispatch_class (const std::string& dispatch_type) const;
111 
112 protected:
113 
114  // A pointer to the actual function.
116  meth m;
117 
118  // The name of the file where this function was defined.
120 
121  // The types this function has been declared to handle (if any).
122  std::set<std::string> dispatch_classes;
123 
124  // A pointer to the jit type that represents the function.
126 
127 private:
128 
130 };
131 
132 #endif
For example cd octave end example noindent changes the current working directory to file
Definition: dirfns.cc:124
bool is_builtin_function(void) const
Definition: ov-builtin.h:94
octave_builtin(meth mm, const std::string &nm="", const std::string &ds="")
Definition: ov-builtin.h:67
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
std::string src_file_name(void) const
Definition: ov-builtin.h:90
octave_function * fcn
Definition: ov-class.cc:1754
std::string file
Definition: ov-builtin.h:119
octave::jit_type * jtype
Definition: ov-builtin.h:125
#define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
Definition: ov-base.h:158
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
Definition: utils.cc:975
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
Definition: ov-usr-fcn.cc:997
std::set< std::string > dispatch_classes
Definition: ov-builtin.h:122
idx type
Definition: ov.cc:3114
octave_builtin(fcn ff, const std::string &nm="", const std::string &ds="")
Definition: ov-builtin.h:62
octave_builtin(fcn ff, const std::string &nm, const std::string &fnm, const std::string &ds)
Definition: ov-builtin.h:72
octave_function * function_value(bool=false)
Definition: ov-builtin.h:92
octave_builtin(meth mm, const std::string &nm, const std::string &fnm, const std::string &ds)
Definition: ov-builtin.h:77
std::string method
Definition: urlwrite.cc:123
octave_builtin(void)
Definition: ov-builtin.h:53
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