GNU Octave  6.2.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-2021 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 
40 namespace octave
41 {
42  class type_info
43  {
44  public:
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  // No copying!
71 
72  type_info (const type_info&) = delete;
73 
74  type_info& operator = (const type_info&) = delete;
75 
76  ~type_info (void) = default;
77 
78  // It is intentional that there is no install_type function.
79 
82  {
83  return register_unary_class_op (op, f, true);
84  }
85 
87  {
88  return register_unary_op (op, t, f, true);
89  }
90 
93  {
94  return register_non_const_unary_op (op, t, f, true);
95  }
96 
99  {
100  return register_binary_class_op (op, f, true);
101  }
102 
103  bool install_binary_op (octave_value::binary_op op, int t1, int t2,
105  {
106  return register_binary_op (op, t1, t2, f, true);
107  }
108 
111  {
112  return register_binary_class_op (op, f, true);
113  }
114 
116  int t_lhs, int t_rhs, binary_op_fcn f)
117  {
118  return register_binary_op (op, t_lhs, t_rhs, f, true);
119  }
120 
121  bool install_cat_op (int t1, int t2, cat_op_fcn f)
122  {
123  return register_cat_op (t1, t2, f, true);
124  }
125 
127  int t_lhs, int t_rhs, assign_op_fcn f)
128  {
129  return register_assign_op (op, t_lhs, t_rhs, f, true);
130  }
131 
134  {
135  return register_assignany_op (op, t_lhs, f, true);
136  }
137 
138  bool install_pref_assign_conv (int t_lhs, int t_rhs, int t_result)
139  {
140  return register_pref_assign_conv (t_lhs, t_rhs, t_result, true);
141  }
142 
143  bool install_widening_op (int t, int t_result,
145  {
146  return register_widening_op (t, t_result, f, true);
147  }
148 
149  int register_type (const std::string&, const std::string&,
150  const octave_value&, bool abort_on_duplicate = false);
151 
153  bool abort_on_duplicate = false);
154 
156  bool abort_on_duplicate = false);
157 
160  bool abort_on_duplicate = false);
161 
164  bool abort_on_duplicate = false);
165 
167  binary_op_fcn, bool abort_on_duplicate = false);
168 
171  bool abort_on_duplicate = false);
172 
174  binary_op_fcn, bool abort_on_duplicate = false);
175 
176  bool register_cat_op (int, int, cat_op_fcn,
177  bool abort_on_duplicate = false);
178 
180  bool abort_on_duplicate = false);
181 
183  bool abort_on_duplicate = false);
184 
185  bool register_pref_assign_conv (int, int, int,
186  bool abort_on_duplicate = false);
187 
189  bool abort_on_duplicate = false);
190 
191  octave_value lookup_type (const std::string& nm);
192 
194 
196 
199 
201 
203 
206 
209 
210  cat_op_fcn lookup_cat_op (int, int);
211 
213 
215 
216  int lookup_pref_assign_conv (int, int);
217 
219 
220  string_vector installed_type_names (void) const;
221 
223 
224  octave_scalar_map unary_ops_map (void) const;
225 
227 
228  octave_scalar_map binary_ops_map (void) const;
229 
231 
232  octave_scalar_map assign_ops_map (void) const;
233 
235 
236  private:
237 
239 
241 
243 
245 
247 
249 
251 
253 
255 
257 
259 
261 
263 
265 
267  };
268 }
269 
270 namespace octave_value_typeinfo
271 {
273 
275 
277 
279 
281 
283 
285 
287 
288  extern int register_type (const std::string& t_name,
289  const std::string& c_name,
290  const octave_value& val);
291 
292  extern octave_value lookup_type (const std::string& nm);
293 
295 
297 
300 
301  extern binary_class_op_fcn
303 
304  extern binary_op_fcn
305  lookup_binary_op (octave_value::binary_op op, int t1, int t2);
306 
307  extern binary_class_op_fcn
309 
310  extern binary_op_fcn
312 
313  extern cat_op_fcn lookup_cat_op (int t1, int t2);
314 
315  extern assign_op_fcn
316  lookup_assign_op (octave_value::assign_op op, int t_lhs, int t_rhs);
317 
318  extern assignany_op_fcn
320 
321  extern int lookup_pref_assign_conv (int t_lhs, int t_rhs);
322 
324  lookup_widening_op (int t, int t_result);
325 
326  extern string_vector installed_type_names (void);
327 
329 }
330 
331 #endif
bool install_assign_op(octave_value::assign_op op, int t_lhs, int t_rhs, assign_op_fcn f)
Definition: ov-typeinfo.h:126
unary_class_op_fcn lookup_unary_class_op(octave_value::unary_op)
Definition: ov-typeinfo.cc:497
octave_value(* assignany_op_fcn)(octave_base_value &, const octave_value_list &, const octave_value &)
Definition: ov-typeinfo.h:66
bool install_binary_op(octave_value::binary_op op, int t1, int t2, binary_op_fcn f)
Definition: ov-typeinfo.h:103
octave_scalar_map compound_binary_ops_map(void) const
Definition: ov-typeinfo.cc:668
bool install_widening_op(int t, int t_result, octave_base_value::type_conv_fcn f)
Definition: ov-typeinfo.h:143
Array< void * > assignany_ops
Definition: ov-typeinfo.h:262
Array< void * > unary_ops
Definition: ov-typeinfo.h:246
octave_value lookup_type(const std::string &nm)
Definition: ov-typeinfo.cc:479
unary_op_fcn lookup_unary_op(octave_value::unary_op, int)
Definition: ov-typeinfo.cc:504
bool register_unary_class_op(octave_value::unary_op, unary_class_op_fcn, bool abort_on_duplicate=false)
Definition: ov-typeinfo.cc:162
bool install_pref_assign_conv(int t_lhs, int t_rhs, int t_result)
Definition: ov-typeinfo.h:138
octave_value(* binary_class_op_fcn)(const octave_value &, const octave_value &)
Definition: ov-typeinfo.h:53
Array< octave_value * > vals
Definition: ov-typeinfo.h:242
bool install_cat_op(int t1, int t2, cat_op_fcn f)
Definition: ov-typeinfo.h:121
non_const_unary_op_fcn lookup_non_const_unary_op(octave_value::unary_op, int)
Definition: ov-typeinfo.cc:511
octave_scalar_map non_const_unary_ops_map(void) const
Definition: ov-typeinfo.cc:618
bool register_binary_class_op(octave_value::binary_op, binary_class_op_fcn, bool abort_on_duplicate=false)
Definition: ov-typeinfo.cc:239
octave_scalar_map binary_ops_map(void) const
Definition: ov-typeinfo.cc:643
Array< int > pref_assign_conv
Definition: ov-typeinfo.h:264
Array< void * > non_const_unary_ops
Definition: ov-typeinfo.h:248
Array< void * > compound_binary_class_ops
Definition: ov-typeinfo.h:254
int lookup_pref_assign_conv(int, int)
Definition: ov-typeinfo.cc:569
assign_op_fcn lookup_assign_op(octave_value::assign_op, int, int)
Definition: ov-typeinfo.cc:554
assignany_op_fcn lookup_assignany_op(octave_value::assign_op, int)
Definition: ov-typeinfo.cc:562
Array< void * > binary_class_ops
Definition: ov-typeinfo.h:250
bool install_unary_class_op(octave_value::unary_op op, unary_class_op_fcn f)
Definition: ov-typeinfo.h:80
Array< void * > compound_binary_ops
Definition: ov-typeinfo.h:256
octave_value(* unary_class_op_fcn)(const octave_value &)
Definition: ov-typeinfo.h:46
bool install_unary_op(octave_value::unary_op op, int t, unary_op_fcn f)
Definition: ov-typeinfo.h:86
Array< void * > widening_ops
Definition: ov-typeinfo.h:266
type_info(int init_tab_sz=16)
Definition: ov-typeinfo.cc:67
bool register_binary_op(octave_value::binary_op, int, int, binary_op_fcn, bool abort_on_duplicate=false)
Definition: ov-typeinfo.cc:265
bool install_non_const_unary_op(octave_value::unary_op op, int t, non_const_unary_op_fcn f)
Definition: ov-typeinfo.h:91
bool install_binary_class_op(octave_value::compound_binary_op op, binary_class_op_fcn f)
Definition: ov-typeinfo.h:109
~type_info(void)=default
bool register_cat_op(int, int, cat_op_fcn, bool abort_on_duplicate=false)
Definition: ov-typeinfo.cc:349
octave_scalar_map unary_ops_map(void) const
Definition: ov-typeinfo.cc:593
bool register_assign_op(octave_value::assign_op, int, int, assign_op_fcn, bool abort_on_duplicate=false)
Definition: ov-typeinfo.cc:373
octave_value(* assign_op_fcn)(octave_base_value &, const octave_value_list &, const octave_base_value &)
Definition: ov-typeinfo.h:63
Array< void * > assign_ops
Definition: ov-typeinfo.h:260
int register_type(const std::string &, const std::string &, const octave_value &, bool abort_on_duplicate=false)
Definition: ov-typeinfo.cc:88
octave_value(* binary_op_fcn)(const octave_base_value &, const octave_base_value &)
Definition: ov-typeinfo.h:56
octave_scalar_map installed_type_info(void) const
Definition: ov-typeinfo.cc:744
octave_value(* unary_op_fcn)(const octave_base_value &)
Definition: ov-typeinfo.h:48
bool register_non_const_unary_op(octave_value::unary_op, int, non_const_unary_op_fcn, bool abort_on_duplicate=false)
Definition: ov-typeinfo.cc:212
octave_value(* cat_op_fcn)(octave_base_value &, const octave_base_value &, const Array< octave_idx_type > &ra_idx)
Definition: ov-typeinfo.h:59
binary_class_op_fcn lookup_binary_class_op(octave_value::binary_op)
Definition: ov-typeinfo.cc:518
Array< void * > binary_ops
Definition: ov-typeinfo.h:252
octave_base_value::type_conv_fcn lookup_widening_op(int, int)
Definition: ov-typeinfo.cc:575
bool install_binary_op(octave_value::compound_binary_op op, int t_lhs, int t_rhs, binary_op_fcn f)
Definition: ov-typeinfo.h:115
bool register_assignany_op(octave_value::assign_op, int, assignany_op_fcn, bool abort_on_duplicate=false)
Definition: ov-typeinfo.cc:402
bool register_widening_op(int, int, octave_base_value::type_conv_fcn, bool abort_on_duplicate=false)
Definition: ov-typeinfo.cc:454
Array< void * > cat_ops
Definition: ov-typeinfo.h:258
type_info(const type_info &)=delete
binary_op_fcn lookup_binary_op(octave_value::binary_op, int, int)
Definition: ov-typeinfo.cc:525
Array< void * > unary_class_ops
Definition: ov-typeinfo.h:244
Array< std::string > types
Definition: ov-typeinfo.h:240
bool install_binary_class_op(octave_value::binary_op op, binary_class_op_fcn f)
Definition: ov-typeinfo.h:97
octave_scalar_map assign_ops_map(void) const
Definition: ov-typeinfo.cc:695
bool install_assignany_op(octave_value::assign_op op, int t_lhs, assignany_op_fcn f)
Definition: ov-typeinfo.h:132
cat_op_fcn lookup_cat_op(int, int)
Definition: ov-typeinfo.cc:547
type_info & operator=(const type_info &)=delete
string_vector installed_type_names(void) const
Definition: ov-typeinfo.cc:582
void(* non_const_unary_op_fcn)(octave_base_value &)
Definition: ov-typeinfo.h:50
octave_scalar_map assignany_ops_map(void) const
Definition: ov-typeinfo.cc:720
bool register_pref_assign_conv(int, int, int, bool abort_on_duplicate=false)
Definition: ov-typeinfo.cc:428
bool register_unary_op(octave_value::unary_op, int, unary_op_fcn, bool abort_on_duplicate=false)
Definition: ov-typeinfo.cc:187
octave_base_value *(* type_conv_fcn)(const octave_base_value &)
Definition: ov-base.h:207
unary_op
Definition: ov.h:83
compound_binary_op
Definition: ov.h:121
assign_op
Definition: ov.h:138
binary_op
Definition: ov.h:96
binary_class_op_fcn lookup_binary_class_op(octave_value::binary_op op)
Definition: ov-typeinfo.cc:808
octave::type_info::cat_op_fcn cat_op_fcn
Definition: ov-typeinfo.h:282
octave::type_info::assign_op_fcn assign_op_fcn
Definition: ov-typeinfo.h:284
unary_class_op_fcn lookup_unary_class_op(octave_value::unary_op op)
Definition: ov-typeinfo.cc:782
int lookup_pref_assign_conv(int t_lhs, int t_rhs)
Definition: ov-typeinfo.cc:869
unary_op_fcn lookup_unary_op(octave_value::unary_op op, int t)
Definition: ov-typeinfo.cc:790
octave::type_info::unary_class_op_fcn unary_class_op_fcn
Definition: ov-typeinfo.h:272
octave::type_info::assignany_op_fcn assignany_op_fcn
Definition: ov-typeinfo.h:286
string_vector installed_type_names(void)
Definition: ov-typeinfo.cc:886
octave_value lookup_type(const std::string &nm)
Definition: ov-typeinfo.cc:774
assign_op_fcn lookup_assign_op(octave_value::assign_op op, int t_lhs, int t_rhs)
Definition: ov-typeinfo.cc:852
non_const_unary_op_fcn lookup_non_const_unary_op(octave_value::unary_op op, int t)
Definition: ov-typeinfo.cc:799
assignany_op_fcn lookup_assignany_op(octave_value::assign_op op, int t_lhs)
Definition: ov-typeinfo.cc:861
binary_op_fcn lookup_binary_op(octave_value::binary_op op, int t1, int t2)
Definition: ov-typeinfo.cc:817
int register_type(const std::string &t_name, const std::string &c_name, const octave_value &val)
Definition: ov-typeinfo.cc:765
octave_scalar_map installed_type_info(void)
Definition: ov-typeinfo.cc:894
octave::type_info::non_const_unary_op_fcn non_const_unary_op_fcn
Definition: ov-typeinfo.h:276
octave::type_info::unary_op_fcn unary_op_fcn
Definition: ov-typeinfo.h:274
octave::type_info::binary_class_op_fcn binary_class_op_fcn
Definition: ov-typeinfo.h:278
octave::type_info::binary_op_fcn binary_op_fcn
Definition: ov-typeinfo.h:280
octave_base_value::type_conv_fcn lookup_widening_op(int t, int t_result)
Definition: ov-typeinfo.cc:878
cat_op_fcn lookup_cat_op(int t1, int t2)
Definition: ov-typeinfo.cc:843
static double f(double k, double l_nu, double c_pm)
Definition: randpoisson.cc:118
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()) ? '\'' :'"'))