|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Allow and ignore extra outargs from user-defined size methodsHi bug-list,
Making a user-defined size method is tricky business. In order to write it correctly, you have to use varargout, test conditions carefully and so forth. It becomes even trickier when Octave is really picky about this, and won't allow you to cheat the least bit (like skipping varargout). I made Octave ignore extra outargs and also fixed a simple printf error too. Attached changeset, parent: 9747:7bda650b691a. David # HG changeset patch # User David Grundberg <davidg@...> # Date 1257234560 -3600 # Node ID 4c116b053fedda6b24c004ce6cc541415d26eb3b # Parent 7bda650b691a21434cddb2452a0fbc77c558a9ca Allow and ignore extra outargs from user-defined size methods diff -r 7bda650b691a -r 4c116b053fed src/ChangeLog --- a/src/ChangeLog Tue Oct 20 15:45:09 2009 +0200 +++ b/src/ChangeLog Tue Nov 03 08:49:20 2009 +0100 @@ -1,3 +1,8 @@ +2009-11-03 David Grundberg <davidg@...> + + * ov-class.cc (octave_class::size): Allow and ignore extra outargs + from user-defined size methods. + 2009-10-20 Jaroslav Hajek <highegg@...> * ov-base.h (builtin_type_t): Declare also btyp_num_types. diff -r 7bda650b691a -r 4c116b053fed src/ov-class.cc --- a/src/ov-class.cc Tue Oct 20 15:45:09 2009 +0200 +++ b/src/ov-class.cc Tue Nov 03 08:49:20 2009 +0100 @@ -306,10 +306,10 @@ octave_value_list args (1, octave_value (this)); octave_value_list lv = feval (meth.function_value (), args, 1); - if (lv.length () == 1 && lv(0).is_matrix_type () && lv(0).dims ().is_vector ()) + if (lv.length () > 0 && lv(0).is_matrix_type () && lv(0).dims ().is_vector ()) retval = lv(0).matrix_value (); else - error ("@%s/size: invalid return value"); + error ("@%s/size: invalid return value", class_name ().c_str ()); } return retval; _______________________________________________ Bug-octave mailing list Bug-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave |
|
|
Re: Allow and ignore extra outargs from user-defined size methodsOn Tue, Nov 3, 2009 at 9:23 AM, David Grundberg <individ@...> wrote:
> Hi bug-list, > > Making a user-defined size method is tricky business. In order to write it > correctly, you have to use varargout, test conditions carefully and so > forth. It becomes even trickier when Octave is really picky about this, and > won't allow you to cheat the least bit (like skipping varargout). > > I made Octave ignore extra outargs and also fixed a simple printf error too. > Attached changeset, parent: 9747:7bda650b691a. > > David > > > # HG changeset patch > # User David Grundberg <davidg@...> > # Date 1257234560 -3600 > # Node ID 4c116b053fedda6b24c004ce6cc541415d26eb3b > # Parent 7bda650b691a21434cddb2452a0fbc77c558a9ca > Allow and ignore extra outargs from user-defined size methods > > diff -r 7bda650b691a -r 4c116b053fed src/ChangeLog > --- a/src/ChangeLog Tue Oct 20 15:45:09 2009 +0200 > +++ b/src/ChangeLog Tue Nov 03 08:49:20 2009 +0100 > @@ -1,3 +1,8 @@ > +2009-11-03 David Grundberg <davidg@...> > + > + * ov-class.cc (octave_class::size): Allow and ignore extra outargs > + from user-defined size methods. > + > 2009-10-20 Jaroslav Hajek <highegg@...> > > * ov-base.h (builtin_type_t): Declare also btyp_num_types. > diff -r 7bda650b691a -r 4c116b053fed src/ov-class.cc > --- a/src/ov-class.cc Tue Oct 20 15:45:09 2009 +0200 > +++ b/src/ov-class.cc Tue Nov 03 08:49:20 2009 +0100 > @@ -306,10 +306,10 @@ > octave_value_list args (1, octave_value (this)); > > octave_value_list lv = feval (meth.function_value (), args, 1); > - if (lv.length () == 1 && lv(0).is_matrix_type () && lv(0).dims > ().is_vector ()) > + if (lv.length () > 0 && lv(0).is_matrix_type () && lv(0).dims > ().is_vector ()) > retval = lv(0).matrix_value (); > else > - error ("@%s/size: invalid return value"); > + error ("@%s/size: invalid return value", class_name ().c_str ()); > } > > return retval; > > _______________________________________________ > Bug-octave mailing list > Bug-octave@... > https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave > > applied, thanks. -- RNDr. Jaroslav Hajek computing expert & GNU Octave developer Aeronautical Research and Test Institute (VZLU) Prague, Czech Republic url: www.highegg.matfyz.cz _______________________________________________ Bug-octave mailing list Bug-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave |
| Free embeddable forum powered by Nabble | Forum Help |