function hLib = crl_table_addsub
%CRL_TABLE_ADDSUB - Provides custom entries for a Code Replacement Library table.

% Copyright 2007-2011 The MathWorks, Inc.

LibPath = fullfile(matlabroot,...
                   'toolbox',...
                   'coder',...
                   'codegendemos',...
                   'coderdemo_tfl');

hLib = RTW.TflTable;

% Create an entry for addition of built-in int16 data type
% Saturation on, Rounding as nearest
op_entry = RTW.TflCOperationEntry;
op_entry.setTflCOperationEntryParameters(...
    'Key',                      'RTW_OP_ADD', ...
    'Priority',                 90, ...
    'SaturationMode',           'RTW_SATURATE_ON_OVERFLOW', ...
    'RoundingMode',             'RTW_ROUND_NEAREST_ML', ...
    'ImplementationName',       's16_add_s16_s16', ...
    'ImplementationHeaderFile', 'MyMath.h', ...
    'ImplementationSourceFile', 'MyMath.c', ...
    'ImplementationHeaderPath', LibPath, ...
    'ImplementationSourcePath', LibPath, ...
    'GenCallback',              'RTW.copyFileToBuildDir');

arg = hLib.getTflArgFromString('y1','int16');
arg.IOType = 'RTW_IO_OUTPUT';
op_entry.addConceptualArg( arg );

arg = hLib.getTflArgFromString('u1','int16');
op_entry.addConceptualArg( arg );

arg = hLib.getTflArgFromString('u2','int16');
op_entry.addConceptualArg( arg );

op_entry.copyConceptualArgsToImplementation();
hLib.addEntry( op_entry );

% Create an entry for subtraction of built-in int16 data type
% Saturation on, Rounding to nearest
op_entry = RTW.TflCOperationEntry;
op_entry.setTflCOperationEntryParameters( ...
    'Key',                      'RTW_OP_MINUS', ...
    'Priority',                 90, ...
    'SaturationMode',           'RTW_SATURATE_ON_OVERFLOW', ...
    'RoundingMode',             'RTW_ROUND_NEAREST_ML', ...
    'ImplementationName',       's16_sub_s16_s16', ...
    'ImplementationHeaderFile', 'MyMath.h', ...
    'ImplementationSourceFile', 'MyMath.c', ...
    'ImplementationHeaderPath', LibPath, ...
    'ImplementationSourcePath', LibPath, ...
    'GenCallback',              'RTW.copyFileToBuildDir');

arg = hLib.getTflArgFromString('y1','int16');
arg.IOType = 'RTW_IO_OUTPUT';
op_entry.addConceptualArg( arg );

arg = hLib.getTflArgFromString('u1','int16');
op_entry.addConceptualArg( arg );

arg = hLib.getTflArgFromString('u2','int16');
op_entry.addConceptualArg( arg );

op_entry.copyConceptualArgsToImplementation();
hLib.addEntry( op_entry );

