Technical data
Compiler Directives
2-25
appear prior to the first GENERATE or GENERATE_TYPE built-in function call.
%language specifies the language as a string. For example:
%language "C"
All blocks in Simulink have a Type parameter. This parameter is a string that
specifies the type of the block, e.g.,
"Sin" or "Gain". The object-oriented facility
uses this type to search the path for a file that implements the correct block.
By default the name of the file is the
Type of the block with .tlc appended, so
for example, if the
Type is "Sin" the Compiler would search for "Sin.tlc"
along the path. You can override this default filename using the
%generatefile directive to specify the filename that you want to use to replace
the default filename. For example:
%generatefile "Sin" "sin_wave.tlc"
The files that implement the block-specific code must contain a %implements
directive indicating both the type and the language being implemented. The
Target Language Compiler will produce an error if the
%implements directive
does not match as expected. For example,
%implements "Sin" ["Ada", "Pascal"]
causes an error if the initial language choice was C.
You can use a single file to implement more than one target language by
specifying the desired languages in a vector. For example:
%implements "Sin" ["C", "Ada"]
Finally, you can implement several types using the wildcard (*) for the type
field:
%implements * ["C", "Ada"]
Note: The use of the wildcard (*) is not recommended because it relaxes error
checking for the %implements directive.
GENERATE and GENERATE_TYPE Functions
The Target Language Compiler has two built-in functions that dispatch
object-oriented calls,
GENERATE and GENERATE_TYPE. You can call any function