00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (octave_value_typeinfo_h)
00024 #define octave_value_typeinfo_h 1
00025
00026 #include <string>
00027
00028 #include "Array.h"
00029
00030 #include "ov.h"
00031
00032 class string_vector;
00033
00034 class
00035 OCTINTERP_API
00036 octave_value_typeinfo
00037 {
00038 public:
00039
00040 typedef octave_value (*unary_class_op_fcn) (const octave_value&);
00041
00042 typedef octave_value (*unary_op_fcn) (const octave_base_value&);
00043
00044 typedef void (*non_const_unary_op_fcn) (octave_base_value&);
00045
00046 typedef octave_value (*binary_class_op_fcn)
00047 (const octave_value&, const octave_value&);
00048
00049 typedef octave_value (*binary_op_fcn)
00050 (const octave_base_value&, const octave_base_value&);
00051
00052 typedef octave_value (*cat_op_fcn)
00053 (octave_base_value&, const octave_base_value&,
00054 const Array<octave_idx_type>& ra_idx);
00055
00056 typedef octave_value (*assign_op_fcn)
00057 (octave_base_value&, const octave_value_list&, const octave_base_value&);
00058
00059 typedef octave_value (*assignany_op_fcn)
00060 (octave_base_value&, const octave_value_list&, const octave_value&);
00061
00062 static bool instance_ok (void);
00063
00064 static int register_type (const std::string&, const std::string&,
00065 const octave_value&);
00066
00067 static bool register_unary_class_op (octave_value::unary_op,
00068 unary_class_op_fcn);
00069
00070 static bool register_unary_op (octave_value::unary_op, int, unary_op_fcn);
00071
00072 static bool register_non_const_unary_op (octave_value::unary_op, int,
00073 non_const_unary_op_fcn);
00074
00075 static bool register_binary_class_op (octave_value::binary_op,
00076 binary_class_op_fcn);
00077
00078 static bool register_binary_op (octave_value::binary_op, int, int,
00079 binary_op_fcn);
00080
00081 static bool register_binary_class_op (octave_value::compound_binary_op,
00082 binary_class_op_fcn);
00083
00084 static bool register_binary_op (octave_value::compound_binary_op, int, int,
00085 binary_op_fcn);
00086
00087 static bool register_cat_op (int, int, cat_op_fcn);
00088
00089 static bool register_assign_op (octave_value::assign_op, int, int,
00090 assign_op_fcn);
00091
00092 static bool register_assignany_op (octave_value::assign_op, int,
00093 assignany_op_fcn);
00094
00095 static bool register_pref_assign_conv (int, int, int);
00096
00097 static bool
00098 register_type_conv_op (int, int, octave_base_value::type_conv_fcn);
00099
00100 static bool
00101 register_widening_op (int, int, octave_base_value::type_conv_fcn);
00102
00103 static octave_value
00104 lookup_type (const std::string& nm)
00105 {
00106 return instance->do_lookup_type (nm);
00107 }
00108
00109 static unary_class_op_fcn
00110 lookup_unary_class_op (octave_value::unary_op op)
00111 {
00112 return instance->do_lookup_unary_class_op (op);
00113 }
00114
00115 static unary_op_fcn
00116 lookup_unary_op (octave_value::unary_op op, int t)
00117 {
00118 return instance->do_lookup_unary_op (op, t);
00119 }
00120
00121 static non_const_unary_op_fcn
00122 lookup_non_const_unary_op (octave_value::unary_op op, int t)
00123 {
00124 return instance->do_lookup_non_const_unary_op (op, t);
00125 }
00126
00127 static binary_class_op_fcn
00128 lookup_binary_class_op (octave_value::binary_op op)
00129 {
00130 return instance->do_lookup_binary_class_op (op);
00131 }
00132
00133 static binary_op_fcn
00134 lookup_binary_op (octave_value::binary_op op, int t1, int t2)
00135 {
00136 return instance->do_lookup_binary_op (op, t1, t2);
00137 }
00138
00139 static binary_class_op_fcn
00140 lookup_binary_class_op (octave_value::compound_binary_op op)
00141 {
00142 return instance->do_lookup_binary_class_op (op);
00143 }
00144
00145 static binary_op_fcn
00146 lookup_binary_op (octave_value::compound_binary_op op, int t1, int t2)
00147 {
00148 return instance->do_lookup_binary_op (op, t1, t2);
00149 }
00150
00151 static cat_op_fcn
00152 lookup_cat_op (int t1, int t2)
00153 {
00154 return instance->do_lookup_cat_op (t1, t2);
00155 }
00156
00157 static assign_op_fcn
00158 lookup_assign_op (octave_value::assign_op op, int t_lhs, int t_rhs)
00159 {
00160 return instance->do_lookup_assign_op (op, t_lhs, t_rhs);
00161 }
00162
00163 static assignany_op_fcn
00164 lookup_assignany_op (octave_value::assign_op op, int t_lhs)
00165 {
00166 return instance->do_lookup_assignany_op (op, t_lhs);
00167 }
00168
00169 static int
00170 lookup_pref_assign_conv (int t_lhs, int t_rhs)
00171 {
00172 return instance->do_lookup_pref_assign_conv (t_lhs, t_rhs);
00173 }
00174
00175 static octave_base_value::type_conv_fcn
00176 lookup_type_conv_op (int t, int t_result)
00177 {
00178 return instance->do_lookup_type_conv_op (t, t_result);
00179 }
00180
00181 static octave_base_value::type_conv_fcn
00182 lookup_widening_op (int t, int t_result)
00183 {
00184 return instance->do_lookup_widening_op (t, t_result);
00185 }
00186
00187 static string_vector installed_type_names (void)
00188 {
00189 return instance->do_installed_type_names ();
00190 }
00191
00192 protected:
00193
00194 octave_value_typeinfo (void)
00195 : num_types (0), types (dim_vector (init_tab_sz, 1), std::string ()),
00196 vals (dim_vector (init_tab_sz, 1)),
00197 unary_class_ops (dim_vector (octave_value::num_unary_ops, 1), 0),
00198 unary_ops (dim_vector (octave_value::num_unary_ops, init_tab_sz), 0),
00199 non_const_unary_ops (dim_vector (octave_value::num_unary_ops, init_tab_sz), 0),
00200 binary_class_ops (dim_vector (octave_value::num_binary_ops, 1), 0),
00201 binary_ops (dim_vector (octave_value::num_binary_ops, init_tab_sz, init_tab_sz), 0),
00202 compound_binary_class_ops (dim_vector (octave_value::num_compound_binary_ops, 1), 0),
00203 compound_binary_ops (dim_vector (octave_value::num_compound_binary_ops, init_tab_sz, init_tab_sz), 0),
00204 cat_ops (dim_vector (init_tab_sz, init_tab_sz), 0),
00205 assign_ops (dim_vector (octave_value::num_assign_ops, init_tab_sz, init_tab_sz), 0),
00206 assignany_ops (dim_vector (octave_value::num_assign_ops, init_tab_sz), 0),
00207 pref_assign_conv (dim_vector (init_tab_sz, init_tab_sz), -1),
00208 type_conv_ops (dim_vector (init_tab_sz, init_tab_sz), 0),
00209 widening_ops (dim_vector (init_tab_sz, init_tab_sz), 0) { }
00210
00211 ~octave_value_typeinfo (void) { }
00212
00213 private:
00214
00215 static const int init_tab_sz;
00216
00217 static octave_value_typeinfo *instance;
00218
00219 static void cleanup_instance (void) { delete instance; instance = 0; }
00220
00221 int num_types;
00222
00223 Array<std::string> types;
00224
00225 Array<octave_value> vals;
00226
00227 Array<void *> unary_class_ops;
00228
00229 Array<void *> unary_ops;
00230
00231 Array<void *> non_const_unary_ops;
00232
00233 Array<void *> binary_class_ops;
00234
00235 Array<void *> binary_ops;
00236
00237 Array<void *> compound_binary_class_ops;
00238
00239 Array<void *> compound_binary_ops;
00240
00241 Array<void *> cat_ops;
00242
00243 Array<void *> assign_ops;
00244
00245 Array<void *> assignany_ops;
00246
00247 Array<int> pref_assign_conv;
00248
00249 Array<void *> type_conv_ops;
00250
00251 Array<void *> widening_ops;
00252
00253 int do_register_type (const std::string&, const std::string&,
00254 const octave_value&);
00255
00256 bool do_register_unary_class_op (octave_value::unary_op, unary_class_op_fcn);
00257
00258 bool do_register_unary_op (octave_value::unary_op, int, unary_op_fcn);
00259
00260 bool do_register_non_const_unary_op (octave_value::unary_op, int,
00261 non_const_unary_op_fcn);
00262
00263 bool do_register_binary_class_op (octave_value::binary_op,
00264 binary_class_op_fcn);
00265
00266 bool do_register_binary_op (octave_value::binary_op, int, int,
00267 binary_op_fcn);
00268
00269 bool do_register_binary_class_op (octave_value::compound_binary_op,
00270 binary_class_op_fcn);
00271
00272 bool do_register_binary_op (octave_value::compound_binary_op, int, int,
00273 binary_op_fcn);
00274
00275 bool do_register_cat_op (int, int, cat_op_fcn);
00276
00277 bool do_register_assign_op (octave_value::assign_op, int, int,
00278 assign_op_fcn);
00279
00280 bool do_register_assignany_op (octave_value::assign_op, int,
00281 assignany_op_fcn);
00282
00283 bool do_register_pref_assign_conv (int, int, int);
00284
00285 bool do_register_type_conv_op (int, int, octave_base_value::type_conv_fcn);
00286
00287 bool do_register_widening_op (int, int, octave_base_value::type_conv_fcn);
00288
00289 octave_value do_lookup_type (const std::string& nm);
00290
00291 unary_class_op_fcn do_lookup_unary_class_op (octave_value::unary_op);
00292
00293 unary_op_fcn do_lookup_unary_op (octave_value::unary_op, int);
00294
00295 non_const_unary_op_fcn do_lookup_non_const_unary_op
00296 (octave_value::unary_op, int);
00297
00298 binary_class_op_fcn do_lookup_binary_class_op (octave_value::binary_op);
00299
00300 binary_op_fcn do_lookup_binary_op (octave_value::binary_op, int, int);
00301
00302 binary_class_op_fcn do_lookup_binary_class_op (octave_value::compound_binary_op);
00303
00304 binary_op_fcn do_lookup_binary_op (octave_value::compound_binary_op, int, int);
00305
00306 cat_op_fcn do_lookup_cat_op (int, int);
00307
00308 assign_op_fcn do_lookup_assign_op (octave_value::assign_op, int, int);
00309
00310 assignany_op_fcn do_lookup_assignany_op (octave_value::assign_op, int);
00311
00312 int do_lookup_pref_assign_conv (int, int);
00313
00314 octave_base_value::type_conv_fcn do_lookup_type_conv_op (int, int);
00315
00316 octave_base_value::type_conv_fcn do_lookup_widening_op (int, int);
00317
00318 string_vector do_installed_type_names (void);
00319
00320
00321
00322 octave_value_typeinfo (const octave_value_typeinfo&);
00323
00324 octave_value_typeinfo& operator = (const octave_value_typeinfo&);
00325 };
00326
00327 #endif