Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 04e92f6a6fd92fbb85e4512ad198d1e53852102f (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
<%@ jet package		=	"org.eclipse.papyrus.cpp.codegen.jet" 
	skeleton        =   "generator.skeleton" 
	imports			=	"org.eclipse.papyrus.cpp.codegen.Constants org.eclipse.papyrus.cpp.codegen.utils.* Cpp.CppInclude org.eclipse.uml2.uml.Class org.eclipse.uml2.uml.Package org.eclipse.uml2.uml.* org.eclipse.emf.common.util.EList org.eclipse.papyrus.cpp.codegen.jet.util.* java.util.* org.eclipse.papyrus.cpp.codegen.Activator" 
 	class			=	"CppBindBody" 
 %>
<%
//////////////////////////////////////////////////////////////////////////////////////////
// Java preparation
//////////////////////////////////////////////////////////////////////////////////////////
	
	// Retrieve the class
	Class currentClass		= (Class) argument;

	// Get the package name
	String className		= currentClass.getName();
	String classFullName	= GenUtils.getFullName (currentClass); 
	String classFULLNAME	= classFullName.toUpperCase(); 
	String parentClass      = "";
	String namespace = GenUtils.getNamespace (currentClass);

	// Retrieve header file suffix
	String headerFileSuffix = Activator.getDefault().getPluginPreferences().getString("headSuffix");

	// Retrieve owner Package
	Package owner = currentClass.getPackage();
	String fullPath	= "";
	
	if (owner != null) {
		fullPath = GenUtils.getFullPath(owner) + "/";
	} // else fullPath == ""

	TemplateBinding tb = GenUtils.getTemplateBindings(currentClass);;

	// prepare parent class declaration
	EList<org.eclipse.uml2.uml.Element> templates = tb.getTargets();
	Class templateClass = (Class) ((TemplateSignature) templates.get(0)).getOwner();	
	parentClass	= GenUtils.qualifiedName (templateClass);

	// Prepare bindings parameter declaration

	String tParamDecl = "";
	Iterator<TemplateParameterSubstitution> tps = tb.getParameterSubstitutions().iterator();
	while(tps.hasNext()) {
		TemplateParameterSubstitution paramSub = tps.next();

		CppTemplateBindingParameter	jetTParam = new CppTemplateBindingParameter();
		tParamDecl = tParamDecl+jetTParam.generate (paramSub);

		if (tps.hasNext()) {
			tParamDecl = tParamDecl + ", ";
		}
	}

	
//////////////////////////////////////////////////////////////////////////////////////////
// The following part contains the template
//////////////////////////////////////////////////////////////////////////////////////////%>
#define <%= classFULLNAME %>_BODY

/************************************************************
              <%= className %> template binding body
 ************************************************************/

<%= Constants.cppIncPreBodyStart %>
<%= ClassUtils.getCppIncludePreBody(currentClass) %>
<%= Constants.cppIncPreBodyEnd %>

<%= Constants.includeHFile %>
#include <<%= fullPath %><%= className %>.<%= headerFileSuffix %>>

<%= Constants.cppIncBodyStart %>
<%= ClassUtils.getCppIncludeBody(currentClass) %>
<%= Constants.cppIncBodyEnd %>

<%= GenUtils.openNS(currentClass) %>

<%= Constants.derivedIncludes %>
<%= ClassUtils.createIncludeDecl(currentClass) %>

/************************************************************/
template class <%= parentClass %> <<%= tParamDecl %>>;

<%= GenUtils.closeNS(currentClass) %>

/************************************************************
              End of <%= className %> template binding body
 ************************************************************/

Back to the top