GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
ov-builtin.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1996-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_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
42
43class tree_evaluator;
44class interpreter;
45
46OCTAVE_END_NAMESPACE(octave)
47
48// Builtin functions.
49
50class OCTINTERP_API octave_builtin : public octave_function
51{
52public:
53
55 : octave_function (), m_fcn (nullptr), m_meth (nullptr), m_file ()
56 { }
57
58 typedef octave_value_list (*meth) (octave::interpreter&,
59 const octave_value_list&, int);
60
61 typedef octave_value_list (*fcn) (const octave_value_list&, int);
62
63 octave_builtin (fcn ff, const std::string& nm = "",
64 const std::string& ds = "")
65 : octave_function (nm, ds), m_fcn (ff), m_meth (nullptr), m_file ()
66 { }
67
68 octave_builtin (meth mm, const std::string& nm = "",
69 const std::string& ds = "")
70 : octave_function (nm, ds), m_fcn (nullptr), m_meth (mm), m_file ()
71 { }
72
73 octave_builtin (fcn ff, const std::string& nm, const std::string& fnm,
74 const std::string& ds)
75 : octave_function (nm, ds), m_fcn (ff), m_meth (nullptr), m_file (fnm)
76 { }
77
78 octave_builtin (meth mm, const std::string& nm, const std::string& fnm,
79 const std::string& ds)
80 : octave_function (nm, ds), m_fcn (nullptr), m_meth (mm), m_file (fnm)
81 { }
82
83 OCTAVE_DISABLE_COPY_MOVE (octave_builtin)
84
85 ~octave_builtin () = default;
86
87 std::string src_file_name () const { return m_file; }
88
89 octave_function * function_value (bool = false) { return this; }
90
91 bool is_builtin_function () const { return true; }
92
94 execute (octave::tree_evaluator& tw, int nargout = 0,
95 const octave_value_list& args = octave_value_list ());
96
97 fcn function () const;
98
99 meth method () const;
100
101 void push_dispatch_class (const std::string& dispatch_type);
102
103 bool handles_dispatch_class (const std::string& dispatch_type) const;
104
105protected:
106
107 // A pointer to the actual function.
108 fcn m_fcn;
109 meth m_meth;
110
111 // The name of the file where this function was defined.
112 std::string m_file;
113
114 // The types this function has been declared to handle (if any).
115 std::set<std::string> m_dispatch_classes;
116
117private:
118
120};
121
122#endif
octave_builtin(fcn ff, const std::string &nm="", const std::string &ds="")
Definition ov-builtin.h:63
~octave_builtin()=default
std::set< std::string > m_dispatch_classes
Definition ov-builtin.h:115
bool is_builtin_function() const
Definition ov-builtin.h:91
octave_builtin(fcn ff, const std::string &nm, const std::string &fnm, const std::string &ds)
Definition ov-builtin.h:73
std::string src_file_name() const
Definition ov-builtin.h:87
octave_builtin(meth mm, const std::string &nm="", const std::string &ds="")
Definition ov-builtin.h:68
octave_builtin(meth mm, const std::string &nm, const std::string &fnm, const std::string &ds)
Definition ov-builtin.h:78
std::string m_file
Definition ov-builtin.h:112
octave_function * function_value(bool=false)
Definition ov-builtin.h:89
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_API(API)
Definition ov-base.h:185