Mercurial > octave
changeset 27078:d7e4d9b383ff
update funcdemo example
* funcdemo.cc (Ffuncdemo): Pass octave_value object to feval instead
of extracting string and pointer to octave_function objects. Use
DEFMETHOD_DLD instead of DEFUN_DLD and call interpreter::feval instead
of ::feval.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 06 May 2019 12:59:49 -0500 |
parents | 4e69b99978b0 |
children | c4cb6f431773 |
files | examples/code/funcdemo.cc |
diffstat | 1 files changed, 4 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/examples/code/funcdemo.cc Mon May 06 12:34:26 2019 -0500 +++ b/examples/code/funcdemo.cc Mon May 06 12:59:49 2019 -0500 @@ -1,7 +1,7 @@ #include <octave/oct.h> #include <octave/parse.h> -DEFUN_DLD (funcdemo, args, nargout, "Function Demo") +DEFMETHOD_DLD (funcdemo, interp, args, nargout, "Function Demo") { int nargin = args.length (); @@ -15,18 +15,9 @@ octave_value_list retval; - if (args(0).is_function_handle () || args(0).is_inline_function ()) - { - octave_function *fcn = args(0).function_value (); - - retval = feval (fcn, newargs, nargout); - } - else if (args(0).is_string ()) - { - std::string fcn = args(0).string_value (); - - retval = feval (fcn, newargs, nargout); - } + if (args(0).is_function_handle () || args(0).is_inline_function () + || args(0).is_string ()) + retval = interp.feval (args(0), newargs, nargout); else error ("funcdemo: INPUT must be string, inline, or function handle");