Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 52feb87b2450f136fe358cbda5844b347902e3e7 (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
<%@ jet package		=	"org.eclipse.papyrus.cpp.codegen.jet.util" 
	skeleton        =   "../../generator.skeleton" 
	imports			=	"org.eclipse.uml2.uml.Class org.eclipse.uml2.uml.* org.eclipse.papyrus.cpp.codegen.utils.GenUtils java.util.Iterator Cpp.*" 
 	class			=	"CppClassTypeAndEnumPackage" 
 %>
<%
//////////////////////////////////////////////////////////////////////////////////////////
// Java preparation
//////////////////////////////////////////////////////////////////////////////////////////
	
	// Retrieve the class
	Classifier currentClass = (Classifier) argument;
	

	// Prepare owned type and enum declaration
	String packageTypeDef = "";
	String packageEnumDef = "";
			
	Iterator<Element> typeIt = currentClass.getOwnedElements().iterator();
	while (typeIt.hasNext()) {
		Element currentElt = typeIt.next();
		if (!GenUtils.hasStereotype(currentElt, CppNoCodeGen.class)) {
			if (currentElt instanceof PrimitiveType) {

				PrimitiveType currentType = (PrimitiveType) currentElt;
				CppPrimitiveTypeDefinition jetPrimitiveType	= new CppPrimitiveTypeDefinition();
				// Execute the util template
				if (currentType.getVisibility() == VisibilityKind.PACKAGE_LITERAL) {
					packageTypeDef = packageTypeDef+jetPrimitiveType.generate(currentType);
				}


			} else if (currentElt instanceof Enumeration) {

				Enumeration currentEnum	= (Enumeration) currentElt;
				CppEnumerationDefinition jetEnum = new CppEnumerationDefinition();
				// Execute the util template
				if (currentEnum.getVisibility() == VisibilityKind.PACKAGE_LITERAL) {
					packageEnumDef = packageEnumDef+jetEnum.generate(currentEnum);
				} 

			}
		}
	}
	
	// If not "" add a comment before declarations
	if (!packageEnumDef.equals("")) {
		packageEnumDef	= "/* Package enumeration definitions                        */"+NL+packageEnumDef;
	}
	if (!packageTypeDef.equals("")) {
		packageTypeDef	= "/* Package type definitions                               */"+NL+packageTypeDef;
	}

	
//////////////////////////////////////////////////////////////////////////////////////////
// The following part contains the template
//////////////////////////////////////////////////////////////////////////////////////////%>
<%= packageTypeDef %>
<%= packageEnumDef %>

Back to the top