26 #if defined (HAVE_CONFIG_H)
49 as_nd_array (const
Array<
int>&
x)
53 for (
int i = 0; i <
x.numel (); i++)
65 retval.xelem (i) =
x(i);
71 : m_num_types (0), m_types (
dim_vector (init_tab_sz, 1),
""),
81 m_cat_ops (
dim_vector (init_tab_sz, init_tab_sz), nullptr),
84 m_pref_assign_conv (
dim_vector (init_tab_sz, init_tab_sz), -1),
85 m_widening_ops (
dim_vector (init_tab_sz, init_tab_sz), nullptr)
96 bool abort_on_duplicate)
100 for (i = 0; i < m_num_types; i++)
102 if (t_name == m_types (i))
104 if (abort_on_duplicate)
106 std::cerr <<
"duplicate type " << t_name << std::endl;
110 warning (
"duplicate type %s\n", t_name.c_str ());
129 m_non_const_unary_ops.
resize
135 m_compound_binary_ops.
resize
152 m_types (i) = t_name;
170 bool abort_on_duplicate)
176 if (abort_on_duplicate)
178 std::cerr <<
"duplicate unary operator '" << op_name
179 <<
"' for class dispatch" << std::endl;
183 warning (
"duplicate unary operator '%s' for class dispatch",
187 m_unary_class_ops.
checkelem (
static_cast<int> (op))
188 =
reinterpret_cast<void *
> (
f);
200 std::string type_name = m_types(t);
202 if (abort_on_duplicate)
204 std::cerr <<
"duplicate unary operator '" << op_name
205 <<
"' for type '" << type_name <<
"'" << std::endl;
209 warning (
"duplicate unary operator '%s' for type '%s'",
210 op_name.c_str (), type_name.c_str ());
213 m_unary_ops.
checkelem (
static_cast<int> (op), t) =
reinterpret_cast<void *
> (
f);
221 bool abort_on_duplicate)
226 std::string type_name = m_types(t);
228 if (abort_on_duplicate)
230 std::cerr <<
"duplicate unary operator '" << op_name
231 <<
"' for type '" << type_name <<
"'" << std::endl;
235 warning (
"duplicate unary operator '%s' for type '%s'",
236 op_name.c_str (), type_name.c_str ());
239 m_non_const_unary_ops.
checkelem (
static_cast<int> (op), t)
240 =
reinterpret_cast<void *
> (
f);
248 bool abort_on_duplicate)
254 if (abort_on_duplicate)
257 std::cerr <<
"duplicate binary operator '" << op_name
258 <<
"' for class dispatch" << std::endl;
262 warning (
"duplicate binary operator '%s' for class dispatch",
266 m_binary_class_ops.
checkelem (
static_cast<int> (op))
267 =
reinterpret_cast<void *
> (
f);
276 bool abort_on_duplicate)
281 std::string t1_name = m_types(t1);
282 std::string t2_name = m_types(t2);
284 if (abort_on_duplicate)
286 std::cerr <<
"duplicate binary operator '" << op_name
287 <<
"' for types '" << t1_name <<
"' and '"
288 << t2_name <<
"'" << std::endl;
292 warning (
"duplicate binary operator '%s' for types '%s' and '%s'",
293 op_name.c_str (), t1_name.c_str (), t1_name.c_str ());
296 m_binary_ops.
checkelem (
static_cast<int> (op), t1, t2)
297 =
reinterpret_cast<void *
> (
f);
305 bool abort_on_duplicate)
311 if (abort_on_duplicate)
313 std::cerr <<
"duplicate compound binary operator '"
314 << op_name <<
"' for class dispatch" << std::endl;
318 warning (
"duplicate compound binary operator '%s' for class dispatch",
322 m_compound_binary_class_ops.
checkelem (
static_cast<int> (op))
323 =
reinterpret_cast<void *
> (
f);
332 bool abort_on_duplicate)
337 std::string t1_name = m_types(t1);
338 std::string t2_name = m_types(t2);
340 if (abort_on_duplicate)
342 std::cerr <<
"duplicate compound binary operator '"
343 << op_name <<
"' for types '" << t1_name
344 <<
"' and '" << t2_name <<
"'" << std::endl;
348 warning (
"duplicate compound binary operator '%s' for types '%s' and '%s'",
349 op_name.c_str (), t1_name.c_str (), t1_name.c_str ());
352 m_compound_binary_ops.
checkelem (
static_cast<int> (op), t1, t2)
353 =
reinterpret_cast<void *
> (
f);
360 bool abort_on_duplicate)
364 std::string t1_name = m_types(t1);
365 std::string t2_name = m_types(t2);
367 if (abort_on_duplicate)
369 std::cerr <<
"duplicate concatenation operator for types '"
370 << t1_name <<
"' and '" << t2_name <<
"'" << std::endl;
374 warning (
"duplicate concatenation operator for types '%s' and '%s'",
375 t1_name.c_str (), t1_name.c_str ());
378 m_cat_ops.
checkelem (t1, t2) =
reinterpret_cast<void *
> (
f);
385 int t_lhs,
int t_rhs,
387 bool abort_on_duplicate)
392 std::string t_lhs_name = m_types(t_lhs);
393 std::string t_rhs_name = m_types(t_rhs);
395 if (abort_on_duplicate)
397 std::cerr <<
"duplicate assignment operator '"
398 << op_name <<
"' for types '" << t_lhs_name
399 <<
"' and '" << t_rhs_name <<
"'" << std::endl;
403 warning (
"duplicate assignment operator '%s' for types '%s' and '%s'",
404 op_name.c_str (), t_lhs_name.c_str (), t_rhs_name.c_str ());
407 m_assign_ops.
checkelem (
static_cast<int> (op), t_lhs, t_rhs)
408 =
reinterpret_cast<void *
> (
f);
416 bool abort_on_duplicate)
421 std::string t_lhs_name = m_types(t_lhs);
423 if (abort_on_duplicate)
425 std::cerr <<
"duplicate assignment operator '" << op_name
426 <<
"' for types '" << t_lhs_name <<
"'" << std::endl;
430 warning (
"duplicate assignment operator '%s' for types '%s'",
431 op_name.c_str (), t_lhs_name.c_str ());
434 m_assignany_ops.
checkelem (
static_cast<int> (op), t_lhs)
435 =
reinterpret_cast<void *
> (
f);
443 bool abort_on_duplicate)
447 std::string t_lhs_name = m_types(t_lhs);
448 std::string t_rhs_name = m_types(t_rhs);
450 if (abort_on_duplicate)
452 std::cerr <<
"overriding assignment conversion for types '"
453 << t_lhs_name <<
"' and '" << t_rhs_name <<
"'"
458 warning (
"overriding assignment conversion for types '%s' and '%s'",
459 t_lhs_name.c_str (), t_rhs_name.c_str ());
462 m_pref_assign_conv.
checkelem (t_lhs, t_rhs) = t_result;
470 bool abort_on_duplicate)
474 std::string t_name = m_types(t);
475 std::string t_result_name = m_types(t_result);
477 if (abort_on_duplicate)
479 std::cerr <<
"overriding widening op for '" << t_name
480 <<
"' to '" << t_result_name <<
"'" << std::endl;
484 warning (
"overriding widening op for '%s' to '%s'",
485 t_name.c_str (), t_result_name.c_str ());
488 m_widening_ops.
checkelem (t, t_result) =
reinterpret_cast<void *
> (
f);
498 for (
int i = 0; i < m_num_types; i++)
500 if (nm == m_types(i))
514 void *
f = m_unary_class_ops.
checkelem (
static_cast<int> (op));
521 void *
f = m_unary_ops.
checkelem (
static_cast<int> (op), t);
528 void *
f = m_non_const_unary_ops.
checkelem (
static_cast<int> (op), t);
535 void *
f = m_binary_class_ops.
checkelem (
static_cast<int> (op));
542 void *
f = m_binary_ops.
checkelem (
static_cast<int> (op), t1, t2);
549 void *
f = m_compound_binary_class_ops.
checkelem (
static_cast<int> (op));
557 void *
f = m_compound_binary_ops.
checkelem (
static_cast<int> (op), t1, t2);
570 int t_lhs,
int t_rhs)
572 void *
f = m_assign_ops.
checkelem (
static_cast<int> (op), t_lhs, t_rhs);
579 void *
f = m_assignany_ops.
checkelem (
static_cast<int> (op), t_lhs);
586 return m_pref_assign_conv.
checkelem (t_lhs, t_rhs);
592 void *
f = m_widening_ops.
checkelem (t, t_result);
601 for (
int i = 0; i < m_num_types; i++)
602 retval(i) = m_types(i);
621 for (
int i = 0; i <
len; i++)
622 tab.
xelem (i) = (m_unary_ops(j, i) !=
nullptr);
646 for (
int i = 0; i <
len; i++)
647 tab.
xelem (i) = (m_non_const_unary_ops(j, i) !=
nullptr);
671 for (
int j = 0; j <
len; j++)
672 for (
int i = 0; i <
len; i++)
673 tab.
xelem (j, i) = (m_binary_ops(k, j, i) !=
nullptr);
697 for (
int j = 0; j <
len; j++)
698 for (
int i = 0; i <
len; i++)
699 tab.
xelem (j, i) = (m_compound_binary_ops(k, j, i) !=
nullptr);
724 for (
int j = 0; j <
len; j++)
725 for (
int i = 0; i <
len; i++)
726 tab.
xelem (j, i) = (m_assign_ops(k, j, i) !=
nullptr);
750 for (
int i = 0; i <
len; i++)
751 tab.
xelem (i) = (m_assignany_ops(j, i) !=
nullptr);
771 retval.
setfield (
"cat_ops", as_bool_nd_array (m_cat_ops));
774 retval.
setfield (
"pref_assign_conv", as_nd_array (m_pref_assign_conv));
775 retval.
setfield (
"widening_ops", as_bool_nd_array (m_widening_ops));
780 OCTAVE_END_NAMESPACE(
octave)
912 OCTAVE_END_NAMESPACE(octave_value_typeinfo)
928 int nargin = args.length ();
940 return ovl (args(0).type_name ());
1042 DEFMETHOD (__dump_typeinfo__, interp, args, ,
1048 if (args.length () > 0)
1056 OCTAVE_END_NAMESPACE(
octave)
charNDArray min(char d, const charNDArray &m)
N Dimensional Array with copy-on-write semantics.
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
octave_idx_type columns() const
T & xelem(octave_idx_type n)
Size of the specified dimension.
T & checkelem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type numel() const
Number of elements in the array.
Vector representing the dimensions (size) of an Array.
octave_base_value *(* type_conv_fcn)(const octave_base_value &)
void setfield(const std::string &key, const octave_value &val)
static std::string binary_op_as_string(binary_op)
static std::string assign_op_as_string(assign_op)
@ num_compound_binary_ops
static std::string unary_op_as_string(unary_op)
static std::string binary_op_fcn_name(binary_op)
bool register_assignany_op(octave_value::assign_op, int, assignany_op_fcn, bool abort_on_duplicate=false)
octave_value(* unary_op_fcn)(const octave_base_value &)
assignany_op_fcn lookup_assignany_op(octave_value::assign_op, int)
octave_value lookup_type(const std::string &nm)
octave_value(* binary_op_fcn)(const octave_base_value &, const octave_base_value &)
assign_op_fcn lookup_assign_op(octave_value::assign_op, int, int)
bool register_widening_op(int, int, octave_base_value::type_conv_fcn, bool abort_on_duplicate=false)
bool register_cat_op(int, int, cat_op_fcn, bool abort_on_duplicate=false)
octave_scalar_map non_const_unary_ops_map() const
bool register_unary_class_op(octave_value::unary_op, unary_class_op_fcn, bool abort_on_duplicate=false)
octave_value(* assignany_op_fcn)(octave_base_value &, const octave_value_list &, const octave_value &)
bool register_binary_class_op(octave_value::binary_op, binary_class_op_fcn, bool abort_on_duplicate=false)
octave_scalar_map assignany_ops_map() const
octave_base_value::type_conv_fcn lookup_widening_op(int, int)
non_const_unary_op_fcn lookup_non_const_unary_op(octave_value::unary_op, int)
octave_scalar_map binary_ops_map() const
octave_value(* binary_class_op_fcn)(const octave_value &, const octave_value &)
string_vector installed_type_names() const
octave_scalar_map assign_ops_map() const
binary_class_op_fcn lookup_binary_class_op(octave_value::binary_op)
type_info(int init_tab_sz=16)
bool register_non_const_unary_op(octave_value::unary_op, int, non_const_unary_op_fcn, bool abort_on_duplicate=false)
bool register_unary_op(octave_value::unary_op, int, unary_op_fcn, bool abort_on_duplicate=false)
octave_scalar_map compound_binary_ops_map() const
bool register_binary_op(octave_value::binary_op, int, int, binary_op_fcn, bool abort_on_duplicate=false)
octave_value(* cat_op_fcn)(const octave_base_value &, const octave_base_value &, const Array< octave_idx_type > &ra_idx)
octave_value(* unary_class_op_fcn)(const octave_value &)
octave_value(* assign_op_fcn)(octave_base_value &, const octave_value_list &, const octave_base_value &)
octave_scalar_map unary_ops_map() const
void(* non_const_unary_op_fcn)(octave_base_value &)
unary_class_op_fcn lookup_unary_class_op(octave_value::unary_op)
bool register_pref_assign_conv(int, int, int, bool abort_on_duplicate=false)
cat_op_fcn lookup_cat_op(int, int)
binary_op_fcn lookup_binary_op(octave_value::binary_op, int, int)
int lookup_pref_assign_conv(int, int)
octave_scalar_map installed_type_info() const
unary_op_fcn lookup_unary_op(octave_value::unary_op, int)
bool register_assign_op(octave_value::assign_op, int, int, assign_op_fcn, bool abort_on_duplicate=false)
int register_type(const std::string &, const std::string &, const octave_value &, bool abort_on_duplicate=false)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
void warning(const char *fmt,...)
type_info & __get_type_info__()
F77_RET_T const F77_DBLE * x
F77_RET_T const F77_DBLE const F77_DBLE * f
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value lookup_type(const std::string &nm)
octave_base_value::type_conv_fcn lookup_widening_op(int t, int t_result)
unary_class_op_fcn lookup_unary_class_op(octave_value::unary_op op)
non_const_unary_op_fcn lookup_non_const_unary_op(octave_value::unary_op op, int t)
octave_scalar_map installed_type_info()
int register_type(const std::string &t_name, const std::string &c_name, const octave_value &val)
binary_op_fcn lookup_binary_op(octave_value::binary_op op, int t1, int t2)
binary_class_op_fcn lookup_binary_class_op(octave_value::binary_op op)
assign_op_fcn lookup_assign_op(octave_value::assign_op op, int t_lhs, int t_rhs)
string_vector installed_type_names()
unary_op_fcn lookup_unary_op(octave_value::unary_op op, int t)
assignany_op_fcn lookup_assignany_op(octave_value::assign_op op, int t_lhs)
void install_ops(type_info &ti)
int lookup_pref_assign_conv(int t_lhs, int t_rhs)
cat_op_fcn lookup_cat_op(int t1, int t2)
octave::type_info::binary_op_fcn binary_op_fcn
octave::type_info::binary_class_op_fcn binary_class_op_fcn
octave::type_info::assign_op_fcn assign_op_fcn
octave::type_info::non_const_unary_op_fcn non_const_unary_op_fcn
octave::type_info::assignany_op_fcn assignany_op_fcn
octave::type_info::unary_op_fcn unary_op_fcn
octave::type_info::cat_op_fcn cat_op_fcn
octave::type_info::unary_class_op_fcn unary_class_op_fcn
void install_types(octave::type_info &)
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.