GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ov-typeinfo.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_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
40OCTAVE_NAMESPACE_BEGIN
41
42 class
43 OCTINTERP_API
45 {
46 public:
47
49
51
53
55 (const octave_value&, const octave_value&);
56
58 (const octave_base_value&, const octave_base_value&);
59
63
66
69
70 explicit type_info (int init_tab_sz = 16);
71
72 // No copying!
73
74 type_info (const type_info&) = delete;
75
76 type_info& operator = (const type_info&) = delete;
77
78 ~type_info (void) = default;
79
80 // It is intentional that there is no install_type function.
81
84 {
85 return register_unary_class_op (op, f, true);
86 }
87
89 {
90 return register_unary_op (op, t, f, true);
91 }
92
95 {
96 return register_non_const_unary_op (op, t, f, true);
97 }
98
101 {
102 return register_binary_class_op (op, f, true);
103 }
104
107 {
108 return register_binary_op (op, t1, t2, f, true);
109 }
110
113 {
114 return register_binary_class_op (op, f, true);
115 }
116
118 int t_lhs, int t_rhs, binary_op_fcn f)
119 {
120 return register_binary_op (op, t_lhs, t_rhs, f, true);
121 }
122
123 bool install_cat_op (int t1, int t2, cat_op_fcn f)
124 {
125 return register_cat_op (t1, t2, f, true);
126 }
127
129 int t_lhs, int t_rhs, assign_op_fcn f)
130 {
131 return register_assign_op (op, t_lhs, t_rhs, f, true);
132 }
133
136 {
137 return register_assignany_op (op, t_lhs, f, true);
138 }
139
140 bool install_pref_assign_conv (int t_lhs, int t_rhs, int t_result)
141 {
142 return register_pref_assign_conv (t_lhs, t_rhs, t_result, true);
143 }
144
145 bool install_widening_op (int t, int t_result,
147 {
148 return register_widening_op (t, t_result, f, true);
149 }
150
151 int register_type (const std::string&, const std::string&,
152 const octave_value&, bool abort_on_duplicate = false);
153
154 bool register_unary_class_op (octave_value::unary_op, unary_class_op_fcn,
155 bool abort_on_duplicate = false);
156
157 bool register_unary_op (octave_value::unary_op, int, unary_op_fcn,
158 bool abort_on_duplicate = false);
159
160 bool register_non_const_unary_op (octave_value::unary_op, int,
162 bool abort_on_duplicate = false);
163
164 bool register_binary_class_op (octave_value::binary_op,
166 bool abort_on_duplicate = false);
167
168 bool register_binary_op (octave_value::binary_op, int, int,
169 binary_op_fcn, bool abort_on_duplicate = false);
170
171 bool register_binary_class_op (octave_value::compound_binary_op,
173 bool abort_on_duplicate = false);
174
175 bool register_binary_op (octave_value::compound_binary_op, int, int,
176 binary_op_fcn, bool abort_on_duplicate = false);
177
178 bool register_cat_op (int, int, cat_op_fcn,
179 bool abort_on_duplicate = false);
180
181 bool register_assign_op (octave_value::assign_op, int, int, assign_op_fcn,
182 bool abort_on_duplicate = false);
183
184 bool register_assignany_op (octave_value::assign_op, int, assignany_op_fcn,
185 bool abort_on_duplicate = false);
186
187 bool register_pref_assign_conv (int, int, int,
188 bool abort_on_duplicate = false);
189
190 bool register_widening_op (int, int, octave_base_value::type_conv_fcn,
191 bool abort_on_duplicate = false);
192
193 octave_value lookup_type (const std::string& nm);
194
196
198
201
203
205
208
211
212 cat_op_fcn lookup_cat_op (int, int);
213
215
217
218 int lookup_pref_assign_conv (int, int);
219
221
223
225
226 octave_scalar_map unary_ops_map (void) const;
227
228 octave_scalar_map non_const_unary_ops_map (void) const;
229
230 octave_scalar_map binary_ops_map (void) const;
231
232 octave_scalar_map compound_binary_ops_map (void) const;
233
234 octave_scalar_map assign_ops_map (void) const;
235
236 octave_scalar_map assignany_ops_map (void) const;
237
238 private:
239
241
243
245
247
249
251
253
255
257
259
261
263
265
267
269 };
270
271OCTAVE_NAMESPACE_END
272
273namespace octave_value_typeinfo
274{
276
278
280
282
284
286
288
290
291 extern OCTINTERP_API int register_type (const std::string& t_name,
292 const std::string& c_name,
293 const octave_value& val);
294
295 extern OCTINTERP_API octave_value lookup_type (const std::string& nm);
296
297 extern OCTINTERP_API unary_class_op_fcn
299
300 extern OCTINTERP_API unary_op_fcn
302
303 extern OCTINTERP_API non_const_unary_op_fcn
305
306 extern OCTINTERP_API binary_class_op_fcn
308
309 extern OCTINTERP_API binary_op_fcn
310 lookup_binary_op (octave_value::binary_op op, int t1, int t2);
311
312 extern OCTINTERP_API binary_class_op_fcn
314
315 extern OCTINTERP_API binary_op_fcn
317
318 extern OCTINTERP_API cat_op_fcn lookup_cat_op (int t1, int t2);
319
320 extern OCTINTERP_API assign_op_fcn
321 lookup_assign_op (octave_value::assign_op op, int t_lhs, int t_rhs);
322
323 extern OCTINTERP_API assignany_op_fcn
325
326 extern OCTINTERP_API int lookup_pref_assign_conv (int t_lhs, int t_rhs);
327
328 extern OCTINTERP_API octave_base_value::type_conv_fcn
329 lookup_widening_op (int t, int t_result);
330
331 extern OCTINTERP_API string_vector installed_type_names (void);
332
333 extern OCTINTERP_API octave_scalar_map installed_type_info (void);
334}
335
336#endif
octave_base_value *(* type_conv_fcn)(const octave_base_value &)
Definition: ov-base.h:235
unary_op
Definition: ov.h:77
compound_binary_op
Definition: ov.h:115
assign_op
Definition: ov.h:132
binary_op
Definition: ov.h:90
string_vector & operator=(const string_vector &)=default
Array< void * > m_compound_binary_class_ops
Definition: ov-typeinfo.h:256
Array< void * > m_compound_binary_ops
Definition: ov-typeinfo.h:258
bool install_binary_class_op(octave_value::compound_binary_op op, binary_class_op_fcn f)
Definition: ov-typeinfo.h:111
bool install_widening_op(int t, int t_result, octave_base_value::type_conv_fcn f)
Definition: ov-typeinfo.h:145
type_info(const type_info &)=delete
Array< octave_value * > m_vals
Definition: ov-typeinfo.h:244
Array< void * > m_binary_ops
Definition: ov-typeinfo.h:254
bool install_cat_op(int t1, int t2, cat_op_fcn f)
Definition: ov-typeinfo.h:123
Array< void * > m_cat_ops
Definition: ov-typeinfo.h:260
~type_info(void)=default
Array< void * > m_unary_class_ops
Definition: ov-typeinfo.h:246
Array< std::string > m_types
Definition: ov-typeinfo.h:242
Array< void * > m_assignany_ops
Definition: ov-typeinfo.h:264
bool install_assignany_op(octave_value::assign_op op, int t_lhs, assignany_op_fcn f)
Definition: ov-typeinfo.h:134
bool install_non_const_unary_op(octave_value::unary_op op, int t, non_const_unary_op_fcn f)
Definition: ov-typeinfo.h:93
bool install_unary_op(octave_value::unary_op op, int t, unary_op_fcn f)
Definition: ov-typeinfo.h:88
bool install_binary_op(octave_value::compound_binary_op op, int t_lhs, int t_rhs, binary_op_fcn f)
Definition: ov-typeinfo.h:117
Array< void * > m_unary_ops
Definition: ov-typeinfo.h:248
int m_num_types
Definition: ov-typeinfo.h:240
Array< void * > m_widening_ops
Definition: ov-typeinfo.h:268
Array< void * > m_non_const_unary_ops
Definition: ov-typeinfo.h:250
Array< void * > m_assign_ops
Definition: ov-typeinfo.h:262
bool install_pref_assign_conv(int t_lhs, int t_rhs, int t_result)
Definition: ov-typeinfo.h:140
Array< int > m_pref_assign_conv
Definition: ov-typeinfo.h:266
bool install_assign_op(octave_value::assign_op op, int t_lhs, int t_rhs, assign_op_fcn f)
Definition: ov-typeinfo.h:128
bool install_unary_class_op(octave_value::unary_op op, unary_class_op_fcn f)
Definition: ov-typeinfo.h:82
Array< void * > m_binary_class_ops
Definition: ov-typeinfo.h:252
bool install_binary_class_op(octave_value::binary_op op, binary_class_op_fcn f)
Definition: ov-typeinfo.h:99
bool install_binary_op(octave_value::binary_op op, int t1, int t2, binary_op_fcn f)
Definition: ov-typeinfo.h:105
F77_RET_T const F77_DBLE const F77_DBLE * f
int register_type(const std::string &t_name, const std::string &c_name, const octave_value &val)
Definition: ov-typeinfo.cc:767
octave_scalar_map installed_type_info(void)
Definition: ov-typeinfo.cc:896
unary_op_fcn lookup_unary_op(octave_value::unary_op op, int t)
Definition: ov-typeinfo.cc:792
unary_class_op_fcn lookup_unary_class_op(octave_value::unary_op op)
Definition: ov-typeinfo.cc:784
octave::type_info::cat_op_fcn cat_op_fcn
Definition: ov-typeinfo.h:285
octave::type_info::assign_op_fcn assign_op_fcn
Definition: ov-typeinfo.h:287
octave::type_info::unary_class_op_fcn unary_class_op_fcn
Definition: ov-typeinfo.h:275
octave_base_value::type_conv_fcn lookup_widening_op(int t, int t_result)
Definition: ov-typeinfo.cc:880
octave::type_info::assignany_op_fcn assignany_op_fcn
Definition: ov-typeinfo.h:289
binary_class_op_fcn lookup_binary_class_op(octave_value::binary_op op)
Definition: ov-typeinfo.cc:810
assignany_op_fcn lookup_assignany_op(octave_value::assign_op op, int t_lhs)
Definition: ov-typeinfo.cc:863
int lookup_pref_assign_conv(int t_lhs, int t_rhs)
Definition: ov-typeinfo.cc:871
string_vector installed_type_names(void)
Definition: ov-typeinfo.cc:888
cat_op_fcn lookup_cat_op(int t1, int t2)
Definition: ov-typeinfo.cc:845
non_const_unary_op_fcn lookup_non_const_unary_op(octave_value::unary_op op, int t)
Definition: ov-typeinfo.cc:801
assign_op_fcn lookup_assign_op(octave_value::assign_op op, int t_lhs, int t_rhs)
Definition: ov-typeinfo.cc:854
octave::type_info::non_const_unary_op_fcn non_const_unary_op_fcn
Definition: ov-typeinfo.h:279
octave::type_info::unary_op_fcn unary_op_fcn
Definition: ov-typeinfo.h:277
octave::type_info::binary_class_op_fcn binary_class_op_fcn
Definition: ov-typeinfo.h:281
binary_op_fcn lookup_binary_op(octave_value::binary_op op, int t1, int t2)
Definition: ov-typeinfo.cc:819
octave_value lookup_type(const std::string &nm)
Definition: ov-typeinfo.cc:776
octave::type_info::binary_op_fcn binary_op_fcn
Definition: ov-typeinfo.h:283
const octave_base_value const Array< octave_idx_type > & ra_idx
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))