Main Content

Simulink.CodeImporter.ParseInfo.getFunctions

Obtain detailed information regarding functions in custom code

    Description

    example

    fcnobjs = obj.ParseInfo.getFunctions(), where obj is an object of class Simulink.CodeImporter or sltest.CodeImporter, returns an array of objects of class Simulink.CodeImporter.Function with detailed information on all Simulink® compatible functions in the custom code.

    Note

    If your code has a function with a pointer output, specify the size of the output by setting the port specification in the returned function object.

    fcnobjs = obj.ParseInfo.getFunctions(fcnlist) returns an array of objects of class Simulink.CodeImporter.Function with detailed information on the custom code functions specified in fcnlist.

    Examples

    collapse all

    Specify and parse custom code, then query information regarding custom code functions.

    obj = Simulink.CodeImporter;
    
    %% Set library file name and output folder
    obj.LibraryFileName = "pumpController";
    obj.OutputFolder = ".";
    
    %% Set the custom code to import
    obj.CustomCode.InterfaceHeaders = ["pumpController.h"];
    obj.CustomCode.IncludePaths = ["./include"];
    obj.CustomCode.SourceFiles = ["src/pumpController.c" "src/utils.c"];
    
    %% Parse code
    obj.parse;
    parseobj = obj.ParseInfo
    
    ans = 
    
      ParseInfo with properties:
    
                   Success: 1
        AvailableFunctions: ["Controller"    "setFanTempThreshold"    "setPumpTempThreshold"]
            EntryFunctions: ["Controller"    "setFanTempThreshold"    "setPumpTempThreshold"]
            AvailableTypes: "pump_control_bus"
                    Errors: []
    
    fcnobjs = parseobj.getFunctions()
    
    fcnobjs = 
    
      1×3 Function array with properties:
    
        Name
        CPrototype
        PortSpecification
        IsEntry
        IsDefined
        IsStub
        ArrayLayout
        IsDeterministic
    
    >> fcnobjs(1)
    
    ans = 
    
      Function with properties:
    
                     Name: "Controller"
               CPrototype: "pump_control_bus Controller(real_T Tset, real_T Troom_in);"
        PortSpecification: [1×1 Simulink.CodeImporter.SimulinkPortSpecification]
                  IsEntry: 1
                IsDefined: 1
                   IsStub: 0
              ArrayLayout: NotSpecified
          IsDeterministic: 0

    Input Arguments

    collapse all

    Names of functions in custom code about which to obtain information, specified as a cell array of character vectors or a string array. fcnlist must be limited to names contained in obj.ParseInfo.AvailableFunctions, that is, functions compatible with Simulink in the specified custom code.

    Data Types: cell array of character vectors | string array

    Output Arguments

    collapse all

    Information about functions in custom code, returned as an array of Simulink.CodeImporter.Function objects, where each object corresponds to one function. Each object includes the function name, C prototype, port specification, whether function is an entry-point function, and whether function is defined in the custom code. See Simulink.CodeImporter.Function.

    Version History

    Introduced in R2021a