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