blob: 8901678c6d44437b19ef4a4ced79c439250deddd (
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
|
<%@ jet package = "org.eclipse.papyrus.cpp.codegen.jet.util"
skeleton = "../../generator.skeleton"
imports = "org.eclipse.papyrus.cpp.codegen.utils.GenUtils org.eclipse.uml2.uml.*"
class = "CppClassTypeAndEnum"
%>
<%
//////////////////////////////////////////////////////////////////////////////////////////
// Java preparation
//////////////////////////////////////////////////////////////////////////////////////////
// Retrieve the class
Classifier currentClass = (Classifier) argument;
// Prepare owned type and enum declaration
String publicTypeDef = "";
String privateTypeDef = "";
String protectedTypeDef = "";
String publicEnumDef = "";
String privateEnumDef = "";
String protectedEnumDef = "";
String publicKeyword = "public:";
String protectedKeyword = "protected:";
String privateKeyword = "private:";
for (Element currentElt : currentClass.getOwnedElements()) {
if (!GenUtils.hasStereotype(currentElt, Cpp.CppNoCodeGen.class)) {
if (currentElt instanceof PrimitiveType) {
org.eclipse.uml2.uml.PrimitiveType currentType = (org.eclipse.uml2.uml.PrimitiveType) currentElt;
CppPrimitiveTypeDefinition jetPrimitiveType = new CppPrimitiveTypeDefinition();
// Execute the util template
if (currentType.getVisibility() == VisibilityKind.PUBLIC_LITERAL) {
publicTypeDef = publicTypeDef+jetPrimitiveType.generate(currentType);
} else if (currentType.getVisibility() == VisibilityKind.PROTECTED_LITERAL) {
protectedTypeDef = protectedTypeDef+jetPrimitiveType.generate(currentType);
} else if (currentType.getVisibility() == VisibilityKind.PRIVATE_LITERAL) {
privateTypeDef = privateTypeDef+jetPrimitiveType.generate(currentType);
}
}
else if (currentElt instanceof Enumeration) {
Enumeration currentEnum = (Enumeration) currentElt;
CppEnumerationDefinition jetEnum = new CppEnumerationDefinition();
// Execute the util template
if (currentEnum.getVisibility() == VisibilityKind.PUBLIC_LITERAL) {
publicEnumDef = publicEnumDef+jetEnum.generate(currentEnum);
} else if (currentEnum.getVisibility() == VisibilityKind.PROTECTED_LITERAL) {
protectedEnumDef = protectedEnumDef+jetEnum.generate(currentEnum);
} else if (currentEnum.getVisibility() == VisibilityKind.PRIVATE_LITERAL) {
privateEnumDef = privateEnumDef+jetEnum.generate(currentEnum);
}
}
}
}
// If not "" add a comment before declarations
if (publicTypeDef.equals("") && publicEnumDef.equals("")) {
publicKeyword = "";
} else {
if (!publicTypeDef.equals("")) {
publicTypeDef = "/* Public type definitions */"+NL+publicTypeDef+NL;
}
if (!publicEnumDef.equals("")) {
publicEnumDef = "/* Public enumeration definitions */"+NL+publicEnumDef+NL;
}
}
if (protectedTypeDef.equals("") && protectedEnumDef.equals("")) {
protectedKeyword = "";
} else {
if (!protectedTypeDef.equals("")) {
protectedTypeDef = "/* Protected type definitions */"+NL+protectedTypeDef+NL;
}
if (!protectedEnumDef.equals("")) {
protectedEnumDef = "/* Protected enumeration definitions */"+NL+protectedEnumDef+NL;
}
}
if (privateTypeDef.equals("") && privateEnumDef.equals("")) {
privateKeyword = "";
} else {
if (!privateTypeDef.equals("")) {
privateTypeDef = "/* Private type definitions */"+NL+privateTypeDef+NL;
}
if (!privateEnumDef.equals("")) {
privateEnumDef = "/* Private enumeration definitions */"+NL+privateEnumDef+NL;
}
}
//////////////////////////////////////////////////////////////////////////////////////////
// The following part contains the template
//////////////////////////////////////////////////////////////////////////////////////////%>
<%= publicKeyword %><%= publicTypeDef %><%= publicEnumDef %><%= protectedKeyword %><%= protectedTypeDef %><%= protectedEnumDef %><%= privateKeyword %><%= privateTypeDef %><%= privateEnumDef %>
|