changeset 19100:eea4f61960d4 gui-release

maint: Periodic merge of stable to gui-release.
author Rik <rik@octave.org>
date Sun, 13 Jul 2014 18:04:42 -0700
parents 23e511f3395d (current diff) 9887440ceb2e (diff)
children d1c649bd90e9 62eb2927917e
files NEWS configure.ac scripts/deprecated/java_get.m scripts/deprecated/java_set.m scripts/deprecated/module.mk
diffstat 11 files changed, 215 insertions(+), 165 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags
+++ b/.hgtags
@@ -88,3 +88,4 @@
 dd669c2ae76c167613f54d6f4db0130fa2124cac rc-3-8-1-4
 43cc202335dc4a53a3d8fc9ca90acaa81d2e63d3 release-3-8-1
 492c5614953571a0b07f4c1621cc7bc5c85c0251 rc-3-8-2-1
+46df2c7b8f4dec400ce353370f2e47a02926026d rc-3-8-2-2
--- a/configure.ac
+++ b/configure.ac
@@ -33,7 +33,7 @@
 
 OCTAVE_COPYRIGHT="Copyright (C) 2013 John W. Eaton and others."
 
-OCTAVE_RELEASE_DATE="2014-06-06"
+OCTAVE_RELEASE_DATE="2014-07-01"
 
 ## The "API version" is used as a way of checking that interfaces in the
 ## liboctave and libinterp libraries haven't changed in a backwardly
--- a/doc/interpreter/java.txi
+++ b/doc/interpreter/java.txi
@@ -48,30 +48,98 @@
 @cindex object, creating a Java object
 @DOCSTRING(javaObject)
 
-@cindex fields, displaying available fields of a Java object
-@strong{FIXME:} Need documentation on how fieldnames() is overloaded to return
-the methods of a Java object.
+@cindex array, creating a Java array
+@DOCSTRING(javaArray)
 
-@cindex field, returning value of Java object field
-@strong{FIXME:} Need documentation on how to use structure-like indexing
-to get fields from Java object.
-
-@cindex field, setting value of Java object field
-@strong{FIXME:} Need documentation on how to use structure-like indexing
-to set fields from Java object.
+There are many different variable types in Octave but only ones created through
+@code{javaObject} can use Java functions.  Before using Java with an unknown
+object the type can be checked with @code{isjava}.
 
 @DOCSTRING(isjava)
 
-@cindex array, creating a Java array
-@DOCSTRING(javaArray)
+Once an object has been created it is natural to find out what fields the
+object has and to read (get) and write (set) them.
+
+@cindex fields, displaying available fields of a Java object
+In Octave the @code{fieldnames} function for structures has been overloaded
+to return the fields of a Java object.  For example:
+
+@example
+@group
+dobj = javaObject ("java.lang.Double", pi);
+fieldnames (dobj)
+@result{}
+@{
+  [1,1] = public static final double java.lang.Double.POSITIVE_INFINITY
+  [1,2] = public static final double java.lang.Double.NEGATIVE_INFINITY
+  [1,3] = public static final double java.lang.Double.NaN
+  [1,4] = public static final double java.lang.Double.MAX_VALUE
+  [1,5] = public static final double java.lang.Double.MIN_NORMAL
+  [1,6] = public static final double java.lang.Double.MIN_VALUE
+  [1,7] = public static final int java.lang.Double.MAX_EXPONENT
+  [1,8] = public static final int java.lang.Double.MIN_EXPONENT
+  [1,9] = public static final int java.lang.Double.SIZE
+  [1,10] = public static final java.lang.Class java.lang.Double.TYPE
+@}
+@end group
+@end example
+
+@cindex field, returning value of Java object field
+The analogy of objects with structures is carried over into reading and
+writing object fields.  To read a field the object is indexed with the
+@samp{.} operator from structures.  This is the preferred method for reading
+fields, but Octave also provides a function interface to read fields with
+@code{java_get}.  An example of both styles is shown below.
+
+@example
+@group
+dobj = javaObject ("java.lang.Double", pi);
+dobj.MAX_VALUE
+@result{}  1.7977e+308
+java_get ("java.lang.Float", "MAX_VALUE")
+@result{}  3.4028e+38
+@end group
+@end example
+
+@DOCSTRING(java_get)
+
+@cindex field, setting value of Java object field
+@DOCSTRING(java_set)
+
+@cindex methods, displaying available methods of a Java object
+To see what functions can be called with an object use @code{methods}.
+For example, using the previously created @var{dobj}:
+
+@example
+@group
+methods (dobj)
+@result{}
+Methods for class java.lang.Double:
+boolean equals(java.lang.Object)
+java.lang.String toString(double)
+java.lang.String toString()
+@dots{}
+@end group
+@end example
+
+To call a method of an object the same structure indexing operator @samp{.}
+is used.  Octave also provides a functional interface to calling the methods
+of an object through @code{javaMethod}.  An example showing both styles is
+shown below.
+
+@example
+@group
+dobj = javaObject ("java.lang.Double", pi);
+dobj.equals (3)
+@result{}  0
+javaMethod ("equals", dobj, pi)
+@result{}  1
+@end group
+@end example
 
 @cindex method, invoking a method of a Java object
 @DOCSTRING(javaMethod)
 
-@cindex methods, displaying available methods of a Java object
-@strong{FIXME:} Need documentation on how methods() is overloaded to return
-the methods of a Java object.
-
 The following three functions are used to display and modify the
 class path used by the Java Virtual Machine.  This is entirely separate
 from Octave's PATH variable and is used by the JVM to find the correct
--- a/libinterp/dldfcn/chol.cc
+++ b/libinterp/dldfcn/chol.cc
@@ -375,7 +375,7 @@
 /*
 %!assert (chol ([2, 1; 1, 1]), [sqrt(2), 1/sqrt(2); 0, 1/sqrt(2)], sqrt (eps))
 %!assert (chol (single ([2, 1; 1, 1])), single ([sqrt(2), 1/sqrt(2); 0, 1/sqrt(2)]), sqrt (eps ("single")))
-%!test   
+%!testif HAVE_CHOLMOD
 %! ## Bug #42587
 %! A = sparse ([1 0 8;0 1 8;8 8 1]);
 %! [Q, p] = chol (A);
deleted file mode 100644
--- a/scripts/deprecated/java_get.m
+++ /dev/null
@@ -1,63 +0,0 @@
-## Copyright (C) 2012-2013 Rik Wehbring
-##
-## This file is part of Octave.
-##
-## Octave is free software; you can redistribute it and/or modify it
-## under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 3 of the License, or (at
-## your option) any later version.
-##
-## Octave is distributed in the hope that it will be useful, but
-## WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn {Loadable Function} {@var{val} =} java_get (@var{obj}, @var{name})
-## Get the value of the field @var{name} of the Java object @var{obj}.  For
-## static fields, @var{obj} can be a string representing the fully qualified
-## name of the corresponding class.
-## 
-## When @var{obj} is a regular Java object, structure-like indexing can be
-## used as a shortcut syntax.  For instance, the two following statements are
-## equivalent
-## 
-## @example
-## @group
-##   java_get (x, "field1")
-##   x.field1
-## @end group
-## @end example
-## 
-## @seealso{java_set, javaMethod, javaObject}
-## @end deftypefn
-
-function retval = java_get (obj, name)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "java_get is obsolete and will be removed from a future version of Octave; use structure-like indexing instead");
-  endif
-
-  if (nargin != 2)
-    print_usage ();
-  endif
-
-  if (isjava (obj))
-    retval = obj.(name);
-  elseif (ischar (obj))
-    ## FIXME: Need a solution for getting static fields of class
-    ##        which does not depend on __java_get__ which will be removed.
-    retval = __java_get__ (obj, name);
-  else
-    error ("java_get: OBJ must be a Java object");
-  endif
-
-endfunction
-
deleted file mode 100644
--- a/scripts/deprecated/java_set.m
+++ /dev/null
@@ -1,63 +0,0 @@
-## Copyright (C) 2012-2013 Rik Wehbring
-##
-## This file is part of Octave.
-##
-## Octave is free software; you can redistribute it and/or modify it
-## under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 3 of the License, or (at
-## your option) any later version.
-##
-## Octave is distributed in the hope that it will be useful, but
-## WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn {Loadable Function} {@var{obj} =} java_set (@var{obj}, @var{name}, @var{val})
-## Set the value of the field @var{name} of the Java object @var{obj} to
-## @var{val}.  For static fields, @var{obj} can be a string representing the
-## fully qualified named of the corresponding Java class.
-## 
-## When @var{obj} is a regular Java object, structure-like indexing can be
-## used as a shortcut syntax.  For instance, the two following statements are
-## equivalent
-## 
-## @example
-## @group
-##   java_set (x, "field1", val)
-##   x.field1 = val
-## @end group
-## @end example
-## 
-## @seealso{java_get, javaMethod, javaObject}
-## @end deftypefn
-
-function retval = java_set (obj, name, val)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "java_set is obsolete and will be removed from a future version of Octave; use structure-like indexing instead");
-  endif
-
-  if (nargin != 3)
-    print_usage ();
-  endif
-
-  if (isjava (obj))
-    obj.(name) = val;
-  elseif (ischar (obj))
-    ## FIXME: Need a solution for getting static fields of class
-    ##        which does not depend on __java_set__ which will be removed.
-    retval = __java_set__ (obj, name, val);
-  else
-    error ("java_set: OBJ must be a Java object");
-  endif
-
-endfunction
-
--- a/scripts/deprecated/module.mk
+++ b/scripts/deprecated/module.mk
@@ -8,11 +8,9 @@
   deprecated/isstr.m \
   deprecated/java_convert_matrix.m \
   deprecated/java_debug.m \
-  deprecated/java_get.m \
   deprecated/java_invoke.m \
   deprecated/java_new.m \
   deprecated/java_unsigned_conversion.m \
-  deprecated/java_set.m \
   deprecated/javafields.m \
   deprecated/javamethods.m \
   deprecated/re_read_readline_init_file.m \
--- a/scripts/gui/listdlg.m
+++ b/scripts/gui/listdlg.m
@@ -164,35 +164,34 @@
 
 
 %!demo
-%! disp ('- test listdlg with selectionmode single. No caption, no prompt.');
-%! itemlist = {'An item \\alpha', 'another', 'yet another'};
-%! s = listdlg ('ListString',itemlist, 'SelectionMode','Single');
+%! disp ("- test listdlg with selectionmode single. No caption, no prompt.");
+%! itemlist = {"An item \\alpha", "another", "yet another"};
+%! s = listdlg ("ListString", itemlist, "SelectionMode", "Single");
 %! imax = numel (s);
 %! for i=1:1:imax
-%!   disp (['Selected: ',num2str (i),': ', itemlist{s (i)}]);
+%!   disp (["Selected: ", num2str(i), ": ", itemlist{s(i)}]);
 %! end
 
 %!demo
-%! disp ('- test listdlg with selectionmode and preselection. Has caption and two lines prompt.');
-%! itemlist = {'An item \\alpha', 'another', 'yet another'};
-%! s = listdlg ('ListString',itemlist, ...
-%!              'SelectionMode','Multiple', ...
-%!              'Name','Selection Dialog', ...
-%!              'InitialValue',[1,2,3,4],
-%!              'PromptString',{'Select <b>an</b> item...', '...or <b>multiple</b> items'} );
+%! disp ("- test listdlg with selectionmode and preselection. Has caption and two lines prompt.");
+%! itemlist = {"An item \\alpha", "another", "yet another"};
+%! s = listdlg ("ListString", itemlist, ...
+%!              "SelectionMode", "Multiple", ...
+%!              "Name", "Selection Dialog", ...
+%!              "InitialValue", [1,2,3,4],
+%!              "PromptString", {"Select <b>an</b> item...", "...or <b>multiple</b> items"});
 %! imax = numel (s);
 %! for i=1:1:imax
-%!   disp (['Selected: ',num2str (i),': ', itemlist{s (i)}]);
+%!   disp (["Selected: ", num2str(i), ": ", itemlist{s(i)}]);
 %! end
 
 %!demo
-%! disp ('- test listdlg with listsize.');
-%! itemlist = {"Neutron","Electron","Quark","Proton","Neutrino"};
-%! s = listdlg ("ListString",itemlist,
-%!              "Name","Bits and Pieces",
-%!              "ListSize",[200 75] );
+%! disp ("- test listdlg with listsize.");
+%! itemlist = {"Neutron", "Electron", "Quark", "Proton", "Neutrino"};
+%! s = listdlg ("ListString", itemlist,
+%!              "Name", "Bits and Pieces",
+%!              "ListSize", [200 75]);
 %! imax = numel (s);
 %! for i=1:1:imax
-%!   disp (['Selected: ',num2str (i),': ', itemlist{s (i)}]);
+%!   disp (["Selected: ", num2str(i), ": ", itemlist{s(i)}]);
 %! end
-
new file mode 100644
--- /dev/null
+++ b/scripts/java/java_get.m
@@ -0,0 +1,54 @@
+## Copyright (C) 2012-2013 Rik Wehbring
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {@var{val} =} java_get (@var{obj}, @var{name})
+## Get the value of the field @var{name} of the Java object @var{obj}.  For
+## static fields, @var{obj} can be a string representing the fully qualified
+## name of the corresponding class.
+## 
+## When @var{obj} is a regular Java object, structure-like indexing can be
+## used as a shortcut syntax.  For instance, the two following statements are
+## equivalent
+## 
+## @example
+## @group
+##   java_get (x, "field1")
+##   x.field1
+## @end group
+## @end example
+## 
+## @seealso{java_set, javaMethod, javaObject}
+## @end deftypefn
+
+function retval = java_get (obj, name)
+
+  if (nargin != 2)
+    print_usage ();
+  endif
+
+  if (isjava (obj))
+    retval = obj.(name);
+  elseif (ischar (obj))
+    retval = __java_get__ (obj, name);
+  else
+    error ("java_get: OBJ must be a Java object");
+  endif
+
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/java/java_set.m
@@ -0,0 +1,54 @@
+## Copyright (C) 2012-2013 Rik Wehbring
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {@var{obj} =} java_set (@var{obj}, @var{name}, @var{val})
+## Set the value of the field @var{name} of the Java object @var{obj} to
+## @var{val}.  For static fields, @var{obj} can be a string representing the
+## fully qualified named of the corresponding Java class.
+## 
+## When @var{obj} is a regular Java object, structure-like indexing can be
+## used as a shortcut syntax.  For instance, the two following statements are
+## equivalent
+## 
+## @example
+## @group
+##   java_set (x, "field1", val)
+##   x.field1 = val
+## @end group
+## @end example
+## 
+## @seealso{java_get, javaMethod, javaObject}
+## @end deftypefn
+
+function retval = java_set (obj, name, val)
+
+  if (nargin != 3)
+    print_usage ();
+  endif
+
+  if (isjava (obj))
+    obj.(name) = val;
+  elseif (ischar (obj))
+    retval = __java_set__ (obj, name, val);
+  else
+    error ("java_set: OBJ must be a Java object");
+  endif
+
+endfunction
+
--- a/scripts/java/module.mk
+++ b/scripts/java/module.mk
@@ -1,6 +1,8 @@
 FCN_FILE_DIRS += java
 
 java_FCN_FILES = \
+  java/java_get.m \
+  java/java_set.m \
   java/javaArray.m \
   java/javaaddpath.m \
   java/javaclasspath.m \