diff libinterp/octave-value/ov-class.cc @ 15785:42cff4396de4

Add methods.m which extends methods() to work on Java objects. Deprecate javamethods.m. Rename C++ methods to __methods__. * scripts/deprecated/javamethods.m: Moved from scripts/java. Added deprecated warning. * scripts/java/javamethods.m: Moved to scripts/deprecated. * scripts/general/methods.m: New m-file which accepts Java and Octave class objects and classnames as inputs. * libinterp/octave-value/ov-class.cc(Fmethods): Renamed methods to __methods__ to avoid clash with methods.m * scripts/deprecated/module.mk: Added javamethods.m to deprecated build. * scripts/general/module.mk: Added methods.m to build. * scripts/java/module.mk: Removed javamethods.m from build.
author Rik <rik@octave.org>
date Thu, 13 Dec 2012 22:41:48 -0800
parents 049e8bbff782
children 317f4857c1e1
line wrap: on
line diff
--- a/libinterp/octave-value/ov-class.cc	Thu Dec 13 22:14:36 2012 +0100
+++ b/libinterp/octave-value/ov-class.cc	Thu Dec 13 22:41:48 2012 -0800
@@ -2103,47 +2103,33 @@
   return retval;
 }
 
-DEFUN (methods, args, nargout,
+DEFUN (__methods__, args, ,
   "-*- texinfo -*-\n\
-@deftypefn  {Built-in Function} {} methods (@var{x})\n\
-@deftypefnx {Built-in Function} {} methods (\"classname\")\n\
-Return a cell array containing the names of the methods for the\n\
-object @var{x} or the named class.\n\
+@deftypefn  {Built-in Function} {} __methods__ (@var{x})\n\
+@deftypefnx {Built-in Function} {} __methods__ (\"classname\")\n\
+Internal function.\n\
+\n\
+Implements @code{methods} for Octave class objects and classnames.\n\
+@seealso{methods}\n\
 @end deftypefn")
 {
   octave_value retval;
 
-  if (args.length () == 1)
-    {
-      octave_value arg = args(0);
-
-      std::string class_name;
+  // Input validation has already been done in methods.m.
+  octave_value arg = args(0);
 
-      if (arg.is_object ())
-        class_name = arg.class_name ();
-      else if (arg.is_string ())
-        class_name = arg.string_value ();
-      else
-        error ("methods: expecting object or class name as argument");
+  std::string class_name;
 
-      if (! error_state)
-        {
-          string_vector sv = load_path::methods (class_name);
-
-          if (nargout == 0)
-            {
-              octave_stdout << "Methods for class " << class_name << ":\n\n";
+  if (arg.is_object ())
+    class_name = arg.class_name ();
+  else if (arg.is_string ())
+    class_name = arg.string_value ();
 
-              sv.list_in_columns (octave_stdout);
-
-              octave_stdout << std::endl;
-            }
-          else
-            retval = Cell (sv);
-        }
+  if (! error_state)
+    {
+      string_vector sv = load_path::methods (class_name);
+      retval = Cell (sv);
     }
-  else
-    print_usage ();
 
   return retval;
 }