GNU Octave  9.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-2024 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 
38 class string_vector;
39 
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 
61  (const octave_base_value&, const octave_base_value&,
63 
66 
69 
70  explicit type_info (int init_tab_sz = 16);
71 
72  OCTAVE_DISABLE_COPY_MOVE (type_info)
73 
74  ~type_info () = default;
75 
76  // It is intentional that there is no install_type function.
77 
80  {
81  return register_unary_class_op (op, f, true);
82  }
83 
85  {
86  return register_unary_op (op, t, f, true);
87  }
88 
91  {
92  return register_non_const_unary_op (op, t, f, true);
93  }
94 
97  {
98  return register_binary_class_op (op, f, true);
99  }
100 
101  bool install_binary_op (octave_value::binary_op op, int t1, int t2,
103  {
104  return register_binary_op (op, t1, t2, f, true);
105  }
106 
109  {
110  return register_binary_class_op (op, f, true);
111  }
112 
114  int t_lhs, int t_rhs, binary_op_fcn f)
115  {
116  return register_binary_op (op, t_lhs, t_rhs, f, true);
117  }
118 
119  bool install_cat_op (int t1, int t2, cat_op_fcn f)
120  {
121  return register_cat_op (t1, t2, f, true);
122  }
123 
125  int t_lhs, int t_rhs, assign_op_fcn f)
126  {
127  return register_assign_op (op, t_lhs, t_rhs, f, true);
128  }
129 
132  {
133  return register_assignany_op (op, t_lhs, f, true);
134  }
135 
136  bool install_pref_assign_conv (int t_lhs, int t_rhs, int t_result)
137  {
138  return register_pref_assign_conv (t_lhs, t_rhs, t_result, true);
139  }
140 
141  bool install_widening_op (int t, int t_result,
143  {
144  return register_widening_op (t, t_result, f, true);
145  }
146 
147  int register_type (const std::string&, const std::string&,
148  const octave_value&, bool abort_on_duplicate = false);
149 
150  bool register_unary_class_op (octave_value::unary_op, unary_class_op_fcn,
151  bool abort_on_duplicate = false);
152 
153  bool register_unary_op (octave_value::unary_op, int, unary_op_fcn,
154  bool abort_on_duplicate = false);
155 
156  bool register_non_const_unary_op (octave_value::unary_op, int,
158  bool abort_on_duplicate = false);
159 
162  bool abort_on_duplicate = false);
163 
165  binary_op_fcn, bool abort_on_duplicate = false);
166 
169  bool abort_on_duplicate = false);
170 
172  binary_op_fcn, bool abort_on_duplicate = false);
173 
174  bool register_cat_op (int, int, cat_op_fcn,
175  bool abort_on_duplicate = false);
176 
177  bool register_assign_op (octave_value::assign_op, int, int, assign_op_fcn,
178  bool abort_on_duplicate = false);
179 
180  bool register_assignany_op (octave_value::assign_op, int, assignany_op_fcn,
181  bool abort_on_duplicate = false);
182 
183  bool register_pref_assign_conv (int, int, int,
184  bool abort_on_duplicate = false);
185 
186  bool register_widening_op (int, int, octave_base_value::type_conv_fcn,
187  bool abort_on_duplicate = false);
188 
189  octave_value lookup_type (const std::string& nm);
190 
192 
194 
197 
199 
201 
204 
207 
208  cat_op_fcn lookup_cat_op (int, int);
209 
211 
213 
214  int lookup_pref_assign_conv (int, int);
215 
217 
219 
221 
222  octave_scalar_map unary_ops_map () const;
223 
224  octave_scalar_map non_const_unary_ops_map () const;
225 
226  octave_scalar_map binary_ops_map () const;
227 
228  octave_scalar_map compound_binary_ops_map () const;
229 
230  octave_scalar_map assign_ops_map () const;
231 
232  octave_scalar_map assignany_ops_map () const;
233 
234 private:
235 
236  int m_num_types;
237 
238  Array<std::string> m_types;
239 
240  Array<octave_value *> m_vals;
241 
242  Array<void *> m_unary_class_ops;
243 
244  Array<void *> m_unary_ops;
245 
246  Array<void *> m_non_const_unary_ops;
247 
248  Array<void *> m_binary_class_ops;
249 
250  Array<void *> m_binary_ops;
251 
252  Array<void *> m_compound_binary_class_ops;
253 
254  Array<void *> m_compound_binary_ops;
255 
256  Array<void *> m_cat_ops;
257 
258  Array<void *> m_assign_ops;
259 
260  Array<void *> m_assignany_ops;
261 
262  Array<int> m_pref_assign_conv;
263 
264  Array<void *> m_widening_ops;
265 };
266 
267 OCTAVE_END_NAMESPACE(octave)
268 
269 OCTAVE_BEGIN_NAMESPACE(octave_value_typeinfo)
270 
272 
274 
276 
278 
280 
282 
284 
286 
287 extern OCTINTERP_API int register_type (const std::string& t_name,
288  const std::string& c_name,
289  const octave_value& val);
290 
291 extern OCTINTERP_API octave_value lookup_type (const std::string& nm);
292 
293 extern OCTINTERP_API unary_class_op_fcn
295 
296 extern OCTINTERP_API unary_op_fcn
298 
299 extern OCTINTERP_API non_const_unary_op_fcn
301 
302 extern OCTINTERP_API binary_class_op_fcn
304 
305 extern OCTINTERP_API binary_op_fcn
306 lookup_binary_op (octave_value::binary_op op, int t1, int t2);
307 
308 extern OCTINTERP_API binary_class_op_fcn
309 lookup_binary_class_op (octave_value::compound_binary_op op);
310 
311 extern OCTINTERP_API binary_op_fcn
312 lookup_binary_op (octave_value::compound_binary_op op, int t1, int t2);
313 
314 extern OCTINTERP_API cat_op_fcn lookup_cat_op (int t1, int t2);
315 
316 extern OCTINTERP_API assign_op_fcn
317 lookup_assign_op (octave_value::assign_op op, int t_lhs, int t_rhs);
318 
319 extern OCTINTERP_API assignany_op_fcn
320 lookup_assignany_op (octave_value::assign_op op, int t_lhs);
321 
322 extern OCTINTERP_API int lookup_pref_assign_conv (int t_lhs, int t_rhs);
323 
324 extern OCTINTERP_API octave_base_value::type_conv_fcn
325 lookup_widening_op (int t, int t_result);
326 
327 extern OCTINTERP_API string_vector installed_type_names ();
328 
329 extern OCTINTERP_API octave_scalar_map installed_type_info ();
330 
331 OCTAVE_END_NAMESPACE(octave_value_typeinfo)
332 
333 #endif
octave_base_value *(* type_conv_fcn)(const octave_base_value &)
Definition: ov-base.h:248
unary_op
Definition: ov.h:79
compound_binary_op
Definition: ov.h:117
assign_op
Definition: ov.h:134
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)
Definition: ov-typeinfo.h:107
bool install_widening_op(int t, int t_result, octave_base_value::type_conv_fcn f)
Definition: ov-typeinfo.h:141
bool install_cat_op(int t1, int t2, cat_op_fcn f)
Definition: ov-typeinfo.h:119
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)
Definition: ov-typeinfo.h:130
bool install_non_const_unary_op(octave_value::unary_op op, int t, non_const_unary_op_fcn f)
Definition: ov-typeinfo.h:89
bool install_unary_op(octave_value::unary_op op, int t, unary_op_fcn f)
Definition: ov-typeinfo.h:84
~type_info()=default
bool install_binary_op(octave_value::compound_binary_op op, int t_lhs, int t_rhs, binary_op_fcn f)
Definition: ov-typeinfo.h:113
bool install_pref_assign_conv(int t_lhs, int t_rhs, int t_result)
Definition: ov-typeinfo.h:136
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)
Definition: ov-typeinfo.h:124
bool install_unary_class_op(octave_value::unary_op op, unary_class_op_fcn f)
Definition: ov-typeinfo.h:78
bool install_binary_class_op(octave_value::binary_op op, binary_class_op_fcn f)
Definition: ov-typeinfo.h:95
bool install_binary_op(octave_value::binary_op op, int t1, int t2, binary_op_fcn f)
Definition: ov-typeinfo.h:101
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
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value lookup_type(const std::string &nm)
Definition: ov-typeinfo.cc:793
octave_base_value::type_conv_fcn lookup_widening_op(int t, int t_result)
Definition: ov-typeinfo.cc:889
octave::type_info::binary_op_fcn binary_op_fcn
Definition: ov-typeinfo.h:279
unary_class_op_fcn lookup_unary_class_op(octave_value::unary_op op)
Definition: ov-typeinfo.cc:801
non_const_unary_op_fcn lookup_non_const_unary_op(octave_value::unary_op op, int t)
Definition: ov-typeinfo.cc:817
octave_scalar_map installed_type_info()
Definition: ov-typeinfo.cc:905
octave::type_info::binary_class_op_fcn binary_class_op_fcn
Definition: ov-typeinfo.h:277
int register_type(const std::string &t_name, const std::string &c_name, const octave_value &val)
Definition: ov-typeinfo.cc:784
octave::type_info::assign_op_fcn assign_op_fcn
Definition: ov-typeinfo.h:283
octave::type_info::non_const_unary_op_fcn non_const_unary_op_fcn
Definition: ov-typeinfo.h:275
octave::type_info::assignany_op_fcn assignany_op_fcn
Definition: ov-typeinfo.h:285
octave::type_info::unary_op_fcn unary_op_fcn
Definition: ov-typeinfo.h:273
binary_op_fcn lookup_binary_op(octave_value::binary_op op, int t1, int t2)
Definition: ov-typeinfo.cc:833
binary_class_op_fcn lookup_binary_class_op(octave_value::binary_op op)
Definition: ov-typeinfo.cc:825
assign_op_fcn lookup_assign_op(octave_value::assign_op op, int t_lhs, int t_rhs)
Definition: ov-typeinfo.cc:865
string_vector installed_type_names()
Definition: ov-typeinfo.cc:897
unary_op_fcn lookup_unary_op(octave_value::unary_op op, int t)
Definition: ov-typeinfo.cc:809
assignany_op_fcn lookup_assignany_op(octave_value::assign_op op, int t_lhs)
Definition: ov-typeinfo.cc:873
octave::type_info::cat_op_fcn cat_op_fcn
Definition: ov-typeinfo.h:281
int lookup_pref_assign_conv(int t_lhs, int t_rhs)
Definition: ov-typeinfo.cc:881
octave::type_info::unary_class_op_fcn unary_class_op_fcn
Definition: ov-typeinfo.h:271
cat_op_fcn lookup_cat_op(int t1, int t2)
Definition: ov-typeinfo.cc:857
octave_value binary_op(type_info &ti, octave_value::binary_op op, const octave_value &a, const octave_value &b)
octave_value unary_op(type_info &ti, octave_value::unary_op op, const octave_value &a)