diff options
author | Henrik Rentz-Reichert | 2013-02-12 11:05:38 +0000 |
---|---|---|
committer | Henrik Rentz-Reichert | 2013-02-12 11:05:38 +0000 |
commit | 7e0321a7fb1a913b0770f24e12eaf91ea8033143 (patch) | |
tree | 6674462b85d55d5e6d41f49454cc00cd4a1cb758 /plugins/org.eclipse.etrice.generator.java | |
parent | 86f27ceded75d0cfff67e0049df95569cae66069 (diff) | |
download | org.eclipse.etrice-7e0321a7fb1a913b0770f24e12eaf91ea8033143.tar.gz org.eclipse.etrice-7e0321a7fb1a913b0770f24e12eaf91ea8033143.tar.xz org.eclipse.etrice-7e0321a7fb1a913b0770f24e12eaf91ea8033143.zip |
[core.room, generator.*] JavaDoc and some minor re-factorings
Diffstat (limited to 'plugins/org.eclipse.etrice.generator.java')
8 files changed, 43 insertions, 36 deletions
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend index 125ee0753..09ae2b916 100644 --- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend +++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend @@ -101,7 +101,7 @@ class ActorClassGen extends GenericActorClassGenerator { «ENDFOR»
//--------------------- interface item IDs
- «genInterfaceItemConstants(xpac, ac)»
+ «xpac.genInterfaceItemConstants»
«configGenAddon.genMinMaxConstants(ac)»
«ac.attributes.attributes»
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend index e81a2e3c2..a1d4b89a9 100644 --- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend +++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend @@ -26,6 +26,7 @@ import org.eclipse.etrice.generator.base.IDataConfiguration import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.etrice.generator.generic.TypeHelpers +import static extension org.eclipse.etrice.core.room.util.RoomHelpers.* class ConfigGenAddon { 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 75c5e0bf0..fdb7a4130 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 @@ -25,6 +25,7 @@ import org.eclipse.etrice.core.room.PrimitiveType import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.etrice.generator.generic.TypeHelpers
+import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
@Singleton
class Initialization {
@@ -84,13 +85,13 @@ class Initialization { }
def private attributeInit(List<Attribute> path, String value){
- var getter = if(path.size == 1) "this" else procedureHelpers.invokeGetters(path.take(path.size-1), null).toString
+ val getter = if(path.size == 1) "this" else procedureHelpers.invokeGetters(path.take(path.size-1), null).toString
return genAttributeInitializer(path.last, value, getter)
}
def genAttributeInitializer(Attribute a, String value, String invokes){
var aType = a.refType.type
- // be careful of: char array with single character ('x')
+ // special treatment of char array with single character ('x')
'''
«IF a.size == 0 || (a.size > 0 && "char".equals(aType.typeName) && !value.matches("'.'|\\(char\\).*"))»
«invokes».«procedureHelpers.invokeSetter(a.name, null, value)»;
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 2eaf4e8cf..c13b83d87 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 @@ -33,6 +33,7 @@ import org.eclipse.etrice.generator.generic.TypeHelpers import org.eclipse.xtext.generator.JavaIoFileSystemAccess import org.eclipse.etrice.core.room.ActorClass import java.util.Collection +import static extension org.eclipse.etrice.core.room.util.RoomHelpers.* @Singleton class VariableServiceGen { @@ -206,11 +207,13 @@ class VariableServiceGen { } def private genGetAttributeValues(List<Attribute> path, ActorInstance ai){ - var a = path.last - if(a.refType.type.primitive){''' - values.put("«ai.path»«path.toAbsolutePath('/')»", «IF a.size>0»toObjectArray(«ENDIF»«ai.varName».«path.invokeGetters(null)»«IF a.size>0»)«ENDIF»); - ''' - } else if(a.refType.type.dataClass){ + val a = path.last + if (a.refType.type.primitive) { + ''' + values.put("«ai.path»«path.toAbsolutePath('/')»", «IF a.size>0»toObjectArray(«ENDIF»«ai.varName».«path.invokeGetters(null)»«IF a.size>0»)«ENDIF»); + ''' + } + else if (a.refType.type.dataClass) { var dataClass = (a.refType.type as DataClass) ''' «FOR at : dataClass.allAttributes» @@ -248,16 +251,16 @@ class VariableServiceGen { def private genSetAttributeValues2(List<Attribute> path, ActorInstance ai){ var a = path.last var aVarName = path.toAbsolutePath("_") - if(a.refType.type.primitive){ - var getters = if(path.size>1)path.take(path.size-1).invokeGetters(null)+"." else "" - ''' - if(«aVarName» != null){ - «ai.varName».«getters»«invokeSetter(a.name, null, aVarName)»; - getDiffMap().put("«ai.path»«path.toAbsolutePath("/")»", «aVarName»); - } - ''' - } else if(a.refType.type.dataClass){ - var dataClass = (a.refType.type as DataClass) + if (a.refType.type.primitive) { + val getters = if(path.size>1)path.take(path.size-1).invokeGetters(null)+"." else "" + ''' + if(«aVarName» != null){ + «ai.varName».«getters»«invokeSetter(a.name, null, aVarName)»; + getDiffMap().put("«ai.path»«path.toAbsolutePath("/")»", «aVarName»); + } + ''' + } else if (a.refType.type.dataClass) { + val dataClass = (a.refType.type as DataClass) ''' «FOR at : dataClass.allAttributes» «genSetAttributeValues2(path.union(at), ai)» diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java index d7e01dcaa..57eff487b 100644 --- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java +++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java @@ -207,7 +207,7 @@ public class ActorClassGen extends GenericActorClassGenerator { _builder.append("//--------------------- ports");
_builder.newLine();
{
- List<Port> _endPorts = this._roomExtensions.getEndPorts(ac);
+ List<Port> _endPorts = RoomHelpers.getEndPorts(ac);
for(final Port ep : _endPorts) {
_builder.append("\t");
_builder.append("protected ");
@@ -264,7 +264,7 @@ public class ActorClassGen extends GenericActorClassGenerator { _builder.append("//--------------------- interface item IDs");
_builder.newLine();
_builder.append("\t");
- String _genInterfaceItemConstants = this.genInterfaceItemConstants(xpac, ac);
+ String _genInterfaceItemConstants = this.genInterfaceItemConstants(xpac);
_builder.append(_genInterfaceItemConstants, " ");
_builder.newLineIfNotEmpty();
_builder.newLine();
@@ -323,7 +323,7 @@ public class ActorClassGen extends GenericActorClassGenerator { _builder.append("// own ports");
_builder.newLine();
{
- List<Port> _endPorts_1 = this._roomExtensions.getEndPorts(ac);
+ List<Port> _endPorts_1 = RoomHelpers.getEndPorts(ac);
for(final Port ep_1 : _endPorts_1) {
_builder.append("\t\t");
String _name_10 = ep_1.getName();
@@ -513,7 +513,7 @@ public class ActorClassGen extends GenericActorClassGenerator { _builder.append("//--------------------- port getters");
_builder.newLine();
{
- List<Port> _endPorts_2 = this._roomExtensions.getEndPorts(ac);
+ List<Port> _endPorts_2 = RoomHelpers.getEndPorts(ac);
for(final Port ep_2 : _endPorts_2) {
_builder.append("\t");
String _portClassName_6 = this._roomExtensions.getPortClassName(ep_2);
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java index 6fce554f8..2218478e0 100644 --- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java +++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java @@ -51,7 +51,7 @@ public class ConfigGenAddon { StringConcatenation _builder = new StringConcatenation();
{
ActorClass _actorClass = ai.getActorClass();
- List<Attribute> _allAttributes = this._roomExtensions.getAllAttributes(_actorClass);
+ List<Attribute> _allAttributes = RoomHelpers.getAllAttributes(_actorClass);
for(final Attribute a : _allAttributes) {
ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
List<Attribute> _union = this._roomExtensions.<Attribute>union(_arrayList, a);
@@ -123,7 +123,7 @@ public class ConfigGenAddon { _matched=true;
StringConcatenation _builder = new StringConcatenation();
{
- List<Attribute> _allAttributes = this._roomExtensions.getAllAttributes(((DataClass) _dataClass));
+ List<Attribute> _allAttributes = RoomHelpers.getAllAttributes(((DataClass) _dataClass));
for(final Attribute e : _allAttributes) {
String _plus = (invokes + ".");
String _name = a.getName();
@@ -326,7 +326,7 @@ public class ConfigGenAddon { public CharSequence genMinMaxConstants(final ActorClass ac) {
StringConcatenation _builder = new StringConcatenation();
{
- List<Attribute> _allAttributes = this._roomExtensions.getAllAttributes(ac);
+ List<Attribute> _allAttributes = RoomHelpers.getAllAttributes(ac);
for(final Attribute a : _allAttributes) {
String _name = a.getName();
ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
@@ -362,7 +362,7 @@ public class ConfigGenAddon { _matched=true;
StringConcatenation _builder = new StringConcatenation();
{
- List<Attribute> _allAttributes = this._roomExtensions.getAllAttributes(((DataClass) _dataClass));
+ List<Attribute> _allAttributes = RoomHelpers.getAllAttributes(((DataClass) _dataClass));
for(final Attribute e : _allAttributes) {
String _plus = (varNamePath + "_");
String _name = e.getName();
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 1e5c9d2b0..a7c9bea30 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 @@ -13,6 +13,7 @@ import org.eclipse.etrice.core.room.DataType; import org.eclipse.etrice.core.room.PortClass;
import org.eclipse.etrice.core.room.PrimitiveType;
import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.etrice.generator.generic.TypeHelpers;
@@ -148,7 +149,7 @@ public class Initialization { if (_isDataClass) {
StringConcatenation _builder = new StringConcatenation();
{
- List<Attribute> _allAttributes = this._roomExtensions.getAllAttributes(((DataClass) aType));
+ List<Attribute> _allAttributes = RoomHelpers.getAllAttributes(((DataClass) aType));
for(final Attribute e : _allAttributes) {
List<Attribute> _union = this._roomExtensions.<Attribute>union(path, e);
CharSequence _attributeInitPrimitiveRec = this.attributeInitPrimitiveRec(_union, roomClass);
@@ -195,7 +196,7 @@ public class Initialization { String _string = _invokeGetters.toString();
_xifexpression = _string;
}
- String getter = _xifexpression;
+ final String getter = _xifexpression;
Attribute _last = IterableExtensions.<Attribute>last(path);
return this.genAttributeInitializer(_last, value, getter);
}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java index 95defa193..c78648f35 100644 --- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java +++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java @@ -24,6 +24,7 @@ import org.eclipse.etrice.core.room.DataType; import org.eclipse.etrice.core.room.RefableType;
import org.eclipse.etrice.core.room.RoomModel;
import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.generator.base.IDataConfiguration;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
@@ -399,7 +400,7 @@ public class VariableServiceGen { _builder.append(" object, Map<String, Object> map){");
_builder.newLineIfNotEmpty();
{
- List<Attribute> _allAttributes = this.roomExt.getAllAttributes(dc_1);
+ List<Attribute> _allAttributes = RoomHelpers.getAllAttributes(dc_1);
for(final Attribute a_2 : _allAttributes) {
{
RefableType _refType = a_2.getRefType();
@@ -592,7 +593,7 @@ public class VariableServiceGen { while (_while) {
{
DataClass dc = visit.pop();
- List<Attribute> _allAttributes = this.roomExt.getAllAttributes(dc);
+ List<Attribute> _allAttributes = RoomHelpers.getAllAttributes(dc);
final Procedure1<Attribute> _function = new Procedure1<Attribute>() {
public void apply(final Attribute a) {
RefableType _refType = a.getRefType();
@@ -663,7 +664,7 @@ public class VariableServiceGen { private CharSequence genGetAttributeValues(final List<Attribute> path, final ActorInstance ai) {
CharSequence _xblockexpression = null;
{
- Attribute a = IterableExtensions.<Attribute>last(path);
+ final Attribute a = IterableExtensions.<Attribute>last(path);
CharSequence _xifexpression = null;
RefableType _refType = a.getRefType();
DataType _type = _refType.getType();
@@ -711,7 +712,7 @@ public class VariableServiceGen { DataClass dataClass = ((DataClass) _type_2);
StringConcatenation _builder_1 = new StringConcatenation();
{
- List<Attribute> _allAttributes = this.roomExt.getAllAttributes(dataClass);
+ List<Attribute> _allAttributes = RoomHelpers.getAllAttributes(dataClass);
for(final Attribute at : _allAttributes) {
List<Attribute> _union = this.roomExt.<Attribute>union(path, at);
CharSequence _genGetAttributeValues = this.genGetAttributeValues(_union, ai);
@@ -861,7 +862,7 @@ public class VariableServiceGen { DataClass dataClass = ((DataClass) _type_7);
StringConcatenation _builder_1 = new StringConcatenation();
{
- List<Attribute> _allAttributes = this.roomExt.getAllAttributes(dataClass);
+ List<Attribute> _allAttributes = RoomHelpers.getAllAttributes(dataClass);
for(final Attribute at : _allAttributes) {
List<Attribute> _union = this.roomExt.<Attribute>union(path, at);
CharSequence _genSetAttributeValues1 = this.genSetAttributeValues1(_union, ai);
@@ -905,7 +906,7 @@ public class VariableServiceGen { } else {
_xifexpression_1 = "";
}
- String getters = _xifexpression_1;
+ final String getters = _xifexpression_1;
StringConcatenation _builder = new StringConcatenation();
_builder.append("if(");
_builder.append(aVarName, "");
@@ -946,10 +947,10 @@ public class VariableServiceGen { {
RefableType _refType_2 = a.getRefType();
DataType _type_2 = _refType_2.getType();
- DataClass dataClass = ((DataClass) _type_2);
+ final DataClass dataClass = ((DataClass) _type_2);
StringConcatenation _builder = new StringConcatenation();
{
- List<Attribute> _allAttributes = this.roomExt.getAllAttributes(dataClass);
+ List<Attribute> _allAttributes = RoomHelpers.getAllAttributes(dataClass);
for(final Attribute at : _allAttributes) {
List<Attribute> _union = this.roomExt.<Attribute>union(path, at);
CharSequence _genSetAttributeValues2 = this.genSetAttributeValues2(_union, ai);
|