function varargout = legacy_code(action, varargin)
%LEGACY_CODE Legacy Code Tool function gateway.
%   LEGACY_CODE('HELP') displays instructions for using the Legacy Code Tool.
%
%   SPEC = LEGACY_CODE('INITIALIZE') initializes the Legacy Code Tool data
%   structure, SPEC, which registers characteristics of existing C or C++ 
%   code and properties of the S-function that the Legacy Code Tool generates.
%                  
%   LEGACY_CODE('SFCN_CMEX_GENERATE', SPEC) generates an S-function source 
%   file as specified by the Legacy Code Tool data structure, SPEC.
%
%   LEGACY_CODE('COMPILE', SPEC, OPTIONS) compiles and links the S-function
%   generated by the Legacy Code Tool based on the data structure, SPEC. 
%   The optional argument OPTIONS is a cell array of strings of any compiler
%   options that you might specify (ex: OPTIONS = {'-g'} for creating a 
%   MEX-file containing additional symbolic information for use in debugging).
%
%   LEGACY_CODE('GENERATE_FOR_SIM', SPEC) generates, compiles, and links
%   the S-function in a single step. The function also generates a TLC
%   file for accelerated simulations, if the SPEC.useTlcWithAccel field of 
%   the Legacy Code Tool data structure is set to 1.
%
%   LEGACY_CODE('SLBLOCK_GENERATE', SPEC, MODELNAME) generates a masked 
%   S-Function block for the S-function generated by the Legacy Code Tool
%   based on the data structure, SPEC. The block appears in the Simulink
%   model specified by MODELNAME. If you omit MODELNAME, the block appears
%   in an empty model editor window.
%
%   LEGACY_CODE('SFCN_TLC_GENERATE', SPEC) generates a TLC file for the 
%   S-function generated by the Legacy Code Tool based on the data 
%   structure, SPEC.
%
%   The data structure SPEC contains the following fields:
%
%                    SFunctionName: a required string specifying a name for the S-function
%                                   to be generated by the Legacy Code Tool.
%      InitializeConditionsFcnSpec: a string specifying a function that the 
%                                   S-function calls at initialization.
%                    OutputFcnSpec: a string specifying the function that the S-function
%                                   calls at each time step.
%                     StartFcnSpec: a string specifying the function that the S-function
%                                   calls when it begins execution.
%                 TerminateFcnSpec: a string specifying the function that the S-function
%                                   calls when it terminates execution. 
%                      HeaderFiles: a cell array of strings specifying the file names 
%                                   of header files required for compilation.
%                      SourceFiles: a cell array of strings specifying source files required 
%                                   for compilation. You can specify the source files using
%                                   absolute or relative path names.
%                     HostLibFiles: a cell array of strings specifying library files required
%                                   for host compilation. You can specify the library files
%                                   using absolute or relative path names.
%                   TargetLibFiles: a cell array of strings specifying library files 
%                                   required for target (that is, standalone) compilation.
%                                   You can specify the library files using absolute or relative path names.
%                         IncPaths: a cell array of strings specifying directories containing header files.
%                                   You can specify the directories using absolute or relative path names.
%                         SrcPaths: a cell array of strings specifying directories containing source files.
%                                   You can specify the directories using absolute or relative path names.
%                         LibPaths: a cell array of strings specifying directories containing host 
%                                   and target library files. You can specify the directories 
%                                   using absolute or relative path names.
%                       SampleTime: one of 'inherited' (default), 'parameterized' 
%                                   or fixed numerical value
%                          Options: a structure that controls S-function options. 
%                                   The structure's fields include:
%                                  isMacro: a logical value specifying whether the legacy code is a C macro (default is false)
%                               isVolatile: a logical value specifying the setting of the S-function 
%                                           SS_OPTION_NONVOLATILE option (default is true).
%                 canBeCalledConditionally: a logical value specifying the setting of the S-function 
%                                           SS_OPTION_CAN_BE_CALLED_CONDITIONALLY option (default is true).
%                          useTlcWithAccel: a logical value specifying the setting of the S-function 
%                                           SS_OPTION_USE_TLC_WITH_ACCELERATOR option (default is true).
%                                 language: one of 'C' (default) or 'C++'
%                         singleCPPMexFile: a logical value (default is false) that, if true (1), 
%                                           specifies that generated code requires you to generate and manage 
%                                           an inlined S-function as only one file (.cpp) instead of two (.c and .tlc).
%            supportsMultipleExecInstances: A logical value specifying whether to include a call to 
%                                           the ssSupportsMultipleExecInstances function. By default, the value is false (0).
%                 convertNDArrayToRowMajor: A logical value specifying the automatic conversion of a matrix between 
%                                           a N-D column-major format and a row-major format. The N-D column-major format 
%                                           is used by MATLAB, Simulink, and the generated code. The row-major format 
%                                           is used by C. By default, the value is false (0).
%                          supportCoverage: a logical value (default is false) that, if true (1), specifies that 
%                                           the generated S-function must be compatible with Model Coverage.
%         supportCoverageAndDesignVerifier: a logical value (default is false) that, if true (1), specifies that 
%                                           the generated S-function must be compatible with Model Coverage
%                                           and Simulink Design Verifier.
%              outputsConditionallyWritten: a logical value (default is false) specifying whether the legacy code conditionally
%                                           writes any of the output ports. If true (1), the generated S-Function specifies
%                                           that the memory associated with each output port cannot be overwritten and is global.
%             supportCodeReuseAcrossModels: a logical value (default is false) that, if true (1), specifies that 
%                                           the generated S-function must be compatible with code reuse across models
%

%   Copyright 2005-2019 The MathWorks, Inc.

% Default action    
if nargin < 1
    action = 'help';
end

[varargout{1:nargout}] = legacycode.LCT.legacyCodeImpl(action, varargin{1:end});

