summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2012-11-08 08:27:38 (EST)
committerJuergen Haug2012-11-08 08:27:38 (EST)
commit0f233b0b11dbc6b1bbaf28e238f56c4371d58f0d (patch)
tree62aba9b01a7ab74d21f0d543b95492c160da92c1
parent7badae06f1e2b21c3a5e0d1b812503655a0f8419 (diff)
downloadorg.eclipse.etrice-0f233b0b11dbc6b1bbaf28e238f56c4371d58f0d.zip
org.eclipse.etrice-0f233b0b11dbc6b1bbaf28e238f56c4371d58f0d.tar.gz
org.eclipse.etrice-0f233b0b11dbc6b1bbaf28e238f56c4371d58f0d.tar.bz2
[CQ 6485][config, generator] refactor dataConfiguration,refs/changes/99/8599/1
attribute init, attribute value input formatting changed Change-Id: I8a3399be56cd67cb6ab75529864b9dcb6f7b7799
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend3
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java6
-rw-r--r--plugins/org.eclipse.etrice.generator.config/.classpath8
-rw-r--r--plugins/org.eclipse.etrice.generator.config/.gitignore1
-rw-r--r--plugins/org.eclipse.etrice.generator.config/.project34
-rw-r--r--plugins/org.eclipse.etrice.generator.config/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--plugins/org.eclipse.etrice.generator.config/META-INF/MANIFEST.MF17
-rw-r--r--plugins/org.eclipse.etrice.generator.config/about.html28
-rw-r--r--plugins/org.eclipse.etrice.generator.config/build.properties4
-rw-r--r--plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend (renamed from plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend)2
-rw-r--r--plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/util/DataConfigurationHelper.java (renamed from plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/config/DataConfigurationHelper.java)2
-rw-r--r--plugins/org.eclipse.etrice.generator.config/xtend-gen/org/eclipse/etrice/generator/config/.DataConfiguration.java._tracebin0 -> 41616 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.config/xtend-gen/org/eclipse/etrice/generator/config/DataConfiguration.java (renamed from plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/config/DataConfiguration.java)2
-rw-r--r--plugins/org.eclipse.etrice.generator.java/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend27
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/JavaExtensions.xtend28
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java73
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java75
-rw-r--r--plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF4
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IDataConfiguration.java3
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java7
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/SendingDataTestJava.room2
22 files changed, 233 insertions, 102 deletions
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
index 8677588..b6ec16c 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
@@ -151,9 +151,6 @@ class CExtensions implements ILanguageExtension {
override String destructorReturnType() {
"void"
}
- override String toCharArrayExpr(String s){
- "\"" + s + "\"";
- }
override String superCall(String baseClassName, String method, String args) {
""
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
index 819c106..b8e04d6 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/CExtensions.java
@@ -245,12 +245,6 @@ public class CExtensions implements ILanguageExtension {
return "void";
}
- public String toCharArrayExpr(final String s) {
- String _plus = ("\"" + s);
- String _plus_1 = (_plus + "\"");
- return _plus_1;
- }
-
public String superCall(final String baseClassName, final String method, final String args) {
return "";
}
diff --git a/plugins/org.eclipse.etrice.generator.config/.classpath b/plugins/org.eclipse.etrice.generator.config/.classpath
new file mode 100644
index 0000000..54357e3
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.config/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="xtend-gen"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.etrice.generator.config/.gitignore b/plugins/org.eclipse.etrice.generator.config/.gitignore
new file mode 100644
index 0000000..092357e
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.config/.gitignore
@@ -0,0 +1 @@
+bin
diff --git a/plugins/org.eclipse.etrice.generator.config/.project b/plugins/org.eclipse.etrice.generator.config/.project
new file mode 100644
index 0000000..4093fbb
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.config/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.etrice.generator.config</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.etrice.generator.config/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.etrice.generator.config/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..f287d53
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.config/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/plugins/org.eclipse.etrice.generator.config/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.generator.config/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..7d151f4
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.config/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: eTrice Generator Config
+Bundle-SymbolicName: org.eclipse.etrice.generator.config;singleton:=true
+Bundle-Version: 0.2.0.qualifier
+Bundle-Vendor: eTrice (Incubation)
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Require-Bundle: org.eclipse.etrice.core.room;bundle-version="0.2.0",
+ org.eclipse.etrice.core.config;bundle-version="0.2.0",
+ org.eclipse.etrice.generator;bundle-version="0.2.0",
+ org.eclipse.etrice.core.genmodel;bundle-version="0.2.0",
+ org.eclipse.xtend.lib,
+ com.google.guava,
+ org.eclipse.xtext.xbase.lib
+Export-Package: org.eclipse.etrice.generator.config
+
diff --git a/plugins/org.eclipse.etrice.generator.config/about.html b/plugins/org.eclipse.etrice.generator.config/about.html
new file mode 100644
index 0000000..f47dbdd
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.config/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.config/build.properties b/plugins/org.eclipse.etrice.generator.config/build.properties
new file mode 100644
index 0000000..eeeed05
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.config/build.properties
@@ -0,0 +1,4 @@
+source.. = src/,\
+ xtend-gen/
+bin.includes = META-INF/,\
+ .
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend b/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend
index 133c1e7..ea7ebfb 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend
+++ b/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend
@@ -23,7 +23,7 @@ import org.eclipse.etrice.core.room.Attribute
import org.eclipse.etrice.core.room.ProtocolClass
import org.eclipse.etrice.core.room.SubSystemClass
import org.eclipse.etrice.generator.base.IDataConfiguration
-import org.eclipse.etrice.generator.config.DataConfigurationHelper
+import org.eclipse.etrice.generator.config.util.DataConfigurationHelper
import org.eclipse.etrice.core.config.BooleanLiteral
import org.eclipse.etrice.core.config.IntLiteral
import org.eclipse.etrice.core.config.RealLiteral
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/config/DataConfigurationHelper.java b/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/util/DataConfigurationHelper.java
index a64c658..bb768ad 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/config/DataConfigurationHelper.java
+++ b/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/util/DataConfigurationHelper.java
@@ -9,7 +9,7 @@
* Juergen Haug
*
*******************************************************************************/
-package org.eclipse.etrice.generator.config;
+package org.eclipse.etrice.generator.config.util;
import java.util.ArrayList;
import java.util.HashMap;
diff --git a/plugins/org.eclipse.etrice.generator.config/xtend-gen/org/eclipse/etrice/generator/config/.DataConfiguration.java._trace b/plugins/org.eclipse.etrice.generator.config/xtend-gen/org/eclipse/etrice/generator/config/.DataConfiguration.java._trace
new file mode 100644
index 0000000..5be2e69
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.config/xtend-gen/org/eclipse/etrice/generator/config/.DataConfiguration.java._trace
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/config/DataConfiguration.java b/plugins/org.eclipse.etrice.generator.config/xtend-gen/org/eclipse/etrice/generator/config/DataConfiguration.java
index cc83255..d7f51d1 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/config/DataConfiguration.java
+++ b/plugins/org.eclipse.etrice.generator.config/xtend-gen/org/eclipse/etrice/generator/config/DataConfiguration.java
@@ -24,7 +24,7 @@ import org.eclipse.etrice.core.room.Attribute;
import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.SubSystemClass;
import org.eclipse.etrice.generator.base.IDataConfiguration;
-import org.eclipse.etrice.generator.config.DataConfigurationHelper;
+import org.eclipse.etrice.generator.config.util.DataConfigurationHelper;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
diff --git a/plugins/org.eclipse.etrice.generator.java/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.generator.java/META-INF/MANIFEST.MF
index 4f2245c..951390e 100644
--- a/plugins/org.eclipse.etrice.generator.java/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.generator.java/META-INF/MANIFEST.MF
@@ -16,7 +16,7 @@ Require-Bundle: org.eclipse.etrice.core.room.ui;bundle-version="0.1.0",
org.eclipse.etrice.generator.doc;bundle-version="0.1.0",
org.eclipse.xtext.generator;bundle-version="2.1.1",
org.eclipse.xtext.util;bundle-version="2.1.1",
- org.eclipse.etrice.core.config;bundle-version="0.2.0"
+ org.eclipse.etrice.generator.config;bundle-version="0.2.0"
Import-Package: org.apache.log4j
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.eclipse.etrice.generator.java
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend
index 17af443..f3484e9 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend
@@ -49,8 +49,7 @@ class Initialization {
«IF tmp.length==0»«defaultInit(a, useClassDefaultsOnly)»«ENDIF»
«ENDFOR»
'''
- }
-
+ }
def private dataConfigurationInit(EObject roomClass, List<Attribute> path){
var a = path.last
var aType = a.refType.type
@@ -66,21 +65,21 @@ class Initialization {
''''''
}
- def private valueInit(List<Attribute> path, String value){
- if(value == null) return ''''''
+ def private valueInit(List<Attribute> path, String literalValue){
+ if(literalValue == null) return ''''''
var a = path.last
var aType = a.refType.type
var getter = if(path.size > 1)procedureHelpers.invokeGetters(path.take(path.size-1), null)+"." else ""
'''
«IF a.size == 0 || aType.characterType»
- «getter»«procedureHelpers.invokeSetter(a.name,null,value)»;
- «ELSEIF value.startsWith("{")»
- «getter»«procedureHelpers.invokeSetter(a.name,null, '''new «aType.typeName»[] «value»''')»;
+ «getter»«procedureHelpers.invokeSetter(a.name,null,literalValue)»;
+ «ELSEIF literalValue.startsWith("{")»
+ «getter»«procedureHelpers.invokeSetter(a.name,null, '''new «aType.typeName»[] «literalValue»''')»;
«ELSE»
{
«aType.typeName»[] _«a.name» = new «aType.typeName»[«a.size»];
for (int i=0;i<«a.size»;i++){
- _«a.name»[i] = «value»;
+ _«a.name»[i] = «literalValue»;
}
«getter»«procedureHelpers.invokeSetter(a.name,null,"_"+a.name)»;
}
@@ -109,8 +108,9 @@ class Initialization {
'''
}
- def private getRoomDefaulValue(Attribute a){
- a.defaultValueLiteral
+ def String getRoomDefaulValue(Attribute a){
+ if(a.refType.type.primitive && a.defaultValueLiteral != null)
+ languageExt.toValueLiteral(a.refType.type as PrimitiveType, a.defaultValueLiteral)
}
def private String getDataConfigValue(EObject roomClass, List<Attribute> path){
@@ -125,11 +125,8 @@ class Initialization {
dataConfigExt.getAttrClassConfigValue(pc, pc.regular.equals(roomClass), path)
}
}
- return if(result != null)
- if(a.size > 0 && !aType.characterType)
- '''{ «FOR e : result.split(',') SEPARATOR ", "»«languageExt.toValueLiteral(aType, e)»«ENDFOR»}'''
- else
- languageExt.toValueLiteral(aType, result)
+ if(result != null)
+ return languageExt.toValueLiteral(aType, result)
}
}
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 e461a45..d76f23f 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);
}
+
+
}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java
index 2c0b54b..e3ff634 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java
@@ -119,10 +119,10 @@ public class Initialization {
return _xblockexpression;
}
- private CharSequence valueInit(final List<Attribute> path, final String value) {
+ private CharSequence valueInit(final List<Attribute> path, final String literalValue) {
CharSequence _xblockexpression = null;
{
- boolean _equals = Objects.equal(value, null);
+ boolean _equals = Objects.equal(literalValue, null);
if (_equals) {
StringConcatenation _builder = new StringConcatenation();
return _builder;
@@ -158,12 +158,12 @@ public class Initialization {
if (_or) {
_builder_1.append(getter, "");
String _name = a.getName();
- CharSequence _invokeSetter = this.procedureHelpers.invokeSetter(_name, null, value);
+ CharSequence _invokeSetter = this.procedureHelpers.invokeSetter(_name, null, literalValue);
_builder_1.append(_invokeSetter, "");
_builder_1.append(";");
_builder_1.newLineIfNotEmpty();
} else {
- boolean _startsWith = value.startsWith("{");
+ boolean _startsWith = literalValue.startsWith("{");
if (_startsWith) {
_builder_1.append(getter, "");
String _name_1 = a.getName();
@@ -172,7 +172,7 @@ public class Initialization {
String _typeName = this._typeHelpers.typeName(aType);
_builder_2.append(_typeName, "");
_builder_2.append("[] ");
- _builder_2.append(value, "");
+ _builder_2.append(literalValue, "");
CharSequence _invokeSetter_1 = this.procedureHelpers.invokeSetter(_name_1, null, _builder_2.toString());
_builder_1.append(_invokeSetter_1, "");
_builder_1.append(";");
@@ -205,7 +205,7 @@ public class Initialization {
String _name_3 = a.getName();
_builder_1.append(_name_3, " ");
_builder_1.append("[i] = ");
- _builder_1.append(value, " ");
+ _builder_1.append(literalValue, " ");
_builder_1.append(";");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t");
@@ -329,9 +329,27 @@ public class Initialization {
return _builder;
}
- private String getRoomDefaulValue(final Attribute a) {
- String _defaultValueLiteral = a.getDefaultValueLiteral();
- return _defaultValueLiteral;
+ public String getRoomDefaulValue(final Attribute a) {
+ String _xifexpression = null;
+ boolean _and = false;
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isPrimitive = this._typeHelpers.isPrimitive(_type);
+ if (!_isPrimitive) {
+ _and = false;
+ } else {
+ String _defaultValueLiteral = a.getDefaultValueLiteral();
+ boolean _notEquals = (!Objects.equal(_defaultValueLiteral, null));
+ _and = (_isPrimitive && _notEquals);
+ }
+ if (_and) {
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ String _defaultValueLiteral_1 = a.getDefaultValueLiteral();
+ String _valueLiteral = this.languageExt.toValueLiteral(((PrimitiveType) _type_1), _defaultValueLiteral_1);
+ _xifexpression = _valueLiteral;
+ }
+ return _xifexpression;
}
private String getDataConfigValue(final EObject roomClass, final List<Attribute> path) {
@@ -375,45 +393,10 @@ public class Initialization {
}
}
String result = _switchResult;
- String _xifexpression = null;
boolean _notEquals = (!Objects.equal(result, null));
if (_notEquals) {
- String _xifexpression_1 = null;
- boolean _and = false;
- int _size = a.getSize();
- boolean _greaterThan = (_size > 0);
- if (!_greaterThan) {
- _and = false;
- } else {
- boolean _isCharacterType = this._typeHelpers.isCharacterType(aType);
- boolean _not = (!_isCharacterType);
- _and = (_greaterThan && _not);
- }
- if (_and) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("{ ");
- {
- String[] _split = result.split(",");
- boolean _hasElements = false;
- for(final String e : _split) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(", ", "");
- }
- String _valueLiteral = this.languageExt.toValueLiteral(aType, e);
- _builder.append(_valueLiteral, "");
- }
- }
- _builder.append("}");
- _xifexpression_1 = _builder.toString();
- } else {
- String _valueLiteral_1 = this.languageExt.toValueLiteral(aType, result);
- _xifexpression_1 = _valueLiteral_1;
- }
- _xifexpression = _xifexpression_1;
+ return this.languageExt.toValueLiteral(aType, result);
}
- return _xifexpression;
}
return null;
}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
index 5ee96b3..782b272 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/JavaExtensions.java
@@ -155,12 +155,6 @@ public class JavaExtensions implements ILanguageExtension {
return "void";
}
- public String toCharArrayExpr(final String s) {
- String _plus = ("\"" + s);
- String _plus_1 = (_plus + "\".toCharArray()");
- return _plus_1;
- }
-
public String superCall(final String baseClassName, final String method, final String args) {
String _plus = ("super." + method);
String _plus_1 = (_plus + "(");
@@ -170,6 +164,64 @@ public class JavaExtensions implements ILanguageExtension {
}
public String toValueLiteral(final PrimitiveType type, final String value) {
+ String _switchResult = null;
+ String _targetName = type.getTargetName();
+ final String _switchValue = _targetName;
+ boolean _matched = false;
+ if (!_matched) {
+ if (Objects.equal(_switchValue,"char")) {
+ _matched=true;
+ String _castValue = this.castValue(type, value);
+ _switchResult = _castValue;
+ }
+ }
+ if (!_matched) {
+ if (Objects.equal(_switchValue,"string")) {
+ _matched=true;
+ String _castValue_1 = this.castValue(type, value);
+ _switchResult = _castValue_1;
+ }
+ }
+ if (!_matched) {
+ boolean _contains = value.contains(",");
+ if (_contains) {
+ _matched=true;
+ String _xblockexpression = null;
+ {
+ String _replace = value.replace("{", "");
+ String _replace_1 = _replace.replace("}", "");
+ String _trim = _replace_1.trim();
+ String[] singleValues = _trim.split(",");
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("{ ");
+ {
+ boolean _hasElements = false;
+ for(final String v : singleValues) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(", ", "");
+ }
+ String _trim_1 = v.trim();
+ String _castValue_2 = this.castValue(type, _trim_1);
+ _builder.append(_castValue_2, "");
+ }
+ }
+ _builder.append(" }");
+ String _string = _builder.toString();
+ _xblockexpression = (_string);
+ }
+ _switchResult = _xblockexpression;
+ }
+ }
+ if (!_matched) {
+ String _castValue_2 = this.castValue(type, value);
+ _switchResult = _castValue_2;
+ }
+ return _switchResult;
+ }
+
+ private String castValue(final PrimitiveType type, final String value) {
String _targetName = type.getTargetName();
final String _switchValue = _targetName;
boolean _matched = false;
@@ -224,15 +276,20 @@ public class JavaExtensions implements ILanguageExtension {
String _plus = ("\'" + value);
return (_plus + "\'");
} else {
- return this.toCharArrayExpr(value);
+ String _replace = value.replace("\\", "\\\\");
+ String _replace_1 = _replace.replace("\"", "\\\"");
+ String _plus_1 = ("\"" + _replace_1);
+ return (_plus_1 + "\".toCharArray()");
}
}
}
if (!_matched) {
if (Objects.equal(_switchValue,"String")) {
_matched=true;
- String _plus_1 = ("\"" + value);
- return (_plus_1 + "\"");
+ String _replace_2 = value.replace("\\", "\\\\");
+ String _replace_3 = _replace_2.replace("\"", "\\\"");
+ String _plus_2 = ("\"" + _replace_3);
+ return (_plus_2 + "\"");
}
}
String _targetName_1 = type.getTargetName();
diff --git a/plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF
index 6c466ed..f2beb78 100644
--- a/plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF
@@ -7,7 +7,6 @@ Bundle-ClassPath: .
Bundle-Vendor: eTrice (Incubation)
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.eclipse.etrice.generator.base,
- org.eclipse.etrice.generator.config,
org.eclipse.etrice.generator.generic
Require-Bundle: org.eclipse.etrice.core.room;bundle-version="0.1.0",
org.eclipse.etrice.core.genmodel;bundle-version="0.2.0",
@@ -17,7 +16,6 @@ Require-Bundle: org.eclipse.etrice.core.room;bundle-version="0.1.0",
org.eclipse.core.resources;bundle-version="3.7.100",
org.eclipse.xtext.generator;bundle-version="2.1.1",
org.eclipse.xtext;bundle-version="2.1.1",
- org.eclipse.xtend.lib;bundle-version="2.3.0",
- org.eclipse.etrice.core.config;bundle-version="0.2.0"
+ org.eclipse.xtend.lib;bundle-version="2.3.0"
Bundle-ActivationPolicy: lazy
Import-Package: org.eclipse.etrice.generator.generic
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IDataConfiguration.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IDataConfiguration.java
index 50756cb..281e790 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IDataConfiguration.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IDataConfiguration.java
@@ -28,9 +28,6 @@ public interface IDataConfiguration {
// static configuration
- /**
- * Array formatting: x,x,x,x,x
- */
public String getAttrClassConfigValue(ActorClass actor, List<Attribute> path);
public String getAttrClassConfigValue(ProtocolClass pc, boolean regular, List<Attribute> path);
public String getAttrClassConfigMinValue(ActorClass actor, List<Attribute> path);
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java
index 8ed211e..1f6fb9c 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ILanguageExtension.java
@@ -169,13 +169,6 @@ public interface ILanguageExtension {
String destructorReturnType();
/**
- *
- * @param s string text
- * @return expression assignable to char array
- */
- String toCharArrayExpr(String s);
-
- /**
* @param baseClassName the name of the base class
* @param method the method to be called
* @param arguments the argument list
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/SendingDataTestJava.room b/tests/org.eclipse.etrice.generator.common.tests/models/SendingDataTestJava.room
index 3e885a4..d6592f6 100644
--- a/tests/org.eclipse.etrice.generator.common.tests/models/SendingDataTestJava.room
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/SendingDataTestJava.room
@@ -171,7 +171,7 @@ RoomModel SendingDataTestJava {
Attribute i32Val: int32 = "4711"
Attribute i64Val: int64 = "11470815"
Attribute i32Array [ 10 ]: int32="{0,1,2,3,4,5,6,7,8,9}"
- Attribute f32Val: float32="3.14f"
+ Attribute f32Val: float32="3.14"
Attribute f64Val: float64="7.987654321"
Attribute data: PingPongData
Attribute dataD: PingPongDataDerived