Mercurial > hg > octave-nkf
changeset 4858:499d2ca46982
[project @ 2004-04-08 18:00:43 by jwe]
author | jwe |
---|---|
date | Thu, 08 Apr 2004 18:00:43 +0000 |
parents | 9794d526639c |
children | 265d566cc770 |
files | src/ChangeLog src/ov-base-mat.cc src/ov-base-nd-array.cc src/ov-base-nd-array.h src/ov.cc |
diffstat | 5 files changed, 32 insertions(+), 261 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2004-04-08 John W. Eaton <jwe@octave.org> + + * ov-base-mat.cc (octave_base_matrix<MT>::do_index_op): Quit early + if an error occurs when creating index vector object. + + * ov.cc (octave_value::numeric_assign): Always call maybe_mutate + on return value. + 2004-04-06 David Bateman <dbateman@free.fr> * DLD_FUNCTIONS/sort.cc: Use the new template sort class, adapt for
--- a/src/ov-base-mat.cc +++ b/src/ov-base-mat.cc @@ -149,7 +149,8 @@ { idx_vector i = idx (0).index_vector (); - retval = MT (matrix.index (i, resize_ok, MT::resize_fill_value ())); + if (! error_state) + retval = MT (matrix.index (i, resize_ok, MT::resize_fill_value ())); } break; @@ -158,20 +159,31 @@ if (n_idx == 2 && nd == 2) { idx_vector i = idx (0).index_vector (); - idx_vector j = idx (1).index_vector (); + + if (! error_state) + { + idx_vector j = idx (1).index_vector (); - retval = MT (matrix.index (i, j, resize_ok, - MT::resize_fill_value ())); + if (! error_state) + retval = MT (matrix.index (i, j, resize_ok, + MT::resize_fill_value ())); + } } else { Array<idx_vector> idx_vec (n_idx); for (int i = 0; i < n_idx; i++) - idx_vec(i) = idx(i).index_vector (); + { + idx_vec(i) = idx(i).index_vector (); - retval = MT (matrix.index (idx_vec, resize_ok, - MT::resize_fill_value ())); + if (error_state) + break; + } + + if (! error_state) + retval = MT (matrix.index (idx_vec, resize_ok, + MT::resize_fill_value ())); } } break;
deleted file mode 100644 --- a/src/ov-base-nd-array.cc +++ /dev/null @@ -1,149 +0,0 @@ -/* - -Copyright (C) 2000 John W. Eaton - -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 2, 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, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma implementation -#endif - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <iostream> - -#include "oct-obj.h" -#include "ov-base.h" -#include "ov-base-nd-array.h" -#include "pr-output.h" - -static inline Array<idx_vector> -idx_list_to_idx_array (const octave_value_list& idx) -{ - int n = idx.length (); - - Array<idx_vector> retval (n); - - for (int i = 0; i < n; i++) - retval(i) = idx(i).index_vector (); - - return retval; -} - -template <class AT> -octave_value -octave_base_nd_array<AT>::do_index_op (const octave_value_list& idx, - int resize_ok) -{ - octave_value retval; - - int len = idx.length (); - - if (len > 1) - { - Array<idx_vector> i = idx_list_to_idx_array (idx); - - retval - = octave_value (new octave_base_nd_array<AT> (AT (array.index (i, resize_ok)))); - } - else if (len == 1) - { - idx_vector i = idx(0).index_vector (); - - retval - = octave_value (new octave_base_nd_array<AT> (AT (array.index (i, resize_ok)))); - } - else - { - std::string n = type_name (); - - error ("invalid number of indices (%d) for %s value", - len, n.c_str ()); - } - - return retval; -} - -template <class AT> -bool -octave_base_nd_array<AT>::is_true (void) const -{ - // XXX FIXME XXX - return false; -} - -template <class AT> -bool -octave_base_nd_array<AT>::print_as_scalar (void) const -{ - // XXX FIXME XXX - return false; -} - -template <class AT> -void -octave_base_nd_array<AT>::print (std::ostream& os, - bool pr_as_read_syntax) const -{ - print_raw (os, pr_as_read_syntax); - newline (os); -} - -template <class AT> -void -octave_base_nd_array<AT>::print_raw (std::ostream& os, - bool pr_as_read_syntax) const -{ - // XXX FIXME XX - os << array; -#if 0 - octave_print_internal (os, array, pr_as_read_syntax, - current_print_indent_level ()); -#endif -} - -template <class AT> -bool -octave_base_nd_array<AT>::print_name_tag (std::ostream& os, - const std::string& name) const -{ - bool retval = false; - - indent (os); - - if (print_as_scalar ()) - os << name << " = "; - else - { - os << name << " ="; - newline (os); - newline (os); - retval = true; - } - - return retval; -} - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/
deleted file mode 100644 --- a/src/ov-base-nd-array.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - -Copyright (C) 2000 John W. Eaton - -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 2, 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, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#if !defined (octave_base_nd_array_h) -#define octave_base_nd_array_h 1 - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma interface -#endif - -#include <cstdlib> - -#include <iostream> -#include <string> - -#include "mx-base.h" -#include "str-vec.h" - -#include "error.h" -#include "ov-base.h" -#include "ov-typeinfo.h" - -class Octave_map; -class octave_value_list; - -class tree_walker; - -// ND array values values. - -template <class AT> -class -octave_base_nd_array : public octave_base_value -{ -public: - - octave_base_nd_array (void) - : octave_base_value () { } - - octave_base_nd_array (const AT& a) - : octave_base_value (), array (a) { } - - octave_base_nd_array (const octave_base_nd_array& a) - : octave_base_value (), array (a.array) { } - - ~octave_base_nd_array (void) { } - - octave_value *clone (void) const { return new octave_base_nd_array (*this); } - octave_value *empty_clone (void) const { return new octave_base_nd_array (); } - - octave_value do_index_op (const octave_value_list& idx, int resize_ok); - - bool is_matrix_type (void) const { return false; } - - bool is_numeric_type (void) const { return true; } - - bool is_defined (void) const { return true; } - - bool is_constant (void) const { return true; } - - bool is_true (void) const; - - virtual bool print_as_scalar (void) const; - - void print (std::ostream& os, bool pr_as_read_syntax = false) const; - - void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; - - bool print_name_tag (std::ostream& os, const std::string& name) const; - -protected: - - AT array; -}; - -#endif - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/
--- a/src/ov.cc +++ b/src/ov.cc @@ -1367,11 +1367,6 @@ { retval = tmp->subsasgn (type, idx, rhs); - // The assignment may have converted to a type that - // is wider than necessary. - - retval.maybe_mutate (); - done = (! error_state); } else @@ -1433,6 +1428,11 @@ } } + // The assignment may have converted to a type that is wider than + // necessary. + + retval.maybe_mutate (); + return retval; }