Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: f37e2687c9d224e576844e26a06ee72a40cba411 (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
77
78
79
[module CppOperationDeclaration('http://www.eclipse.org/uml2/4.0.0/UML', 'http://papyrus/C_CppProfile/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)) then
	''
else
	if (hasStereotype(l2::Destroy)) then
		'~'
	else
		'void '
	endif
endif
/]


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


[template public CppConstOp(operation : Operation)]
[if (hasStereotype(operation, 'Const'))] const[/if]
[/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()/] [operation.name/]([CppOperationParameters()/])[CppConstOp()/][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()/]) {
	[getBody('C/C++')/]
}
[else]
[templateSignature()/][InlineTxt()/][CppReturnSpec()/][operation.class.name/]::[operation.name/]([CppOperationParameters()/])[CppConstOp()/][CppConstInit()/] {
	[getBodyInTemplate('C/C++')/]
}
[/if]
[/template]

Back to the top