diff src/ov-class.cc @ 10272:272179888089

Fclass: improve argument decoding
author John W. Eaton <jwe@octave.org>
date Mon, 08 Feb 2010 01:36:18 -0500
parents 1d430a849f3c
children 57a59eae83cc
line wrap: on
line diff
--- a/src/ov-class.cc	Mon Feb 08 07:20:27 2010 +0100
+++ b/src/ov-class.cc	Mon Feb 08 01:36:18 2010 -0500
@@ -1721,18 +1721,18 @@
     retval = args(0).class_name ();
   else
     {
-      Octave_map m = args(0).map_value ();
+      octave_function *fcn = octave_call_stack::caller ();
 
-      if (! error_state)
-	{
-	  std::string id = args(1).string_value ();
+      if (fcn && fcn->is_class_constructor ())
+        {
+          Octave_map m = args(0).map_value ();
 
-	  if (! error_state)
-	    {
-	      octave_function *fcn = octave_call_stack::caller ();
+          if (! error_state)
+            {
+              std::string id = args(1).string_value ();
 
-	      if (fcn && fcn->is_class_constructor ())
-		{
+              if (! error_state)
+                {
 		  if (nargin == 2)
 		    retval = octave_value (new octave_class (m, id));
 		  else
@@ -1753,15 +1753,15 @@
 		      else if (! it->second.compare (retval))
 			error ("class: object of class `%s' does not match previously constructed objects", id.c_str ());
 		    }
-		}
+                }
 	      else
-		error ("class: invalid call from outside class constructor");
+                error ("class: expecting character string as second argument");
 	    }
 	  else
-	    error ("class: expecting character string as second argument");
+            error ("class: expecting structure as first argument");
 	}
       else
-	error ("class: expecting structure as first argument");
+        error ("class: invalid call from outside class constructor");
     }
 
   return retval;