summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2012-11-07 12:11:38 (EST)
committerJuergen Haug2012-11-07 12:11:38 (EST)
commit7badae06f1e2b21c3a5e0d1b812503655a0f8419 (patch)
tree6038b7a9228bd0de324ed187ff425b6f8052243b
parent1a88593291ca91aebc655ceebcbd3a053f4f41b6 (diff)
downloadorg.eclipse.etrice-7badae06f1e2b21c3a5e0d1b812503655a0f8419.zip
org.eclipse.etrice-7badae06f1e2b21c3a5e0d1b812503655a0f8419.tar.gz
org.eclipse.etrice-7badae06f1e2b21c3a5e0d1b812503655a0f8419.tar.bz2
[CQ 6485][config, generator] refactor dataConfiguration,refs/changes/72/8572/1
rewritten attribute init java Change-Id: I333fd9420c2f38f4c4d15ce9c4dc1bd18051d36e
-rw-r--r--plugins/org.eclipse.etrice.core.config/META-INF/MANIFEST.MF4
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend75
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java2
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java626
-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.java15
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend (renamed from plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfiguration.xtend)21
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/config/DataConfigurationHelper.java (renamed from plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfigurationHelper.java)3
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/config/DataConfiguration.java (renamed from plugins/org.eclipse.etrice.core.config/xtend-gen/org/eclipse/etrice/core/config/DataConfiguration.java)4
10 files changed, 421 insertions, 335 deletions
diff --git a/plugins/org.eclipse.etrice.core.config/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.core.config/META-INF/MANIFEST.MF
index fe79b8a..54d73ce 100644
--- a/plugins/org.eclipse.etrice.core.config/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.core.config/META-INF/MANIFEST.MF
@@ -19,11 +19,9 @@ Require-Bundle: org.eclipse.xtext;bundle-version="2.1.1";visibility:=reexport,
org.eclipse.emf.common,
org.antlr.runtime,
org.eclipse.xtext.common.types;bundle-version="2.1.1",
- org.eclipse.etrice.core.room;bundle-version="0.2.0",
- org.eclipse.etrice.core.genmodel;bundle-version="0.2.0"
+ org.eclipse.etrice.core.room;bundle-version="0.2.0"
Import-Package: org.apache.commons.logging,
org.apache.log4j,
- org.eclipse.etrice.generator.base,
org.eclipse.xtend.lib,
org.eclipse.xtext.xbase.lib
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
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 27524c4..17af443 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
@@ -26,9 +26,9 @@ import org.eclipse.etrice.core.room.PrimitiveType
import org.eclipse.etrice.core.room.ProtocolClass
import org.eclipse.etrice.generator.base.IDataConfiguration
import org.eclipse.etrice.generator.generic.ILanguageExtension
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.etrice.generator.generic.TypeHelpers
-import org.eclipse.etrice.generator.generic.ProcedureHelpers
@Singleton
class Initialization {
@@ -39,35 +39,40 @@ class Initialization {
@Inject IDataConfiguration dataConfigExt
@Inject ProcedureHelpers procedureHelpers
- def attributeInitialization(List<Attribute> attribs, EObject roomClass, boolean useClassDefaultsOnly) {
+ def attributeInitialization(List<Attribute> attribs, EObject roomClass, boolean useClassDefaultsOnly) {
+ var tmp = ''''''
'''
// initialize attributes
«FOR a : attribs»
- «attributeInit(roomClass, new ArrayList<Attribute>.union(a), useClassDefaultsOnly)»
+ «tmp = dataConfigurationInit(roomClass, new ArrayList<Attribute>.union(a))»
+ «IF tmp.length==0»«(tmp = valueInit(new ArrayList<Attribute>.union(a), getRoomDefaulValue(a)))»«ENDIF»
+ «IF tmp.length==0»«defaultInit(a, useClassDefaultsOnly)»«ENDIF»
«ENDFOR»
'''
}
- def private attributeInit(EObject roomClass, List<Attribute> path, boolean useClassDefaultsOnly) {
+ def private dataConfigurationInit(EObject roomClass, List<Attribute> path){
var a = path.last
var aType = a.refType.type
if(aType.dataClass){
- var result =
- '''
- «FOR e : (aType as DataClass).attributes»
- «attributeInit(roomClass, path.union(e), useClassDefaultsOnly)»
- «ENDFOR»
- '''
- if(result.length > 0)
- return result
+ return '''
+ «FOR e : (aType as DataClass).attributes»
+ «dataConfigurationInit(roomClass, path.union(e))»
+ «ENDFOR»
+ '''
}
-
- var value = getInitValueLiteral(roomClass, path)
+ else if(aType.primitive)
+ return valueInit(path, getDataConfigValue(roomClass, path))
+ ''''''
+ }
+
+ def private valueInit(List<Attribute> path, String value){
+ if(value == 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 ""
- return
'''
- «IF value!=null»
- «IF a.size == 0 || aType.characterType»
+ «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»''')»;
@@ -79,28 +84,36 @@ class Initialization {
}
«getter»«procedureHelpers.invokeSetter(a.name,null,"_"+a.name)»;
}
- «ENDIF»
- «ELSEIF path.size == 1 && (aType instanceof ComplexType || a.size>1 || !useClassDefaultsOnly)»
+ «ENDIF»
+ '''
+ }
+
+ def private defaultInit(Attribute a, boolean useClassDefaultsOnly){
+ '''
+ «IF a.refType.type instanceof ComplexType || a.size>1 || !useClassDefaultsOnly»
«IF a.size==0»
«IF a.refType.isRef»
«a.name» = «languageExt.nullPointer()»;
«ELSE»
- «a.name» = «languageExt.defaultValue(aType)»;
+ «a.name» = «languageExt.defaultValue(a.refType.type)»;
«ENDIF»
«ELSE»
- «a.name» = new «aType.typeName»[«a.size»];
+ «a.name» = new «a.refType.type.typeName»[«a.size»];
«IF !useClassDefaultsOnly»
for (int i=0;i<«a.size»;i++){
- «a.name»[i] = «IF a.refType.isRef»«languageExt.nullPointer()»«ELSE»«languageExt.defaultValue(aType)»«ENDIF»;
+ «a.name»[i] = «IF a.refType.isRef»«languageExt.nullPointer()»«ELSE»«languageExt.defaultValue(a.refType.type)»«ENDIF»;
}
«ENDIF»
«ENDIF»
«ENDIF»
'''
-
}
- def private getInitValueLiteral(EObject roomClass, List<Attribute> path){
+ def private getRoomDefaulValue(Attribute a){
+ a.defaultValueLiteral
+ }
+
+ def private String getDataConfigValue(EObject roomClass, List<Attribute> path){
var a = path.last
if(a.refType.type.primitive){
var aType = a.refType.type as PrimitiveType
@@ -112,14 +125,12 @@ class Initialization {
dataConfigExt.getAttrClassConfigValue(pc, pc.regular.equals(roomClass), path)
}
}
- if(result != null)
- return if(a.size == 0 || aType.characterType)
- languageExt.toValueLiteral(aType, result)
- else
- // array syntax ?
- '''{ «FOR s : result.split(",") SEPARATOR ' ,'»«languageExt.toValueLiteral(aType, s.trim)»«ENDFOR» }'''.toString
+ 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(path.size == 1)
- a.defaultValueLiteral
}
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend
index 70a69b5..ae8283f 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * Copyright (c) 2012 Juergen Haug
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java
index 59d479e..0f4b912 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java
@@ -41,7 +41,7 @@ public class GeneratorModule extends GeneratorBaseModule {
binder.bind(ITranslationProvider.class).to(JavaTranslationProvider.class);
- binder.bind(IDataConfiguration.class).to(org.eclipse.etrice.core.config.DataConfiguration.class);
+ binder.bind(IDataConfiguration.class).to(org.eclipse.etrice.generator.config.DataConfiguration.class);
}
}
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 23921e1..2c0b54b 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
@@ -43,332 +43,378 @@ public class Initialization {
private ProcedureHelpers procedureHelpers;
public CharSequence attributeInitialization(final List<Attribute> attribs, final EObject roomClass, final boolean useClassDefaultsOnly) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("// initialize attributes");
- _builder.newLine();
+ CharSequence _xblockexpression = null;
{
- for(final Attribute a : attribs) {
- ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
- List<Attribute> _union = this._roomExtensions.<Attribute>union(_arrayList, a);
- CharSequence _attributeInit = this.attributeInit(roomClass, _union, useClassDefaultsOnly);
- _builder.append(_attributeInit, "");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-
- private CharSequence attributeInit(final EObject roomClass, final List<Attribute> path, final boolean useClassDefaultsOnly) {
- Attribute a = IterableExtensions.<Attribute>last(path);
- RefableType _refType = a.getRefType();
- DataType aType = _refType.getType();
- boolean _isDataClass = this._typeHelpers.isDataClass(aType);
- if (_isDataClass) {
StringConcatenation _builder = new StringConcatenation();
+ CharSequence tmp = _builder;
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("// initialize attributes");
+ _builder_1.newLine();
{
- EList<Attribute> _attributes = ((DataClass) aType).getAttributes();
- for(final Attribute e : _attributes) {
- List<Attribute> _union = this._roomExtensions.<Attribute>union(path, e);
- CharSequence _attributeInit = this.attributeInit(roomClass, _union, useClassDefaultsOnly);
- _builder.append(_attributeInit, "");
- _builder.newLineIfNotEmpty();
+ for(final Attribute a : attribs) {
+ ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
+ List<Attribute> _union = this._roomExtensions.<Attribute>union(_arrayList, a);
+ CharSequence _dataConfigurationInit = this.dataConfigurationInit(roomClass, _union);
+ CharSequence _tmp = tmp = _dataConfigurationInit;
+ _builder_1.append(_tmp, "");
+ _builder_1.newLineIfNotEmpty();
+ {
+ int _length = tmp.length();
+ boolean _equals = (_length == 0);
+ if (_equals) {
+ ArrayList<Attribute> _arrayList_1 = new ArrayList<Attribute>();
+ List<Attribute> _union_1 = this._roomExtensions.<Attribute>union(_arrayList_1, a);
+ String _roomDefaulValue = this.getRoomDefaulValue(a);
+ CharSequence _valueInit = this.valueInit(_union_1, _roomDefaulValue);
+ CharSequence _tmp_1 = tmp = _valueInit;
+ _builder_1.append(_tmp_1, "");
+ }
+ }
+ _builder_1.newLineIfNotEmpty();
+ {
+ int _length_1 = tmp.length();
+ boolean _equals_1 = (_length_1 == 0);
+ if (_equals_1) {
+ CharSequence _defaultInit = this.defaultInit(a, useClassDefaultsOnly);
+ _builder_1.append(_defaultInit, "");
+ }
+ }
+ _builder_1.newLineIfNotEmpty();
}
}
- CharSequence result = _builder;
- int _length = result.length();
- boolean _greaterThan = (_length > 0);
- if (_greaterThan) {
- return result;
- }
+ _xblockexpression = (_builder_1);
}
- String value = this.getInitValueLiteral(roomClass, path);
- String _xifexpression = null;
- int _size = path.size();
- boolean _greaterThan_1 = (_size > 1);
- if (_greaterThan_1) {
- int _size_1 = path.size();
- int _minus = (_size_1 - 1);
- Iterable<Attribute> _take = IterableExtensions.<Attribute>take(path, _minus);
- CharSequence _invokeGetters = this.procedureHelpers.invokeGetters(_take, null);
- String _plus = (_invokeGetters + ".");
- _xifexpression = _plus;
- } else {
- _xifexpression = "";
- }
- String getter = _xifexpression;
- StringConcatenation _builder_1 = new StringConcatenation();
+ return _xblockexpression;
+ }
+
+ private CharSequence dataConfigurationInit(final EObject roomClass, final List<Attribute> path) {
+ CharSequence _xblockexpression = null;
{
- boolean _notEquals = (!Objects.equal(value, null));
- if (_notEquals) {
+ Attribute a = IterableExtensions.<Attribute>last(path);
+ RefableType _refType = a.getRefType();
+ DataType aType = _refType.getType();
+ boolean _isDataClass = this._typeHelpers.isDataClass(aType);
+ if (_isDataClass) {
+ StringConcatenation _builder = new StringConcatenation();
{
- boolean _or = false;
- int _size_2 = a.getSize();
- boolean _equals = (_size_2 == 0);
- if (_equals) {
- _or = true;
- } else {
- boolean _isCharacterType = this._typeHelpers.isCharacterType(aType);
- _or = (_equals || _isCharacterType);
+ EList<Attribute> _attributes = ((DataClass) aType).getAttributes();
+ for(final Attribute e : _attributes) {
+ List<Attribute> _union = this._roomExtensions.<Attribute>union(path, e);
+ CharSequence _dataConfigurationInit = this.dataConfigurationInit(roomClass, _union);
+ _builder.append(_dataConfigurationInit, "");
+ _builder.newLineIfNotEmpty();
}
- if (_or) {
+ }
+ return _builder;
+ } else {
+ boolean _isPrimitive = this._typeHelpers.isPrimitive(aType);
+ if (_isPrimitive) {
+ String _dataConfigValue = this.getDataConfigValue(roomClass, path);
+ return this.valueInit(path, _dataConfigValue);
+ }
+ }
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _xblockexpression = (_builder_1);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence valueInit(final List<Attribute> path, final String value) {
+ CharSequence _xblockexpression = null;
+ {
+ boolean _equals = Objects.equal(value, null);
+ if (_equals) {
+ StringConcatenation _builder = new StringConcatenation();
+ return _builder;
+ }
+ Attribute a = IterableExtensions.<Attribute>last(path);
+ RefableType _refType = a.getRefType();
+ DataType aType = _refType.getType();
+ String _xifexpression = null;
+ int _size = path.size();
+ boolean _greaterThan = (_size > 1);
+ if (_greaterThan) {
+ int _size_1 = path.size();
+ int _minus = (_size_1 - 1);
+ Iterable<Attribute> _take = IterableExtensions.<Attribute>take(path, _minus);
+ CharSequence _invokeGetters = this.procedureHelpers.invokeGetters(_take, null);
+ String _plus = (_invokeGetters + ".");
+ _xifexpression = _plus;
+ } else {
+ _xifexpression = "";
+ }
+ String getter = _xifexpression;
+ StringConcatenation _builder_1 = new StringConcatenation();
+ {
+ boolean _or = false;
+ int _size_2 = a.getSize();
+ boolean _equals_1 = (_size_2 == 0);
+ if (_equals_1) {
+ _or = true;
+ } else {
+ boolean _isCharacterType = this._typeHelpers.isCharacterType(aType);
+ _or = (_equals_1 || _isCharacterType);
+ }
+ if (_or) {
+ _builder_1.append(getter, "");
+ String _name = a.getName();
+ CharSequence _invokeSetter = this.procedureHelpers.invokeSetter(_name, null, value);
+ _builder_1.append(_invokeSetter, "");
+ _builder_1.append(";");
+ _builder_1.newLineIfNotEmpty();
+ } else {
+ boolean _startsWith = value.startsWith("{");
+ if (_startsWith) {
_builder_1.append(getter, "");
- String _name = a.getName();
- CharSequence _invokeSetter = this.procedureHelpers.invokeSetter(_name, null, value);
- _builder_1.append(_invokeSetter, "");
+ String _name_1 = a.getName();
+ StringConcatenation _builder_2 = new StringConcatenation();
+ _builder_2.append("new ");
+ String _typeName = this._typeHelpers.typeName(aType);
+ _builder_2.append(_typeName, "");
+ _builder_2.append("[] ");
+ _builder_2.append(value, "");
+ CharSequence _invokeSetter_1 = this.procedureHelpers.invokeSetter(_name_1, null, _builder_2.toString());
+ _builder_1.append(_invokeSetter_1, "");
_builder_1.append(";");
_builder_1.newLineIfNotEmpty();
} else {
- boolean _startsWith = value.startsWith("{");
- if (_startsWith) {
- _builder_1.append(getter, "");
- String _name_1 = a.getName();
- StringConcatenation _builder_2 = new StringConcatenation();
- _builder_2.append("new ");
- String _typeName = this._typeHelpers.typeName(aType);
- _builder_2.append(_typeName, "");
- _builder_2.append("[] ");
- _builder_2.append(value, "");
- CharSequence _invokeSetter_1 = this.procedureHelpers.invokeSetter(_name_1, null, _builder_2.toString());
- _builder_1.append(_invokeSetter_1, "");
- _builder_1.append(";");
- _builder_1.newLineIfNotEmpty();
- } else {
- _builder_1.append("{");
- _builder_1.newLine();
- _builder_1.append("\t");
- String _typeName_1 = this._typeHelpers.typeName(aType);
- _builder_1.append(_typeName_1, " ");
- _builder_1.append("[] _");
- String _name_2 = a.getName();
- _builder_1.append(_name_2, " ");
- _builder_1.append(" = new ");
- String _typeName_2 = this._typeHelpers.typeName(aType);
- _builder_1.append(_typeName_2, " ");
- _builder_1.append("[");
- int _size_3 = a.getSize();
- _builder_1.append(_size_3, " ");
- _builder_1.append("];");
- _builder_1.newLineIfNotEmpty();
- _builder_1.append("\t");
- _builder_1.append("for (int i=0;i<");
- int _size_4 = a.getSize();
- _builder_1.append(_size_4, " ");
- _builder_1.append(";i++){");
- _builder_1.newLineIfNotEmpty();
- _builder_1.append("\t\t");
- _builder_1.append("_");
- String _name_3 = a.getName();
- _builder_1.append(_name_3, " ");
- _builder_1.append("[i] = ");
- _builder_1.append(value, " ");
- _builder_1.append(";");
- _builder_1.newLineIfNotEmpty();
- _builder_1.append("\t");
- _builder_1.append("}");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append(getter, " ");
- String _name_4 = a.getName();
- String _name_5 = a.getName();
- String _plus_1 = ("_" + _name_5);
- CharSequence _invokeSetter_2 = this.procedureHelpers.invokeSetter(_name_4, null, _plus_1);
- _builder_1.append(_invokeSetter_2, " ");
- _builder_1.append(";");
- _builder_1.newLineIfNotEmpty();
- _builder_1.append("}");
- _builder_1.newLine();
- }
+ _builder_1.append("{");
+ _builder_1.newLine();
+ _builder_1.append("\t");
+ String _typeName_1 = this._typeHelpers.typeName(aType);
+ _builder_1.append(_typeName_1, " ");
+ _builder_1.append("[] _");
+ String _name_2 = a.getName();
+ _builder_1.append(_name_2, " ");
+ _builder_1.append(" = new ");
+ String _typeName_2 = this._typeHelpers.typeName(aType);
+ _builder_1.append(_typeName_2, " ");
+ _builder_1.append("[");
+ int _size_3 = a.getSize();
+ _builder_1.append(_size_3, " ");
+ _builder_1.append("];");
+ _builder_1.newLineIfNotEmpty();
+ _builder_1.append("\t");
+ _builder_1.append("for (int i=0;i<");
+ int _size_4 = a.getSize();
+ _builder_1.append(_size_4, " ");
+ _builder_1.append(";i++){");
+ _builder_1.newLineIfNotEmpty();
+ _builder_1.append("\t\t");
+ _builder_1.append("_");
+ String _name_3 = a.getName();
+ _builder_1.append(_name_3, " ");
+ _builder_1.append("[i] = ");
+ _builder_1.append(value, " ");
+ _builder_1.append(";");
+ _builder_1.newLineIfNotEmpty();
+ _builder_1.append("\t");
+ _builder_1.append("}");
+ _builder_1.newLine();
+ _builder_1.append("\t");
+ _builder_1.append(getter, " ");
+ String _name_4 = a.getName();
+ String _name_5 = a.getName();
+ String _plus_1 = ("_" + _name_5);
+ CharSequence _invokeSetter_2 = this.procedureHelpers.invokeSetter(_name_4, null, _plus_1);
+ _builder_1.append(_invokeSetter_2, " ");
+ _builder_1.append(";");
+ _builder_1.newLineIfNotEmpty();
+ _builder_1.append("}");
+ _builder_1.newLine();
}
}
+ }
+ _xblockexpression = (_builder_1);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence defaultInit(final Attribute a, final boolean useClassDefaultsOnly) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _or = false;
+ boolean _or_1 = false;
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ if ((_type instanceof ComplexType)) {
+ _or_1 = true;
} else {
- boolean _and = false;
- int _size_5 = path.size();
- boolean _equals_1 = (_size_5 == 1);
- if (!_equals_1) {
- _and = false;
- } else {
- boolean _or_1 = false;
- boolean _or_2 = false;
- if ((aType instanceof ComplexType)) {
- _or_2 = true;
- } else {
- int _size_6 = a.getSize();
- boolean _greaterThan_2 = (_size_6 > 1);
- _or_2 = ((aType instanceof ComplexType) || _greaterThan_2);
- }
- if (_or_2) {
- _or_1 = true;
- } else {
- boolean _not = (!useClassDefaultsOnly);
- _or_1 = (_or_2 || _not);
- }
- _and = (_equals_1 && _or_1);
- }
- if (_and) {
- {
- int _size_7 = a.getSize();
- boolean _equals_2 = (_size_7 == 0);
- if (_equals_2) {
- {
- RefableType _refType_1 = a.getRefType();
- boolean _isRef = _refType_1.isRef();
- if (_isRef) {
- String _name_6 = a.getName();
- _builder_1.append(_name_6, "");
- _builder_1.append(" = ");
- String _nullPointer = this.languageExt.nullPointer();
- _builder_1.append(_nullPointer, "");
- _builder_1.append(";");
- _builder_1.newLineIfNotEmpty();
- } else {
- String _name_7 = a.getName();
- _builder_1.append(_name_7, "");
- _builder_1.append(" = ");
- String _defaultValue = this.languageExt.defaultValue(aType);
- _builder_1.append(_defaultValue, "");
- _builder_1.append(";");
- _builder_1.newLineIfNotEmpty();
- }
+ int _size = a.getSize();
+ boolean _greaterThan = (_size > 1);
+ _or_1 = ((_type instanceof ComplexType) || _greaterThan);
+ }
+ if (_or_1) {
+ _or = true;
+ } else {
+ boolean _not = (!useClassDefaultsOnly);
+ _or = (_or_1 || _not);
+ }
+ if (_or) {
+ {
+ int _size_1 = a.getSize();
+ boolean _equals = (_size_1 == 0);
+ if (_equals) {
+ {
+ RefableType _refType_1 = a.getRefType();
+ boolean _isRef = _refType_1.isRef();
+ if (_isRef) {
+ String _name = a.getName();
+ _builder.append(_name, "");
+ _builder.append(" = ");
+ String _nullPointer = this.languageExt.nullPointer();
+ _builder.append(_nullPointer, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ } else {
+ String _name_1 = a.getName();
+ _builder.append(_name_1, "");
+ _builder.append(" = ");
+ RefableType _refType_2 = a.getRefType();
+ DataType _type_1 = _refType_2.getType();
+ String _defaultValue = this.languageExt.defaultValue(_type_1);
+ _builder.append(_defaultValue, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
}
- } else {
- String _name_8 = a.getName();
- _builder_1.append(_name_8, "");
- _builder_1.append(" = new ");
- String _typeName_3 = this._typeHelpers.typeName(aType);
- _builder_1.append(_typeName_3, "");
- _builder_1.append("[");
- int _size_8 = a.getSize();
- _builder_1.append(_size_8, "");
- _builder_1.append("];");
- _builder_1.newLineIfNotEmpty();
- {
- boolean _not_1 = (!useClassDefaultsOnly);
- if (_not_1) {
- _builder_1.append("for (int i=0;i<");
- int _size_9 = a.getSize();
- _builder_1.append(_size_9, "");
- _builder_1.append(";i++){");
- _builder_1.newLineIfNotEmpty();
- _builder_1.append("\t");
- String _name_9 = a.getName();
- _builder_1.append(_name_9, " ");
- _builder_1.append("[i] = ");
- {
- RefableType _refType_2 = a.getRefType();
- boolean _isRef_1 = _refType_2.isRef();
- if (_isRef_1) {
- String _nullPointer_1 = this.languageExt.nullPointer();
- _builder_1.append(_nullPointer_1, " ");
- } else {
- String _defaultValue_1 = this.languageExt.defaultValue(aType);
- _builder_1.append(_defaultValue_1, " ");
- }
+ }
+ } else {
+ String _name_2 = a.getName();
+ _builder.append(_name_2, "");
+ _builder.append(" = new ");
+ RefableType _refType_3 = a.getRefType();
+ DataType _type_2 = _refType_3.getType();
+ String _typeName = this._typeHelpers.typeName(_type_2);
+ _builder.append(_typeName, "");
+ _builder.append("[");
+ int _size_2 = a.getSize();
+ _builder.append(_size_2, "");
+ _builder.append("];");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _not_1 = (!useClassDefaultsOnly);
+ if (_not_1) {
+ _builder.append("for (int i=0;i<");
+ int _size_3 = a.getSize();
+ _builder.append(_size_3, "");
+ _builder.append(";i++){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_3 = a.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("[i] = ");
+ {
+ RefableType _refType_4 = a.getRefType();
+ boolean _isRef_1 = _refType_4.isRef();
+ if (_isRef_1) {
+ String _nullPointer_1 = this.languageExt.nullPointer();
+ _builder.append(_nullPointer_1, " ");
+ } else {
+ RefableType _refType_5 = a.getRefType();
+ DataType _type_3 = _refType_5.getType();
+ String _defaultValue_1 = this.languageExt.defaultValue(_type_3);
+ _builder.append(_defaultValue_1, " ");
}
- _builder_1.append(";");
- _builder_1.newLineIfNotEmpty();
- _builder_1.append("}");
- _builder_1.newLine();
}
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
}
}
}
}
}
}
- return _builder_1;
+ return _builder;
}
- private String getInitValueLiteral(final EObject roomClass, final List<Attribute> path) {
- String _xblockexpression = null;
- {
- Attribute a = IterableExtensions.<Attribute>last(path);
- RefableType _refType = a.getRefType();
- DataType _type = _refType.getType();
- boolean _isPrimitive = this._typeHelpers.isPrimitive(_type);
- if (_isPrimitive) {
- RefableType _refType_1 = a.getRefType();
- DataType _type_1 = _refType_1.getType();
- PrimitiveType aType = ((PrimitiveType) _type_1);
- String _switchResult = null;
- boolean _matched = false;
- if (!_matched) {
- if (roomClass instanceof ActorClass) {
- final ActorClass _actorClass = (ActorClass)roomClass;
- _matched=true;
- String _attrClassConfigValue = this.dataConfigExt.getAttrClassConfigValue(_actorClass, path);
- _switchResult = _attrClassConfigValue;
- }
+ private String getRoomDefaulValue(final Attribute a) {
+ String _defaultValueLiteral = a.getDefaultValueLiteral();
+ return _defaultValueLiteral;
+ }
+
+ private String getDataConfigValue(final EObject roomClass, final List<Attribute> path) {
+ Attribute a = IterableExtensions.<Attribute>last(path);
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isPrimitive = this._typeHelpers.isPrimitive(_type);
+ if (_isPrimitive) {
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ PrimitiveType aType = ((PrimitiveType) _type_1);
+ String _switchResult = null;
+ boolean _matched = false;
+ if (!_matched) {
+ if (roomClass instanceof ActorClass) {
+ final ActorClass _actorClass = (ActorClass)roomClass;
+ _matched=true;
+ String _attrClassConfigValue = this.dataConfigExt.getAttrClassConfigValue(_actorClass, path);
+ _switchResult = _attrClassConfigValue;
}
- if (!_matched) {
- if (roomClass instanceof PortClass) {
- final PortClass _portClass = (PortClass)roomClass;
- _matched=true;
- String _xifexpression = null;
- EObject _eContainer = _portClass.eContainer();
- if ((_eContainer instanceof ProtocolClass)) {
- String _xblockexpression_1 = null;
- {
- EObject _eContainer_1 = _portClass.eContainer();
- ProtocolClass pc = ((ProtocolClass) _eContainer_1);
- PortClass _regular = pc.getRegular();
- boolean _equals = _regular.equals(_portClass);
- String _attrClassConfigValue = this.dataConfigExt.getAttrClassConfigValue(pc, _equals, path);
- _xblockexpression_1 = (_attrClassConfigValue);
- }
- _xifexpression = _xblockexpression_1;
+ }
+ if (!_matched) {
+ if (roomClass instanceof PortClass) {
+ final PortClass _portClass = (PortClass)roomClass;
+ _matched=true;
+ String _xifexpression = null;
+ EObject _eContainer = _portClass.eContainer();
+ if ((_eContainer instanceof ProtocolClass)) {
+ String _xblockexpression = null;
+ {
+ EObject _eContainer_1 = _portClass.eContainer();
+ ProtocolClass pc = ((ProtocolClass) _eContainer_1);
+ PortClass _regular = pc.getRegular();
+ boolean _equals = _regular.equals(_portClass);
+ String _attrClassConfigValue = this.dataConfigExt.getAttrClassConfigValue(pc, _equals, path);
+ _xblockexpression = (_attrClassConfigValue);
}
- _switchResult = _xifexpression;
+ _xifexpression = _xblockexpression;
}
+ _switchResult = _xifexpression;
}
- String result = _switchResult;
- boolean _notEquals = (!Objects.equal(result, null));
- if (_notEquals) {
- String _xifexpression = null;
- boolean _or = false;
- int _size = a.getSize();
- boolean _equals = (_size == 0);
- if (_equals) {
- _or = true;
- } else {
- boolean _isCharacterType = this._typeHelpers.isCharacterType(aType);
- _or = (_equals || _isCharacterType);
- }
- if (_or) {
- String _valueLiteral = this.languageExt.toValueLiteral(aType, result);
- _xifexpression = _valueLiteral;
- } else {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("{ ");
- {
- String[] _split = result.split(",");
- boolean _hasElements = false;
- for(final String s : _split) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(" ,", "");
- }
- String _trim = s.trim();
- String _valueLiteral_1 = this.languageExt.toValueLiteral(aType, _trim);
- _builder.append(_valueLiteral_1, "");
+ }
+ 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(" }");
- String _string = _builder.toString();
- _xifexpression = _string;
}
- return _xifexpression;
+ _builder.append("}");
+ _xifexpression_1 = _builder.toString();
+ } else {
+ String _valueLiteral_1 = this.languageExt.toValueLiteral(aType, result);
+ _xifexpression_1 = _valueLiteral_1;
}
+ _xifexpression = _xifexpression_1;
}
- String _xifexpression_1 = null;
- int _size_1 = path.size();
- boolean _equals_1 = (_size_1 == 1);
- if (_equals_1) {
- String _defaultValueLiteral = a.getDefaultValueLiteral();
- _xifexpression_1 = _defaultValueLiteral;
- }
- _xblockexpression = (_xifexpression_1);
+ return _xifexpression;
}
- return _xblockexpression;
+ return null;
}
}
diff --git a/plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF
index f2beb78..6c466ed 100644
--- a/plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF
@@ -7,6 +7,7 @@ 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",
@@ -16,6 +17,7 @@ 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.xtend.lib;bundle-version="2.3.0",
+ org.eclipse.etrice.core.config;bundle-version="0.2.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 2f7d5b7..50756cb 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
@@ -1,3 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Juergen Haug
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug
+ *
+ *******************************************************************************/
+
package org.eclipse.etrice.generator.base;
import java.util.List;
@@ -10,11 +22,8 @@ import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.SubSystemClass;
public interface IDataConfiguration {
-
- public static boolean LANGUAGE_SPECIFIC_VALUES = false;
public void doSetup();
-
public boolean setResources(ResourceSet resource, ILogger logger);
// static configuration
diff --git a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfiguration.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend
index fe0d33f..133c1e7 100644
--- a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfiguration.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend
@@ -1,4 +1,16 @@
-package org.eclipse.etrice.core.config
+/*******************************************************************************
+ * Copyright (c) 2012 Juergen Haug
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.config
import java.util.ArrayList
import java.util.List
@@ -11,6 +23,13 @@ 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.core.config.BooleanLiteral
+import org.eclipse.etrice.core.config.IntLiteral
+import org.eclipse.etrice.core.config.RealLiteral
+import org.eclipse.etrice.core.config.StringLiteral
+import org.eclipse.etrice.core.config.LiteralArray
+import org.eclipse.etrice.core.config.Literal
class DataConfiguration implements IDataConfiguration {
diff --git a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfigurationHelper.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/config/DataConfigurationHelper.java
index 7dd9106..a64c658 100644
--- a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfigurationHelper.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/config/DataConfigurationHelper.java
@@ -9,7 +9,7 @@
* Juergen Haug
*
*******************************************************************************/
-package org.eclipse.etrice.core.config;
+package org.eclipse.etrice.generator.config;
import java.util.ArrayList;
import java.util.HashMap;
@@ -23,6 +23,7 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.etrice.core.config.ActorClassConfig;
import org.eclipse.etrice.core.config.ActorInstanceConfig;
+import org.eclipse.etrice.core.config.AttrClassConfig;
import org.eclipse.etrice.core.config.AttrInstanceConfig;
import org.eclipse.etrice.core.config.ConfigModel;
import org.eclipse.etrice.core.config.ProtocolClassConfig;
diff --git a/plugins/org.eclipse.etrice.core.config/xtend-gen/org/eclipse/etrice/core/config/DataConfiguration.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/config/DataConfiguration.java
index d56189b..cc83255 100644
--- a/plugins/org.eclipse.etrice.core.config/xtend-gen/org/eclipse/etrice/core/config/DataConfiguration.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/config/DataConfiguration.java
@@ -1,4 +1,4 @@
-package org.eclipse.etrice.core.config;
+package org.eclipse.etrice.generator.config;
import com.google.common.base.Objects;
import java.util.ArrayList;
@@ -9,7 +9,6 @@ import org.eclipse.etrice.core.ConfigStandaloneSetup;
import org.eclipse.etrice.core.config.AttrClassConfig;
import org.eclipse.etrice.core.config.AttrInstanceConfig;
import org.eclipse.etrice.core.config.BooleanLiteral;
-import org.eclipse.etrice.core.config.DataConfigurationHelper;
import org.eclipse.etrice.core.config.DynamicConfig;
import org.eclipse.etrice.core.config.IntLiteral;
import org.eclipse.etrice.core.config.Literal;
@@ -25,6 +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.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;