changeset 3223:3ee04ff37b3e

[project @ 1998-11-20 19:34:15 by jwe]
author jwe
date Fri, 20 Nov 1998 19:34:16 +0000
parents dae85431bade
children 1e7532b9173b
files src/Makefile.in src/ov-base-mat.h src/ov-bool.cc src/ov-bool.h src/ov-complex.cc src/ov-complex.h src/ov-scalar.cc src/ov-scalar.h
diffstat 8 files changed, 41 insertions(+), 170 deletions(-) [+]
line wrap: on
line diff
--- a/src/Makefile.in	Thu Nov 19 22:14:09 1998 +0000
+++ b/src/Makefile.in	Fri Nov 20 19:34:16 1998 +0000
@@ -64,9 +64,9 @@
   DLD_STATIC_OBJ := $(DLD_OBJ)
 endif
 
-OV_INCLUDES := ov-re-mat.h ov-cx-mat.h ov-ch-mat.h \
-	ov-list.h ov-struct.h ov-scalar.h ov-range.h \
-	ov-complex.h ov-va-args.h ov-colon.h ov-base.h ov-base-mat.h \
+OV_INCLUDES := ov-re-mat.h ov-cx-mat.h ov-ch-mat.h ov-list.h \
+	ov-struct.h ov-scalar.h ov-range.h ov-complex.h ov-va-args.h \
+	ov-colon.h ov-base.h ov-base-mat.h ov-base-scalar.h \
 	ov-str-mat.h ov-bool-mat.h ov-bool.h ov-file.h ov.h \
 	ov-fcn.h ov-builtin.h ov-mapper.h ov-usr-fcn.h ov-typeinfo.h
 
@@ -104,10 +104,10 @@
 
 OP_SRC := $(addprefix OPERATORS/, $(OP_XSRC))
 
-OV_SRC := ov-base.cc ov-base-mat.cc ov-ch-mat.cc ov-list.cc ov-re-mat.cc \
-	ov-cx-mat.cc ov-range.cc ov-scalar.cc ov-complex.cc \
-	ov-str-mat.cc ov-struct.cc ov-va-args.cc ov-colon.cc \
-	ov-bool-mat.cc ov-bool.cc ov-file.cc ov.cc ov-fcn.cc \
+OV_SRC := ov-base.cc ov-base-mat.cc ov-base-scalar.cc ov-ch-mat.cc \
+	ov-list.cc ov-re-mat.cc ov-cx-mat.cc ov-range.cc ov-scalar.cc \
+	ov-complex.cc ov-str-mat.cc ov-struct.cc ov-va-args.cc \
+	ov-colon.cc ov-bool-mat.cc ov-bool.cc ov-file.cc ov.cc ov-fcn.cc \
 	ov-builtin.cc ov-mapper.cc ov-usr-fcn.cc ov-typeinfo.cc
 
 PT_SRC := pt.cc pt-arg-list.cc pt-assign.cc pt-binop.cc pt-check.cc \
--- a/src/ov-base-mat.h	Thu Nov 19 22:14:09 1998 +0000
+++ b/src/ov-base-mat.h	Fri Nov 20 19:34:16 1998 +0000
@@ -47,7 +47,8 @@
 
 // Real matrix values.
 
-template <class MT> class
+template <class MT>
+class
 octave_base_matrix : public octave_base_value
 {
 public:
--- a/src/ov-bool.cc	Thu Nov 19 22:14:09 1998 +0000
+++ b/src/ov-bool.cc	Fri Nov 20 19:34:16 1998 +0000
@@ -36,10 +36,15 @@
 #include "oct-obj.h"
 #include "ops.h"
 #include "ov-bool.h"
+#include "ov-base.h"
+#include "ov-base-scalar.h"
+#include "ov-base-scalar.cc"
 #include "ov-re-mat.h"
 #include "ov-scalar.h"
 #include "pr-output.h"
 
+template class octave_base_scalar<bool>;
+
 DEFINE_OCTAVE_ALLOCATOR (octave_bool);
 
 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_bool, "bool");
@@ -107,28 +112,6 @@
   return octave_value (s);
 }
 
-void
-octave_bool::print (ostream& os, bool pr_as_read_syntax) const
-{
-  print_raw (os, pr_as_read_syntax);
-  newline (os);
-}
-
-void
-octave_bool::print_raw (ostream& os, bool pr_as_read_syntax) const
-{
-  indent (os);
-  octave_print_internal (os, scalar, pr_as_read_syntax);
-}
-
-bool
-octave_bool::print_name_tag (ostream& os, const string& name) const
-{
-  indent (os);
-  os << name << " = ";
-  return false;    
-}
-
 /*
 ;;; Local Variables: ***
 ;;; mode: C++ ***
--- a/src/ov-bool.h	Thu Nov 19 22:14:09 1998 +0000
+++ b/src/ov-bool.h	Fri Nov 20 19:34:16 1998 +0000
@@ -39,6 +39,7 @@
 #include "str-vec.h"
 
 #include "ov-base.h"
+#include "ov-base-scalar.h"
 #include "ov-typeinfo.h"
 
 class Octave_map;
@@ -49,18 +50,18 @@
 // Real scalar values.
 
 class
-octave_bool : public octave_base_value
+octave_bool : public octave_base_scalar<bool>
 {
 public:
 
   octave_bool (void)
-    : octave_base_value (), scalar (false) { }
+    : octave_base_scalar<bool> (false) { }
 
   octave_bool (bool b)
-    : octave_base_value (), scalar (b) { }
+    : octave_base_scalar<bool> (b) { }
 
   octave_bool (const octave_bool& s)
-    : octave_base_value (), scalar (s.scalar) { }
+    : octave_base_scalar<bool> (s) { }
 
   ~octave_bool (void) { }
 
@@ -72,28 +73,12 @@
 
   idx_vector index_vector (void) const { return idx_vector (scalar); }
 
-  int rows (void) const { return 1; }
-  int columns (void) const { return 1; }
-
-  int length (void) const { return 1; }
-
-  bool is_defined (void) const { return true; }
-
-  bool is_constant (void) const { return true; }
-
   bool is_real_scalar (void) const { return true; }
 
-  octave_value all (void) const { return scalar; }
-  octave_value any (void) const { return scalar; }
-
   bool is_bool_type (void) const { return true; }
 
   bool is_real_type (void) const { return true; }
 
-  bool is_scalar_type (void) const { return true; }
-
-  bool is_numeric_type (void) const { return true; }
-
   bool valid_as_scalar_index (void) const { return scalar; }
 
   bool valid_as_zero_index (void) const { return ! scalar; }
@@ -119,17 +104,8 @@
 
   octave_value convert_to_str (void) const;
 
-  void print (ostream& os, bool pr_as_read_syntax = false) const;
-
-  void print_raw (ostream& os, bool pr_as_read_syntax = false) const;
-
-  bool print_name_tag (ostream& os, const string& name) const;
-
 private:
 
-  // The value of this scalar.
-  bool scalar;
-
   DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
 
   DECLARE_OCTAVE_ALLOCATOR
--- a/src/ov-complex.cc	Thu Nov 19 22:14:09 1998 +0000
+++ b/src/ov-complex.cc	Fri Nov 20 19:34:16 1998 +0000
@@ -35,11 +35,16 @@
 #include "oct-obj.h"
 #include "ops.h"
 #include "ov-complex.h"
+#include "ov-base.h"
+#include "ov-base-scalar.h"
+#include "ov-base-scalar.cc"
 #include "ov-cx-mat.h"
 #include "ov-scalar.h"
 #include "gripes.h"
 #include "pr-output.h"
 
+template class octave_base_scalar<Complex>;
+
 DEFINE_OCTAVE_ALLOCATOR (octave_complex);
 
 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_complex, "complex scalar");
@@ -149,28 +154,6 @@
   return ComplexMatrix (1, 1, scalar);
 }
 
-void
-octave_complex::print (ostream& os, bool pr_as_read_syntax) const
-{
-  print_raw (os, pr_as_read_syntax);
-  newline (os);
-}
-
-void
-octave_complex::print_raw (ostream& os, bool pr_as_read_syntax) const
-{
-  indent (os);
-  octave_print_internal (os, scalar, pr_as_read_syntax);
-}
-
-bool
-octave_complex::print_name_tag (ostream& os, const string& name) const
-{
-  indent (os);
-  os << name << " = ";
-  return false;    
-}
-
 /*
 ;;; Local Variables: ***
 ;;; mode: C++ ***
--- a/src/ov-complex.h	Thu Nov 19 22:14:09 1998 +0000
+++ b/src/ov-complex.h	Fri Nov 20 19:34:16 1998 +0000
@@ -39,6 +39,7 @@
 
 #include "error.h"
 #include "ov-base.h"
+#include "ov-base-scalar.h"
 #include "ov-typeinfo.h"
 
 class Octave_map;
@@ -49,18 +50,18 @@
 // Complex scalar values.
 
 class
-octave_complex : public octave_base_value
+octave_complex : public octave_base_scalar<Complex>
 {
 public:
 
   octave_complex (void)
-    : octave_base_value () { }
+    : octave_base_scalar<Complex> () { }
 
   octave_complex (const Complex& c)
-    : octave_base_value (), scalar (c) { }
+    : octave_base_scalar<Complex> (c) { }
 
   octave_complex (const octave_complex& c)
-    : octave_base_value (), scalar (c.scalar) { }
+    : octave_base_scalar<Complex> (c) { }
 
   ~octave_complex (void) { }
 
@@ -70,38 +71,14 @@
 
   octave_value do_index_op (const octave_value_list& idx);
 
-  int rows (void) const { return 1; }
-  int columns (void) const { return 1; }
-
-  int length (void) const
-  {
-    int r = rows ();
-    int c = columns ();
-
-    return r > c ? r : c;
-  }
-
-  bool is_defined (void) const { return true; }
-
-  bool is_constant (void) const { return true; }
-
   bool is_complex_scalar (void) const { return true; }
 
-  octave_value all (void) const { return (scalar != 0.0); }
-  octave_value any (void) const { return (scalar != 0.0); }
-
   bool is_complex_type (void) const { return true; }
 
-  bool is_scalar_type (void) const { return true; }
-
-  bool is_numeric_type (void) const { return true; }
-
   // XXX FIXME XXX ???
   bool valid_as_scalar_index (void) const { return false; }
   bool valid_as_zero_index (void) const { return false; }
 
-  bool is_true (void) const { return (scalar != 0.0); }
-
   double double_value (bool = false) const;
 
   double scalar_value (bool frc_str_conv = false) const
@@ -117,16 +94,8 @@
 
   void decrement (void) { scalar -= 1.0; }
 
-  void print (ostream& os, bool pr_as_read_syntax = false) const;
-
-  void print_raw (ostream& os, bool pr_as_read_syntax = false) const;
-
-  bool print_name_tag (ostream& os, const string& name) const;
-
 private:
 
-  Complex scalar;
-
   DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
 
   DECLARE_OCTAVE_ALLOCATOR
--- a/src/ov-scalar.cc	Thu Nov 19 22:14:09 1998 +0000
+++ b/src/ov-scalar.cc	Fri Nov 20 19:34:16 1998 +0000
@@ -34,12 +34,17 @@
 #include "gripes.h"
 #include "oct-obj.h"
 #include "ov-scalar.h"
+#include "ov-base.h"
+#include "ov-base-scalar.h"
+#include "ov-base-scalar.cc"
 #include "ov-re-mat.h"
 #include "ov-typeinfo.h"
 #include "pr-output.h"
 #include "xdiv.h"
 #include "xpow.h"
 
+template class octave_base_scalar<double>;
+
 DEFINE_OCTAVE_ALLOCATOR (octave_scalar);
 
 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_scalar, "scalar");
@@ -104,28 +109,6 @@
   return retval;
 }
 
-void
-octave_scalar::print (ostream& os, bool pr_as_read_syntax) const
-{
-  print_raw (os, pr_as_read_syntax);
-  newline (os);
-}
-
-void
-octave_scalar::print_raw (ostream& os, bool pr_as_read_syntax) const
-{
-  indent (os);
-  octave_print_internal (os, scalar, pr_as_read_syntax);
-}
-
-bool
-octave_scalar::print_name_tag (ostream& os, const string& name) const
-{
-  indent (os);
-  os << name << " = ";
-  return false;    
-}
-
 /*
 ;;; Local Variables: ***
 ;;; mode: C++ ***
--- a/src/ov-scalar.h	Thu Nov 19 22:14:09 1998 +0000
+++ b/src/ov-scalar.h	Fri Nov 20 19:34:16 1998 +0000
@@ -40,6 +40,7 @@
 #include "str-vec.h"
 
 #include "ov-base.h"
+#include "ov-base-scalar.h"
 #include "ov-typeinfo.h"
 
 class Octave_map;
@@ -50,18 +51,18 @@
 // Real scalar values.
 
 class
-octave_scalar : public octave_base_value
+octave_scalar : public octave_base_scalar<double>
 {
 public:
 
   octave_scalar (void)
-    : octave_base_value (), scalar (0.0) { }
+    : octave_base_scalar<double> (0.0) { }
 
   octave_scalar (double d)
-    : octave_base_value (), scalar (d) { }
+    : octave_base_scalar<double> (d) { }
 
   octave_scalar (const octave_scalar& s)
-    : octave_base_value (), scalar (s.scalar) { }
+    : octave_base_scalar<double> (s) { }
 
   ~octave_scalar (void) { }
 
@@ -71,23 +72,9 @@
 
   idx_vector index_vector (void) const { return idx_vector (scalar); }
 
-  int rows (void) const { return 1; }
-  int columns (void) const { return 1; }
-
-  int length (void) const { return 1; }
-
-  bool is_constant (void) const { return true; }
-
-  bool is_defined (void) const { return true; }
-
   bool is_real_scalar (void) const { return true; }
 
-  octave_value all (void) const { return (scalar != 0.0); }
-  octave_value any (void) const { return (scalar != 0.0); }
-
   bool is_real_type (void) const { return true; }
-  bool is_scalar_type (void) const { return true; }
-  bool is_numeric_type (void) const { return true; }
 
   bool valid_as_scalar_index (void) const
     { return (! xisnan (scalar) && NINT (scalar) == 1); }
@@ -95,8 +82,6 @@
   bool valid_as_zero_index (void) const
     { return (! xisnan (scalar) && NINT (scalar) == 0); }
 
-  bool is_true (void) const { return (scalar != 0.0); }
-
   double double_value (bool = false) const { return scalar; }
 
   double scalar_value (bool = false) const { return scalar; }
@@ -109,23 +94,14 @@
   ComplexMatrix complex_matrix_value (bool = false) const
     { return  ComplexMatrix (1, 1, Complex (scalar)); }
 
+  octave_value convert_to_str (void) const;
+
   void increment (void) { ++scalar; }
 
   void decrement (void) { --scalar; }
 
-  octave_value convert_to_str (void) const;
-
-  void print (ostream& os, bool pr_as_read_syntax = false) const;
-
-  void print_raw (ostream& os, bool pr_as_read_syntax = false) const;
-
-  bool print_name_tag (ostream& os, const string& name) const;
-
 private:
 
-  // The value of this scalar.
-  double scalar;
-
   DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
 
   DECLARE_OCTAVE_ALLOCATOR