Mercurial > hg > octave-lojdl
changeset 10492:a6b64a7a3769
make feval work with overloaded handles
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 07 Apr 2010 10:15:58 +0200 |
parents | 077fef5da460 |
children | 2f8bacc2a57d |
files | liboctave/ChangeLog liboctave/str-vec.h src/ChangeLog src/oct-parse.yy |
diffstat | 4 files changed, 22 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2010-04-07 Jaroslav Hajek <highegg@gmail.com> + + * str-vec.h (string_vector::string_vector (const Array<std::string>)): + New constructor. + 2010-04-06 Jaroslav Hajek <highegg@gmail.com> * idx-vector.cc (idx_vector::complement): Rewrite.
--- a/liboctave/str-vec.h +++ b/liboctave/str-vec.h @@ -51,6 +51,9 @@ string_vector (const std::set<std::string>& lst); + string_vector (const Array<std::string>& s) + : Array<std::string> (s.as_column ()) { } + string_vector (const char * const *s); string_vector (const char * const *s, octave_idx_type n);
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-04-07 Jaroslav Hajek <highegg@gmail.com> + + * oct-parse.yy (feval): Use do_multi_index_op on handles. + (get_feval_args): Use array slicing functions rather than loops. + 2010-04-06 Jaroslav Hajek <highegg@gmail.com> * ov-base-sparse.cc (octave_base_sparse::delete_elements): Rewrite.
--- a/src/oct-parse.yy +++ b/src/oct-parse.yy @@ -4057,28 +4057,13 @@ static octave_value_list get_feval_args (const octave_value_list& args) { - int tmp_nargin = args.length () - 1; - - octave_value_list retval (tmp_nargin, octave_value ()); - - for (int i = 0; i < tmp_nargin; i++) - retval(i) = args(i+1); + octave_value_list retval = args.slice (1, args.length () - 1); string_vector arg_names = args.name_tags (); - if (! arg_names.empty ()) + if (arg_names.length () > 1) { - // tmp_nargin and arg_names.length () - 1 may differ if - // we are passed all_va_args. - - int n = arg_names.length () - 1; - - int len = n > tmp_nargin ? tmp_nargin : n; - - string_vector tmp_arg_names (len); - - for (int i = 0; i < len; i++) - tmp_arg_names(i) = arg_names(i+1); + string_vector tmp_arg_names = arg_names.linear_slice (1, args.length () - 1); retval.stash_name_tags (tmp_arg_names); } @@ -4115,17 +4100,14 @@ retval = feval (name, tmp_args, nargout); } } - else + else if (f_arg.is_function_handle () || f_arg.is_inline_function ()) { - octave_function *fcn = f_arg.function_value (); - - if (fcn) - { - octave_value_list tmp_args = get_feval_args (args); - - retval = feval (fcn, tmp_args, nargout); - } + const octave_value_list tmp_args = get_feval_args (args); + + retval = f_arg.do_multi_index_op (nargout, tmp_args); } + else + error ("feval: first argument must be a string, inline function or a function handle"); } return retval;