function d = isDone(obj)
%MATLAB Code Generation Library function.
% Implement isDone function for System objects.

%#codegen

%   Copyright 2007-2014 The MathWorks, Inc.

coder.inline('always');

eml_invariant(nargin == 1, ...
    'MATLAB:system:codeGenNoSystemObjectInput', 'isDone');

eml_invariant(coder.const(isa(obj, 'matlab.system.mixin.FiniteSource')), ...
                'MATLAB:system:isDoneCallbyNonSource');

eml_invariant(coder.const(isa(obj, 'matlab.system.SystemAdaptor')), ...
    'MATLAB:system:codeGenNotSystemObjectInput', 'isDone');

comp = eml_sea_get_obj(obj);

coder.extrinsic('eml_try_catch');
[errId, errMsg, N] = coder.const(@eml_try_catch,'getNumOutputs', comp);
eml_lib_assert(isempty(errMsg), errId, errMsg);

coder.extrinsic('properties');

% Need to generate code only for objects which have eof output
if N > 1 && coder.const(feval([class(comp) '.isEOFPortAvailable']))
    d = eml_sea_method_call('isDone', obj);
else
    d = false;
end
