Hi anyone explain me about GENERATE and GENERATE_TYPE Functions in tlc file?

1 次查看(过去 30 天)
Hello Matlab users,
Anyone pls explain me about GENERATE and GENERATE_TYPE Functions in tlc file writing?
GENERATE_TYPE(block, "Output", "dp_read")
In this structure (Output = "Function name which we want to call", What about block, dp_read. Am using Level 2 M file S Function am not getting any information related to this.
Please help me in resolving this issue.
Thanks in Advance....

回答(1 个)

Valmir Sadiku
Valmir Sadiku 2013-5-23
here you can show example how to use GENERATE : http://www.weizmann.ac.il/matlab/toolbox/rtw/tlc_ref/cp_lan17.html
  3 个评论
Valmir Sadiku
Valmir Sadiku 2013-5-24
编辑:Valmir Sadiku 2013-5-24
are you able to get the following example to work? if not, tell which error you get?
The following listing is polymorph.tlc.
%%polymorph.tlc
%language "C"
%%create records used as scopes within the dispatched functions
%createrecord MyRecord { Type "MyBlock"; data 123 }
%createrecord YourRecord { Type "YourBlock"; theStuff 666 }
%%dispatch the functions thru the GENERATE call.
%%dispatch to MyBlock implementation
%<GENERATE(MyRecord, "aFunc")>
%%dispatch to YourBlock implementation
%<GENERATE(YourRecord, "aFunc")>
%%end of polymorph.tlc
The following listing is MyBlock.tlc.
%%MyBlock.tlc
%implements "MyBlock" "C"
%%aFunc is invoked thru a GENERATE call in polymorph.tlc.
%%MyRecord is in generate scope in this function.
%%Therefore, fields of MyRecord can be referenced without
%%qualification
%function aFunc(r) Output
%selectfile STDOUT
The value of MyRecord.data is: %<data>
%closefile STDOUT
%endfunction
%%end of MyBlock.tlc
The following listing is YourBlock.tlc.
%%YourBlock.tlc
%implements "YourBlock" "C"
%%aFunc is invoked thru a GENERATE call in polymorph.tlc.
%%YourRecord is in generate scope in this function.
%%Therefore, fields of YourRecord can be referenced without
%%qualification
%function aFunc(r) Output
%selectfile STDOUT
The value of YourRecord.theStuff is: %<theStuff>
%closefile STDOUT
%endfunction
%%end of YourBlock.tlc
The invocation and output of polymorph.tlc, as displayed on the MATLAB console, are shown below:
tlc -v polymorph.tlc
The value of MyRecord.data is: 123
The value of YourRecord.theStuff is: 666
We use in this case STDOUT file to print values to the matlab window.
Which error you got?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Target Language Compiler 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by