function varargout = step(obj, varargin)
%MATLAB Code Generation Library function.
% Implement step function for System objects.

%   Copyright 2007-2016 The MathWorks, Inc.
%#codegen

coder.inline('always');
coder.internal.allowEnumInputs;
coder.internal.allowHalfInputs;

% These lines need to be before eml_sea_get_obj. This is to make
% sure we have a System object before trying to get the object.
checkSystemObjectInput(obj, 'step');

comp = eml_sea_get_obj(obj);

coder.extrinsic('eml_try_catch');

eml_invariant(coder.const(feval('isa', comp, 'matlab.system.SystemAdaptor')), ...
           'MATLAB:system:codeGenUnSupportedObj');

[errId, errMsg, numinputs]  = coder.const(@eml_try_catch,'getNumInputs',  comp);
eml_lib_assert(isempty(errMsg), errId, errMsg);
[errId, errMsg, numoutputs] = coder.const(@eml_try_catch,'getNumOutputs', comp);
eml_lib_assert(isempty(errMsg), errId, errMsg);

eml_invariant((nargin-1) <= numinputs, ...
    'MATLAB:system:maxNumInputs', ...
    coder.const(numinputs), coder.const(nargin-1));
eml_invariant((nargin-1) >= numinputs, ...
    'MATLAB:system:minNumInputs', ...
    coder.const(numinputs), coder.const(nargin-1));
eml_invariant((nargout) <= numoutputs, ...
    'MATLAB:system:maxNumOutputs', ...
    coder.const(nargout), coder.const(numoutputs));

% Check for input types
% Call builtin to make sure overloaded methods are not used
for i=coder.unroll(1:nargin-1)
    eml_invariant(eml_is_const(class(varargin{i})) && ...
        (builtin('isnumeric',varargin{i}) || builtin('islogical', varargin{i}) || builtin('isfi', varargin{i})) && ...
        (~builtin('issparse',varargin{i}) && ~isenum(varargin{i})), ...
        'MATLAB:system:codeGenInvalidInputsTypes', 'step');
end

if numoutputs == 0
    eml_sea_method_call('step',obj,varargin{:});
elseif numoutputs == 1
    varargout{1} = eml_sea_method_call('step', obj, varargin{:});
elseif numoutputs == 2
    [varargout{1}, varargout{2}] = eml_sea_method_call('step', obj, varargin{:});
elseif numoutputs == 3
    [varargout{1}, varargout{2}, varargout{3}] = eml_sea_method_call('step', obj, varargin{:});
elseif numoutputs == 4
    [varargout{1}, varargout{2}, varargout{3}, varargout{4}] = eml_sea_method_call('step', obj, varargin{:});
elseif numoutputs == 5
    [varargout{1}, varargout{2}, varargout{3}, varargout{4}, varargout{5}] = eml_sea_method_call('step', obj, varargin{:});
elseif numoutputs == 6
    [varargout{1}, varargout{2}, varargout{3}, varargout{4}, varargout{5}, varargout{6}] = eml_sea_method_call('step', obj, varargin{:});
elseif numoutputs == 7
    [varargout{1}, varargout{2}, varargout{3}, varargout{4}, varargout{5}, varargout{6}, varargout{7}] = eml_sea_method_call('step', obj, varargin{:});
elseif numoutputs == 8
    [varargout{1}, varargout{2}, varargout{3}, varargout{4}, varargout{5}, varargout{6}, varargout{7}, varargout{8}] = eml_sea_method_call('step', obj, varargin{:});
elseif numoutputs == 9
    [varargout{1}, varargout{2}, varargout{3}, varargout{4}, varargout{5}, varargout{6}, varargout{7}, varargout{8}, varargout{9}] = eml_sea_method_call('step', obj, varargin{:});
elseif numoutputs == 10
    [varargout{1}, varargout{2}, varargout{3}, varargout{4}, varargout{5}, varargout{6}, varargout{7}, varargout{8}, varargout{9}, varargout{10}] = eml_sea_method_call('step', obj, varargin{:});
elseif numoutputs == 11
    [varargout{1}, varargout{2}, varargout{3}, varargout{4}, varargout{5}, varargout{6}, varargout{7}, varargout{8}, varargout{9}, varargout{10}, varargout{11}] = eml_sea_method_call('step', obj, varargin{:});
elseif numoutputs == 12
    [varargout{1}, varargout{2}, varargout{3}, varargout{4}, varargout{5}, varargout{6}, varargout{7}, varargout{8}, varargout{9}, varargout{10}, varargout{11}, varargout{12}] = eml_sea_method_call('step', obj, varargin{:});
end

