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 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 Array<void *> unary_ops;
00226
00227 Array<void *> non_const_unary_ops;
00228
00229 Array<void *> binary_class_ops;
00230
00231 Array<void *> binary_ops;
00232
00233 Array<void *> compound_binary_class_ops;
00234
00235 Array<void *> compound_binary_ops;
00236
00237 Array<void *> cat_ops;
00238
00239 Array<void *> assign_ops;
00240
00241 Array<void *> assignany_ops;
00242
00243 Array<int> pref_assign_conv;
00244
00245 Array<void *> type_conv_ops;
00246
00247 Array<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