function update(obj, varargin)
%MATLAB Code Generation Library function.
% Implement update 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, 'update');

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);

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));

% Check for input types
% Call builtin to make sure overloaded methods are not used
for i=coder.unroll(1:nargin-1)
  if ~eml_ambiguous_types
    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', 'update');
  end
end

eml_sea_method_call('update',obj,varargin{:});

