changeset 20309:140ce5e857bf

maint: Periodic merge of stable to default.
author Rik <rik@octave.org>
date Tue, 23 Jun 2015 20:00:59 -0700
parents c2206fda3986 (current diff) b8c1b3e9aa91 (diff)
children 92c0fead20da
files libinterp/corefcn/graphics.in.h libinterp/corefcn/oct-hdf5.h libinterp/octave-value/ov-java.cc
diffstat 22 files changed, 115 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/examples/code/myfeval.c	Mon Jun 22 16:40:39 2015 -0700
+++ b/examples/code/myfeval.c	Tue Jun 23 20:00:59 2015 -0700
@@ -10,7 +10,7 @@
 
   mexPrintf ("I have %d inputs and %d outputs\n", nrhs, nlhs);
 
-  if (nrhs < 1 || ! mxIsString (prhs[0]))
+  if (nrhs < 1 || ! mxIsChar (prhs[0]))
     mexErrMsgTxt ("ARG1 must be a function name");
 
   str = mxArrayToString (prhs[0]);
--- a/examples/code/mypow2.c	Mon Jun 22 16:40:39 2015 -0700
+++ b/examples/code/mypow2.c	Tue Jun 23 20:00:59 2015 -0700
@@ -8,8 +8,8 @@
   mwIndex i;
   double *vri, *vro;
 
-  if (nrhs != 1 || ! mxIsNumeric (prhs[0]))
-    mexErrMsgTxt ("ARG1 must be a matrix");
+  if (nrhs != 1 || ! mxIsDouble (prhs[0]))
+    mexErrMsgTxt ("ARG1 must be a double matrix");
 
   n = mxGetNumberOfElements (prhs[0]);
   plhs[0] = mxCreateNumericArray (mxGetNumberOfDimensions (prhs[0]),
--- a/examples/code/myprop.c	Mon Jun 22 16:40:39 2015 -0700
+++ b/examples/code/myprop.c	Tue Jun 23 20:00:59 2015 -0700
@@ -9,10 +9,10 @@
 
   if (nrhs < 2 || nrhs > 3)
     mexErrMsgTxt ("incorrect number of arguments");
-  if (!mxIsDouble (prhs[0]))
-    mexErrMsgTxt ("handle expected to be a double scalar");
-  if (!mxIsChar (prhs[1]))
-    mexErrMsgTxt ("expected property to be a string");
+  if (! mxIsDouble (prhs[0]))
+    mexErrMsgTxt ("handle must be a double scalar");
+  if (! mxIsChar (prhs[1]))
+    mexErrMsgTxt ("property must be a string");
 
   handle = mxGetScalar (prhs[0]);
   mxGetString (prhs[1], property, 256);
--- a/examples/code/myset.c	Mon Jun 22 16:40:39 2015 -0700
+++ b/examples/code/myset.c	Tue Jun 23 20:00:59 2015 -0700
@@ -6,29 +6,32 @@
 {
   char *str;
   mxArray *v;
+  int found = 0;
 
-  if (nrhs != 2 || ! mxIsString (prhs[0]))
-    mexErrMsgTxt ("expects symbol name and value");
+  if (nrhs != 2 || ! mxIsChar (prhs[0]))
+    mexErrMsgTxt ("Arguments must be a symbol name and a value");
 
   str = mxArrayToString (prhs[0]);
 
+  // FIXME: If variable does not exist, error is reported which prevents
+  //        subsequent mexGetArray function from working.
   v = mexGetArray (str, "global");
-
   if (v)
     {
       mexPrintf ("%s is a global variable with the following value:\n", str);
       mexCallMATLAB (0, NULL, 1, &v, "disp");
+      found = 1;
     }
 
-  v = mexGetArray (str, "caller");
+  if (! found)
+    v = mexGetArray (str, "caller");
 
-  if (v)
+  if (! found && v)
     {
       mexPrintf ("%s is a caller variable with the following value:\n", str);
       mexCallMATLAB (0, NULL, 1, &v, "disp");
     }
 
   // WARNING!! Can't do this in MATLAB!  Must copy variable first.
-  mxSetName (prhs[1], str);
-  mexPutArray (prhs[1], "caller");
+  mexPutVariable ("caller", str, prhs[1]);
 }
--- a/examples/code/mystruct.c	Mon Jun 22 16:40:39 2015 -0700
+++ b/examples/code/mystruct.c	Tue Jun 23 20:00:59 2015 -0700
@@ -10,7 +10,7 @@
   const char *keys[] = { "this", "that" };
 
   if (nrhs != 1 || ! mxIsStruct (prhs[0]))
-    mexErrMsgTxt ("expects struct");
+    mexErrMsgTxt ("ARG1 must be a struct");
 
   for (i = 0; i < mxGetNumberOfFields (prhs[0]); i++)
     for (j = 0; j < mxGetNumberOfElements (prhs[0]); j++)
--- a/libgui/graphics/GLCanvas.cc	Mon Jun 22 16:40:39 2015 -0700
+++ b/libgui/graphics/GLCanvas.cc	Tue Jun 23 20:00:59 2015 -0700
@@ -46,6 +46,7 @@
 #endif
 {
   setFocusPolicy (Qt::ClickFocus);
+  setFocus();
 }
 
 GLCanvas::~GLCanvas (void)
--- a/libgui/graphics/gl-select.cc	Mon Jun 22 16:40:39 2015 -0700
+++ b/libgui/graphics/gl-select.cc	Tue Jun 23 20:00:59 2015 -0700
@@ -206,11 +206,11 @@
 opengl_selector::draw_image (const image::properties& props)
 {
   Matrix xd = props.get_xdata ().matrix_value ();
-  octave_idx_type nc = props.get_cdata ().matrix_value ().columns ();
+  octave_idx_type nc = props.get_cdata ().columns ();
   double x_pix_size = (xd(1) - xd(0)) / (nc - 1);
 
   Matrix yd = props.get_ydata ().matrix_value ();
-  octave_idx_type nr = props.get_cdata ().matrix_value ().rows ();
+  octave_idx_type nr = props.get_cdata ().rows ();
   double y_pix_size = (yd(1) - yd(0)) / (nr - 1);
 
   ColumnVector p1(3, 0.0), p2(3, 0.0), p3(3, 0.0), p4(3, 0.0);
--- a/libgui/src/octave-gui.cc	Mon Jun 22 16:40:39 2015 -0700
+++ b/libgui/src/octave-gui.cc	Tue Jun 23 20:00:59 2015 -0700
@@ -123,14 +123,13 @@
 #endif
 
   // show wizard if this is the first run
-  if (resource_manager::is_first_run ())
+  if (resource_manager::is_first_run () && start_gui)
     {
       // before wizard
       resource_manager::config_translators (&qt_tr, &qsci_tr, &gui_tr);
       application.installTranslator (&qt_tr);
       application.installTranslator (&gui_tr);
-      if (start_gui)
-        application.installTranslator (&qsci_tr);
+      application.installTranslator (&qsci_tr);
 
       welcome_wizard welcomeWizard;
 
--- a/libinterp/corefcn/graphics.in.h	Mon Jun 22 16:40:39 2015 -0700
+++ b/libinterp/corefcn/graphics.in.h	Tue Jun 23 20:00:59 2015 -0700
@@ -1461,6 +1461,7 @@
   {
     size_constraints.remove (dim_vector (1, -1));
     size_constraints.remove (dim_vector (-1, 1));
+    size_constraints.remove (dim_vector (0, 0));
 
     add_constraint (dim_vector (1, len));
     add_constraint (dim_vector (len, 1));
@@ -4742,7 +4743,9 @@
     void init (void)
     {
       xdata.add_constraint (2);
+      xdata.add_constraint (dim_vector (0, 0));
       ydata.add_constraint (2);
+      ydata.add_constraint (dim_vector (0, 0));
       cdata.add_constraint ("double");
       cdata.add_constraint ("single");
       cdata.add_constraint ("logical");
--- a/libinterp/corefcn/mex.cc	Mon Jun 22 16:40:39 2015 -0700
+++ b/libinterp/corefcn/mex.cc	Tue Jun 23 20:00:59 2015 -0700
@@ -617,8 +617,8 @@
   {
     if (ndims_arg < 2)
       {
-        dims[0] = 1;
-        dims[1] = 1;
+        dims[0] = 0;
+        dims[1] = 0;
       }
 
     for (mwIndex i = 0; i < ndims_arg; i++)
--- a/libinterp/corefcn/oct-hdf5.h	Mon Jun 22 16:40:39 2015 -0700
+++ b/libinterp/corefcn/oct-hdf5.h	Tue Jun 23 20:00:59 2015 -0700
@@ -29,14 +29,12 @@
 
 #include "oct-hdf5-types.h"
 
-#define HDF5_SAVE_TYPE H5T_NATIVE_UINT8
 
 #ifdef USE_64_BIT_IDX_T
 #define H5T_NATIVE_IDX H5T_NATIVE_INT64
 #else
 #define H5T_NATIVE_IDX H5T_NATIVE_INT
 #endif
-
 #endif
 
 #endif
--- a/libinterp/octave-value/ov-int16.cc	Mon Jun 22 16:40:39 2015 -0700
+++ b/libinterp/octave-value/ov-int16.cc	Tue Jun 23 20:00:59 2015 -0700
@@ -40,6 +40,10 @@
 #include "ops.h"
 #include "ov-base.h"
 
+#if defined (HAVE_HDF5)
+#define HDF5_SAVE_TYPE H5T_NATIVE_INT16
+#endif
+
 #include "ov-base-int.h"
 #include "ov-base-int.cc"
 #include "ov-int16.h"
--- a/libinterp/octave-value/ov-int32.cc	Mon Jun 22 16:40:39 2015 -0700
+++ b/libinterp/octave-value/ov-int32.cc	Tue Jun 23 20:00:59 2015 -0700
@@ -40,6 +40,10 @@
 #include "ops.h"
 #include "ov-base.h"
 
+#if defined (HAVE_HDF5)
+#define HDF5_SAVE_TYPE H5T_NATIVE_INT32
+#endif
+
 #include "ov-base-int.h"
 #include "ov-base-int.cc"
 #include "ov-int32.h"
--- a/libinterp/octave-value/ov-int64.cc	Mon Jun 22 16:40:39 2015 -0700
+++ b/libinterp/octave-value/ov-int64.cc	Tue Jun 23 20:00:59 2015 -0700
@@ -40,6 +40,10 @@
 #include "ops.h"
 #include "ov-base.h"
 
+#if defined (HAVE_HDF5)
+#define HDF5_SAVE_TYPE H5T_NATIVE_INT64
+#endif
+
 #include "ov-base-int.h"
 #include "ov-base-int.cc"
 #include "ov-int64.h"
--- a/libinterp/octave-value/ov-int8.cc	Mon Jun 22 16:40:39 2015 -0700
+++ b/libinterp/octave-value/ov-int8.cc	Tue Jun 23 20:00:59 2015 -0700
@@ -40,6 +40,10 @@
 #include "ops.h"
 #include "ov-base.h"
 
+#if defined (HAVE_HDF5)
+#define HDF5_SAVE_TYPE H5T_NATIVE_INT8
+#endif
+
 #include "ov-base-int.h"
 #include "ov-base-int.cc"
 #include "ov-int8.h"
--- a/libinterp/octave-value/ov-java.cc	Mon Jun 22 16:40:39 2015 -0700
+++ b/libinterp/octave-value/ov-java.cc	Tue Jun 23 20:00:59 2015 -0700
@@ -1281,6 +1281,20 @@
       jobj = jni_env->NewStringUTF (s.c_str ());
       jcls = jni_env->GetObjectClass (jobj);
     }
+  else if (val.is_cellstr ())
+    {
+      const Array<std::string> str_arr = val.cellstr_value ();
+      const octave_idx_type n = str_arr.numel ();
+      jclass_ref scls (jni_env, jni_env->FindClass ("java/lang/String"));
+      jobjectArray array = jni_env->NewObjectArray (n, scls, NULL);
+      for (octave_idx_type i = 0; i < n; i++)
+        {
+          jstring_ref jstr (jni_env, jni_env->NewStringUTF (str_arr(i).c_str ()));
+          jni_env->SetObjectArrayElement (array, i, jstr);
+        }
+      jobj = array;
+      jcls = jni_env->GetObjectClass (jobj);
+    }
   else if (val.numel () > 1 && val.dims ().is_vector ())
     {
 #define IF_UNBOX_PRIMITIVE_ARRAY(CHECK_TYPE, METHOD_TYPE, OCTAVE_TYPE, JAVA_TYPE, JAVA_TYPE_CAP) \
@@ -1414,20 +1428,6 @@
           error ("cannot convert matrix of type '%s'", val.class_name ().c_str ());
         }
     }
-  else if (val.is_cellstr ())
-    {
-      Cell cellStr = val.cell_value ();
-      jclass_ref scls (jni_env, jni_env->FindClass ("java/lang/String"));
-      jobjectArray array = jni_env->NewObjectArray (cellStr.numel (), scls, 0);
-      for (int i = 0; i < cellStr.numel (); i++)
-        {
-          jstring_ref jstr (jni_env,
-                            jni_env->NewStringUTF (cellStr(i).string_value().c_str ()));
-          jni_env->SetObjectArrayElement (array, i, jstr);
-        }
-      jobj = array;
-      jcls = jni_env->GetObjectClass (jobj);
-    }
   else
     {
       jclass rcls = find_octave_class (jni_env, "org/octave/OctaveReference");
@@ -2502,4 +2502,10 @@
 %! assert (class (javaObject ("java.lang.Byte", int8 (1))), "java.lang.Byte");
 %! assert (class (javaObject ("java.lang.Short", uint16 (1))), "java.lang.Short");
 %! assert (class (javaObject ("java.lang.Short", int16 (1))), "java.lang.Short");
+
+## Automatic conversion from string cell array into String[] (bug #45290)
+%!testif HAVE_JAVA
+%! assert (javaMethod ("binarySearch", "java.util.Arrays", {"aaa", "bbb", "ccc", "zzz"}, "aaa"), 0)
+%! assert (javaMethod ("binarySearch", "java.util.Arrays", {"aaa", "bbb", "ccc", "zzz"}, "zzz"), 3)
+%! assert (javaMethod ("binarySearch", "java.util.Arrays", {"aaa", "bbb", "ccc", "zzz"}, "hhh") < 0)
 */
--- a/libinterp/octave-value/ov-uint16.cc	Mon Jun 22 16:40:39 2015 -0700
+++ b/libinterp/octave-value/ov-uint16.cc	Tue Jun 23 20:00:59 2015 -0700
@@ -40,6 +40,10 @@
 #include "ops.h"
 #include "ov-base.h"
 
+#if defined (HAVE_HDF5)
+#define HDF5_SAVE_TYPE H5T_NATIVE_UINT16
+#endif
+
 #include "ov-base-int.h"
 #include "ov-base-int.cc"
 #include "ov-uint16.h"
--- a/libinterp/octave-value/ov-uint32.cc	Mon Jun 22 16:40:39 2015 -0700
+++ b/libinterp/octave-value/ov-uint32.cc	Tue Jun 23 20:00:59 2015 -0700
@@ -40,6 +40,10 @@
 #include "ops.h"
 #include "ov-base.h"
 
+#if defined (HAVE_HDF5)
+#define HDF5_SAVE_TYPE H5T_NATIVE_UINT32
+#endif
+
 #include "ov-base-int.h"
 #include "ov-base-int.cc"
 #include "ov-uint32.h"
--- a/libinterp/octave-value/ov-uint64.cc	Mon Jun 22 16:40:39 2015 -0700
+++ b/libinterp/octave-value/ov-uint64.cc	Tue Jun 23 20:00:59 2015 -0700
@@ -40,6 +40,10 @@
 #include "ops.h"
 #include "ov-base.h"
 
+#if defined (HAVE_HDF5)
+#define HDF5_SAVE_TYPE H5T_NATIVE_UINT64
+#endif
+
 #include "ov-base-int.h"
 #include "ov-base-int.cc"
 #include "ov-uint64.h"
--- a/libinterp/octave-value/ov-uint8.cc	Mon Jun 22 16:40:39 2015 -0700
+++ b/libinterp/octave-value/ov-uint8.cc	Tue Jun 23 20:00:59 2015 -0700
@@ -40,6 +40,10 @@
 #include "ops.h"
 #include "ov-base.h"
 
+#if defined (HAVE_HDF5)
+#define HDF5_SAVE_TYPE H5T_NATIVE_UINT8
+#endif
+
 #include "ov-base-int.h"
 #include "ov-base-int.cc"
 #include "ov-uint8.h"
--- a/scripts/specfun/ellipke.m	Mon Jun 22 16:40:39 2015 -0700
+++ b/scripts/specfun/ellipke.m	Tue Jun 23 20:00:59 2015 -0700
@@ -94,7 +94,6 @@
   endif
 
   sz = size (m);
-  m = m(:);
   if (! isreal (m))
     error ("ellipke: M must be real");
   elseif (any (m > 1))
@@ -127,8 +126,8 @@
     mult_k = 1./sqrt (1 - m(idx_neg));
     mult_e = sqrt (1 - m(idx_neg));
     m(idx_neg) = -m(idx_neg) ./ (1 - m(idx_neg));
-    a = ones (sum (idx), 1);
     b = sqrt (1 - m(idx));
+    a = ones (size (b));
     c = sqrt (m(idx));
     f = 0.5;
     sum = f*c.^2;
--- a/test/io.tst	Mon Jun 22 16:40:39 2015 -0700
+++ b/test/io.tst	Tue Jun 23 20:00:59 2015 -0700
@@ -191,6 +191,35 @@
 %!
 %! assert (save_status && load_status);
 
+%!testif HAVE_HDF5
+%!
+%! s8  =   int8 (fix ((2^8  - 1) * (rand (2, 2) - 0.5)));
+%! u8  =  uint8 (fix ((2^8  - 1) * (rand (2, 2) - 0.5)));
+%! s16 =  int16 (fix ((2^16 - 1) * (rand (2, 2) - 0.5)));
+%! u16 = uint16 (fix ((2^16 - 1) * (rand (2, 2) - 0.5)));
+%! s32 =  int32 (fix ((2^32 - 1) * (rand (2, 2) - 0.5)));
+%! u32 = uint32 (fix ((2^32 - 1) * (rand (2, 2) - 0.5)));
+%! s64 =  int64 (fix ((2^64 - 1) * (rand (2, 2) - 0.5)));
+%! u64 = uint64 (fix ((2^64 - 1) * (rand (2, 2) - 0.5)));
+%! s8t = s8; u8t = u8; s16t = s16; u16t = u16; s32t = s32; u32t = u32;
+%! s64t = s64; u64t = u64;
+%! h5file = tempname ();
+%! unwind_protect
+%!   eval (sprintf ("save -hdf5 %s %s", h5file, "s8 u8 s16 u16 s32 u32 s64 u64"));
+%!   clear s8 u8 s16 u16 s32 u32 s64 u64;
+%!   load (h5file);
+%!   assert (s8, s8t);
+%!   assert (u8, u8t);
+%!   assert (s16, s16t);
+%!   assert (u16, u16t);
+%!   assert (s32, s32t);
+%!   assert (u32, u32t);
+%!   assert (s64, s64t);
+%!   assert (u64, u64t);
+%! unwind_protect_cleanup
+%!   unlink (h5file);
+%! end_unwind_protect
+
 %!test
 %!
 %! STR.scalar_fld = 1;
@@ -639,3 +668,8 @@
 
 %!assert (sprintf ("%c,%c,%c,%c", "abcd"), "a,b,c,d");
 %!assert (sprintf ("%s,%s,%s,%s", "abcd"), "abcd,");
+
+%!assert (sprintf ("|%x|", "Octave"), "|4f||63||74||61||76||65|");
+%!assert (sprintf ("|%X|", "Octave"), "|4F||63||74||61||76||65|");
+%!assert (sprintf ("|%o|", "Octave"), "|117||143||164||141||166||145|");
+