GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ov-typeinfo.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2015 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_ov_typeinfo_h)
24 #define octave_ov_typeinfo_h 1
25 
26 #include <string>
27 
28 #include "Array.h"
29 
30 #include "ov.h"
31 
32 class string_vector;
33 
34 class
37 {
38 public:
39 
40  typedef octave_value (*unary_class_op_fcn) (const octave_value&);
41 
42  typedef octave_value (*unary_op_fcn) (const octave_base_value&);
43 
44  typedef void (*non_const_unary_op_fcn) (octave_base_value&);
45 
46  typedef octave_value (*binary_class_op_fcn)
47  (const octave_value&, const octave_value&);
48 
49  typedef octave_value (*binary_op_fcn)
51 
52  typedef octave_value (*cat_op_fcn)
55 
56  typedef octave_value (*assign_op_fcn)
57  (octave_base_value&, const octave_value_list&, const octave_base_value&);
58 
59  typedef octave_value (*assignany_op_fcn)
60  (octave_base_value&, const octave_value_list&, const octave_value&);
61 
62  static bool instance_ok (void);
63 
64  static int register_type (const std::string&, const std::string&,
65  const octave_value&);
66 
67  static bool register_unary_class_op (octave_value::unary_op,
68  unary_class_op_fcn);
69 
70  static bool register_unary_op (octave_value::unary_op, int, unary_op_fcn);
71 
72  static bool register_non_const_unary_op (octave_value::unary_op, int,
73  non_const_unary_op_fcn);
74 
75  static bool register_binary_class_op (octave_value::binary_op,
76  binary_class_op_fcn);
77 
78  static bool register_binary_op (octave_value::binary_op, int, int,
79  binary_op_fcn);
80 
81  static bool register_binary_class_op (octave_value::compound_binary_op,
82  binary_class_op_fcn);
83 
84  static bool register_binary_op (octave_value::compound_binary_op, int, int,
85  binary_op_fcn);
86 
87  static bool register_cat_op (int, int, cat_op_fcn);
88 
89  static bool register_assign_op (octave_value::assign_op, int, int,
90  assign_op_fcn);
91 
92  static bool register_assignany_op (octave_value::assign_op, int,
93  assignany_op_fcn);
94 
95  static bool register_pref_assign_conv (int, int, int);
96 
97  static bool
98  register_type_conv_op (int, int, octave_base_value::type_conv_fcn);
99 
100  static bool
101  register_widening_op (int, int, octave_base_value::type_conv_fcn);
102 
103  static octave_value
104  lookup_type (const std::string& nm)
105  {
106  return instance->do_lookup_type (nm);
107  }
108 
109  static unary_class_op_fcn
111  {
112  return instance->do_lookup_unary_class_op (op);
113  }
114 
115  static unary_op_fcn
117  {
118  return instance->do_lookup_unary_op (op, t);
119  }
120 
121  static non_const_unary_op_fcn
123  {
124  return instance->do_lookup_non_const_unary_op (op, t);
125  }
126 
127  static binary_class_op_fcn
129  {
130  return instance->do_lookup_binary_class_op (op);
131  }
132 
133  static binary_op_fcn
135  {
136  return instance->do_lookup_binary_op (op, t1, t2);
137  }
138 
139  static binary_class_op_fcn
141  {
142  return instance->do_lookup_binary_class_op (op);
143  }
144 
145  static binary_op_fcn
147  {
148  return instance->do_lookup_binary_op (op, t1, t2);
149  }
150 
151  static cat_op_fcn
152  lookup_cat_op (int t1, int t2)
153  {
154  return instance->do_lookup_cat_op (t1, t2);
155  }
156 
157  static assign_op_fcn
158  lookup_assign_op (octave_value::assign_op op, int t_lhs, int t_rhs)
159  {
160  return instance->do_lookup_assign_op (op, t_lhs, t_rhs);
161  }
162 
163  static assignany_op_fcn
165  {
166  return instance->do_lookup_assignany_op (op, t_lhs);
167  }
168 
169  static int
170  lookup_pref_assign_conv (int t_lhs, int t_rhs)
171  {
172  return instance->do_lookup_pref_assign_conv (t_lhs, t_rhs);
173  }
174 
176  lookup_type_conv_op (int t, int t_result)
177  {
178  return instance->do_lookup_type_conv_op (t, t_result);
179  }
180 
182  lookup_widening_op (int t, int t_result)
183  {
184  return instance->do_lookup_widening_op (t, t_result);
185  }
186 
188  {
189  return instance->do_installed_type_names ();
190  }
191 
192 protected:
193 
195  : num_types (0), types (dim_vector (init_tab_sz, 1), std::string ()),
196  vals (dim_vector (init_tab_sz, 1)),
197  unary_class_ops (dim_vector (octave_value::num_unary_ops, 1), 0),
198  unary_ops (dim_vector (octave_value::num_unary_ops, init_tab_sz), 0),
199  non_const_unary_ops (dim_vector (octave_value::num_unary_ops, init_tab_sz), 0),
200  binary_class_ops (dim_vector (octave_value::num_binary_ops, 1), 0),
201  binary_ops (dim_vector (octave_value::num_binary_ops, init_tab_sz, init_tab_sz), 0),
202  compound_binary_class_ops (dim_vector (octave_value::num_compound_binary_ops, 1), 0),
203  compound_binary_ops (dim_vector (octave_value::num_compound_binary_ops, init_tab_sz, init_tab_sz), 0),
204  cat_ops (dim_vector (init_tab_sz, init_tab_sz), 0),
205  assign_ops (dim_vector (octave_value::num_assign_ops, init_tab_sz, init_tab_sz), 0),
206  assignany_ops (dim_vector (octave_value::num_assign_ops, init_tab_sz), 0),
207  pref_assign_conv (dim_vector (init_tab_sz, init_tab_sz), -1),
208  type_conv_ops (dim_vector (init_tab_sz, init_tab_sz), 0),
209  widening_ops (dim_vector (init_tab_sz, init_tab_sz), 0) { }
210 
212 
213 private:
214 
215  static const int init_tab_sz;
216 
218 
219  static void cleanup_instance (void) { delete instance; instance = 0; }
220 
222 
224 
226 
228 
230 
232 
234 
236 
238 
240 
242 
244 
246 
248 
250 
252 
253  int do_register_type (const std::string&, const std::string&,
254  const octave_value&);
255 
256  bool do_register_unary_class_op (octave_value::unary_op, unary_class_op_fcn);
257 
258  bool do_register_unary_op (octave_value::unary_op, int, unary_op_fcn);
259 
260  bool do_register_non_const_unary_op (octave_value::unary_op, int,
261  non_const_unary_op_fcn);
262 
263  bool do_register_binary_class_op (octave_value::binary_op,
264  binary_class_op_fcn);
265 
266  bool do_register_binary_op (octave_value::binary_op, int, int,
267  binary_op_fcn);
268 
269  bool do_register_binary_class_op (octave_value::compound_binary_op,
270  binary_class_op_fcn);
271 
272  bool do_register_binary_op (octave_value::compound_binary_op, int, int,
273  binary_op_fcn);
274 
275  bool do_register_cat_op (int, int, cat_op_fcn);
276 
277  bool do_register_assign_op (octave_value::assign_op, int, int,
278  assign_op_fcn);
279 
280  bool do_register_assignany_op (octave_value::assign_op, int,
281  assignany_op_fcn);
282 
283  bool do_register_pref_assign_conv (int, int, int);
284 
285  bool do_register_type_conv_op (int, int, octave_base_value::type_conv_fcn);
286 
287  bool do_register_widening_op (int, int, octave_base_value::type_conv_fcn);
288 
289  octave_value do_lookup_type (const std::string& nm);
290 
291  unary_class_op_fcn do_lookup_unary_class_op (octave_value::unary_op);
292 
293  unary_op_fcn do_lookup_unary_op (octave_value::unary_op, int);
294 
295  non_const_unary_op_fcn do_lookup_non_const_unary_op
296  (octave_value::unary_op, int);
297 
298  binary_class_op_fcn do_lookup_binary_class_op (octave_value::binary_op);
299 
300  binary_op_fcn do_lookup_binary_op (octave_value::binary_op, int, int);
301 
302  binary_class_op_fcn do_lookup_binary_class_op (octave_value::compound_binary_op);
303 
304  binary_op_fcn do_lookup_binary_op (octave_value::compound_binary_op,
305  int, int);
306 
307  cat_op_fcn do_lookup_cat_op (int, int);
308 
309  assign_op_fcn do_lookup_assign_op (octave_value::assign_op, int, int);
310 
311  assignany_op_fcn do_lookup_assignany_op (octave_value::assign_op, int);
312 
313  int do_lookup_pref_assign_conv (int, int);
314 
315  octave_base_value::type_conv_fcn do_lookup_type_conv_op (int, int);
316 
317  octave_base_value::type_conv_fcn do_lookup_widening_op (int, int);
318 
319  string_vector do_installed_type_names (void);
320 
321  // No copying!
322 
324 
326 };
327 
328 #endif
static const int init_tab_sz
Definition: ov-typeinfo.h:215
Array< void * > binary_ops
Definition: ov-typeinfo.h:235
assign_op
Definition: ov.h:131
const octave_base_value const Array< octave_idx_type > & ra_idx
static void cleanup_instance(void)
Definition: ov-typeinfo.h:219
static string_vector installed_type_names(void)
Definition: ov-typeinfo.h:187
static non_const_unary_op_fcn lookup_non_const_unary_op(octave_value::unary_op op, int t)
Definition: ov-typeinfo.h:122
Array< int > pref_assign_conv
Definition: ov-typeinfo.h:247
Array< octave_value > vals
Definition: ov-typeinfo.h:225
binary_op
Definition: ov.h:87
Array< void * > binary_class_ops
Definition: ov-typeinfo.h:233
STL namespace.
static binary_op_fcn lookup_binary_op(octave_value::binary_op op, int t1, int t2)
Definition: ov-typeinfo.h:134
static int lookup_pref_assign_conv(int t_lhs, int t_rhs)
Definition: ov-typeinfo.h:170
static octave_value_typeinfo * instance
Definition: ov-typeinfo.h:217
static unary_class_op_fcn lookup_unary_class_op(octave_value::unary_op op)
Definition: ov-typeinfo.h:110
static octave_value lookup_type(const std::string &nm)
Definition: ov-typeinfo.h:104
#define OCTINTERP_API
Definition: mexproto.h:66
static assignany_op_fcn lookup_assignany_op(octave_value::assign_op op, int t_lhs)
Definition: ov-typeinfo.h:164
static octave_base_value::type_conv_fcn lookup_type_conv_op(int t, int t_result)
Definition: ov-typeinfo.h:176
Array< void * > non_const_unary_ops
Definition: ov-typeinfo.h:231
Array< void * > assignany_ops
Definition: ov-typeinfo.h:245
Array< void * > unary_class_ops
Definition: ov-typeinfo.h:227
string_vector & operator=(const string_vector &s)
Definition: str-vec.h:63
static binary_class_op_fcn lookup_binary_class_op(octave_value::binary_op op)
Definition: ov-typeinfo.h:128
Array< void * > cat_ops
Definition: ov-typeinfo.h:241
Array< void * > type_conv_ops
Definition: ov-typeinfo.h:249
static cat_op_fcn lookup_cat_op(int t1, int t2)
Definition: ov-typeinfo.h:152
octave_base_value *(* type_conv_fcn)(const octave_base_value &)
Definition: ov-base.h:185
static binary_class_op_fcn lookup_binary_class_op(octave_value::compound_binary_op op)
Definition: ov-typeinfo.h:140
Array< void * > unary_ops
Definition: ov-typeinfo.h:229
Array< void * > assign_ops
Definition: ov-typeinfo.h:243
compound_binary_op
Definition: ov.h:114
Array< void * > widening_ops
Definition: ov-typeinfo.h:251
static assign_op_fcn lookup_assign_op(octave_value::assign_op op, int t_lhs, int t_rhs)
Definition: ov-typeinfo.h:158
Array< void * > compound_binary_ops
Definition: ov-typeinfo.h:239
unary_op
Definition: ov.h:74
Array< std::string > types
Definition: ov-typeinfo.h:223
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
static unary_op_fcn lookup_unary_op(octave_value::unary_op op, int t)
Definition: ov-typeinfo.h:116
Array< void * > compound_binary_class_ops
Definition: ov-typeinfo.h:237
static octave_base_value::type_conv_fcn lookup_widening_op(int t, int t_result)
Definition: ov-typeinfo.h:182
static binary_op_fcn lookup_binary_op(octave_value::compound_binary_op op, int t1, int t2)
Definition: ov-typeinfo.h:146