Skip to content

Commit 1725c53

Browse files
author
Sonia Mathew
committed
Generated HTML for Release 2.0.7
1 parent 3e246e0 commit 1725c53

34 files changed

+929
-241
lines changed

docs/art-lang/cpp-extensions/index.html

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,13 @@
542542
Inheritance
543543
</a>
544544

545+
</li>
546+
547+
<li class="md-nav__item">
548+
<a href="#generated-files" class="md-nav__link">
549+
Generated Files
550+
</a>
551+
545552
</li>
546553

547554
</ul>
@@ -1340,6 +1347,13 @@
13401347
Inheritance
13411348
</a>
13421349

1350+
</li>
1351+
1352+
<li class="md-nav__item">
1353+
<a href="#generated-files" class="md-nav__link">
1354+
Generated Files
1355+
</a>
1356+
13431357
</li>
13441358

13451359
</ul>
@@ -1367,7 +1381,9 @@
13671381

13681382
<h1>C++ Extensions</h1>
13691383

1370-
<p>An Art file may contain code snippets at various places, where the C++ code within these snippets takes the form of expressions (e.g., guard conditions), statements (e.g., transition effects), or declarations (e.g., types, functions, variables, etc.). While most code snippets are copied directly to the generated C++ files during the translation process from an Art file to C+, certain snippets containing declarations (specifically, those marked as <code>rt::decl</code> and <code>rt::impl</code>) undergo parsing and analysis by the code generator. The code generator identifies and processes certain C+ extensions, such as attributes applied to the declarations in these snippets, translating them into additional C++ code. This capability enables the code generator to enhance the C++ code you write by incorporating additional boilerplate code. This chapter provides details on the applicable C++ extensions and the corresponding generated code for each.</p>
1384+
<p>An Art file may contain code snippets at various places, where the C++ code within these snippets takes the form of expressions (e.g., guard conditions), statements (e.g., transition effects), or declarations (e.g., types, functions, variables, etc.). While most code snippets are copied directly to the generated C++ files during the translation process from an Art file to C++, certain snippets containing declarations (specifically, those marked as <code>rt::decl</code> and <code>rt::impl</code>) undergo parsing and analysis by the code generator. The code generator identifies and processes certain C+ extensions, such as attributes applied to the declarations in these snippets, translating them into additional C++ code. This capability enables the code generator to enhance the C++ code you write by incorporating additional boilerplate code. </p>
1385+
<p>An alternative to using <code>rt::decl</code> and <code>rt::impl</code> code snippets in an Art file is to directly <a href="../../building/build-cpp-files/">include C++ source files</a> in your workspace folder. Code in such C++ files are also analyzed by the code generator, and extra code will be generated from attributes present in them. The main difference in this case is that the extra code will be placed in separate generated files, since there is no Art file that will be translated to C++ where it could be placed. See <a href="#generated-files">Generated Files</a> for more information.</p>
1386+
<p>This chapter provides details on the applicable C++ extensions and the corresponding generated code for each.</p>
13711387
<h2 id="type-descriptor">Type Descriptor</h2>
13721388
<p>A type descriptor is meta data about a C++ type. The <a href="../../target-rts/">TargetRTS</a> uses the type descriptor to know how to initialize, copy, move, destroy, encode and decode an instance of the type. Type descriptors for all primitive C++ types are included in the TargetRTS, but for other types you need to ensure type descriptors are available if you plan to use them in a way where the TargetRTS needs it.</p>
13731389
<div class="admonition note">
@@ -1537,6 +1553,41 @@ <h3 id="automatically-generated">Automatically Generated</h3>
15371553
`
15381554
</code></pre>
15391555
<p>Note that the default implementation of a type descriptor for a typedef or type alias makes the assumption that the typedefed or aliased type is a structured type which has both a parameterless constructor, a copy constructor and a move constructor. If this assumption is not correct, you need to write your own type descriptor functions, or even <a href="#manually-implemented">implement the whole type descriptor manually</a>.</p>
1556+
<p>If your <code>[[rt::auto_descriptor]]</code> marked type is defined in a C++ header file (see <a href="../../building/build-cpp-files/">C++ Source Files</a>), and you want to customize its type descriptor, you need to declare the custom type descriptor functions in the header file, and then implement them in a C++ implementation file. Here is the above example again, but now using C++ source files <code>MyTypes.h</code> and <code>MyTypes.cpp</code> instead of an Art file.</p>
1557+
<p><em>MyTypes.h</em></p>
1558+
<pre><code class="language-cpp"> #ifndef MyTypes_h
1559+
#define MyTypes_h
1560+
1561+
#include &quot;RTStructures.h&quot;
1562+
#include &lt;string&gt;
1563+
1564+
enum class [[rt::auto_descriptor]] Colors {
1565+
Red, Green, Yellow
1566+
};
1567+
1568+
void rtg_Colors_init(const RTObject_class * type, Colors * target);
1569+
1570+
typedef std::string [[rt::auto_descriptor]] MyString;
1571+
1572+
int rtg_MyString_encode(const RTObject_class* type, const MyString* source, RTEncoding* coding);
1573+
1574+
#endif // MyTypes_h
1575+
</code></pre>
1576+
<p><em>MyTypes.cpp</em></p>
1577+
<pre><code class="language-cpp"> #include &quot;MyTypes.h&quot;
1578+
1579+
void rtg_Colors_init(const RTObject_class * type, Colors * target)
1580+
{
1581+
*target = Colors::Green; // Make Green the default color instead of Red
1582+
}
1583+
1584+
#if OBJECT_ENCODE
1585+
int rtg_MyString_encode(const RTObject_class* type, const MyString* source, RTEncoding* coding)
1586+
{
1587+
return coding-&gt;put_string(source-&gt;c_str()); // Encode as string literal
1588+
}
1589+
#endif
1590+
</code></pre>
15401591
<div class="admonition example">
15411592
<p class="admonition-title">Example</p>
15421593
<p>You can find sample applications that use automatically generated type descriptors here:</p>
@@ -1545,7 +1596,10 @@ <h3 id="automatically-generated">Automatically Generated</h3>
15451596
<li><a href="https://github.com/secure-dev-ops/code-realtime/tree/main/art-comp-test/tests/enum_type_descriptor_custom_encode">Automatically generated type descriptor for an enum class with a custom encode function</a></li>
15461597
<li><a href="https://github.com/secure-dev-ops/code-realtime/tree/main/art-comp-test/tests/struct_type_descriptor">Automatically generated type descriptor for a struct</a></li>
15471598
<li><a href="https://github.com/secure-dev-ops/code-realtime/tree/main/art-comp-test/tests/struct_type_descriptor_nested">Automatically generated type descriptor for a struct that contains another struct</a></li>
1548-
<li><a href="https://github.com/secure-dev-ops/code-realtime/tree/main/art-comp-test/tests/typedef_type_descriptor">Automatically generated type descriptor for a typedef and type alias</a></li>
1599+
<li><a href="https://github.com/secure-dev-ops/code-realtime/tree/main/art-comp-test/tests/typedef_type_descriptor">Automatically generated type descriptor for a typedef and type alias (with customized type descriptors)</a></li>
1600+
<li><a href="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>
1601+
<li><a href="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>
1602+
<li><a href="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>
15491603
</ul>
15501604
</div>
15511605
<h3 id="manually-implemented">Manually Implemented</h3>
@@ -1633,6 +1687,12 @@ <h3 id="inheritance">Inheritance</h3>
16331687
<p class="admonition-title">Example</p>
16341688
<p>You can find a sample application that uses an automatically implemented type descriptor for a class that inherits from another class <a href="https://github.com/secure-dev-ops/code-realtime/tree/main/art-comp-test/tests/type_descriptor_inheritance">here</a>.</p>
16351689
</div>
1690+
<h3 id="generated-files">Generated Files</h3>
1691+
<p>The code mentioned above related to type descriptors, which the code generator generates for the <code>[[rt::auto_descriptor]]</code> and <code>[[rt::manual_descriptor]]</code> attributes, will be placed in generated header and implementation files:</p>
1692+
<ol>
1693+
<li>If the type with the attribute is located in an <code>[[rt::decl]]</code> code snippet in an Art file, the generated files get the same name as the Art file, but with the extensions <code>.h</code> or <code>.cpp</code> appended. For example, if the Art file is called <code>MyTypes.art</code> the type descriptor code for a type contained in an <code>[[rt::decl]]</code> code snippet in that file will be placed in files <code>MyTypes.art.h</code> and <code>MyTypes.art.cpp</code>. To use the type you include the file <code>MyTypes.art.h</code>.</li>
1694+
<li>If the type with the attribute is located in a C++ header file that is present in the workspace folder (see <a href="../../building/build-cpp-files/">C++ Source Files</a>), the generated files get the same name as the C++ header file but prefixed with <code>RTType_</code>. For example, if your workspace folder contains a file <code>MyType.h</code> with a type that has a type descriptor attribute applied, two files <code>RTType_MyType.h</code> and <code>RTType_MyType.cpp</code> will be generated. Note that <code>RTType_MyType.h</code> will include the original header file <code>MyType.h</code> which means that if you need to use the type in a way that requires its type descriptor, you should include <code>RTType_MyType.h</code> rather than <code>MyType.h</code>.</li>
1695+
</ol>
16361696

16371697

16381698

2.16 KB
Loading
52.2 KB
Loading

docs/building/images/tc-editor.png

8.89 KB
Loading

docs/building/transformation-configurations/index.html

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,26 @@
931931
Editing Transformation Configurations
932932
</a>
933933

934+
<nav class="md-nav" aria-label="Editing Transformation Configurations">
935+
<ul class="md-nav__list">
936+
937+
<li class="md-nav__item">
938+
<a href="#form-based-tc-editor" class="md-nav__link">
939+
Form-based TC Editor
940+
</a>
941+
942+
</li>
943+
944+
<li class="md-nav__item">
945+
<a href="#custom-tc-properties" class="md-nav__link">
946+
Custom TC Properties
947+
</a>
948+
949+
</li>
950+
951+
</ul>
952+
</nav>
953+
934954
</li>
935955

936956
<li class="md-nav__item">
@@ -1480,6 +1500,26 @@
14801500
Editing Transformation Configurations
14811501
</a>
14821502

1503+
<nav class="md-nav" aria-label="Editing Transformation Configurations">
1504+
<ul class="md-nav__list">
1505+
1506+
<li class="md-nav__item">
1507+
<a href="#form-based-tc-editor" class="md-nav__link">
1508+
Form-based TC Editor
1509+
</a>
1510+
1511+
</li>
1512+
1513+
<li class="md-nav__item">
1514+
<a href="#custom-tc-properties" class="md-nav__link">
1515+
Custom TC Properties
1516+
</a>
1517+
1518+
</li>
1519+
1520+
</ul>
1521+
</nav>
1522+
14831523
</li>
14841524

14851525
<li class="md-nav__item">
@@ -1718,7 +1758,7 @@
17181758
<h1>Transformation Configurations</h1>
17191759

17201760
<p>A transformation configuration (or TC for short) contains all properties needed for transforming Art files into C++ code and for building the generated code into an application or a library. It is a text file in JavaScript format with the file extension .tcjs. Using JavaScript for defining build properties has many advantages. For example, it allows for <a href="../build-variants/#dynamic-transformation-configurations">dynamic properties</a> where the value is not a static value but computed dynamically by JavaScript code when the TC is built.</p>
1721-
<p>Code RealTime provides a dedicated language server for TCs to make them just as easy to work with as Art files. A <a href="#editing-transformation-configurations">form-based editor</a> is also provided as an alternative.</p>
1761+
<p>Code RealTime provides a dedicated language server for TCs to make them just as easy to work with as Art files. A <a href="#form-based-tc-editor">form-based editor</a> is also provided as an alternative.</p>
17221762
<h2 id="creating-transformation-configurations">Creating Transformation Configurations</h2>
17231763
<p>To create a new TC select a file in the workspace folder that contains the Art files you want to transform to C++. Then invoke the command <strong>File - New File - Transformation Configuration</strong>. In the popup that appears specify the name of the TC or keep the suggested default name.</p>
17241764
<p><img alt="" src="../images/default-tc-name.png" /></p>
@@ -1756,9 +1796,22 @@ <h2 id="editing-transformation-configurations">Editing Transformation Configurat
17561796
<li>TC properties are validated when edited and found problems will be reported. Click the "More information" hyperlink for a more detailed description of a problem, including suggestions for how to fix it.</li>
17571797
</ul>
17581798
<p><img alt="" src="../images/tc-editor-validation.png" /></p>
1799+
<h3 id="form-based-tc-editor">Form-based TC Editor</h3>
17591800
<p>As an alternative to editing a TC as a JavaScript file Code RealTime also provides a form-based editor which may be easier to use, especially until you are familiar with all TC properties that exist and what they mean.</p>
17601801
<p>To open the form-based TC editor, right-click on a TC file and invoke the context menu command <strong>Edit Properties (UI)</strong>. </p>
17611802
<p><img alt="" src="../images/tc-editor.png" /></p>
1803+
<p>The editor groups the TC properties into three sections:</p>
1804+
<ul>
1805+
<li>
1806+
<p><strong>General</strong>: Properties which define the scope of the TC (which elements to transform to C++ and where to place generated files)</p>
1807+
</li>
1808+
<li>
1809+
<p><strong>Code Generation</strong>: Properties that control how Art elements are transformed into C++ code, and other properties that affect the generated code</p>
1810+
</li>
1811+
<li>
1812+
<p><strong>Build</strong>: Properties that control how generated C++ code is built into a library or an executable</p>
1813+
</li>
1814+
</ul>
17621815
<p>Each available TC property has its own widget for viewing and editing the value. The type of widget depends on the type of TC property. For example, an enumerated property like "C++ Code Standard" uses a drop down menu.</p>
17631816
<p><img alt="" src="../images/tc-editor-cpp-code-standard.png" /></p>
17641817
<p>Click the info button to view documentation about a certain TC property. Click the button again to hide the documentation.</p>
@@ -1768,6 +1821,19 @@ <h2 id="editing-transformation-configurations">Editing Transformation Configurat
17681821
<p>You can tell which TC properties that have a custom (i.e. non-default) value set by looking at the color of the property name. Properties with custom values set have names shown in blue which are hyperlinks that will navigate to the value in the TC file. Such properties also have a "Delete" button which can be used for deleting the property value (i.e. to restore the property to use its default value).</p>
17691822
<p><img alt="" src="../images/tc-with-value.png" /></p>
17701823
<p>You can freely choose if you want to edit TC files as text files or using the form-based TC editor, and you can even use both at the same time. The form-based TC editor is automatically updated as soon as you edit the TC file, and the TC file is automatically updated when a widget with a modified value loses focus. </p>
1824+
<h3 id="custom-tc-properties">Custom TC Properties</h3>
1825+
<p>You can add your own custom properties to a TC by simply assigning a value to them. This allows you to persist your own custom data in TC files. Here is an example:</p>
1826+
<pre><code class="language-js">tc.customBuild = true;
1827+
</code></pre>
1828+
<p>Custom properties are ignored when building the TC, but can be seen and used by <a href="../build-variants/">Build Variant scripts</a> when implementing a custom way of building your application.</p>
1829+
<p>In the TC text editor custom properties can be recognized by a tooltip that says "any":</p>
1830+
<p><img alt="" src="../images/custom_property.png" /></p>
1831+
<p>In the form-based TC editor custom properties are not shown, but a hyperlink <strong>More Properties</strong> appears under the title text if the TC has one or many custom properties. You can click this link to navigate to the custom properties in the TC text editor.</p>
1832+
<p><img alt="" src="../images/more_properties.png" /></p>
1833+
<div class="admonition note">
1834+
<p class="admonition-title">Note</p>
1835+
<p>The <strong>More Properties</strong> hyperlink is also useful for navigating to TC properties which the form-based TC editor doesn't (yet) support, for example the <a href="#threads">threads</a> property.</p>
1836+
</div>
17711837
<h2 id="transformation-configuration-prerequisites">Transformation Configuration Prerequisites</h2>
17721838
<p>A TC can either build a library or an executable. This is controlled by the <a href="#topcapsule">topCapsule</a> property. If this property is set the TC will build an executable, otherwise it will build a library. To ensure that a library gets built before an executable that links with it, you can set the <a href="#prerequisites">prerequisites</a> property of the executable TC to reference the library TC. Doing so will also cause the executable to link with the library automatically (i.e. you then don't need to manually set-up necessary preprocessor include paths or linker paths using other TC properties).</p>
17731839
<p>If you change the prerequisites of a TC you should again <a href="#setting-a-transformation-configuration-as-active">set it as active</a> so that the prerequisite TCs also become active.</p>
@@ -1804,7 +1870,7 @@ <h2 id="art-build-view">Art Build View</h2>
18041870
</li>
18051871
</ul>
18061872
<h2 id="properties">Properties</h2>
1807-
<p>Below is a table that lists all properties that can be used in a TC. Note that many TC properties have default values and you only need to specify a value for a TC property if its different from the default value. Each property is described in a section of its own below the table.</p>
1873+
<p>Below is a table that lists all properties that can be used in a TC (in addition to <a href="#custom-tc-properties">custom properties</a>). Note that many TC properties have default values and you only need to specify a value for a TC property if its different from the default value. Each property is described in a section of its own below the table.</p>
18081874
<p id="tc_properties"/>
18091875

18101876
<table>

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ <h2>
13871387
<!-- Copyright and theme information -->
13881388
<div><p>If you encounter any problems while using Code RealTime or have questions or suggestions about its features, feel free to <a href="https://github.com/secure-dev-ops/code-realtime/issues">raise an issue</a>, or contact us at <a href="mailto:code-realtime@hcl-software.com">code-realtime@hcl-software.com</a>. We're here to assist you!</p></div>
13891389
<div class="md-footer-copyright">
1390-
<a href=" https://www.hcltechsw.com/ " title="MkDocs"><p> Copyright &copy; 2022, 2024 HCL Technologies Ltd. IBM Corporation. All Rights Reserved.</p></a>
1390+
<a href=" https://www.hcltechsw.com/ " title="MkDocs"><p> Copyright &copy; 2022, 2025 HCL Technologies Ltd. IBM Corporation. All Rights Reserved.</p></a>
13911391
<br>Made with
13921392
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
13931393
Material for MkDocs

0 commit comments

Comments
 (0)