diff options
author | Thomas Schuetz | 2011-12-28 10:02:20 +0000 |
---|---|---|
committer | Thomas Schuetz | 2011-12-28 10:02:20 +0000 |
commit | 6883e25c985d76bc574169cad7a206a9b466edb0 (patch) | |
tree | ae5a411df4acf4e934160636a94efc79d6887835 | |
parent | f4b8522e373ce1cd9552516612446b6d44c82728 (diff) | |
download | org.eclipse.etrice-6883e25c985d76bc574169cad7a206a9b466edb0.tar.gz org.eclipse.etrice-6883e25c985d76bc574169cad7a206a9b466edb0.tar.xz org.eclipse.etrice-6883e25c985d76bc574169cad7a206a9b466edb0.zip |
[generator.c] structure for C-Gen for ActorClass
18 files changed, 225 insertions, 317 deletions
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend index c5e7c9e6c..5064a4c41 100644 --- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend +++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend @@ -7,6 +7,7 @@ * * CONTRIBUTORS: * Henrik Rentz-Reichert (initial contribution) + * Thomas Schuetz (changed for C code generator) * *******************************************************************************/ @@ -39,14 +40,25 @@ class ActorClassGen { def doGenerate(Root root) { for (xpac: root.xpActorClasses) { var path = xpac.actorClass.generationTargetPath+xpac.actorClass.getPath - var file = xpac.actorClass.getCHeaderFileName - logger.logInfo("generating ActorClass implementation '"+file+"' in '"+path+"'") + + // header file + logger.logInfo("generating ActorClass header '"+xpac.actorClass.getCHeaderFileName+"' in '"+path+"'") + fileAccess.setOutputPath(path) + fileAccess.generateFile(xpac.actorClass.getCHeaderFileName, root.generateHeaderFile(xpac, xpac.actorClass)) + + // header file + logger.logInfo("generating ActorClass header '"+xpac.actorClass.getCSourceFileName +"' in '"+path+"'") fileAccess.setOutputPath(path) - fileAccess.generateFile(file, root.generate(xpac, xpac.actorClass)) + fileAccess.generateFile(xpac.actorClass.getCSourceFileName , root.generateSourceFile(xpac, xpac.actorClass)) } } - def generate(Root root, ExpandedActorClass xpac, ActorClass ac) {''' + def generateHeaderFile(Root root, ExpandedActorClass xpac, ActorClass ac) {''' + #ifndef _«xpac.name»_H_ + #define _«xpac.name»_H_ + + #include "datatypes.h" + package «ac.getPackage»; import org.eclipse.etrice.runtime.java.messaging.Address; @@ -57,10 +69,14 @@ class ActorClassGen { import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase; import org.eclipse.etrice.runtime.java.debugging.DebuggingService; + + «FOR dataClass : root.getReferencedDataClasses(ac)»«IF dataClass.name != ac.name»#include "«dataClass.name».h"«ENDIF» + «ENDFOR» + «FOR model : root.getReferencedModels(ac)»import «model.name».*; «ENDFOR» - «FOR pc : root.getReferencedProtocols(ac)»import «pc.^package».«pc.name».*; + «FOR pc : root.getReferencedProtocolClasses(ac)»import «pc.^package».«pc.name».*; «ENDFOR» «helpers.UserCode(ac.userCode1)» @@ -163,6 +179,15 @@ class ActorClassGen { } «ENDIF» }; + + #endif /* _«xpac.name»_H_ */ + + ''' + } + + def generateSourceFile(Root root, ExpandedActorClass xpac, ActorClass ac) {''' + #include "«xpac.getCHeaderFileName»" + ''' } diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend index d7a9cca7d..9014cba52 100644 --- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend +++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend @@ -37,16 +37,14 @@ class DataClassGen { var path = dc.generationTargetPath+dc.getPath // header file - var headerFile = dc.getCHeaderFileName - logger.logInfo("generating DataClass header '"+headerFile+"' in '"+path+"'") + logger.logInfo("generating DataClass header '"+dc.getCHeaderFileName+"' in '"+path+"'") fileAccess.setOutputPath(path) - fileAccess.generateFile(headerFile, root.generateHeaderFile(dc)) + fileAccess.generateFile(dc.getCHeaderFileName, root.generateHeaderFile(dc)) - // header file - var sourceFile = dc.getCSourceFileName - logger.logInfo("generating DataClass source '"+headerFile+"' in '"+path+"'") + // source file + logger.logInfo("generating DataClass source '"+dc.getCSourceFileName+"' in '"+path+"'") fileAccess.setOutputPath(path) - fileAccess.generateFile(sourceFile, root.generateSourceFile(dc)) + fileAccess.generateFile(dc.getCSourceFileName, root.generateSourceFile(dc)) } } @@ -55,7 +53,7 @@ class DataClassGen { #ifndef _«dc.name»_H_ #define _«dc.name»_H_ - #include "../../src/datatypes.h" + #include "datatypes.h" /* TODO: includes only for used DataClasses, also for other models */ «FOR dataClass : root.getReferencedDataClasses(dc)»«IF dataClass.name != dc.name»#include "«dataClass.name».h"«ENDIF» @@ -64,11 +62,8 @@ class DataClassGen { «helpers.UserCode(dc.userCode1)» typedef struct { - «helpers.UserCode(dc.userCode2)» - «helpers.Attributes(dc.attributes)» - } «dc.name»«IF dc.base!=null» /* extends -> inheritance not implemented yet */ «dc.base.name»«ENDIF»; // TODO: do we need setters and getters for C and C++ ? diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/MainGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/MainGen.xtend index 6dae1889d..b13f8fa2b 100644 --- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/MainGen.xtend +++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/MainGen.xtend @@ -42,7 +42,7 @@ class MainGen implements IGenerator { def void doGenerate(Root e) { dataClassGen.doGenerate(e); //protocolClassGen.doGenerate(e); - //actorClassGen.doGenerate(e); + actorClassGen.doGenerate(e); //subsystemClassGen.doGenerate(e); if (!e.library) { diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java index 0e43bb098..110a11ffc 100644 --- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java +++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java @@ -2,6 +2,7 @@ package org.eclipse.etrice.generator.c.gen; import com.google.inject.Inject; import com.google.inject.Singleton; +import java.util.HashSet; import java.util.List; import org.eclipse.emf.common.util.EList; import org.eclipse.etrice.core.room.ActorClass; @@ -66,22 +67,50 @@ public class ActorClassGen { String path = _operator_plus; ActorClass _actorClass_2 = xpac.getActorClass(); String _cHeaderFileName = this.stdExt.getCHeaderFileName(_actorClass_2); - String file = _cHeaderFileName; - String _operator_plus_1 = StringExtensions.operator_plus("generating ActorClass implementation \'", file); + String _operator_plus_1 = StringExtensions.operator_plus("generating ActorClass header \'", _cHeaderFileName); String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'"); String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path); String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'"); this.logger.logInfo(_operator_plus_4); this.fileAccess.setOutputPath(path); ActorClass _actorClass_3 = xpac.getActorClass(); - StringConcatenation _generate = this.generate(root, xpac, _actorClass_3); - this.fileAccess.generateFile(file, _generate); + String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(_actorClass_3); + ActorClass _actorClass_4 = xpac.getActorClass(); + StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, xpac, _actorClass_4); + this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile); + ActorClass _actorClass_5 = xpac.getActorClass(); + String _cSourceFileName = this.stdExt.getCSourceFileName(_actorClass_5); + String _operator_plus_5 = StringExtensions.operator_plus("generating ActorClass header \'", _cSourceFileName); + String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'"); + String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path); + String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'"); + this.logger.logInfo(_operator_plus_8); + this.fileAccess.setOutputPath(path); + ActorClass _actorClass_6 = xpac.getActorClass(); + String _cSourceFileName_1 = this.stdExt.getCSourceFileName(_actorClass_6); + ActorClass _actorClass_7 = xpac.getActorClass(); + StringConcatenation _generateSourceFile = this.generateSourceFile(root, xpac, _actorClass_7); + this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile); } } } - public StringConcatenation generate(final Root root, final ExpandedActorClass xpac, final ActorClass ac) { + public StringConcatenation generateHeaderFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) { StringConcatenation _builder = new StringConcatenation(); + _builder.append("#ifndef _"); + String _name = xpac.getName(); + _builder.append(_name, ""); + _builder.append("_H_"); + _builder.newLineIfNotEmpty(); + _builder.append("#define _"); + String _name_1 = xpac.getName(); + _builder.append(_name_1, ""); + _builder.append("_H_"); + _builder.newLineIfNotEmpty(); + _builder.newLine(); + _builder.append("#include \"datatypes.h\""); + _builder.newLine(); + _builder.newLine(); _builder.append("package "); String _package = this.roomExt.getPackage(ac); _builder.append(_package, ""); @@ -103,26 +132,45 @@ public class ActorClassGen { _builder.append("import org.eclipse.etrice.runtime.java.debugging.DebuggingService;"); _builder.newLine(); _builder.newLine(); + _builder.newLine(); + { + HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(ac); + for(final DataClass dataClass : _referencedDataClasses) { + { + String _name_2 = dataClass.getName(); + String _name_3 = ac.getName(); + boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_name_2, _name_3); + if (_operator_notEquals) { + _builder.append("#include \""); + String _name_4 = dataClass.getName(); + _builder.append(_name_4, ""); + _builder.append(".h\""); + } + } + _builder.newLineIfNotEmpty(); + } + } + _builder.newLine(); { EList<RoomModel> _referencedModels = root.getReferencedModels(ac); for(final RoomModel model : _referencedModels) { _builder.append("import "); - String _name = model.getName(); - _builder.append(_name, ""); + String _name_5 = model.getName(); + _builder.append(_name_5, ""); _builder.append(".*;"); _builder.newLineIfNotEmpty(); } } _builder.newLine(); { - EList<ProtocolClass> _referencedProtocols = root.getReferencedProtocols(ac); - for(final ProtocolClass pc : _referencedProtocols) { + EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac); + for(final ProtocolClass pc : _referencedProtocolClasses) { _builder.append("import "); String _package_1 = this.roomExt.getPackage(pc); _builder.append(_package_1, ""); _builder.append("."); - String _name_1 = pc.getName(); - _builder.append(_name_1, ""); + String _name_6 = pc.getName(); + _builder.append(_name_6, ""); _builder.append(".*;"); _builder.newLineIfNotEmpty(); } @@ -142,16 +190,16 @@ public class ActorClassGen { } } _builder.append("class "); - String _name_2 = ac.getName(); - _builder.append(_name_2, ""); + String _name_7 = ac.getName(); + _builder.append(_name_7, ""); _builder.append(" extends "); { ActorClass _base = ac.getBase(); - boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_base, null); - if (_operator_notEquals) { + boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_base, null); + if (_operator_notEquals_1) { ActorClass _base_1 = ac.getBase(); - String _name_3 = _base_1.getName(); - _builder.append(_name_3, ""); + String _name_8 = _base_1.getName(); + _builder.append(_name_8, ""); } else { _builder.append("ActorClassBase"); } @@ -177,8 +225,8 @@ public class ActorClassGen { String _portClassName = this.roomExt.getPortClassName(ep); _builder.append(_portClassName, " "); _builder.append(" "); - String _name_4 = ep.getName(); - _builder.append(_name_4, " "); + String _name_9 = ep.getName(); + _builder.append(_name_9, " "); _builder.append(" = null;"); _builder.newLineIfNotEmpty(); } @@ -194,8 +242,8 @@ public class ActorClassGen { String _portClassName_1 = this.roomExt.getPortClassName(sap); _builder.append(_portClassName_1, " "); _builder.append(" "); - String _name_5 = sap.getName(); - _builder.append(_name_5, " "); + String _name_10 = sap.getName(); + _builder.append(_name_10, " "); _builder.append(" = null;"); _builder.newLineIfNotEmpty(); } @@ -212,8 +260,8 @@ public class ActorClassGen { _builder.append(_portClassName_2, " "); _builder.append(" "); SPPRef _spp = svc.getSpp(); - String _name_6 = _spp.getName(); - _builder.append(_name_6, " "); + String _name_11 = _spp.getName(); + _builder.append(_name_11, " "); _builder.append(" = null;"); _builder.newLineIfNotEmpty(); } @@ -227,8 +275,8 @@ public class ActorClassGen { for(final Port ep_1 : _endPorts_1) { _builder.append("\t"); _builder.append("protected static final int IFITEM_"); - String _name_7 = ep_1.getName(); - _builder.append(_name_7, " "); + String _name_12 = ep_1.getName(); + _builder.append(_name_12, " "); _builder.append(" = "); int _interfaceItemLocalId = xpac.getInterfaceItemLocalId(ep_1); int _operator_plus = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1)); @@ -242,8 +290,8 @@ public class ActorClassGen { for(final SAPRef sap_1 : _strSAPs_1) { _builder.append("\t"); _builder.append("protected static final int IFITEM_"); - String _name_8 = sap_1.getName(); - _builder.append(_name_8, " "); + String _name_13 = sap_1.getName(); + _builder.append(_name_13, " "); _builder.append(" = "); int _interfaceItemLocalId_1 = xpac.getInterfaceItemLocalId(sap_1); int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId_1), ((Integer)1)); @@ -258,8 +306,8 @@ public class ActorClassGen { _builder.append("\t"); _builder.append("protected static final int IFITEM_"); SPPRef _spp_1 = svc_1.getSpp(); - String _name_9 = _spp_1.getName(); - _builder.append(_name_9, " "); + String _name_14 = _spp_1.getName(); + _builder.append(_name_14, " "); _builder.append(" = "); SPPRef _spp_2 = svc_1.getSpp(); int _interfaceItemLocalId_2 = xpac.getInterfaceItemLocalId(_spp_2); @@ -278,8 +326,8 @@ public class ActorClassGen { _builder.newLineIfNotEmpty(); _builder.append("\t"); EList<Operation> _operations = ac.getOperations(); - String _name_10 = ac.getName(); - StringConcatenation _OperationsDeclaration = this.helpers.OperationsDeclaration(_operations, _name_10); + String _name_15 = ac.getName(); + StringConcatenation _OperationsDeclaration = this.helpers.OperationsDeclaration(_operations, _name_15); _builder.append(_OperationsDeclaration, " "); _builder.newLineIfNotEmpty(); _builder.newLine(); @@ -288,8 +336,8 @@ public class ActorClassGen { _builder.newLine(); _builder.append("\t"); _builder.append("public "); - String _name_11 = ac.getName(); - _builder.append(_name_11, " "); + String _name_16 = ac.getName(); + _builder.append(_name_16, " "); _builder.append("(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){"); _builder.newLineIfNotEmpty(); { @@ -307,8 +355,8 @@ public class ActorClassGen { } _builder.append("\t\t"); _builder.append("setClassName(\""); - String _name_12 = ac.getName(); - _builder.append(_name_12, " "); + String _name_17 = ac.getName(); + _builder.append(_name_17, " "); _builder.append("\");"); _builder.newLineIfNotEmpty(); _builder.append("\t\t"); @@ -321,11 +369,11 @@ public class ActorClassGen { for(final Attribute a : _attributes_1) { { String _defaultValueLiteral = a.getDefaultValueLiteral(); - boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_defaultValueLiteral, null); - if (_operator_notEquals_1) { + boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_defaultValueLiteral, null); + if (_operator_notEquals_2) { _builder.append("\t\t"); - String _name_13 = a.getName(); - _builder.append(_name_13, " "); + String _name_18 = a.getName(); + _builder.append(_name_18, " "); _builder.append(" = "); String _defaultValueLiteral_1 = a.getDefaultValueLiteral(); _builder.append(_defaultValueLiteral_1, " "); @@ -334,16 +382,16 @@ public class ActorClassGen { } else { Type _type = a.getType(); DataClass _type_1 = _type.getType(); - boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_type_1, null); - if (_operator_notEquals_2) { + boolean _operator_notEquals_3 = ObjectExtensions.operator_notEquals(_type_1, null); + if (_operator_notEquals_3) { _builder.append("\t\t"); - String _name_14 = a.getName(); - _builder.append(_name_14, " "); + String _name_19 = a.getName(); + _builder.append(_name_19, " "); _builder.append(" = new "); Type _type_2 = a.getType(); DataClass _type_3 = _type_2.getType(); - String _name_15 = _type_3.getName(); - _builder.append(_name_15, " "); + String _name_20 = _type_3.getName(); + _builder.append(_name_20, " "); _builder.append("();"); _builder.newLineIfNotEmpty(); } @@ -359,17 +407,17 @@ public class ActorClassGen { List<Port> _endPorts_2 = this.roomExt.getEndPorts(ac); for(final Port ep_2 : _endPorts_2) { _builder.append("\t\t"); - String _name_16 = ep_2.getName(); - _builder.append(_name_16, " "); + String _name_21 = ep_2.getName(); + _builder.append(_name_21, " "); _builder.append(" = new "); String _portClassName_3 = this.roomExt.getPortClassName(ep_2); _builder.append(_portClassName_3, " "); _builder.append("(this, \""); - String _name_17 = ep_2.getName(); - _builder.append(_name_17, " "); + String _name_22 = ep_2.getName(); + _builder.append(_name_22, " "); _builder.append("\", IFITEM_"); - String _name_18 = ep_2.getName(); - _builder.append(_name_18, " "); + String _name_23 = ep_2.getName(); + _builder.append(_name_23, " "); _builder.append(", "); { int _multiplicity = ep_2.getMultiplicity(); @@ -379,8 +427,8 @@ public class ActorClassGen { } } _builder.append("port_addr[IFITEM_"); - String _name_19 = ep_2.getName(); - _builder.append(_name_19, " "); + String _name_24 = ep_2.getName(); + _builder.append(_name_24, " "); _builder.append("]"); { int _multiplicity_1 = ep_2.getMultiplicity(); @@ -390,8 +438,8 @@ public class ActorClassGen { } } _builder.append(", peer_addr[IFITEM_"); - String _name_20 = ep_2.getName(); - _builder.append(_name_20, " "); + String _name_25 = ep_2.getName(); + _builder.append(_name_25, " "); _builder.append("]"); { int _multiplicity_2 = ep_2.getMultiplicity(); @@ -411,23 +459,23 @@ public class ActorClassGen { EList<SAPRef> _strSAPs_2 = ac.getStrSAPs(); for(final SAPRef sap_2 : _strSAPs_2) { _builder.append("\t\t"); - String _name_21 = sap_2.getName(); - _builder.append(_name_21, " "); + String _name_26 = sap_2.getName(); + _builder.append(_name_26, " "); _builder.append(" = new "); String _portClassName_4 = this.roomExt.getPortClassName(sap_2); _builder.append(_portClassName_4, " "); _builder.append("(this, \""); - String _name_22 = sap_2.getName(); - _builder.append(_name_22, " "); + String _name_27 = sap_2.getName(); + _builder.append(_name_27, " "); _builder.append("\", IFITEM_"); - String _name_23 = sap_2.getName(); - _builder.append(_name_23, " "); + String _name_28 = sap_2.getName(); + _builder.append(_name_28, " "); _builder.append(", 0, port_addr[IFITEM_"); - String _name_24 = sap_2.getName(); - _builder.append(_name_24, " "); + String _name_29 = sap_2.getName(); + _builder.append(_name_29, " "); _builder.append("][0], peer_addr[IFITEM_"); - String _name_25 = sap_2.getName(); - _builder.append(_name_25, " "); + String _name_30 = sap_2.getName(); + _builder.append(_name_30, " "); _builder.append("][0]); "); _builder.newLineIfNotEmpty(); } @@ -440,27 +488,27 @@ public class ActorClassGen { for(final ServiceImplementation svc_2 : _serviceImplementations_2) { _builder.append("\t\t"); SPPRef _spp_3 = svc_2.getSpp(); - String _name_26 = _spp_3.getName(); - _builder.append(_name_26, " "); + String _name_31 = _spp_3.getName(); + _builder.append(_name_31, " "); _builder.append(" = new "); String _portClassName_5 = this.roomExt.getPortClassName(svc_2); _builder.append(_portClassName_5, " "); _builder.append("(this, \""); SPPRef _spp_4 = svc_2.getSpp(); - String _name_27 = _spp_4.getName(); - _builder.append(_name_27, " "); + String _name_32 = _spp_4.getName(); + _builder.append(_name_32, " "); _builder.append("\", IFITEM_"); SPPRef _spp_5 = svc_2.getSpp(); - String _name_28 = _spp_5.getName(); - _builder.append(_name_28, " "); + String _name_33 = _spp_5.getName(); + _builder.append(_name_33, " "); _builder.append(", port_addr[IFITEM_"); SPPRef _spp_6 = svc_2.getSpp(); - String _name_29 = _spp_6.getName(); - _builder.append(_name_29, " "); + String _name_34 = _spp_6.getName(); + _builder.append(_name_34, " "); _builder.append("], peer_addr[IFITEM_"); SPPRef _spp_7 = svc_2.getSpp(); - String _name_30 = _spp_7.getName(); - _builder.append(_name_30, " "); + String _name_35 = _spp_7.getName(); + _builder.append(_name_35, " "); _builder.append("]); "); _builder.newLineIfNotEmpty(); } @@ -524,8 +572,8 @@ public class ActorClassGen { _builder.newLine(); { StateMachine _stateMachine = ac.getStateMachine(); - boolean _operator_notEquals_3 = ObjectExtensions.operator_notEquals(_stateMachine, null); - if (_operator_notEquals_3) { + boolean _operator_notEquals_4 = ObjectExtensions.operator_notEquals(_stateMachine, null); + if (_operator_notEquals_4) { _builder.append("\t"); StringConcatenation _genStateMachine = this.stateMachineGen.genStateMachine(xpac, ac); _builder.append(_genStateMachine, " "); @@ -565,6 +613,24 @@ public class ActorClassGen { } _builder.append("};"); _builder.newLine(); + _builder.newLine(); + _builder.append("#endif /* _"); + String _name_36 = xpac.getName(); + _builder.append(_name_36, ""); + _builder.append("_H_ */"); + _builder.newLineIfNotEmpty(); + _builder.newLine(); + return _builder; + } + + public StringConcatenation generateSourceFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) { + StringConcatenation _builder = new StringConcatenation(); + _builder.append("#include \""); + String _cHeaderFileName = this.stdExt.getCHeaderFileName(xpac); + _builder.append(_cHeaderFileName, ""); + _builder.append("\""); + _builder.newLineIfNotEmpty(); + _builder.newLine(); return _builder; } diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java index 65919c1f6..406b24c84 100644 --- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java +++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java @@ -45,25 +45,25 @@ public class DataClassGen { String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path); String path = _operator_plus; String _cHeaderFileName = this.stdExt.getCHeaderFileName(dc); - String headerFile = _cHeaderFileName; - String _operator_plus_1 = StringExtensions.operator_plus("generating DataClass header \'", headerFile); + String _operator_plus_1 = StringExtensions.operator_plus("generating DataClass header \'", _cHeaderFileName); String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'"); String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path); String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'"); this.logger.logInfo(_operator_plus_4); this.fileAccess.setOutputPath(path); + String _cHeaderFileName_1 = this.stdExt.getCHeaderFileName(dc); StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, dc); - this.fileAccess.generateFile(headerFile, _generateHeaderFile); + this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile); String _cSourceFileName = this.stdExt.getCSourceFileName(dc); - String sourceFile = _cSourceFileName; - String _operator_plus_5 = StringExtensions.operator_plus("generating DataClass source \'", headerFile); + String _operator_plus_5 = StringExtensions.operator_plus("generating DataClass source \'", _cSourceFileName); String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'"); String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path); String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'"); this.logger.logInfo(_operator_plus_8); this.fileAccess.setOutputPath(path); + String _cSourceFileName_1 = this.stdExt.getCSourceFileName(dc); StringConcatenation _generateSourceFile = this.generateSourceFile(root, dc); - this.fileAccess.generateFile(sourceFile, _generateSourceFile); + this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile); } } } @@ -81,7 +81,7 @@ public class DataClassGen { _builder.append("_H_"); _builder.newLineIfNotEmpty(); _builder.newLine(); - _builder.append("#include \"../../src/datatypes.h\""); + _builder.append("#include \"datatypes.h\""); _builder.newLine(); _builder.newLine(); _builder.append("/* TODO: includes only for used DataClasses, also for other models */"); @@ -112,20 +112,16 @@ public class DataClassGen { _builder.newLine(); _builder.append("typedef struct {"); _builder.newLine(); - _builder.newLine(); _builder.append("\t"); DetailCode _userCode2 = dc.getUserCode2(); StringConcatenation _UserCode_1 = this.helpers.UserCode(_userCode2); _builder.append(_UserCode_1, " "); _builder.newLineIfNotEmpty(); - _builder.newLine(); _builder.append("\t"); EList<Attribute> _attributes = dc.getAttributes(); StringConcatenation _Attributes = this.helpers.Attributes(_attributes); _builder.append(_Attributes, " "); _builder.newLineIfNotEmpty(); - _builder.append("\t"); - _builder.newLine(); _builder.append("} "); String _name_5 = dc.getName(); _builder.append(_name_5, ""); diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java index 42faa3c18..b95d38cb9 100644 --- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java +++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/MainGen.java @@ -49,6 +49,7 @@ public class MainGen implements IGenerator { public void doGenerate(final Root e) { this.dataClassGen.doGenerate(e); + this.actorClassGen.doGenerate(e); boolean _isLibrary = e.isLibrary(); boolean _operator_not = BooleanExtensions.operator_not(_isLibrary); if (_operator_not) { 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 d30a162fb..e98032cdd 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 @@ -59,7 +59,7 @@ class ActorClassGen { «FOR model : root.getReferencedModels(ac)»import «model.name».*;
«ENDFOR»
- «FOR pc : root.getReferencedProtocols(ac)»import «pc.^package».«pc.name».*;
+ «FOR pc : root.getReferencedProtocolClasses(ac)»import «pc.^package».«pc.name».*;
«ENDFOR»
«helpers.UserCode(ac.userCode1)»
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 21914800c..8c3910171 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 @@ -115,8 +115,8 @@ public class ActorClassGen { } _builder.newLine(); { - EList<ProtocolClass> _referencedProtocols = root.getReferencedProtocols(ac); - for(final ProtocolClass pc : _referencedProtocols) { + EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac); + for(final ProtocolClass pc : _referencedProtocolClasses) { _builder.append("import "); String _package_1 = this.roomExt.getPackage(pc); _builder.append(_package_1, ""); diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/Root.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/Root.java index 5707b2cac..e7fe1f94b 100644 --- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/Root.java +++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/Root.java @@ -212,8 +212,10 @@ public interface Root extends EObject { * @model
* @generated
*/
- EList<ProtocolClass> getReferencedProtocols(ActorClass cls);
+ EList<ProtocolClass> getReferencedProtocolClasses(ActorClass cls);
+ // TODO: is this the right place ?
HashSet<DataClass> getReferencedDataClasses(DataClass cls);
+ HashSet<DataClass> getReferencedDataClasses(ActorClass cls);
} // Root
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/impl/RootImpl.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/impl/RootImpl.java index d97877ebf..09c74739b 100644 --- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/impl/RootImpl.java +++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/impl/RootImpl.java @@ -341,7 +341,7 @@ public class RootImpl extends EObjectImpl implements Root { * <!-- end-user-doc -->
* @generated NOT
*/
- public EList<ProtocolClass> getReferencedProtocols(ActorClass cls) {
+ public EList<ProtocolClass> getReferencedProtocolClasses(ActorClass cls) {
if (cls instanceof ExpandedActorClass)
cls = ((ExpandedActorClass)cls).getActorClass();
@@ -724,5 +724,13 @@ public class RootImpl extends EObjectImpl implements Root { return dataClasses;
}
+ public HashSet<DataClass> getReferencedDataClasses(ActorClass cls){
+ HashSet<DataClass> dataClasses = new HashSet<DataClass>();
+ getAttributeDataClasses(dataClasses, cls.getAttributes());
+ getOperationDataClasses(dataClasses, cls.getOperations());
+ return dataClasses;
+ }
+
+
} //RootImpl
diff --git a/runtime/org.eclipse.etrice.runtime.c/.cproject b/runtime/org.eclipse.etrice.runtime.c/.cproject index c2a96784b..afb7aca7f 100644 --- a/runtime/org.eclipse.etrice.runtime.c/.cproject +++ b/runtime/org.eclipse.etrice.runtime.c/.cproject @@ -34,6 +34,9 @@ <tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.debug.1185604346" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.debug"> <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.mingw.lib.debug.option.optimization.level.157947957" name="Optimization Level" superClass="gnu.c.compiler.mingw.lib.debug.option.optimization.level" valueType="enumerated"/> <option id="gnu.c.compiler.mingw.lib.debug.option.debugging.level.1083191317" name="Debug Level" superClass="gnu.c.compiler.mingw.lib.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/> + <option id="gnu.c.compiler.option.include.paths.790097072" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/include}""/> + </option> <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.361048721" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> </tool> <tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.base.597146923" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.base"/> @@ -107,4 +110,7 @@ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/> </scannerConfigBuildInfo> </storageModule> + <storageModule moduleId="refreshScope" versionNumber="1"> + <resource resourceType="PROJECT" workspacePath="/org.eclipse.etrice.runtime.c"/> + </storageModule> </cproject> diff --git a/runtime/org.eclipse.etrice.runtime.c/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/runtime/org.eclipse.etrice.runtime.c/.settings/org.eclipse.cdt.managedbuilder.core.prefs new file mode 100644 index 000000000..5ab07a7b2 --- /dev/null +++ b/runtime/org.eclipse.etrice.runtime.c/.settings/org.eclipse.cdt.managedbuilder.core.prefs @@ -0,0 +1,14 @@ +#Tue Dec 27 19:24:40 CET 2011 +eclipse.preferences.version=1 +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.505530637/CPATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.505530637/CPATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.505530637/C_INCLUDE_PATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.505530637/C_INCLUDE_PATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.505530637/append=true +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.debug.505530637/appendContributed=true +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.release.406040144/CPATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.release.406040144/CPATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.release.406040144/C_INCLUDE_PATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.release.406040144/C_INCLUDE_PATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.release.406040144/append=true +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.lib.release.406040144/appendContributed=true diff --git a/runtime/org.eclipse.etrice.runtime.c/Debug/.gitignore b/runtime/org.eclipse.etrice.runtime.c/Debug/.gitignore new file mode 100644 index 000000000..85de9cf93 --- /dev/null +++ b/runtime/org.eclipse.etrice.runtime.c/Debug/.gitignore @@ -0,0 +1 @@ +src diff --git a/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a b/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a Binary files differnew file mode 100644 index 000000000..b7d8582b1 --- /dev/null +++ b/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a diff --git a/runtime/org.eclipse.etrice.runtime.c/Release/.gitignore b/runtime/org.eclipse.etrice.runtime.c/Release/.gitignore new file mode 100644 index 000000000..85de9cf93 --- /dev/null +++ b/runtime/org.eclipse.etrice.runtime.c/Release/.gitignore @@ -0,0 +1 @@ +src diff --git a/runtime/org.eclipse.etrice.runtime.c/src/include/datatypes.h b/runtime/org.eclipse.etrice.runtime.c/src/include/datatypes.h deleted file mode 100644 index ff97c8489..000000000 --- a/runtime/org.eclipse.etrice.runtime.c/src/include/datatypes.h +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 protos software gmbh (http://www.protos.de). - * 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: - * Thomas Schuetz (initial contribution) - * - *******************************************************************************/ - -#ifndef _DATATYPES_H_ -#define _DATATYPES_H_ - -/* unsigned integer datatypes */ -typedef unsigned char uint8; -typedef unsigned short int uint16; -typedef unsigned long uint32; - -/* signed integer datatypes */ -typedef char int8; -typedef short int int16; -typedef long int32; - -/* float datatypes */ -typedef float float32; -typedef double float64; - -/* boolean datatypes and values */ -typedef char boool; /* TODO: bool, Bool, Boolean, and boolean are already defined in some platforms*/ -#ifndef TRUE - #define TRUE 1 -#endif -#ifndef FALSE - #define FALSE 0 -#endif - - -#endif /* _DATATYPES_H_ */ diff --git a/runtime/org.eclipse.etrice.runtime.c/src/runit/RUnit.c b/runtime/org.eclipse.etrice.runtime.c/src/runit/RUnit.c deleted file mode 100644 index e80553f54..000000000 --- a/runtime/org.eclipse.etrice.runtime.c/src/runit/RUnit.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * RUnit.c - * - * Created on: 26.12.2011 - * Author: tschuetz - */ - -#include "RUnit.h" - - -void RUnit_open(const char *testSuiteName) { - RUnit_passCount = 0; - RUnit_failCount = 0; - printf("************* TEST START **************\n"); - - if (RUnit_reportfile == NULL) { - RUnit_reportfile = fopen("report.xml", "w+"); - if (RUnit_reportfile != NULL) { - fprintf( - RUnit_reportfile, - "<testsuite name=\"%s\" tests=\"0\" failures=\"0\" errors=\"0\" time=\"0\">\n", - testSuiteName); - } else { - printf("Unable to open file!"); - } - } -} - -void RUnit_close(void) { - printf("\n"); - if (RUnit_failCount > 0) { - printf("************* TEST FAILED *************\n"); - } else { - printf("************* TEST PASSED *************\n"); - } - printf("Number of Tests: %ld\n", RUnit_failCount + RUnit_passCount); - printf("Failed: %ld\n", RUnit_failCount); - printf("Passed: %ld\n", RUnit_passCount); - printf("***************************************\n"); - - if (RUnit_reportfile != NULL) { - fprintf(RUnit_reportfile, "</testsuite>\n"); - fclose(RUnit_reportfile); - RUnit_reportfile = NULL; - } - -} - -void EXPECT_TRUE(const char* testcase, boool condition) { - if (condition == FALSE) { - RUnit_writeTestLog(testcase, FALSE, "*** FAIL: EXPECT_TRUE == FALSE"); - } else { - RUnit_writeTestLog(testcase, TRUE, ""); - } -} - -void EXPECT_FALSE(const char* testcase, boool condition) { - if (condition == TRUE) { - RUnit_writeTestLog(testcase, FALSE, "*** FAIL: EXPECT_FALSE == TRUE"); - } else { - RUnit_writeTestLog(testcase, FALSE, ""); - } -} - -//_________ - -void RUnit_buildTestLogXML(char* xml, const char *testcase, boool result, const char *resulttext) { - if (result == TRUE) { - sprintf( - xml, - "\t<testcase name=\"%s\" classname=\"none\" time=\"0.0000\"/>\n", - testcase); - } else { - sprintf( - xml, - "\t<testcase name=\"%s\" classname=\"none\" time=\"0.0000\">\n\t\t<failure message=\"%s\" type=\"\"/>\n\t</testcase>\n", - testcase, resulttext); - } -} - -void RUnit_writeTestLog(const char *testcase, boool result, const char *resulttext) { - char writeBuffer[256]; // TODO TS: write secure buffers for string handling ... - - // counting - if (result == TRUE) { - RUnit_passCount++; - printf("PASS: %s: %s\n", testcase, resulttext); - } - else { - RUnit_failCount++; - printf("FAIL: %s: %s\n", testcase, resulttext); - } - - // writing to file - if (RUnit_reportfile != NULL) { - RUnit_buildTestLogXML(writeBuffer, testcase, result, resulttext); - fprintf(RUnit_reportfile, writeBuffer); - } -} - diff --git a/runtime/org.eclipse.etrice.runtime.c/src/runit/RUnit.h b/runtime/org.eclipse.etrice.runtime.c/src/runit/RUnit.h deleted file mode 100644 index 9a5a63f9c..000000000 --- a/runtime/org.eclipse.etrice.runtime.c/src/runit/RUnit.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * RUnit.h - * - * Created on: 26.12.2011 - * Author: tschuetz - */ - -#ifndef RUNIT_H_ -#define RUNIT_H_ - -#include "datatypes.h" -#include <stdio.h> - - -//*** global variables -// file handling -static FILE* RUnit_reportfile = NULL; - -// counters -static int32 RUnit_passCount = 0; -static int32 RUnit_failCount = 0; - -// time measuring -static RUnit_startTime = 0; -static RUnit_currentTime = 0; - - -// forward declarations -void RUnit_open(const char *testSuiteName); -void RUnit_close(void); -void RUnit_writeTestLog(const char *testcase, boool result, const char *resulttext); - - -void EXPECT_TRUE(const char* testcase, boool condition); -void EXPECT_FALSE(const char* testcase, boool condition); - -//void EXPECT_EQUAL(const char* testcase, int8 expected, int8 actual); -//void EXPECT_EQUAL(const char* testcase, int16 expected, int16 actual); -//void EXPECT_EQUAL(const char* testcase, int32 expected, int32 actual); -//void EXPECT_EQUAL(const char* testcase, uint8 expected, uint8 actual); -//void EXPECT_EQUAL(const char* testcase, uint16 expected, uint16 actual); -//void EXPECT_EQUAL(const char* testcase, uint32 expected, uint32 actual); - - -#define EXPECT_EQUAL_INT(testcase, expected, actual) \ - if (expected != actual) { \ - char testresult[256]; \ - sprintf(testresult, "expected=%ld, actual=%ld", expected, actual); \ - RUnit_writeTestLog(testcase, FALSE, testresult); \ - } \ - else { \ - RUnit_writeTestLog(testcase, TRUE, ""); \ - } - -#define FLOAT_PRECISION 0.0001 - -#define EXPECT_EQUAL_FLOAT(testcase, expected, actual) \ - if (expected-actual < -FLOAT_PRECISION || expected-actual > FLOAT_PRECISION) { \ - char testresult[256]; \ - sprintf(testresult, "expected=%f, actual=%f", expected, actual); \ - RUnit_writeTestLog(testcase, FALSE, testresult); \ - } \ - else { \ - RUnit_writeTestLog(testcase, TRUE, ""); \ - } - -#endif /* RUNIT_H_ */ |