Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a21d28529ef218f0780fef4b763299b0c234ca86 (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
[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::acceleo::GenUtils/]
[import org::eclipse::papyrus::cpp::codegen::utils::CppGenUtils/]
[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/]


[comment
return a list of owned operations, since this is not supported directly on a classifier/]
[query public getOwnedOperations(cl : Classifier) : Sequence(Operation) =
	if (cl.oclIsKindOf(Class)) then
		oclAsType(Class).ownedOperation
	else
		if (cl.oclIsKindOf(DataType)) then
			oclAsType(DataType).ownedOperation
		else
			null
		endif
	endif
/]

[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.cppQualifiedName()/][returnResult().modPtr()/][returnResult().modRef()/] [/if]
[/template]


[template public CppReturnSpec(behavior : Behavior)]
[if (returnResult() = null)]void [else][returnResult().modConst()/] [returnResult().type.cppQualifiedName()/][returnResult().modPtr()/][returnResult().modRef()/] [/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()/][destructor()/][operation.name/]([CppOperationParameters(true)/])[modConst()/][virtualSuffix()/];
[/template]

[template public CppBehaviorDeclaration(behavior : Behavior)]
[CppBehaviorDoc()/]
[InlineTxt()/][CppReturnSpec()/][behavior.name/]([CppBehaviorParameters(true)/])[modConst()/];
[/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 throws(operation: Operation)]
[if (operation.raisedException->size() > 0)]
throws [for (raisedException) separator(',')][name/][/for]
[/if]
[/template]


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


[template public CppBehaviorImplementation(behavior : OpaqueBehavior)]
[CppBehaviorDoc()/]
[CppReturnSpec()/][behavior._context.name/]::[behavior.name/]([CppBehaviorParameters(false)/])[modConst()/] {
	[getBodyFromOB('C/C++')/]
}
[/template]

Back to the top