Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 81c80bce0dbdb13615b35f8c92c6be1e9142c581 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
[module CppOperations('http://www.eclipse.org/uml2/4.0.0/UML', 'http://www.eclipse.org/papyrus/C_Cpp/1', 'http://www.eclipse.org/uml2/4.0.0/UML/Profile/L2')/]
[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/]
[import org::eclipse::papyrus::cpp::codegen::utils::Modifier/]
[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppDocumentation/]
[import org::eclipse::papyrus::cpp::codegen::acceleo::util::operation::CppParameter/]
[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppTemplates/]


[template public virtualTxt(operation : Operation)]
[if((operation.interface <> null) or (operation.isAbstract) or (operation.hasStereotype(Virtual)))]virtual [/if]
[/template]


[template public virtualSuffix(operation : Operation)]
[if((operation.interface <> null) or (operation.isAbstract))] = 0[/if]
[/template]


[query public ConsDestructorOrVoid(operation : Operation) : String =
if hasStereotype(l2::Create) or hasStereotype(l2::Destroy) then
	''
else
	'void '
endif/]


[query public destructor(operation : Operation) : String =
if hasStereotype(l2::Destroy) then
	'~'
else
	''
endif/]

[template public CppReturnSpec(operation : Operation)]
[if (type = null)][ConsDestructorOrVoid()/][else][returnResult().modConst()/] [type.qualifiedName()/] [/if][returnResult().modPtr()/][returnResult().modRef()/]
[/template]


[template public InlineTxt(element : Element)]
[if (hasStereotype(Inline))]inline [/if]
[/template]


[template public staticTxt(operation : Operation)]
[if (isStatic)]static [/if]
[/template]

[template public CppOperationDeclaration(operation : Operation)]
[CppOperationDoc()/]
[InlineTxt()/][virtualTxt()/][staticTxt()/][CppReturnSpec()/] [destructor()/][operation.name/]([CppOperationParameters(true)/])[modConst()/][virtualSuffix()/];
[/template]


[template public CppConstInit(operation : Operation)]
[if (hasStereotype(ConstInit) and hasStereotype(l2::Create))] : [getApplication(ConstInit).oclAsType(ConstInit).initialisation/][/if]
[/template]


[comment wrapper for native query (otherwise Acceleo does not indent properly)/]
[template public getBodyInTemplate(operation : Operation, language : String)]
[getBody(language).trim()/]
[/template]


[template public CppOperationImplementation(operation : Operation)]
[CppOperationDoc()/]
[if (operation.name = 'main')]
[CppReturnSpec()/][operation.name/]([CppOperationParameters(false)/]) {
	[getBody('C/C++')/]
}
[else]
[templateSignature()/][InlineTxt()/][CppReturnSpec()/][operation.class.name/][templateShortSignature()/]::[destructor()/][operation.name/]([CppOperationParameters(false)/])[modConst()/][CppConstInit()/] {
	[getBodyInTemplate('C/C++')/]
}
[/if]
[/template]

Back to the top