Skip to main content
summaryrefslogtreecommitdiffstats
blob: e71028e526675a04cb43864f7e1d4568e3b02bcf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
[module CppPrimitiveTypes('http://www.eclipse.org/uml2/5.0.0/UML', 'http://www.eclipse.org/papyrus/C_Cpp/1')/]
[import org::eclipse::papyrus::acceleo::GenUtils/]
[import org::eclipse::papyrus::cpp::codegen::utils::CppGenUtils/]
[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppDocumentation/]


[comment
 * Support two different kinds of primitive types
 * (1) those that are native types of the programming language such as long
 *     For these, no additional definition has to be done and they should be referenced
 *     with their name only
 * (2) those that correspond to a typedef (e.g. typedef long ErrorType). These require
 *     a typedef definition within the package and need to be referenced with their
 *     fully qualified name (e.g. MyPackage::ErrorType)
 * (3) Sometimes the name of the type defined by a typedef does not appear at the end, e.g.
 *     when defining functionPointers such as "typedef int (*HandlerFct) (void*);"
 *	   (a function with a void* argument returning int)
 *     Support this case via a specific 'typeName' constant that gets replaced by the name of the
 *     type
 */
/]
[template public CppPrimitiveTypeDefinition(primitiveType : PrimitiveType)]
[CppElementDoc()/]
[if (hasStereotype(Typedef))]
typedef [getApplication(Typedef).oclAsType(Typedef).definition.replaceAll('typeName', primitiveType.name)
	/][if (not getApplication(Typedef).oclAsType(Typedef).definition.contains('typeName'))] [primitiveType.name/][/if];
[else]
[getStdtypes(primitiveType)/];
[/if]
[/template]

Back to the top