blob: c73e7add19ee14b8843b780268ea6b91cc52a41b (
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
|
package org.eclipse.etrice.generator.cpp.gen
import org.eclipse.etrice.core.room.Attribute
import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.core.room.RefableType
class CppProcedureHelpers extends ProcedureHelpers {
override protected getterHeader(Attribute attribute, String classname) {
val constModifier = if(attribute.size == 0 && (attribute.type.type.isPrimitive || attribute.type.ref)) ' const' else ''
super.getterHeader(attribute, classname) + constModifier
}
override declarationString(Attribute attribute) {
switch it : attribute {
// no reference
case size > 0: super.declarationString(it)
default: super.signatureString(type) + ' ' + name
}
}
override signatureString(RefableType type) {
switch it : type {
case null: 'void'
case !(isRef || type.type.primitive): super.signatureString(type) + '&'
default: super.signatureString(type)
}
}
override signatureString(Attribute attribute) {
switch it : attribute {
case size > 0: super.signatureString(attribute) + '&'
default: type.signatureString
}
}
/**
* @param attributes a list of {@link Attribute}s
* @return an argument list for the attributes with const except for ref {@link Attribute}s
*/
def constArgList(Iterable<Attribute> attributes) {
attributes.map[(if(!type.ref) 'const ' else '' ) + signatureString + ' ' + name].join(', ')
}
}
|