GNU Octave 7.1.0
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-2022 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_ov_builtin_h)
27#define octave_ov_builtin_h 1
28
29#include "octave-config.h"
30
31#include <list>
32#include <set>
33#include <string>
34
35#include "ov-fcn.h"
36#include "ov-typeinfo.h"
37
38class octave_value;
40
41namespace octave
42{
43 class tree_evaluator;
44 class interpreter;
45}
46
47// Builtin functions.
48
49class
50OCTINTERP_API
52{
53public:
54
56 : octave_function (), m_fcn (nullptr), m_meth (nullptr), m_file ()
57 { }
58
59 typedef octave_value_list (*meth) (octave::interpreter&,
60 const octave_value_list&, int);
61
62 typedef octave_value_list (*fcn) (const octave_value_list&, int);
63
64 octave_builtin (fcn ff, const std::string& nm = "",
65 const std::string& ds = "")
66 : octave_function (nm, ds), m_fcn (ff), m_meth (nullptr), m_file ()
67 { }
68
69 octave_builtin (meth mm, const std::string& nm = "",
70 const std::string& ds = "")
71 : octave_function (nm, ds), m_fcn (nullptr), m_meth (mm), m_file ()
72 { }
73
74 octave_builtin (fcn ff, const std::string& nm, const std::string& fnm,
75 const std::string& ds)
76 : octave_function (nm, ds), m_fcn (ff), m_meth (nullptr), m_file (fnm)
77 { }
78
79 octave_builtin (meth mm, const std::string& nm, const std::string& fnm,
80 const std::string& ds)
81 : octave_function (nm, ds), m_fcn (nullptr), m_meth (mm), m_file (fnm)
82 { }
83
84 // No copying!
85
86 octave_builtin (const octave_builtin& ob) = delete;
87
89
90 ~octave_builtin (void) = default;
91
92 std::string src_file_name (void) const { return m_file; }
93
94 octave_function * function_value (bool = false) { return this; }
95
96 bool is_builtin_function (void) const { return true; }
97
99 execute (octave::tree_evaluator& tw, int nargout = 0,
100 const octave_value_list& args = octave_value_list ());
101
102 fcn function (void) const;
103
104 meth method (void) const;
105
106 void push_dispatch_class (const std::string& dispatch_type);
107
108 bool handles_dispatch_class (const std::string& dispatch_type) const;
109
110protected:
111
112 // A pointer to the actual function.
113 fcn m_fcn;
114 meth m_meth;
115
116 // The name of the file where this function was defined.
117 std::string m_file;
118
119 // The types this function has been declared to handle (if any).
120 std::set<std::string> m_dispatch_classes;
121
122private:
123
125};
126
127#endif
interpreter & operator=(const interpreter &)=delete
int execute(void)
Definition: interpreter.cc:833
octave_builtin(fcn ff, const std::string &nm="", const std::string &ds="")
Definition: ov-builtin.h:64
octave_builtin(const octave_builtin &ob)=delete
std::set< std::string > m_dispatch_classes
Definition: ov-builtin.h:120
std::string src_file_name(void) const
Definition: ov-builtin.h:92
octave_builtin(fcn ff, const std::string &nm, const std::string &fnm, const std::string &ds)
Definition: ov-builtin.h:74
octave_builtin(meth mm, const std::string &nm="", const std::string &ds="")
Definition: ov-builtin.h:69
~octave_builtin(void)=default
octave_builtin(meth mm, const std::string &nm, const std::string &fnm, const std::string &ds)
Definition: ov-builtin.h:79
std::string m_file
Definition: ov-builtin.h:117
octave_function * function_value(bool=false)
Definition: ov-builtin.h:94
bool is_builtin_function(void) const
Definition: ov-builtin.h:96
octave_builtin(void)
Definition: ov-builtin.h:55
#define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
Definition: ov-base.h:173