| ... | @@ -7,9 +7,9 @@ The C++ code generation comes with the following elements |
... | @@ -7,9 +7,9 @@ The C++ code generation comes with the following elements |
|
|
* A CDT editor integration, allowing you to edit the code of a class in a CDT editor
|
|
* A CDT editor integration, allowing you to edit the code of a class in a CDT editor
|
|
|
|
|
|
|
|
[[c_profile]]
|
|
[[c_profile]]
|
|
|
== C++ profile
|
|
== C/C++ profile
|
|
|
|
|
|
|
|
The C++ profile defines a set of stereotypes that add C++ specific information to a UML model. For instance, a parameter of an operation might be passed by value, reference or as a pointer. The latter can be specified via the stereotypes C_Cpp::Ref and C_Cpp::Ptr respectively.
|
|
The C/C++ profile defines a set of stereotypes that add C/C++ specific information to a UML model. For instance, a parameter of an operation might be passed by value, reference or as a pointer. The latter can be specified via the stereotypes C_Cpp::Ref and C_Cpp::Ptr respectively.
|
|
|
|
|
|
|
|
In the sequence, we shortly describe all stereotypes in alphabetical order:
|
|
In the sequence, we shortly describe all stereotypes in alphabetical order:
|
|
|
|
|
|
| ... | @@ -49,19 +49,32 @@ In the sequence, we shortly describe all stereotypes in alphabetical order: |
... | @@ -49,19 +49,32 @@ In the sequence, we shortly describe all stereotypes in alphabetical order: |
|
|
[[code_generator]]
|
|
[[code_generator]]
|
|
|
== Code generator
|
|
== Code generator
|
|
|
|
|
|
|
|
The C++ code generator focuses on structural elements. It will generate code for classes, datatypes (C++ structs or unions) and primitive types along with their relationships such as inheritance and associations.
|
|
The C and the C++ code generator focuses on structural elements. It will generate code for classes, datatypes (structs or unions) and primitive types along with their relationships such as inheritance and associations.
|
|
|
|
|
|
|
|
The behavior of operations must be supplied in form of an opaque behavior, i.e. a text block that is stored inside the model.
|
|
The behavior of operations must be supplied in form of an opaque behavior, i.e. a text block that is stored inside the model.
|
|
|
The generator will produce a header and body file. Required #include directives are largely handled automatically, for instance if a certain type appears in the signature of one of your operations, the required #include will be added. For types that are only appearing within the opaque behavior, the user has to add an explicit dependency. An associated #include directive will be added to the body file. If additional definitions, e.g. #defines are required, it is possible to do that via the stereotype "Include" (see above).
|
|
The generator will produce a header and body file. Required #include directives are largely handled automatically, for instance if a certain type appears in the signature of one of your operations, the required #include will be added. For types that are only appearing within the opaque behavior, the user has to add an explicit dependency. An associated #include directive will be added to the body file. If additional definitions, e.g. #defines are required, it is possible to do that via the stereotype "Include" (see above).
|
|
|
|
|
|
|
|
The code generator places the created files in a folder hierarchy that corresponds to the package hierarchy in the model. By default, the files are generated into a CDT project with the name org.eclipse.papyrus.cppgen.. The prefix can be configured in the preferences. *Note*: enumerations and primitive type definitions are currently not placed into a separate file, but added to the file generated for the (nearest) package of these types. So don't be surprised, if you do not find a file that has the name of your enumeration or primitive type. This might change in the future.
|
|
The code generator places the created files in a folder hierarchy that corresponds to the package hierarchy in the model. By default, the files are generated into a CDT project with the name org.eclipse.papyrus.cppgen.<model-name>. The prefix can be configured in the preferences. *Note*: enumerations and primitive type definitions are currently not placed into a separate file, but added to the file generated for the (nearest) package of these types. So don't be surprised, if you do not find a file that has the name of your enumeration or primitive type. This might change in the future.
|
|
|
|
|
|
|
|
There is a support for external libraries that might include system libraries or legacy code. These libraries can be represented in your model by means of a stereotyped package. The stereotype "ExternalLibrary" provides information about include directories and library paths that are used to configure the generated CDT project - if there is an explicit or automatic dependency to the external library. For instance, the user can place a class called "pthread" into the external library package of the same name. No code is generated for this class. If the application classes reference a pthread class into their signature, the external library is taken into account.
|
|
There is a support for external libraries that might include system libraries or legacy code. These libraries can be represented in your model by means of a stereotyped package. The stereotype "ExternalLibrary" provides information about include directories and library paths that are used to configure the generated CDT project - if there is an explicit or automatic dependency to the external library. For instance, the user can place a class called "pthread" into the external library package of the same name. No code is generated for this class. If the application classes reference a pthread class into their signature, the external library is taken into account.
|
|
|
|
|
|
|
|
[[creating_a_hello_world_example]]
|
|
[[creating_a_hello_world_example]]
|
|
|
=== Creating a Hello World example
|
|
=== Creating a Hello World example for C++
|
|
|
|
|
|
|
|
Papyrus/Codegen/CppHelloWorld
|
|
Use the File->New->Example menu entry. A dialog will a tree selection will come up. In this dialog select
|
|
|
|
|
|
|
|
Examples > Papyrus Examples > Papyrus Designer examples based on direct code generation.
|
|
|
|
|
|
|
|
A new window shows several examples in this category. Chose the example *HelloWorldOO*.
|
|
|
|
Use Designer > "Generate code" on the root package. Select the C++ code generator. This will generated a project called *org.eclipse.papyrus.cppgen.HelloWorldOO* that you can build and compile.
|
|
|
|
|
|
|
|
=== Creating a simple C code example
|
|
|
|
|
|
|
|
Use the File->New->Example menu entry. A dialog will a tree selection will come up. In this dialog select
|
|
|
|
|
|
|
|
A new window shows several examples in this category. Chose the example *BathtubSM*
|
|
|
|
|
|
|
|
Use Designer->"Generate code" on the root package. Select the C++ code generator. This will generate a project called *org.eclipse.papyrus.cppgen.BathtubSM* that you can build and compile.
|
|
|
|
|
|
|
|
[[statemachine_support]]
|
|
[[statemachine_support]]
|
|
|
=== Statemachine support
|
|
=== Statemachine support
|
| ... | | ... | |