Mercurial > octave
changeset 23683:ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
* ov.h (octave_value::is_classdef_meta): New function.
* ov-base.h (octave_base_value::is_classdef_meta):
New virtual function.
* ov-classdef.cc (octave_classdef_meta::is_classdef_meta):
New function.
* pt-eval.cc (tree_evaluator::visit_index_expression):
Handle calls to functions from +package directories. Don't call
subsref on function objects unless they are classdef_meta objects.
If indexing produces a function object, call it.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 23 Jun 2017 18:18:07 -0400 |
parents | 6fe13cd3543c |
children | c84328c2a6c7 |
files | libinterp/octave-value/ov-base.h libinterp/octave-value/ov-classdef.cc libinterp/octave-value/ov.h libinterp/parse-tree/pt-eval.cc |
diffstat | 4 files changed, 21 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-base.h Fri Jun 23 12:32:19 2017 -0700 +++ b/libinterp/octave-value/ov-base.h Fri Jun 23 18:18:07 2017 -0400 @@ -370,6 +370,8 @@ virtual bool isobject (void) const { return false; } + virtual bool is_classdef_meta (void) const { return false; } + virtual bool is_classdef_object (void) const { return false; } virtual bool isjava (void) const { return false; }
--- a/libinterp/octave-value/ov-classdef.cc Fri Jun 23 12:32:19 2017 -0700 +++ b/libinterp/octave-value/ov-classdef.cc Fri Jun 23 18:18:07 2017 -0400 @@ -1017,6 +1017,8 @@ ~octave_classdef_meta (void) { object.meta_release (); } + bool is_classdef_meta (void) const { return true; } + octave_function * function_value (bool = false) { return this; } octave_value_list
--- a/libinterp/octave-value/ov.h Fri Jun 23 12:32:19 2017 -0700 +++ b/libinterp/octave-value/ov.h Fri Jun 23 18:18:07 2017 -0400 @@ -586,6 +586,9 @@ bool is_map (void) const { return rep->isstruct (); } + bool is_classdef_meta (void) const + { return rep->is_classdef_meta (); } + bool is_classdef_object (void) const { return rep->is_classdef_object (); }
--- a/libinterp/parse-tree/pt-eval.cc Fri Jun 23 12:32:19 2017 -0700 +++ b/libinterp/parse-tree/pt-eval.cc Fri Jun 23 18:18:07 2017 -0400 @@ -1362,7 +1362,8 @@ p_dyn_field++; } - if (! idx.empty ()) + if (! idx.empty () && (! base_expr_val.is_function () + || base_expr_val.is_classdef_meta ())) { try { @@ -1374,6 +1375,18 @@ } } + // This happens if... ?? + + octave_value val = (retval.length () ? retval(0) : octave_value ()); + + if (val.is_function ()) + { + octave_function *fcn = val.function_value (true); + + if (fcn) + retval = fcn->call (*this, nargout); + } + m_value_stack.push (retval); }