function plc_ide_list = plc_custom_ide
%

%   Copyright 2022-2023 The MathWorks, Inc.

    plc_ide_list(1) = get_ide_info_gxworks3;
end

function ide_info = get_ide_info_gxworks3
    ide_info.name = 'gxworks3';
    ide_info.description = 'MITSUBISHI ELECTRIC MELSOFT GX Works3';
    ide_info.path = ''; % IDE path
    ide_info.format = 'xml'; % generic|xml
    ide_info.fileExtension = 'xml';
    ide_info.cfg = get_ide_cfg_gxworks3;
    ide_info.precg_callback = PLCCoder.PLCCGMgr.PLC_PLUGIN_CG_CALLBACK_EMPTY; 
    ide_info.postcg_callback = 'plc_postcg_callback_gxworks3';
    ide_info.xmltree_callback = PLCCoder.PLCCGMgr.PLC_PLUGIN_CG_CALLBACK_EMPTY;
    ide_info.pluginVersion = 1.2;
    ide_info.compatibleBuildVersion = 1.6;
end

function cfg = get_ide_cfg_gxworks3
    cfg.fConvertEnumToInteger = true;
    cfg.fConvertNamedConstantToInteger = true;
    cfg.fConvertAggregateInitValueToAssignment = true;
    cfg.fInt16AsBaseInt = true;
    cfg.fSupportGlobalConst = true;
    cfg.fUsePLCTruncFcn= true;
    cfg.fReplaceShiftFunctions = true; % PLC_SHL needs to cast 2nd input to WORD
    cfg.fEmitterFcn = 'plc_emit_code_gxworks3';
    cfg.fTargetKeywordHook = 'plc_gxworks3_keyword_hook';
    cfg.fTargetRegexKeywordHook = 'plc_gxworks3_regex_keyword_hook';
    cfg.fSimplifyAllIntrinsicFcn = true;
    cfg.fSimplifyOperatorNameList = {'SHL', 'SHR', 'ROL', 'ROR', 'BITWISE_AND', 'BITWISE_OR', 'BITWISE_XOR', 'BITWISE_NOT'};
    cfg.fSimplifyOperator = true;
    cfg.fSimplifyOperatorOutputExpr = true;
    cfg.fConvertReadOnlyInputVarAssignment = true;
    cfg.fUseUnsignedIntegerTypeForBitstringType = true;
    cfg.fUseUnsignedIntegerTypeForShiftOpCount = true;
    cfg.fInt16SwitchExpr = true;
    cfg.fEnableGlobalRenaming = true;
    cfg.fStructTypeNestLevelLimit = 5;
end

% LocalWords:  MELCO GX postcg MELSOFT precg SHL nd SHR ROL ROR
