[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: structures Matlab - Octave
From: |
David Bateman |
Subject: |
Re: structures Matlab - Octave |
Date: |
Thu, 29 Dec 2005 15:34:49 +0100 |
User-agent: |
Mozilla Thunderbird 0.8 (X11/20040923) |
Sorry to respond to my own mail... The last version had a minor typo (ie
"> 1" -> "> 0"). Please find an updated patch attached. This would means
the "a.b=1; c = a.b" would be an error. The attached version of the
patch fixes it.
D.
--
David Bateman address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin +33 1 69 35 77 01 (Fax)
91193 Gif-Sur-Yvette FRANCE
The information contained in this communication has been classified as:
[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary
*** ./src/oct-map.cc~ 2005-12-12 21:45:17.000000000 +0100
--- ./src/oct-map.cc 2005-12-29 14:59:12.759992084 +0100
***************
*** 210,215 ****
--- 210,240 ----
}
Octave_map&
+ Octave_map::maybe_delete_elements (const octave_value_list& idx)
+ {
+ string_vector t_keys = keys();
+ octave_idx_type len = t_keys.length ();
+
+ if (len > 0)
+ {
+ for (octave_idx_type i = 0; i < len; i++)
+ {
+ std::string k = t_keys[i];
+
+ map[k] = contents (k).assign (idx, Cell());
+
+ if (error_state)
+ break;
+ }
+
+ if (!error_state)
+ dimensions = contents(t_keys[0]).dims();
+ }
+
+ return *this;
+ }
+
+ Octave_map&
Octave_map::assign (const octave_value_list& idx, const Octave_map& rhs)
{
string_vector t_keys = empty () ? rhs.keys () : equiv_keys (*this, rhs);
*** ./src/oct-map.h~ 2005-12-12 21:45:17.000000000 +0100
--- ./src/oct-map.h 2005-12-29 14:22:10.288252500 +0100
***************
*** 133,138 ****
--- 133,140 ----
Octave_map concat (const Octave_map& rb, const Array<octave_idx_type>&
ra_idx);
+ Octave_map& maybe_delete_elements (const octave_value_list& idx);
+
Octave_map& assign (const octave_value_list& idx, const Octave_map& rhs);
Octave_map& assign (const octave_value_list& idx, const std::string& k,
*** ./src/ov-struct.cc~ 2005-12-15 02:10:05.000000000 +0100
--- ./src/ov-struct.cc 2005-12-29 15:30:24.930889373 +0100
***************
*** 133,141 ****
case '.':
{
! Cell t = dotref (idx.front ());
! retval(0) = (t.length () == 1) ? t(0) : octave_value (t, true);
}
break;
--- 133,144 ----
case '.':
{
! if (map.numel() > 0)
! {
! Cell t = dotref (idx.front ());
! retval(0) = (t.length () == 1) ? t(0) : octave_value (t, true);
! }
}
break;
***************
*** 307,325 ****
}
else
{
! Octave_map rhs_map = t_rhs.map_value ();
!
! if (! error_state)
{
! map.assign (idx.front (), rhs_map);
if (! error_state)
! retval = octave_value (this, count + 1);
else
! gripe_failed_assignment ();
}
else
! error ("invalid structure assignment");
}
}
break;
--- 310,345 ----
}
else
{
! if (t_rhs.is_map())
{
! Octave_map rhs_map = t_rhs.map_value ();
if (! error_state)
! {
! map.assign (idx.front (), rhs_map);
!
! if (! error_state)
! retval = octave_value (this, count + 1);
! else
! gripe_failed_assignment ();
! }
else
! error ("invalid structure assignment");
}
else
! {
! if (t_rhs.is_empty())
! {
! map.maybe_delete_elements (idx.front());
!
! if (! error_state)
! retval = octave_value (this, count + 1);
! else
! gripe_failed_assignment ();
! }
! else
! error ("invalid structure assignment");
! }
}
}
break;
***************
*** 393,399 ****
if (Vstruct_levels_to_print >= 0)
{
! bool print_keys_only = (Vstruct_levels_to_print == 0);
Vstruct_levels_to_print--;
--- 413,420 ----
if (Vstruct_levels_to_print >= 0)
{
! bool print_keys_only = (Vstruct_levels_to_print == 0 ||
! map.numel() == 0);
Vstruct_levels_to_print--;
***************
*** 403,409 ****
increment_indent_level ();
! octave_idx_type n = map.numel ();
if (n > 1 && print_keys_only)
{
--- 424,430 ----
increment_indent_level ();
! octave_idx_type n = map_keys().length();
if (n > 1 && print_keys_only)
{