changeset 10961:2cc9b08bfd39

fixes in binders code
author Jaroslav Hajek <highegg@gmail.com>
date Sun, 12 Sep 2010 21:10:35 +0200
parents 409ceee18acc
children efc0f560e690
files src/ChangeLog src/ov-fcn-handle.cc
diffstat 2 files changed, 18 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
+2010-09-12  Jaroslav Hajek  <highegg@gmail.com>
+
+	* ov-fcn-handle.cc (octave_fcn_binder::maybe_binder): Stash name tags
+	in the template.
+	(octave_fcn_binder::do_multi_index_op): Don't use xelem to ensure
+	proper unsharing. Make a shallow copy prior to call to ensure
+	consistency throughout recursive calls.
+
 2010-09-11  Jaroslav Hajek  <highegg@gmail.com>
 
 	* ov-fcn-handle.h (octave_fcn_binder): New subclass.
--- a/src/ov-fcn-handle.cc
+++ b/src/ov-fcn-handle.cc
@@ -1900,6 +1900,11 @@
 
               if (! bad)
                 {
+                  // Stash proper name tags.
+                  std::list<string_vector> arg_names = idx_expr->arg_names ();
+                  assert (arg_names.size () == 1);
+                  arg_template.stash_name_tags (arg_names.front ());
+
                   retval = new octave_fcn_binder (f, root_val, arg_template, 
                                                   arg_mask, npar);
                 }
@@ -1933,10 +1938,13 @@
         {
           int j = arg_mask[i];
           if (j >= 0)
-             arg_template.xelem(i) = args(j);
+             arg_template(i) = args(j); // May force a copy...
         }
 
-      retval = root_handle.do_multi_index_op (nargout, arg_template, lvalue_list);
+      // Make a shallow copy of arg_template, to ensure consistency throughout the following
+      // call even if we happen to get back here.
+      octave_value_list tmp (arg_template);
+      retval = root_handle.do_multi_index_op (nargout, tmp, lvalue_list);
     }
   else
      retval = octave_fcn_handle::do_multi_index_op (nargout, args, lvalue_list);