Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2012-11-08 13:27:38 +0000
committerJuergen Haug2012-11-08 13:27:38 +0000
commit0f233b0b11dbc6b1bbaf28e238f56c4371d58f0d (patch)
tree62aba9b01a7ab74d21f0d543b95492c160da92c1 /plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
parent7badae06f1e2b21c3a5e0d1b812503655a0f8419 (diff)
downloadorg.eclipse.etrice-0f233b0b11dbc6b1bbaf28e238f56c4371d58f0d.tar.gz
org.eclipse.etrice-0f233b0b11dbc6b1bbaf28e238f56c4371d58f0d.tar.xz
org.eclipse.etrice-0f233b0b11dbc6b1bbaf28e238f56c4371d58f0d.zip
[CQ 6485][config, generator] refactor dataConfiguration,
attribute init, attribute value input formatting changed Change-Id: I8a3399be56cd67cb6ab75529864b9dcb6f7b7799
Diffstat (limited to 'plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend')
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend28
1 files changed, 22 insertions, 6 deletions
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
index e461a45fd..d76f23f5a 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend
@@ -100,13 +100,27 @@ class JavaExtensions implements ILanguageExtension {
override String destructorReturnType() {
"void"
}
- override String toCharArrayExpr(String s){
- "\"" + s + "\".toCharArray()"
- }
+
override String superCall(String baseClassName, String method, String args) {
"super."+method+"("+args+");"
}
- override String toValueLiteral(PrimitiveType type, String value){
+
+ override toValueLiteral(PrimitiveType type, String value) {
+ switch(type.targetName){
+ case "char":
+ castValue(type, value)
+ case "string":
+ castValue(type, value)
+ case value.contains(','):{
+ var singleValues = value.replace('{', '').replace('}', '').trim.split(',')
+ '''{ «FOR v: singleValues SEPARATOR ', '»«castValue(type, v.trim)»«ENDFOR» }'''.toString
+ }
+ default:
+ castValue(type, value)
+ }
+ }
+
+ def private castValue(PrimitiveType type, String value){
switch(type.targetName){
case "boolean":
return value
@@ -126,10 +140,10 @@ class JavaExtensions implements ILanguageExtension {
if(value.length == 1)
return "'"+value+"'"
else
- return value.toCharArrayExpr
+ return "\""+value.replace("\\", "\\\\").replace("\"", "\\\"")+"\".toCharArray()"
}
case "String":
- return "\""+value+"\""
+ return "\""+value.replace("\\", "\\\\").replace("\"", "\\\"")+"\""
}
throw new UnsupportedOperationException(type.targetName)
@@ -183,4 +197,6 @@ class JavaExtensions implements ILanguageExtension {
return newArrayList(dataArg, typedData, typedArgList);
}
+
+
}

Back to the top