diff src/ov-base.h @ 9685:e793865ede63

implement builtin_type
author Jaroslav Hajek <highegg@gmail.com>
date Fri, 02 Oct 2009 08:27:44 +0200
parents e08d72bb988e
children 34d6f005db4b
line wrap: on
line diff
--- a/src/ov-base.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-base.h	Fri Oct 02 08:27:44 2009 +0200
@@ -55,6 +55,51 @@
 
 class tree_walker;
 
+enum builtin_type_t
+{
+  btyp_double,
+  btyp_float,
+  btyp_complex,
+  btyp_float_complex,
+  btyp_int8,
+  btyp_int16,
+  btyp_int32,
+  btyp_int64,
+  btyp_uint8,
+  btyp_uint16,
+  btyp_uint32,
+  btyp_uint64,
+  btyp_char,
+  btyp_bool,
+  btyp_unknown
+};
+
+template <class T>
+struct class_to_btyp
+{
+  static const builtin_type_t btyp = btyp_unknown;
+};
+
+#define DEF_CLASS_TO_BTYP(CLASS,BTYP) \
+template <> \
+struct class_to_btyp<CLASS> \
+{ static const builtin_type_t btyp = BTYP; }
+
+DEF_CLASS_TO_BTYP (double, btyp_double);
+DEF_CLASS_TO_BTYP (float, btyp_float);
+DEF_CLASS_TO_BTYP (Complex, btyp_complex);
+DEF_CLASS_TO_BTYP (FloatComplex, btyp_float_complex);
+DEF_CLASS_TO_BTYP (octave_int8, btyp_int8);
+DEF_CLASS_TO_BTYP (octave_int16, btyp_int16);
+DEF_CLASS_TO_BTYP (octave_int32, btyp_int32);
+DEF_CLASS_TO_BTYP (octave_int64, btyp_int64);
+DEF_CLASS_TO_BTYP (octave_uint8, btyp_uint8);
+DEF_CLASS_TO_BTYP (octave_uint16, btyp_uint16);
+DEF_CLASS_TO_BTYP (octave_uint32, btyp_uint32);
+DEF_CLASS_TO_BTYP (octave_uint64, btyp_uint64);
+DEF_CLASS_TO_BTYP (bool, btyp_bool);
+DEF_CLASS_TO_BTYP (char, btyp_char);
+
 // T_ID is the type id of struct objects, set by register_type().
 // T_NAME is the type name of struct objects.
 
@@ -282,6 +327,8 @@
 
   virtual octave_value any (int = 0) const;
 
+  virtual builtin_type_t builtin_type (void) const { return btyp_unknown; }
+
   virtual bool is_double_type (void) const { return false; }
 
   virtual bool is_single_type (void) const { return false; }