# HG changeset patch # User Michael Goffioul # Date 1390530283 18000 # Node ID 9ca314e79956eaab1868336a0f52ac54b339a1a6 # Parent c9b284dd28c62383b99a7ab0bd331a6c5ee9c15a Allow to call superclass constructor without arguments. * ov-classdef.cc (octave_classdef_superclass_ref::function_value): New method. * pt-funcall.h (tree_funcall::rvalue): Move definition to C++. * pt-funcall.cc (tree_funcall::rvalue): Moved from header. If the result of the function call is a single function object, re-index the function to yield the proper result it required (similar logic as in pt-id.cc). diff -r c9b284dd28c6 -r 9ca314e79956 libinterp/octave-value/ov-classdef.cc --- a/libinterp/octave-value/ov-classdef.cc Thu Jan 23 14:40:35 2014 -0800 +++ b/libinterp/octave-value/ov-classdef.cc Thu Jan 23 21:24:43 2014 -0500 @@ -1040,6 +1040,8 @@ ~octave_classdef_superclass_ref (void) { } + octave_function* function_value (bool = false) { return this; } + octave_value_list subsref (const std::string& type, const std::list& idx, diff -r c9b284dd28c6 -r 9ca314e79956 libinterp/parse-tree/pt-funcall.cc --- a/libinterp/parse-tree/pt-funcall.cc Thu Jan 23 14:40:35 2014 -0800 +++ b/libinterp/parse-tree/pt-funcall.cc Thu Jan 23 21:24:43 2014 -0500 @@ -81,3 +81,31 @@ { tw.visit_funcall (*this); } + +octave_value_list +tree_funcall::rvalue (int nargout) +{ + octave_value_list retval; + + retval = feval (fcn.function_value (), args, nargout); + + if (retval.length () == 1 && retval(0).is_function ()) + { + // The return object is a function. We may need to re-index it using the + // same logic as for identifier. This is primarily used for superclass + // references in classdef. + + octave_value val = retval(0); + octave_function *f = val.function_value (true); + + if (f && ! (is_postfix_indexed () + && f->is_postfix_index_handled (postfix_index ()))) + { + octave_value_list tmp_args; + + retval = val.do_multi_index_op (nargout, tmp_args); + } + } + + return retval; +} diff -r c9b284dd28c6 -r 9ca314e79956 libinterp/parse-tree/pt-funcall.h --- a/libinterp/parse-tree/pt-funcall.h Thu Jan 23 14:40:35 2014 -0800 +++ b/libinterp/parse-tree/pt-funcall.h Thu Jan 23 21:24:43 2014 -0500 @@ -71,10 +71,7 @@ return retval; } - octave_value_list rvalue (int nargout) - { - return feval (fcn.function_value (), args, nargout); - } + octave_value_list rvalue (int nargout); octave_value function (void) const { return fcn; }