You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>The C++ implementation of a type descriptor consists of four parts. In the code shown below we assume the type descriptor describes a type called "MyType".</p>
1613
-
<p><strong>1) A type descriptor object</strong></p>
1681
+
<h4id="1-type-descriptor-object">1) Type descriptor object</h4>
1614
1682
<p>This is a variable typed by <ahref="../../targetrts-api/struct_r_t_object__class.html">RTObject_class</a> with a name that has the prefix "RTType_". It will be declared in the header file:</p>
<p>Member variables of <ahref="../../targetrts-api/struct_r_t_object__class.html">RTObject_class</a> store all information about the type, such as its name and byte size. Some of the member variables store pointers to type descriptor functions which the TargetRTS will call when it needs to do something with an instance of the type, for example copy or encode it.</p>
1624
-
<p><strong>2) Type descriptor functions</strong></p>
1692
+
<h4id="2-type-descriptor-functions">2) Type descriptor functions</h4>
1625
1693
<p>These are functions with a certain prototype, each of which performs a specific action on an instance of the type. The type descriptor object stores pointers to these functions. For a partial type descriptor, some of these pointers will be <code>nullptr</code> and then the corresponding type descriptor function does not exist. Below is the list of type descriptor functions that can be part of a type descriptor:</p>
<p>The encode function usually encodes the instance into a string representation, and the decode function usually parses the same string representation and creates an instance of the type from it. However, the functions use interface classes <ahref="../../targetrts-api/class_r_t_encoding.html"><code>RTEncoding</code></a> and <ahref="../../targetrts-api/class_r_t_decoding.html"><code>RTDecoding</code></a> from the TargetRTS which can be implemented in many different ways. Note also that you can globally disable the support for encoding and/or decoding by unsetting the macros <ahref="../../target-rts/build/#object_decode-and-object_encode"><code>OBJECT_DECODE</code> and <code>OBJECT_ENCODE</code></a> respectively. Learn more about encoding and decoding <ahref="../../target-rts/encoding-decoding/">in this chapter</a>.</p>
1670
-
<p><strong>3) A type installer object</strong></p>
1738
+
<h4id="3-type-installer-object">3) Type installer object</h4>
1671
1739
<p>Decoding functions typically need to look up a type descriptor from the name of the type. For example, if it finds the type name "MyType" in the string that it parses, it needs to find the type descriptor object for "MyType" so it can allocate memory for an instance of "MyType" and then initialize it. To facilitate this lookup the TargetRTS keeps a type descriptor registry. The purpose of the type installer object is to add the type descriptor to this registry. The C++ code looks like this:</p>
<p>This is a struct which encapsulates an untyped instance of the type and its type descriptor. Its name has the prefix "RTTypedValue_". The struct has constructors that enable construction from a reference to an instance of the type. The typed value struct is the glue between generated code and TargetRTS code. TargetRTS functions get an untyped instance together with the type descriptor, and the type descriptor provides all information it needs to know about the type.</p>
1678
1746
<p>The typed value struct will be declared and implemented in the header file:</p>
<p>If the type is nested within another type the typed value struct gets a name where scope qualifiers (<code>::</code>) have been replaced with underscores (<code>_</code>). For example, a nested type <code>OuterType::InnerType</code> gets a typed value struct with the name <code>RTTypedValue_OuterType_InnerType</code>.</p>
<p>The code generator will automatically generate a type descriptor for a C++ type if you mark it with the <code>rt::auto_descriptor</code> attribute. The generated type descriptor functions will get a default implementation that depends on the kind of type. If the default implementation is not appropriate for your type you can simply provide your own implementation of one or many type descriptor functions in an <code>rt::impl</code> code snippet. </p>
<li><ahref="https://github.com/secure-dev-ops/code-realtime/tree/main/art-comp-test/tests/struct_type_descriptor_header_file">Automatically generated type descriptor for a struct defined in a C++ header file</a></li>
1820
1889
<li><ahref="https://github.com/secure-dev-ops/code-realtime/tree/main/art-comp-test/tests/enum_type_descriptor_header_file">Automatically generated type descriptor for an enum defined in a C++ header file</a></li>
1821
1890
<li><ahref="https://github.com/secure-dev-ops/code-realtime/tree/main/art-comp-test/tests/typedef_type_descriptor_header_file">Automatically generated type descriptor for a typedef and type alias defined in a C++ header file (with customized type descriptors)</a></li>
1891
+
<li><ahref="https://github.com/secure-dev-ops/code-realtime/tree/main/art-comp-test/tests/nested_type_descriptor">Automatically generated type descriptor for nested types</a></li>
Copy file name to clipboardExpand all lines: docs/art-lang/index.html
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -2296,7 +2296,8 @@ <h2 id="protocol-and-event">Protocol and Event</h2>
2296
2296
<pclass="admonition-title">Note</p>
2297
2297
<p>An event can have at most one parameter. If you need to send multiple data objects with an event you can declare an event parameter of struct or class type.</p>
2298
2298
</div>
2299
-
<p>The C++ type of an event parameter must be specified either as a primitive type or as an unqualified name of a user-defined type. If a user-defined type is used, it must usually have a <ahref="cpp-extensions/#type-descriptor">type descriptor</a> so the TargetRTS can copy or move the data at run-time when the event is sent. However, in some special cases a type descriptor is not required, for example if the user-defined type is a typedef or type alias of a primitive type. In those cases you must use the <code>[[rt::no_descriptor]]</code> attribute to specify that you want to pass the event parameter without using a type descriptor. See the validation rule <ahref="../validation/#cpp_4000_eventtypewithouttypedescriptor">CPP_4000_eventTypeWithoutTypeDescriptor</a> for examples and more information.</p>
2299
+
<p>The C++ type of an event parameter can be any primitive or user-defined type. Types may be specified with qualified names if necessary (e.g. <code>A::B</code>), but cannot have type modifiers (e.g. <code>Type*</code>) or template parameters (e.g. <code>T<A></code>). If required you can create a typedef or type alias of the type you want to use, and then use the name of that typedef or type alias as the event parameter type. </p>
2300
+
<p>If a user-defined type is used, it must usually have a <ahref="cpp-extensions/#type-descriptor">type descriptor</a> so the TargetRTS can copy or move the data at run-time when the event is sent. However, in some special cases a type descriptor is not required, for example if the user-defined type is a typedef or type alias of a primitive type. In those cases you must use the <code>[[rt::no_descriptor]]</code> attribute to specify that you want to pass the event parameter without using a type descriptor. See the validation rule <ahref="../validation/#cpp_4000_eventtypewithouttypedescriptor">CPP_4000_eventTypeWithoutTypeDescriptor</a> for examples and more information.</p>
2300
2301
<p>The following code snippets can be used for a protocol:</p>
<li>The Properties view now shows the name of a selected symbol or line in its header. It also has a new button in the header for moving the selection upwards in the hierarchy of nested symbols. Clicking the button while holding down the Shift key moves the selection to the diagram itself (i.e. has the same effect as clicking in the diagram background). The new button helps for example when working in big and deeply nested state diagrams, where enclosing symbols or the diagram background often are not visible. It also makes it easier to understand which internal transitions that may trigger when a nested state is active.</li>
<li>It's now possible to resize choice symbols in state diagrams, when manual diagram layout is used. This can for example be useful if there are many outgoing transitions from the choice.</li>
1371
+
<li>The Z-order of symbols has been adjusted to ensure that symbols that are covered by an expanded symbol are drawn behind it. Previously such covered symbols could appear on top of the expanded symbol which made them look like nested symbols.</li>
1372
+
<li>The sizes of some non-resizable symbols in state diagrams have been adjusted to be the same as those in Model RealTime. This avoids unnecessary differences in diagram layout when exporting models from Model RealTime to Code RealTime.</li>
1373
+
<li>Traces shown in a sequence diagram can now be filtered using regular expressions (both for instances and messages). The sequence diagram viewer also has an improved scroll behavior to make it possible to open very large trace files. Trace messages are split into pages where only the currently viewed page is shown in the trace viewer.</li>
<li>When the validation rule <ahref="https://secure-dev-ops.github.io/code-realtime/validation/#art_0036_unexpectedtriggers">ART_0036</a> finds a transition which has unexpected triggers because it originates from an entry or exit point with incoming transitions, it now reports those incoming transitions as related elements. This makes it easier to understand which of the incoming transitions that cause the triggers to be unexpected and to navigate to them.</li>
1378
+
<li>Environment variables in TC include paths are now supported and correctly expanded in the JSON files that are generated for C++ language servers. Also, these JSON files now specify the actual compiler that will be used when compiling the code, which enables the C++ language servers to give a better experience when viewing and editing C++ code.</li>
1379
+
<li>Errors in a TC or in its prerequisites, for example syntax errors, are now better reported when building the TC.</li>
1380
+
<li>The C++ code generator now supports generation of type descriptors for nested types.</li>
1381
+
<li>Include paths with spaces are now correctly generated into the Makefile. An include path string is enclosed in double quotes if it contains spaces or references an environment variable (which potentially can be defined with spaces).</li>
1382
+
<li>Version 2.4.0 of the Art Exporter is now available. In the new version it's now possible to customize the severity of problems reported during export, and to turn off reporting of problems that have already been analyzed. Many other improvements are included as well; see <ahref="https://model-realtime.hcldoc.com/help/topic/com.ibm.xtools.rsarte.webdoc/Utilities/Art%20Exporter.html">this page</a> for more detailed release notes.</li>
0 commit comments