GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
ov-typeinfo.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_typeinfo_h)
27#define octave_ov_typeinfo_h 1
28
29#include "octave-config.h"
30
31#include <string>
32
33#include "Array.h"
34
35#include "oct-map.h"
36#include "ov.h"
37
38class string_vector;
39
41
42class OCTINTERP_API type_info
43{
44public:
45
47
49
51
53 (const octave_value&, const octave_value&);
54
56 (const octave_base_value&, const octave_base_value&);
57
61
64
67
68 explicit type_info (int init_tab_sz = 16);
69
70 OCTAVE_DISABLE_COPY_MOVE (type_info)
71
72 ~type_info () = default;
73
74 // It is intentional that there is no install_type function.
75
78 {
79 return register_unary_class_op (op, f, true);
80 }
81
83 {
84 return register_unary_op (op, t, f, true);
85 }
86
89 {
90 return register_non_const_unary_op (op, t, f, true);
91 }
92
95 {
96 return register_binary_class_op (op, f, true);
97 }
98
101 {
102 return register_binary_op (op, t1, t2, f, true);
103 }
104
107 {
108 return register_binary_class_op (op, f, true);
109 }
110
112 int t_lhs, int t_rhs, binary_op_fcn f)
113 {
114 return register_binary_op (op, t_lhs, t_rhs, f, true);
115 }
116
117 bool install_cat_op (int t1, int t2, cat_op_fcn f)
118 {
119 return register_cat_op (t1, t2, f, true);
120 }
121
123 int t_lhs, int t_rhs, assign_op_fcn f)
124 {
125 return register_assign_op (op, t_lhs, t_rhs, f, true);
126 }
127
130 {
131 return register_assignany_op (op, t_lhs, f, true);
132 }
133
134 bool install_pref_assign_conv (int t_lhs, int t_rhs, int t_result)
135 {
136 return register_pref_assign_conv (t_lhs, t_rhs, t_result, true);
137 }
138
139 bool install_widening_op (int t, int t_result,
141 {
142 return register_widening_op (t, t_result, f, true);
143 }
144
145 int register_type (const std::string&, const std::string&,
146 const octave_value&, bool abort_on_duplicate = false);
147
148 bool register_unary_class_op (octave_value::unary_op, unary_class_op_fcn,
149 bool abort_on_duplicate = false);
150
151 bool register_unary_op (octave_value::unary_op, int, unary_op_fcn,
152 bool abort_on_duplicate = false);
153
154 bool register_non_const_unary_op (octave_value::unary_op, int,
156 bool abort_on_duplicate = false);
157
160 bool abort_on_duplicate = false);
161
163 binary_op_fcn, bool abort_on_duplicate = false);
164
167 bool abort_on_duplicate = false);
168
170 binary_op_fcn, bool abort_on_duplicate = false);
171
172 bool register_cat_op (int, int, cat_op_fcn,
173 bool abort_on_duplicate = false);
174
175 bool register_assign_op (octave_value::assign_op, int, int, assign_op_fcn,
176 bool abort_on_duplicate = false);
177
178 bool register_assignany_op (octave_value::assign_op, int, assignany_op_fcn,
179 bool abort_on_duplicate = false);
180
181 bool register_pref_assign_conv (int, int, int,
182 bool abort_on_duplicate = false);
183
184 bool register_widening_op (int, int, octave_base_value::type_conv_fcn,
185 bool abort_on_duplicate = false);
186
187 octave_value lookup_type (const std::string& nm);
188
190
192
195
197
199
202
205
206 cat_op_fcn lookup_cat_op (int, int);
207
209
211
212 int lookup_pref_assign_conv (int, int);
213
215
217
219
220 octave_scalar_map unary_ops_map () const;
221
222 octave_scalar_map non_const_unary_ops_map () const;
223
224 octave_scalar_map binary_ops_map () const;
225
226 octave_scalar_map compound_binary_ops_map () const;
227
228 octave_scalar_map assign_ops_map () const;
229
230 octave_scalar_map assignany_ops_map () const;
231
232private:
233
234 int m_num_types;
235
236 Array<std::string> m_types;
237
239
240 Array<void *> m_unary_class_ops;
241
242 Array<void *> m_unary_ops;
243
244 Array<void *> m_non_const_unary_ops;
245
246 Array<void *> m_binary_class_ops;
247
248 Array<void *> m_binary_ops;
249
250 Array<void *> m_compound_binary_class_ops;
251
252 Array<void *> m_compound_binary_ops;
253
254 Array<void *> m_cat_ops;
255
256 Array<void *> m_assign_ops;
257
258 Array<void *> m_assignany_ops;
259
260 Array<int> m_pref_assign_conv;
261
262 Array<void *> m_widening_ops;
263};
264
265OCTAVE_END_NAMESPACE(octave)
266
267OCTAVE_BEGIN_NAMESPACE(octave_value_typeinfo)
268
270
272
274
276
278
280
282
284
285extern OCTINTERP_API int register_type (const std::string& t_name,
286 const std::string& c_name,
287 const octave_value& val);
288
289extern OCTINTERP_API octave_value lookup_type (const std::string& nm);
290
291extern OCTINTERP_API unary_class_op_fcn
293
294extern OCTINTERP_API unary_op_fcn
295lookup_unary_op (octave_value::unary_op op, int t);
296
297extern OCTINTERP_API non_const_unary_op_fcn
298lookup_non_const_unary_op (octave_value::unary_op op, int t);
299
300extern OCTINTERP_API binary_class_op_fcn
302
303extern OCTINTERP_API binary_op_fcn
304lookup_binary_op (octave_value::binary_op op, int t1, int t2);
305
306extern OCTINTERP_API binary_class_op_fcn
307lookup_binary_class_op (octave_value::compound_binary_op op);
308
309extern OCTINTERP_API binary_op_fcn
310lookup_binary_op (octave_value::compound_binary_op op, int t1, int t2);
311
312extern OCTINTERP_API cat_op_fcn lookup_cat_op (int t1, int t2);
313
314extern OCTINTERP_API assign_op_fcn
315lookup_assign_op (octave_value::assign_op op, int t_lhs, int t_rhs);
316
317extern OCTINTERP_API assignany_op_fcn
318lookup_assignany_op (octave_value::assign_op op, int t_lhs);
319
320extern OCTINTERP_API int lookup_pref_assign_conv (int t_lhs, int t_rhs);
321
322extern OCTINTERP_API octave_base_value::type_conv_fcn
323lookup_widening_op (int t, int t_result);
324
325extern OCTINTERP_API string_vector installed_type_names ();
326
327extern OCTINTERP_API octave_scalar_map installed_type_info ();
328
329OCTAVE_END_NAMESPACE(octave_value_typeinfo)
330
331#endif
N Dimensional Array with copy-on-write semantics.
Definition Array.h:130
octave_base_value *(* type_conv_fcn)(const octave_base_value &)
Definition ov-base.h:257
compound_binary_op
Definition ov.h:117
binary_op
Definition ov.h:92
bool register_binary_class_op(octave_value::compound_binary_op, binary_class_op_fcn, bool abort_on_duplicate=false)
bool install_binary_class_op(octave_value::compound_binary_op op, binary_class_op_fcn f)
bool install_widening_op(int t, int t_result, octave_base_value::type_conv_fcn f)
bool install_cat_op(int t1, int t2, cat_op_fcn f)
bool register_binary_class_op(octave_value::binary_op, binary_class_op_fcn, bool abort_on_duplicate=false)
bool install_assignany_op(octave_value::assign_op op, int t_lhs, assignany_op_fcn f)
bool install_non_const_unary_op(octave_value::unary_op op, int t, non_const_unary_op_fcn f)
Definition ov-typeinfo.h:87
bool install_unary_op(octave_value::unary_op op, int t, unary_op_fcn f)
Definition ov-typeinfo.h:82
~type_info()=default
bool install_binary_op(octave_value::compound_binary_op op, int t_lhs, int t_rhs, binary_op_fcn f)
bool install_pref_assign_conv(int t_lhs, int t_rhs, int t_result)
bool register_binary_op(octave_value::binary_op, int, int, binary_op_fcn, bool abort_on_duplicate=false)
bool register_binary_op(octave_value::compound_binary_op, int, int, binary_op_fcn, bool abort_on_duplicate=false)
bool install_assign_op(octave_value::assign_op op, int t_lhs, int t_rhs, assign_op_fcn f)
bool install_unary_class_op(octave_value::unary_op op, unary_class_op_fcn f)
Definition ov-typeinfo.h:76
bool install_binary_class_op(octave_value::binary_op op, binary_class_op_fcn f)
Definition ov-typeinfo.h:93
bool install_binary_op(octave_value::binary_op op, int t1, int t2, binary_op_fcn f)
Definition ov-typeinfo.h:99
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
F77_RET_T const F77_DBLE const F77_DBLE * f
const octave_base_value const Array< octave_idx_type > & ra_idx
octave_value lookup_type(const std::string &nm)
octave_base_value::type_conv_fcn lookup_widening_op(int t, int t_result)
octave::type_info::binary_op_fcn binary_op_fcn
unary_class_op_fcn lookup_unary_class_op(octave_value::unary_op op)
non_const_unary_op_fcn lookup_non_const_unary_op(octave_value::unary_op op, int t)
octave_scalar_map installed_type_info()
octave::type_info::binary_class_op_fcn binary_class_op_fcn
int register_type(const std::string &t_name, const std::string &c_name, const octave_value &val)
octave::type_info::assign_op_fcn assign_op_fcn
octave::type_info::non_const_unary_op_fcn non_const_unary_op_fcn
octave::type_info::assignany_op_fcn assignany_op_fcn
octave::type_info::unary_op_fcn unary_op_fcn
binary_op_fcn lookup_binary_op(octave_value::binary_op op, int t1, int t2)
binary_class_op_fcn lookup_binary_class_op(octave_value::binary_op op)
assign_op_fcn lookup_assign_op(octave_value::assign_op op, int t_lhs, int t_rhs)
string_vector installed_type_names()
unary_op_fcn lookup_unary_op(octave_value::unary_op op, int t)
assignany_op_fcn lookup_assignany_op(octave_value::assign_op op, int t_lhs)
octave::type_info::cat_op_fcn cat_op_fcn
int lookup_pref_assign_conv(int t_lhs, int t_rhs)
octave::type_info::unary_class_op_fcn unary_class_op_fcn
cat_op_fcn lookup_cat_op(int t1, int t2)