GNU Octave  3.8.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-2013 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)
54  const Array<octave_idx_type>& ra_idx);
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
110  lookup_unary_class_op (octave_value::unary_op op)
111  {
112  return instance->do_lookup_unary_class_op (op);
113  }
114 
115  static unary_op_fcn
116  lookup_unary_op (octave_value::unary_op op, int t)
117  {
118  return instance->do_lookup_unary_op (op, t);
119  }
120 
121  static non_const_unary_op_fcn
122  lookup_non_const_unary_op (octave_value::unary_op op, int t)
123  {
124  return instance->do_lookup_non_const_unary_op (op, t);
125  }
126 
127  static binary_class_op_fcn
128  lookup_binary_class_op (octave_value::binary_op op)
129  {
130  return instance->do_lookup_binary_class_op (op);
131  }
132 
133  static binary_op_fcn
134  lookup_binary_op (octave_value::binary_op op, int t1, int t2)
135  {
136  return instance->do_lookup_binary_op (op, t1, t2);
137  }
138 
139  static binary_class_op_fcn
140  lookup_binary_class_op (octave_value::compound_binary_op op)
141  {
142  return instance->do_lookup_binary_class_op (op);
143  }
144 
145  static binary_op_fcn
146  lookup_binary_op (octave_value::compound_binary_op op, int t1, int t2)
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
164  lookup_assignany_op (octave_value::assign_op op, int t_lhs)
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 
187  static string_vector installed_type_names (void)
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