changeset 11459:990c9cb52e5f

__isequal__: compare objects as if they are structures
author John W. Eaton <jwe@octave.org>
date Fri, 07 Jan 2011 14:48:55 -0500
parents 93a039fe681e
children 17936067b48f
files scripts/ChangeLog scripts/general/private/__isequal__.m
diffstat 2 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Fri Jan 07 14:14:35 2011 -0500
+++ b/scripts/ChangeLog	Fri Jan 07 14:48:55 2011 -0500
@@ -1,3 +1,8 @@
+2011-01-07  John W. Eaton  <jwe@octave.org>
+
+	* general/private/__isequal__.m: Compare objects as if they are
+	structures.
+
 2011-01-07  John W. Eaton  <jwe@octave.org>
 
 	* linear-algebra/logm.m: Style fixes.
--- a/scripts/general/private/__isequal__.m	Fri Jan 07 14:14:35 2011 -0500
+++ b/scripts/general/private/__isequal__.m	Fri Jan 07 14:48:55 2011 -0500
@@ -59,7 +59,7 @@
   ## All arguments must either be of the same class or they must be
   ## numeric values.
   t = (all (strcmp (class(x),
-                   cellfun (@class, varargin, "uniformoutput", false)))
+                    cellfun (@class, varargin, "uniformoutput", false)))
        || ((isnumeric (x) || islogical (x))
            && all (cellfun (@isnumeric, varargin)
                    | cellfun (@islogical, varargin))));
@@ -83,6 +83,12 @@
     endwhile
   endif
 
+  ## From here on, compare objects as if they were structures.
+  if (isobject (x))
+    x = struct (x);
+    varargin = cellfun (@struct, varargin, "uniformoutput", false);
+  endif
+
   if (t)
     ## Check individual classes.
     if (isstruct (x))