Main Content

Simulink.CodeImporter.Options class

Package: Simulink.CodeImporter

Specify additional import options for Simulink.CodeImporter and sltest.CodeImporter classes

Description

Use the Simulink.CodeImporter class to specify options for importing custom code beyond what is specified in the CustomCode property of the relevant Simulink.CodeImporter object.

The Simulink.CodeImporter.Options class is a handle class.

Creation

When you create an object of class Simulink.CodeImporter, an object of class Simulink.CodeImporter.Options is automatically created as the Options property of that object. Do not create an object of class Simulink.CodeImporter.Options directly.

Properties

expand all

Default size of C argument passed by pointer to function in the generated C Caller block port specifications, specified as a character vector or string scalar. By default, the value is set to '-1', meaning that the size is inherited. A value of '1' indicates that arguments passed by address to functions are scalars, unless you override this setting in the Simulink.CodeImporter.SimulinkPortSpecification corresponding to a particular function.

Data Types: character vector | string scalar

Automatic creation of test harness during import, specified as a logical scalar. Specify whether the Simulink® Code Importer should automatically create a test harness for each block in the generated Simulink library (Simulink Test™ license required).

Data Types: logical

Name by which generated Simulink library appears in Simulink Library Browser, specified as a character vector or string scalar. By default, the value is an empty string, meaning that the generated library does not appear in the Simulink Library Browser. If you specify a name, the Simulink Code Importer generates the file slblocks.m as part of the artifacts the Code Importer creates.

Example: "Controller Library"

Data Types: character vector | string scalar

Examples

collapse all

Create a Simulink.CodeImporter object and set options.

obj = Simulink.CodeImporter;
obj.CustomCode.InterfaceHeaders = ["pumpController.h"];
obj.CustomCode.IncludePaths = ["./include"];
obj.CustomCode.SourceFiles = ["src/pumpController.c" "src/utils.c"];
obj.Options.LibraryBrowserName="Controller Library";

obj.Options
ans = 

  Options with properties:

    PassByPointerDefaultSize: "-1"
           CreateTestHarness: 0
          LibraryBrowserName: "Controller Library"
Introduced in R2021a