changeset 32136:bd26d9693501

new octave_base_value functions to create storable values * ov-base.h, ov-base.cc (octave_base_value::storable_value, octave_base_value::make_storable_value): New virtual functions.
author Petter T. <petter.vilhelm@gmail.com>
date Mon, 19 Jun 2023 10:27:30 -0400
parents eb5c236389ad
children 644ad8448c49
files libinterp/octave-value/ov-base.cc libinterp/octave-value/ov-base.h
diffstat 2 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/octave-value/ov-base.cc	Mon Jun 19 10:27:27 2023 -0400
+++ b/libinterp/octave-value/ov-base.cc	Mon Jun 19 10:27:30 2023 -0400
@@ -61,6 +61,7 @@
 #include "pr-output.h"
 #include "utils.h"
 #include "variables.h"
+#include "ov-inline.h"
 
 builtin_type_t btyp_mixed_numeric (builtin_type_t x, builtin_type_t y)
 {
@@ -121,6 +122,22 @@
   return resize (dim_vector ()).clone ();
 }
 
+// FIXME: Unlike other virtual functions in the octave_base_value
+// class, the storable_value and make_storable_value functions defined
+// here are not used by the corresponding octave_value functions.  This
+// inconsistency is likely to cause some confusion.
+octave_value
+octave_base_value::storable_value (void)
+{
+  return octave_value_factory::make_copy (this);
+}
+
+octave_base_value *
+octave_base_value::make_storable_value (void)
+{
+  return this;
+}
+
 octave_value
 octave_base_value::squeeze () const
 {
--- a/libinterp/octave-value/ov-base.h	Mon Jun 19 10:27:27 2023 -0400
+++ b/libinterp/octave-value/ov-base.h	Mon Jun 19 10:27:30 2023 -0400
@@ -794,6 +794,10 @@
 
   virtual octave_value dump () const;
 
+  virtual octave_value storable_value (void);
+
+  virtual octave_base_value * make_storable_value (void);
+
   // Standard mappers.  Register new ones here.
   enum unary_mapper_t
   {