Mercurial > hg > octave-lyh
comparison src/ov-struct.cc @ 9190:7a10410db2c6
[mq]: x
author | Robert T. Short <rtshort@ieee.org> |
---|---|
date | Fri, 08 May 2009 15:18:22 -0400 |
parents | 961410931a4f |
children | c2248cc4821a |
comparison
equal
deleted
inserted
replaced
9189:8a348e4be8bb | 9190:7a10410db2c6 |
---|---|
699 If the values are cell arrays, create a structure array and initialize\n\ | 699 If the values are cell arrays, create a structure array and initialize\n\ |
700 its values. The dimensions of each cell array of values must match.\n\ | 700 its values. The dimensions of each cell array of values must match.\n\ |
701 Singleton cells and non-cell values are repeated so that they fill\n\ | 701 Singleton cells and non-cell values are repeated so that they fill\n\ |
702 the entire array. If the cells are empty, create an empty structure\n\ | 702 the entire array. If the cells are empty, create an empty structure\n\ |
703 array with the specified field names.\n\ | 703 array with the specified field names.\n\ |
704 \n\ | |
705 If the argument is an object, return the underlying struct.\n\ | |
704 @end deftypefn") | 706 @end deftypefn") |
705 { | 707 { |
706 octave_value retval; | 708 octave_value retval; |
707 | 709 |
708 int nargin = args.length (); | 710 int nargin = args.length (); |
712 // struct (empty_matrix) returns an empty struct with the same | 714 // struct (empty_matrix) returns an empty struct with the same |
713 // dimensions as the empty matrix. | 715 // dimensions as the empty matrix. |
714 | 716 |
715 // Note that struct () creates a 1x1 struct with no fields for | 717 // Note that struct () creates a 1x1 struct with no fields for |
716 // compatibility with Matlab. | 718 // compatibility with Matlab. |
719 | |
720 if (nargin == 1 && args(0).is_object ()) | |
721 { | |
722 Octave_map m = args(0).map_value (); | |
723 retval = octave_value (new octave_struct (m)); | |
724 | |
725 return retval; | |
726 } | |
717 | 727 |
718 if ((nargin == 1 || nargin == 2) | 728 if ((nargin == 1 || nargin == 2) |
719 && args(0).is_empty () && args(0).is_real_matrix ()) | 729 && args(0).is_empty () && args(0).is_real_matrix ()) |
720 { | 730 { |
721 Cell fields; | 731 Cell fields; |