Mercurial > jwe > octave
changeset 26970:392b14b0c085
override dispatch class for function handles (bug #45351)
* cdef-utils.cc (get_class_context): If dispatch class is set in call
stack, use it instead of looking at the dispatch class that is stored
in the current function.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 25 Mar 2019 16:24:45 +0000 |
parents | 4ba365817652 |
children | 342fc514de46 |
files | libinterp/octave-value/cdef-utils.cc |
diffstat | 1 files changed, 14 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/octave-value/cdef-utils.cc Mon Mar 25 16:21:11 2019 +0000 +++ b/libinterp/octave-value/cdef-utils.cc Mon Mar 25 16:24:45 2019 +0000 @@ -241,13 +241,25 @@ cdef_class get_class_context (std::string& name, bool& in_constructor) { + name = ""; + in_constructor = false; + cdef_class cls; + // If the dispatch class is set in the current stack frame it + // overrides whatever dispatch class there is for the currently + // executing function so that function handles returned from class + // methods will use the dispatch class of the class in which they + // are defined instead of the class in which they are executing. + call_stack& cs = __get_call_stack__ ("get_class_context"); - octave_function *fcn = cs.current (); + std::string dispatch_class = cs.get_dispatch_class (); - in_constructor = false; + if (! dispatch_class.empty ()) + return lookup_class (dispatch_class); + + octave_function *fcn = cs.current (); if (fcn && (fcn->is_class_method () || fcn->is_classdef_constructor ()