transplant
transplant copied to clipboard
Nargout for class methods
08478bbe8ab42777ff0cc7b893cda29ab6f05212: This fails when a class method name is identical to a function on the MATLAB search path. For example calling the method myclass.plot()
, nargout will return the number of arguments of the MATLAB built-in plot
function. That's why I added a bit more checking:
try
[~, funType] = which(msg('name'));
funType = strsplit(funType,' ');
if numel(funType)==2 && strcmp(funType{2},'method')
argTemp = msg('args');
className = funType{1};
if ~isempty(argTemp) && isa(argTemp{1},className)
% the function name corresponds to the
% class of the first argument
resultsize = nargout(msg('name'));
end
end
if isempty(resultsize)
resultsize = nargout(fun);
end
catch
resultsize = -1;
end
Right now, I don't have enough time to look into this. I'd be grateful for a pull request. Otherwise, I'll have a look in two weeks.