diff libinterp/octave-value/ov-classdef.cc @ 16692:b9833510355d classdef

Add object array property indexing. * libinterp/octave-value/ov-classdef.cc (cdef_object_array::subsref): Support '.' indexing with single property name. Technically this also applies to methods without any arguments.
author Michael Goffioul <michael.goffioul@gmail.com>
date Mon, 20 May 2013 22:59:10 -0400
parents 50c8831878d2
children 50b37deadb66
line wrap: on
line diff
--- a/libinterp/octave-value/ov-classdef.cc	Mon May 20 20:17:19 2013 -0400
+++ b/libinterp/octave-value/ov-classdef.cc	Mon May 20 22:59:10 2013 -0400
@@ -1244,6 +1244,38 @@
         }
       break;
 
+    case '.':
+      if (type.size () == 1 && idx.size () == 1)
+        {
+          Cell c (dims ());
+
+          octave_idx_type n = array.numel ();
+
+          // dummy variables
+          size_t dummy_skip;
+          cdef_class dummy_cls;
+
+          for (octave_idx_type i = 0; i < n; i++)
+            {
+              octave_value_list r = array(i).subsref (type, idx, 1, dummy_skip,
+                                                      dummy_cls);
+
+              if (! error_state)
+                {
+                  if (r.length () > 0)
+                    c(i) = r(0);
+                }
+              else
+                break;
+            }
+
+          if (! error_state)
+            retval(0) = octave_value (c, true);
+
+          break;
+        }
+      // fall through "default"
+
     default:
       ::error ("can't perform indexing operation on array of %s objects",
                class_name ().c_str ());