Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a7dde0e50da20b59a51ddebb82e6a436abb1f7dc (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
<%@ jet package		=	"org.eclipse.papyrus.cpp.codegen.jet.util" 
	skeleton        =   "../../generator.skeleton" 
	imports			=	"org.eclipse.uml2.uml.* org.eclipse.uml2.uml.Class Cpp.* org.eclipse.papyrus.cpp.codegen.StdStereo org.eclipse.papyrus.cpp.codegen.utils.GenUtils" 
	class			=	"CppOperationTemplateImplementation" 
%>
<%
//////////////////////////////////////////////////////////////////////////////////////////
// Java preparation
//////////////////////////////////////////////////////////////////////////////////////////

		// Retrieve the Operation
		Operation currentOperation	= (Operation) argument;

		String operationName		= currentOperation.getName();
		String opParameters			= "";
		String returnTypeName		= "void";
		String isConst				= "";
		String isInline				= "";

		// Retrieve class & class name
		Class currentClass = currentOperation.getClass_ ();
		String className 		= currentClass.getName();
		
		// Retrieve body content
		String body = GenUtils.getBody (currentOperation, "C/C++");

		// Prepare return type
		CppOperationReturnType jetRT = new CppOperationReturnType();
		returnTypeName	= jetRT.generate(currentOperation);	
		if (! "".equals(returnTypeName)) {
			returnTypeName = returnTypeName + " ";
		}

		// Creator / Destructor: use function within StdStereo
		if (StdStereo.isApplied(currentOperation, StdStereo.create)) {
			returnTypeName		= "";
		}
		if (StdStereo.isApplied(currentOperation, StdStereo.destroy)) {
			returnTypeName		= "";
			operationName		= "~"+operationName;
		}
	
		// If inline operation
		if (GenUtils.hasStereotype(currentOperation, CppInline.class)) {
			isInline = "inline ";
		}
	
		// Const op
		if (GenUtils.hasStereotype(currentOperation, CppConst.class)) {
			isConst	= " const";
		}

		// Prepare parameters
		CppOperationParametersWithoutDefaultValue jetParams	
			= new CppOperationParametersWithoutDefaultValue();
		opParameters = jetParams.generate(currentOperation);


		// Prepare template parameter declaration without type
		String tparamWoType	= "";

		if (currentClass != null) {
			tparamWoType = GenUtils.getTemplateParametersWoType(currentClass);
		}
	
//////////////////////////////////////////////////////////////////////////////////////////
// The following part contains the template
//////////////////////////////////////////////////////////////////////////////////////////
// Package visibility 
	if (currentOperation.getVisibility() == VisibilityKind.PACKAGE_LITERAL) {
	
//////////////////////////////////////////////////////////////////////////////////////////

%><%= isInline %><%= returnTypeName %><%= operationName %>(<%= opParameters %>)<%= isConst %> {
<%= body %>
}<%

//////////////////////////////////////////////////////////////////////////////////////////
	
	} else { // Default case

//////////////////////////////////////////////////////////////////////////////////////////	

%><%= isInline %><%= returnTypeName %><%= className %><<%= tparamWoType %>>::<%= operationName %>(<%= opParameters %>)<%= isConst %> {
<%= body %>
}<%

//////////////////////////////////////////////////////////////////////////////////////////
	}
//////////////////////////////////////////////////////////////////////////////////////////%>

Back to the top