changeset 9685:e793865ede63

implement builtin_type
author Jaroslav Hajek <highegg@gmail.com>
date Fri, 02 Oct 2009 08:27:44 +0200
parents c5ff5f858cfd
children 5e433877634f
files liboctave/ChangeLog liboctave/lo-traits.h src/ChangeLog src/data.cc src/oct-stream.cc src/ov-base.h src/ov-bool-mat.h src/ov-bool-sparse.h src/ov-bool.h src/ov-ch-mat.h src/ov-complex.h src/ov-cx-diag.h src/ov-cx-mat.h src/ov-cx-sparse.h src/ov-float.h src/ov-flt-complex.h src/ov-flt-cx-diag.h src/ov-flt-cx-mat.h src/ov-flt-re-diag.h src/ov-flt-re-mat.h src/ov-int16.h src/ov-int32.h src/ov-int64.h src/ov-int8.h src/ov-intx.h src/ov-range.h src/ov-re-diag.h src/ov-re-mat.h src/ov-re-sparse.h src/ov-scalar.h src/ov-uint16.h src/ov-uint32.h src/ov-uint64.h src/ov-uint8.h src/ov.h
diffstat 35 files changed, 204 insertions(+), 73 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Thu Oct 01 21:59:27 2009 +0200
+++ b/liboctave/ChangeLog	Fri Oct 02 08:27:44 2009 +0200
@@ -1,3 +1,7 @@
+2009-10-02  Jaroslav Hajek  <highegg@gmail.com>
+
+	* lo-traits.h (strip_template_param): New trait class.
+
 2009-10-01  Jaroslav Hajek  <highegg@gmail.com>
 
 	* Array.cc (Array<T>::permute): Fast case identity permutation.
--- a/liboctave/lo-traits.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/liboctave/lo-traits.h	Fri Oct 02 08:27:44 2009 +0200
@@ -81,6 +81,23 @@
   typedef typename if_then_else<is_class_type<T>::no, T, T const&>::result type;
 };
 
+// Will turn TemplatedClass<T> to T, leave T otherwise.
+// Useful for stripping wrapper classes, like octave_int.
+
+template<template<typename> class TemplatedClass, typename T>
+class strip_template_param
+{
+public:
+  typedef T type;
+};
+
+template<template<typename> class TemplatedClass, typename T>
+class strip_template_param<TemplatedClass, TemplatedClass<T> >
+{
+public:
+  typedef T type;
+};
+
 #endif
 
 /*
--- a/src/ChangeLog	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ChangeLog	Fri Oct 02 08:27:44 2009 +0200
@@ -1,3 +1,40 @@
+2009-10-02  Jaroslav Hajek  <highegg@gmail.com>
+
+	* ov.h: Define also diag matrix extractors.
+	(octave_type_traits, octave_array_type_traits): Remove.
+	(octave_value::builtin_type): New method.
+	* oct-stream.cc (do_read): Update.
+	* data.cc (identity_matrix): Update.
+	* ov-base.h (builtin_type_t): New enum.
+	(octave_base_value::builtin_type): New method.
+	* ov-re-mat.h (octave_matrix::builtin_type): New method.
+	* ov-flt-re-mat.h (octave_float_matrix::builtin_type): New method.
+	* ov-cx-mat.h (octave_complex_matrix::builtin_type): New method.
+	* ov-flt-cx-mat.h (octave_float_complex_matrix::builtin_type): New method.
+	* ov-bool-mat.h (octave_bool_matrix::builtin_type): New method.
+	* ov-ch-mat.h (octave_char_matrix::builtin_type): New method.
+	* ov-scalar.h (octave_scalar::builtin_type): New method.
+	* ov-float.h (octave_float::builtin_type): New method.
+	* ov-complex.h (octave_complex::builtin_type): New method.
+	* ov-bool.h (octave_bool::builtin_type): New method.
+	* ov-flt-complex.h (octave_float_complex::builtin_type): New method.
+	* ov-re-diag.h (octave_diag_matrix::builtin_type): New method.
+	* ov-flt-re-diag.h (octave_float_diag_matrix::builtin_type): New method.
+	* ov-cx-diag.h (octave_complex_diag_matrix::builtin_type): New method.
+	* ov-flt-cx-diag.h (octave_float_complex_diag_matrix::builtin_type): New method.
+	* ov-re-sparse.h (octave_sparse_matrix::builtin_type): New method.
+	* ov-cx-sparse.h (octave_sparse_complex_matrix::builtin_type): New method.
+	* ov-bool-sparse.h (octave_sparse_bool_matrix::builtin_type): New method.
+	* ov-intx.h (octave_int_matrix::builtin_type, octave_int_scalar::builtin_type): New methods.
+	* ov-int8.h: Define OCTAVE_INT_BTYP.
+	* ov-int16.h: Define OCTAVE_INT_BTYP.
+	* ov-int32.h: Define OCTAVE_INT_BTYP.
+	* ov-int64.h: Define OCTAVE_INT_BTYP.
+	* ov-uint8.h: Define OCTAVE_INT_BTYP.
+	* ov-uint16.h: Define OCTAVE_INT_BTYP.
+	* ov-uint32.h: Define OCTAVE_INT_BTYP.
+	* ov-uint64.h: Define OCTAVE_INT_BTYP.
+
 2009-10-01  Jaroslav Hajek  <highegg@gmail.com>
 
 	* DLD-FUNCTIONS/cellfun.cc (Fcellfun): Fix initialization, add missing
--- a/src/data.cc	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/data.cc	Fri Oct 02 08:27:44 2009 +0200
@@ -4160,7 +4160,7 @@
 {
   octave_value retval;
 
-  typename octave_array_type_traits<MT>::element_type one (1);
+  typename MT::element_type one (1);
 
   if (nr == 1 && nc == 1)
     retval = one;
@@ -4168,7 +4168,7 @@
     {
       dim_vector dims (nr, nc);
 
-      typename octave_array_type_traits<MT>::element_type zero (0);
+      typename MT::element_type zero (0);
 
       MT m (dims, zero);
 
--- a/src/oct-stream.cc	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/oct-stream.cc	Fri Oct 02 08:27:44 2009 +0200
@@ -3072,10 +3072,10 @@
 
   count = 0;
 
-  typename octave_array_type_traits<RET_T>::element_type elt_zero
-    = typename octave_array_type_traits<RET_T>::element_type ();
-
-  typename octave_array_type_traits<RET_T>::element_type *dat = 0;
+  typename RET_T::element_type elt_zero
+    = typename RET_T::element_type ();
+
+  typename RET_T::element_type *dat = 0;
 
   octave_idx_type max_size = 0;
 
@@ -3117,8 +3117,8 @@
 
   union
   {
-    char buf[sizeof (typename octave_type_traits<READ_T>::val_type)];
-    typename octave_type_traits<READ_T>::val_type val;
+    char buf[sizeof (typename strip_template_param<octave_int, READ_T>::type)];
+    typename strip_template_param<octave_int, READ_T>::type val;
   } u;
 
   std::istream *isp = strm.input_stream ();
@@ -3144,22 +3144,22 @@
 		  break;
 		}
 
-	      is.read (u.buf, sizeof (typename octave_type_traits<READ_T>::val_type));
+	      is.read (u.buf, sizeof (typename strip_template_param<octave_int, READ_T>::type));
 
 	      // We only swap bytes for integer types.  For float
 	      // types, the format conversion will also handle byte
 	      // swapping.
 
 	      if (swap)
-		swap_bytes<sizeof (typename octave_type_traits<READ_T>::val_type)> (u.buf);
+		swap_bytes<sizeof (typename strip_template_param<octave_int, READ_T>::type)> (u.buf);
 	      else if (do_float_fmt_conv)
 		do_float_format_conversion
 		  (u.buf,
-		   sizeof (typename octave_type_traits<READ_T>::val_type),
+		   sizeof (typename strip_template_param<octave_int, READ_T>::type),
 		   1, from_flt_fmt, oct_mach_info::float_format ());
 
-	      typename octave_array_type_traits<RET_T>::element_type tmp
-		= static_cast <typename octave_array_type_traits<RET_T>::element_type> (u.val);
+	      typename RET_T::element_type tmp
+		= static_cast <typename RET_T::element_type> (u.val);
 
 	      if (is)
 		{
@@ -3414,13 +3414,13 @@
 void
 write_int (std::ostream& os, bool swap, const T& val)
 {
-  typename octave_type_traits<T>::val_type tmp = val.value ();
+  typename T::val_type tmp = val.value ();
 
   if (swap)
-    swap_bytes<sizeof (typename octave_type_traits<T>::val_type)> (&tmp);
+    swap_bytes<sizeof (typename T::val_type)> (&tmp);
 
   os.write (reinterpret_cast<const char *> (&tmp),
-	    sizeof (typename octave_type_traits<T>::val_type));
+	    sizeof (typename T::val_type));
 }
 
 template void write_int (std::ostream&, bool, const octave_int8&);
--- 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; }
--- a/src/ov-bool-mat.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-bool-mat.h	Fri Oct 02 08:27:44 2009 +0200
@@ -80,6 +80,8 @@
   idx_vector index_vector (void) const 
     { return idx_cache ? *idx_cache : set_idx_cache (idx_vector (matrix)); }
 
+  builtin_type_t builtin_type (void) const { return btyp_bool; }
+
   bool is_bool_matrix (void) const { return true; }
 
   bool is_bool_type (void) const { return true; }
--- a/src/ov-bool-sparse.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-bool-sparse.h	Fri Oct 02 08:27:44 2009 +0200
@@ -88,6 +88,8 @@
   idx_vector index_vector (void) const 
     { return idx_vector (bool_array_value ()); }
 
+  builtin_type_t builtin_type (void) const { return btyp_bool; }
+
   bool is_bool_matrix (void) const { return true; }
 
   bool is_bool_type (void) const { return true; }
--- a/src/ov-bool.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-bool.h	Fri Oct 02 08:27:44 2009 +0200
@@ -73,6 +73,8 @@
 
   idx_vector index_vector (void) const { return idx_vector (scalar); }
 
+  builtin_type_t builtin_type (void) const { return btyp_bool; }
+
   bool is_real_scalar (void) const { return true; }
 
   bool is_bool_scalar (void) const { return true; }
--- a/src/ov-ch-mat.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-ch-mat.h	Fri Oct 02 08:27:44 2009 +0200
@@ -82,6 +82,8 @@
 
   idx_vector index_vector (void) const;
 
+  builtin_type_t builtin_type (void) const { return btyp_char; }
+
   bool is_char_matrix (void) const { return true; }
   bool is_real_matrix (void) const { return true; }
 
--- a/src/ov-complex.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-complex.h	Fri Oct 02 08:27:44 2009 +0200
@@ -87,6 +87,8 @@
 		    || lo_ieee_isnan (std::imag (scalar))));
     }
 
+  builtin_type_t builtin_type (void) const { return btyp_complex; }
+
   bool is_complex_scalar (void) const { return true; }
 
   bool is_complex_type (void) const { return true; }
--- a/src/ov-cx-diag.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-cx-diag.h	Fri Oct 02 08:27:44 2009 +0200
@@ -57,6 +57,8 @@
 
   octave_base_value *try_narrowing_conversion (void);
 
+  builtin_type_t builtin_type (void) const { return btyp_complex; }
+
   bool is_complex_matrix (void) const { return true; }
 
   bool is_complex_type (void) const { return true; }
--- a/src/ov-cx-mat.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-cx-mat.h	Fri Oct 02 08:27:44 2009 +0200
@@ -90,6 +90,8 @@
 
   octave_base_value *try_narrowing_conversion (void);
 
+  builtin_type_t builtin_type (void) const { return btyp_complex; }
+
   bool is_complex_matrix (void) const { return true; }
 
   bool is_complex_type (void) const { return true; }
--- a/src/ov-cx-sparse.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-cx-sparse.h	Fri Oct 02 08:27:44 2009 +0200
@@ -97,6 +97,8 @@
 
   void assign (const octave_value_list& idx, const SparseMatrix& rhs);
 
+  builtin_type_t builtin_type (void) const { return btyp_complex; }
+
   bool is_complex_matrix (void) const { return true; }
 
   bool is_complex_type (void) const { return true; }
--- a/src/ov-float.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-float.h	Fri Oct 02 08:27:44 2009 +0200
@@ -82,6 +82,8 @@
   octave_value any (int = 0) const
     { return (scalar != 0 && ! lo_ieee_isnan (scalar)); }
 
+  builtin_type_t builtin_type (void) const { return btyp_float; }
+
   bool is_real_scalar (void) const { return true; }
 
   bool is_real_type (void) const { return true; }
--- a/src/ov-flt-complex.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-flt-complex.h	Fri Oct 02 08:27:44 2009 +0200
@@ -85,6 +85,8 @@
 		    || lo_ieee_isnan (std::imag (scalar))));
     }
 
+  builtin_type_t builtin_type (void) const { return btyp_float_complex; }
+
   bool is_complex_scalar (void) const { return true; }
 
   bool is_complex_type (void) const { return true; }
--- a/src/ov-flt-cx-diag.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-flt-cx-diag.h	Fri Oct 02 08:27:44 2009 +0200
@@ -55,6 +55,8 @@
 
   octave_base_value *try_narrowing_conversion (void);
 
+  builtin_type_t builtin_type (void) const { return btyp_float_complex; }
+
   bool is_complex_matrix (void) const { return true; }
 
   bool is_complex_type (void) const { return true; }
--- a/src/ov-flt-cx-mat.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-flt-cx-mat.h	Fri Oct 02 08:27:44 2009 +0200
@@ -88,6 +88,8 @@
 
   octave_base_value *try_narrowing_conversion (void);
 
+  builtin_type_t builtin_type (void) const { return btyp_float_complex; }
+
   bool is_complex_matrix (void) const { return true; }
 
   bool is_complex_type (void) const { return true; }
--- a/src/ov-flt-re-diag.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-flt-re-diag.h	Fri Oct 02 08:27:44 2009 +0200
@@ -55,6 +55,8 @@
 
   octave_base_value *try_narrowing_conversion (void);
 
+  builtin_type_t builtin_type (void) const { return btyp_float; }
+
   bool is_real_matrix (void) const { return true; }
 
   bool is_real_type (void) const { return true; }
--- a/src/ov-flt-re-mat.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-flt-re-mat.h	Fri Oct 02 08:27:44 2009 +0200
@@ -91,6 +91,8 @@
   idx_vector index_vector (void) const 
     { return idx_cache ? *idx_cache : set_idx_cache (idx_vector (matrix)); }
 
+  builtin_type_t builtin_type (void) const { return btyp_float; }
+
   bool is_real_matrix (void) const { return true; }
 
   bool is_real_type (void) const { return true; }
--- a/src/ov-int16.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-int16.h	Fri Oct 02 08:27:44 2009 +0200
@@ -35,6 +35,8 @@
 
 #define OCTAVE_INT_MX_CLASS mxINT16_CLASS
 
+#define OCTAVE_INT_BTYP btyp_int16
+
 #include "ov-intx.h"
 
 #undef OCTAVE_INT_T
@@ -49,6 +51,8 @@
 
 #undef OCTAVE_INT_MX_CLASS
 
+#undef OCTAVE_INT_BTYP
+
 #endif
 
 /*
--- a/src/ov-int32.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-int32.h	Fri Oct 02 08:27:44 2009 +0200
@@ -35,6 +35,8 @@
 
 #define OCTAVE_INT_MX_CLASS mxINT32_CLASS
 
+#define OCTAVE_INT_BTYP btyp_int32
+
 #include "ov-intx.h"
 
 #undef OCTAVE_INT_T
@@ -49,6 +51,8 @@
 
 #undef OCTAVE_INT_MX_CLASS
 
+#undef OCTAVE_INT_BTYP
+
 #endif
 
 /*
--- a/src/ov-int64.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-int64.h	Fri Oct 02 08:27:44 2009 +0200
@@ -35,6 +35,8 @@
 
 #define OCTAVE_INT_MX_CLASS mxINT64_CLASS
 
+#define OCTAVE_INT_BTYP btyp_int64
+
 #include "ov-intx.h"
 
 #undef OCTAVE_INT_T
@@ -49,6 +51,8 @@
 
 #undef OCTAVE_INT_MX_CLASS
 
+#undef OCTAVE_INT_BTYP
+
 #endif
 
 /*
--- a/src/ov-int8.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-int8.h	Fri Oct 02 08:27:44 2009 +0200
@@ -35,6 +35,8 @@
 
 #define OCTAVE_INT_MX_CLASS mxINT8_CLASS
 
+#define OCTAVE_INT_BTYP btyp_int8
+
 #include "ov-intx.h"
 
 #undef OCTAVE_INT_T
@@ -49,6 +51,8 @@
 
 #undef OCTAVE_INT_MX_CLASS
 
+#undef OCTAVE_INT_BTYP
+
 #endif
 
 /*
--- a/src/ov-intx.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-intx.h	Fri Oct 02 08:27:44 2009 +0200
@@ -68,6 +68,8 @@
 
   bool is_integer_type (void) const { return true; }
 
+  builtin_type_t builtin_type (void) const { return OCTAVE_INT_BTYP; }
+
 private:
 
   template <class IM>
@@ -442,6 +444,8 @@
 
   bool is_integer_type (void) const { return true; }
 
+  builtin_type_t builtin_type (void) const { return OCTAVE_INT_BTYP; }
+
 private:
 
   template <class IS>
--- a/src/ov-range.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-range.h	Fri Oct 02 08:27:44 2009 +0200
@@ -158,6 +158,8 @@
   sortmode is_sorted_rows (sortmode mode = UNSORTED) const
     { return mode ? mode : ASCENDING; }
 
+  builtin_type_t builtin_type (void) const { return btyp_double; }
+
   bool is_real_type (void) const { return true; }
 
   bool is_double_type (void) const { return true; }
--- a/src/ov-re-diag.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-re-diag.h	Fri Oct 02 08:27:44 2009 +0200
@@ -60,6 +60,8 @@
   octave_value do_index_op (const octave_value_list& idx,
 			    bool resize_ok = false);
 
+  builtin_type_t builtin_type (void) const { return btyp_double; }
+
   bool is_real_matrix (void) const { return true; }
 
   bool is_real_type (void) const { return true; }
--- a/src/ov-re-mat.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-re-mat.h	Fri Oct 02 08:27:44 2009 +0200
@@ -108,6 +108,8 @@
   idx_vector index_vector (void) const
     { return idx_cache ? *idx_cache : set_idx_cache (idx_vector (matrix)); }
 
+  builtin_type_t builtin_type (void) const { return btyp_double; }
+
   bool is_real_matrix (void) const { return true; }
 
   bool is_real_type (void) const { return true; }
--- a/src/ov-re-sparse.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-re-sparse.h	Fri Oct 02 08:27:44 2009 +0200
@@ -93,6 +93,8 @@
 
   idx_vector index_vector (void) const;
 
+  builtin_type_t builtin_type (void) const { return btyp_double; }
+
   bool is_real_matrix (void) const { return true; }
 
   bool is_real_type (void) const { return true; }
--- a/src/ov-scalar.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-scalar.h	Fri Oct 02 08:27:44 2009 +0200
@@ -83,6 +83,8 @@
   octave_value any (int = 0) const
     { return (scalar != 0 && ! lo_ieee_isnan (scalar)); }
 
+  builtin_type_t builtin_type (void) const { return btyp_double; }
+
   bool is_real_scalar (void) const { return true; }
 
   bool is_real_type (void) const { return true; }
--- a/src/ov-uint16.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-uint16.h	Fri Oct 02 08:27:44 2009 +0200
@@ -35,6 +35,8 @@
 
 #define OCTAVE_INT_MX_CLASS mxUINT16_CLASS
 
+#define OCTAVE_INT_BTYP btyp_uint16
+
 #include "ov-intx.h"
 
 #undef OCTAVE_INT_T
@@ -49,6 +51,8 @@
 
 #undef OCTAVE_INT_MX_CLASS
 
+#undef OCTAVE_INT_BTYP
+
 #endif
 
 /*
--- a/src/ov-uint32.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-uint32.h	Fri Oct 02 08:27:44 2009 +0200
@@ -35,6 +35,8 @@
 
 #define OCTAVE_INT_MX_CLASS mxUINT32_CLASS
 
+#define OCTAVE_INT_BTYP btyp_uint32
+
 #include "ov-intx.h"
 
 #undef OCTAVE_INT_T
@@ -49,6 +51,8 @@
 
 #undef OCTAVE_INT_MX_CLASS
 
+#undef OCTAVE_INT_BTYP
+
 #endif
 
 /*
--- a/src/ov-uint64.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-uint64.h	Fri Oct 02 08:27:44 2009 +0200
@@ -35,6 +35,8 @@
 
 #define OCTAVE_INT_MX_CLASS mxUINT64_CLASS
 
+#define OCTAVE_INT_BTYP btyp_uint64
+
 #include "ov-intx.h"
 
 #undef OCTAVE_INT_T
@@ -49,6 +51,8 @@
 
 #undef OCTAVE_INT_MX_CLASS
 
+#undef OCTAVE_INT_BTYP
+
 #endif
 
 /*
--- a/src/ov-uint8.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov-uint8.h	Fri Oct 02 08:27:44 2009 +0200
@@ -35,6 +35,8 @@
 
 #define OCTAVE_INT_MX_CLASS mxUINT8_CLASS
 
+#define OCTAVE_INT_BTYP btyp_uint8
+
 #include "ov-intx.h"
 
 #undef OCTAVE_INT_T
@@ -49,6 +51,8 @@
 
 #undef OCTAVE_INT_MX_CLASS
 
+#undef OCTAVE_INT_BTYP
+
 #endif
 
 /*
--- a/src/ov.h	Thu Oct 01 21:59:27 2009 +0200
+++ b/src/ov.h	Fri Oct 02 08:27:44 2009 +0200
@@ -550,6 +550,9 @@
   octave_value any (int dim = 0) const
     { return rep->any (dim); }
 
+  builtin_type_t builtin_type (void) const
+    { return rep->builtin_type (); }
+
   // Floating point types.
 
   bool is_double_type (void) const
@@ -1252,63 +1255,6 @@
 
 extern OCTINTERP_API void install_types (void);
 
-// FIXME -- these trait classes probably belong somehwere else...
-
-template <typename T>
-class
-octave_type_traits
-{
-public:
-  typedef T val_type;
-};
-
-#define OCTAVE_TYPE_TRAIT(T, VAL_T) \
-  template <> \
-  class \
-  octave_type_traits<T> \
-  { \
-  public: \
-    typedef VAL_T val_type; \
-  }
-
-OCTAVE_TYPE_TRAIT (octave_int8, octave_int8::val_type);
-OCTAVE_TYPE_TRAIT (octave_uint8, octave_uint8::val_type);
-OCTAVE_TYPE_TRAIT (octave_int16, octave_int16::val_type);
-OCTAVE_TYPE_TRAIT (octave_uint16, octave_uint16::val_type);
-OCTAVE_TYPE_TRAIT (octave_int32, octave_int32::val_type);
-OCTAVE_TYPE_TRAIT (octave_uint32, octave_uint32::val_type);
-OCTAVE_TYPE_TRAIT (octave_int64, octave_int64::val_type);
-OCTAVE_TYPE_TRAIT (octave_uint64, octave_uint64::val_type);
-
-template <typename T>
-class octave_array_type_traits
-{
-public:
-  typedef T element_type;
-};
-
-#define OCTAVE_ARRAY_TYPE_TRAIT(T, ELT_T) \
-  template <> \
-  class \
-  octave_array_type_traits<T> \
-  { \
-  public: \
-    typedef ELT_T element_type; \
-  }
-
-OCTAVE_ARRAY_TYPE_TRAIT (charNDArray, char);
-OCTAVE_ARRAY_TYPE_TRAIT (boolNDArray, bool);
-OCTAVE_ARRAY_TYPE_TRAIT (int8NDArray, octave_int8);
-OCTAVE_ARRAY_TYPE_TRAIT (uint8NDArray, octave_uint8);
-OCTAVE_ARRAY_TYPE_TRAIT (int16NDArray, octave_int16);
-OCTAVE_ARRAY_TYPE_TRAIT (uint16NDArray, octave_uint16);
-OCTAVE_ARRAY_TYPE_TRAIT (int32NDArray, octave_int32);
-OCTAVE_ARRAY_TYPE_TRAIT (uint32NDArray, octave_uint32);
-OCTAVE_ARRAY_TYPE_TRAIT (int64NDArray, octave_int64);
-OCTAVE_ARRAY_TYPE_TRAIT (uint64NDArray, octave_uint64);
-OCTAVE_ARRAY_TYPE_TRAIT (NDArray, double);
-OCTAVE_ARRAY_TYPE_TRAIT (FloatNDArray, float);
-
 // This will eventually go away, but for now it can be used to
 // simplify the transition to the new octave_value class hierarchy,
 // which uses octave_base_value instead of octave_value for the type
@@ -1373,6 +1319,12 @@
 DEF_VALUE_EXTRACTOR (ComplexRowVector, complex_row_vector)
 DEF_VALUE_EXTRACTOR (FloatComplexRowVector, float_complex_row_vector)
 
+DEF_VALUE_EXTRACTOR (DiagMatrix, diag_matrix)
+DEF_VALUE_EXTRACTOR (FloatDiagMatrix, float_diag_matrix)
+DEF_VALUE_EXTRACTOR (ComplexDiagMatrix, complex_diag_matrix)
+DEF_VALUE_EXTRACTOR (FloatComplexDiagMatrix, float_complex_diag_matrix)
+DEF_VALUE_EXTRACTOR (PermMatrix, perm_matrix)
+
 #undef DEF_VALUE_EXTRACTOR
 
 #endif