changeset 23881:5aec653c88e7

new function for accessing classdef objects * ov.h, ov.cc (octave_value::classdef_object_value): New function. * ov-base.h, ov-base.cc (octave_base_value::classdef_object_value): New virtual function. * ov-classdef.h (octave_classdef::classdef_object_value): New function. diff --git a/libinterp/octave-value/ov-base.cc b/libinterp/octave-value/ov-base.cc --- a/libinterp/octave-value/ov-base.cc +++ b/libinterp/octave-value/ov-base.cc @@ -45,6 +45,7 @@ along with Octave; see the file COPYING. #include "ov-base.h" #include "ov-cell.h" #include "ov-ch-mat.h" +#include "ov-classdef.h" #include "ov-complex.h" #include "ov-cx-mat.h" #include "ov-fcn-handle.h" @@ -884,6 +885,18 @@ octave_base_value::parent_class_names (v err_wrong_type_arg ("octave_base_value::parent_class_names()", type_name ()); } +octave_classdef * +octave_base_value::classdef_object_value (bool silent) +{ + octave_classdef *retval = nullptr; + + if (! silent) + err_wrong_type_arg ("octave_base_value::classdef_object_value()", + type_name ()); + + return retval; +} + octave_function * octave_base_value::function_value (bool silent) { diff --git a/libinterp/octave-value/ov-base.h b/libinterp/octave-value/ov-base.h --- a/libinterp/octave-value/ov-base.h +++ b/libinterp/octave-value/ov-base.h @@ -47,6 +47,7 @@ class octave_map; class octave_scalar_map; class octave_value; class octave_value_list; +class octave_classdef; class octave_function; class octave_user_function; class octave_user_script; @@ -598,6 +599,8 @@ public: virtual bool is_instance_of (const std::string&) const { return false; } + virtual octave_classdef * classdef_object_value (bool silent = false); + virtual octave_function * function_value (bool silent = false); virtual octave_user_function * user_function_value (bool silent = false); diff --git a/libinterp/octave-value/ov-classdef.h b/libinterp/octave-value/ov-classdef.h --- a/libinterp/octave-value/ov-classdef.h +++ b/libinterp/octave-value/ov-classdef.h @@ -1398,6 +1398,8 @@ public: octave_base_value * empty_clone (void) const { return new octave_classdef (object.empty_clone ()); } + octave_classdef * classdef_object_value (bool = false) { return this; } + cdef_object get_object (void) const { return object; } cdef_object& get_object_ref (void) { return object; } diff --git a/libinterp/octave-value/ov.h b/libinterp/octave-value/ov.h --- a/libinterp/octave-value/ov.h +++ b/libinterp/octave-value/ov.h @@ -986,6 +986,8 @@ public: bool is_instance_of (const std::string& cls_name) const { return rep->is_instance_of (cls_name); } + octave_classdef * classdef_object_value (bool silent = false) const; + octave_function * function_value (bool silent = false) const; octave_user_function * user_function_value (bool silent = false) const;
author John W. Eaton <jwe@octave.org>
date Fri, 11 Aug 2017 09:05:58 -0400
parents 1b232c0c19e6
children 8e61b91f2e24
files libinterp/octave-value/ov-base.cc libinterp/octave-value/ov-base.h libinterp/octave-value/ov-classdef.h libinterp/octave-value/ov.cc libinterp/octave-value/ov.h
diffstat 5 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/octave-value/ov-base.cc	Fri Aug 11 08:05:01 2017 -0700
+++ b/libinterp/octave-value/ov-base.cc	Fri Aug 11 09:05:58 2017 -0400
@@ -45,6 +45,7 @@
 #include "ov-base.h"
 #include "ov-cell.h"
 #include "ov-ch-mat.h"
+#include "ov-classdef.h"
 #include "ov-complex.h"
 #include "ov-cx-mat.h"
 #include "ov-fcn-handle.h"
@@ -884,6 +885,18 @@
   err_wrong_type_arg ("octave_base_value::parent_class_names()", type_name ());
 }
 
+octave_classdef *
+octave_base_value::classdef_object_value (bool silent)
+{
+  octave_classdef *retval = nullptr;
+
+  if (! silent)
+    err_wrong_type_arg ("octave_base_value::classdef_object_value()",
+                        type_name ());
+
+  return retval;
+}
+
 octave_function *
 octave_base_value::function_value (bool silent)
 {
--- a/libinterp/octave-value/ov-base.h	Fri Aug 11 08:05:01 2017 -0700
+++ b/libinterp/octave-value/ov-base.h	Fri Aug 11 09:05:58 2017 -0400
@@ -47,6 +47,7 @@
 class octave_scalar_map;
 class octave_value;
 class octave_value_list;
+class octave_classdef;
 class octave_function;
 class octave_user_function;
 class octave_user_script;
@@ -598,6 +599,8 @@
   virtual bool is_instance_of (const std::string&) const
   { return false; }
 
+  virtual octave_classdef * classdef_object_value (bool silent = false);
+
   virtual octave_function * function_value (bool silent = false);
 
   virtual octave_user_function * user_function_value (bool silent = false);
--- a/libinterp/octave-value/ov-classdef.h	Fri Aug 11 08:05:01 2017 -0700
+++ b/libinterp/octave-value/ov-classdef.h	Fri Aug 11 09:05:58 2017 -0400
@@ -1398,6 +1398,8 @@
   octave_base_value * empty_clone (void) const
   { return new octave_classdef (object.empty_clone ()); }
 
+  octave_classdef * classdef_object_value (bool = false) { return this; }
+
   cdef_object get_object (void) const { return object; }
 
   cdef_object& get_object_ref (void) { return object; }
--- a/libinterp/octave-value/ov.cc	Fri Aug 11 08:05:01 2017 -0700
+++ b/libinterp/octave-value/ov.cc	Fri Aug 11 09:05:58 2017 -0400
@@ -1642,6 +1642,12 @@
   return rep->function_value (silent);
 }
 
+octave_classdef *
+octave_value::classdef_object_value (bool silent) const
+{
+  return rep->classdef_object_value (silent);
+}
+
 octave_user_function *
 octave_value::user_function_value (bool silent) const
 {
--- a/libinterp/octave-value/ov.h	Fri Aug 11 08:05:01 2017 -0700
+++ b/libinterp/octave-value/ov.h	Fri Aug 11 09:05:58 2017 -0400
@@ -986,6 +986,8 @@
   bool is_instance_of (const std::string& cls_name) const
   { return rep->is_instance_of (cls_name); }
 
+  octave_classdef * classdef_object_value (bool silent = false) const;
+
   octave_function * function_value (bool silent = false) const;
 
   octave_user_function * user_function_value (bool silent = false) const;