Even though the code generated by QM™ is not intended to be edited manually outside QM™, it still needs to be understood and debugged using a traditional source-level debuggers.
Also, some engineering organizations require all code, including auto-generated code, to comply with the internal coding standards. Such standards often dictate very specific commenting style, like provision of special file comments, function comments, variable comments, etc.
To enhance the readability of the generated code and to meet the special commenting style requirements, QM™ can emit several kinds of various comments, all described in the following sections.
At the top of each generated file, QM™ generates a top-level comment, which has two purposes:
The following snippet of code shows the top-level file comment in the case when the underlying QP framework is used under the open-source GPL license:
/***************************************************************************** * Model: test1.qm * File: ./file.c * * This code has been generated by QM tool (see state-machine.com/qm). * DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost. * * This program is open source software: you can redistribute it and/or * modify it under the terms of the GNU General Public License as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. *****************************************************************************/
The following snippet of C++ code shows the top-level file comment in the case when the underlying QP framework is used under a commercial QP license (NOTE: In C, the generated comments use the C comment style /*...*
/):
////////////////////////////////////////////////////////////////////////////// // Model: test2.qm // File: ./file.cpp // // This code has been generated by QM tool (see state-machine.com/qm). // DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost. // // This code is covered by the following commercial QP license: // License # : QPCPP-SP-141224A // Issued to : Bamboozle Technologies, Inc. // Framework(s): qpcpp // Support ends: 2015-12-24 // Product(s) : // eGizmo Shuffle 2nd Generation //////////////////////////////////////////////////////////////////////////////
QM™ allows you to generate comments from the documentation property that is available in many model items, such as classes, attributes, operations, and states.
The following screen shot shows an example of the documentation property that generates comments. Specifically, the example generates a comment with the declaration of the class as well another comment with the definition of the class.
The QM code generator uses the following algorithm to generate comments form the documentation property:
*...*
/) and C++-style comments (//
) are allowed. If no comment is found, the documentation property generates no comments. (NOTE: Any comments in the documentation property are clearly indicated by syntax highlighting);QM™ generates also comments that contain the model-links. These model-link comments have a generic form: /* ${<fully-qualified-name>} *
/, where <fully-qualified-name>
is the Fully-Qualified Item Name of the referenced item. The following code snippet provides several examples of model-reference comments at lines 1, 5, 7, and 19:
The model-link comments allow you to quickly open the linked model item as the Current Item in QM™ To do so, you only need to:
Finally, to improve readability of the generated code, QM™ generates divider comments to visually separate various sections of code, as illustrated in the following snippet of generated code (lines 1, 6, and 7):
The divider comments often contain the Fully-Qualified Item Name of the model item that follows, so you can use the divider comments to quickly open the referenced model item as the Current Item in QM™, as described in the previous section Model-Link Comments.
Next: Conditional Compilation