From ccba971b5844820b1152b87b8b817723afa4ca6f Mon Sep 17 00:00:00 2001 From: Juergen Haug Date: Thu, 7 May 2015 13:21:34 +0200 Subject: Revert "[generator.c] Bug 439014 add port and message label to data-driven events in MSC Change-Id: I2461a0c6432b797f9f3066bad7150dff39d72ac5" This reverts commit 1ad3ee4d5dbf55c1c68d2ee7bb2bb0ac94c2fead. --- .../etrice/generator/c/gen/ProtocolClassGen.xtend | 78 +++++++++++++--------- 1 file changed, 45 insertions(+), 33 deletions(-) (limited to 'plugins/org.eclipse.etrice.generator.c/src/org') diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend index a3fde7720..4cb4b94c7 100644 --- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend +++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend @@ -230,7 +230,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator { «ENDFOR» «IF (pc.getPortClass(conj) != null)» - «pc.getAllOperations(!conj).operationsDeclaration(portClassName)» + «pc.getPortClass(conj).operations.operationsDeclaration(portClassName)» «ENDIF» «IF pc.handlesReceive(conj)» @@ -302,38 +302,50 @@ class ProtocolClassGen extends GenericProtocolClassGenerator { ''' } - def private genDataDrivenPortSources(ProtocolClass pc){ + def private genDataDrivenPortSources(ProtocolClass pc) { var messages = pc.allIncomingMessages.filter(m|m.data!=null) - messages.map[message | - var type = message.data.refType.type - var refp = if (!(type.enumerationOrPrimitive)) "*" else "" - // log message name and data in MSC, if feasible - var messageLog = switch type { - //case type.isEnumeration: '''«type.name»_getLiteralName(data)''' - case type.isBoolean: '''data?"«message.name»(true)":"«message.name»(false)"''' - default : '''"«message.name»"''' - } - ''' - «messageSetterSignature(pc.getPortClassName(true), message.name, ', '+type.name+refp+' data')» { - «IF Main::settings.generateMSCInstrumentation» - #ifdef ET_ASYNC_MSC_LOGGER_ACTIVATE - { - const char** peerName; - for (peerName=self->peerNames; *peerName!=NULL; ++peerName) { - ET_MSC_LOGGER_ASYNC_OUT(self->instName, «messageLog», *peerName) - ET_MSC_LOGGER_ASYNC_IN(self->instName, «messageLog», *peerName) - } - } - #endif - «ENDIF» - self->«message.name» = «refp»data; - } - - «messageGetterSignature(pc.getPortClassName(false), message.name, type.name)» { - return self->peer->«message.name»; - } - ''' - ].join + val enumMsgs = messages.filter(m|m.data.refType.type.isEnumeration) + val boolMsgs = messages.filter(m|m.data.refType.type.isBoolean) + val usesMSC = Main::settings.generateMSCInstrumentation && !(enumMsgs.empty && boolMsgs.empty) + /* + * MSC code is generated for all enumerations and all booleans of the messages of this protocol + */ + ''' + «FOR message : messages» + «var typeName =message.data.refType.type.typeName» + «var refp = if (!(message.data.refType.type.enumerationOrPrimitive)) "*" else ""» + «var data = ", "+typeName+refp+" data"» + «messageSetterSignature(pc.getPortClassName(true), message.name, data)» { + «IF usesMSC && enumMsgs.exists(m|m==message)» + #ifdef ET_ASYNC_MSC_LOGGER_ACTIVATE + { + const char** peerName; + for (peerName=self->peerNames; *peerName!=NULL; ++peerName) { + ET_MSC_LOGGER_ASYNC_OUT(self->instName, «message.data.refType.type.name»_getLiteralName(data), *peerName) + ET_MSC_LOGGER_ASYNC_IN(self->instName, «message.data.refType.type.name»_getLiteralName(data), *peerName) + } + } + #endif + «ENDIF» + «IF usesMSC && boolMsgs.exists(m|m==message)» + #ifdef ET_ASYNC_MSC_LOGGER_ACTIVATE + { + const char** peerName; + for (peerName=self->peerNames; *peerName!=NULL; ++peerName) { + ET_MSC_LOGGER_ASYNC_OUT(self->instName, data?"true":"false", *peerName) + ET_MSC_LOGGER_ASYNC_IN(self->instName, data?"true":"false", *peerName) + } + } + #endif + «ENDIF» + self->«message.name» = «refp»data; + } + «messageGetterSignature(pc.getPortClassName(false), message.name, typeName)» { + return self->peer->«message.name»; + } + + «ENDFOR» + ''' } def private portClassSource(ProtocolClass pc, Boolean conj) { @@ -406,7 +418,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator { /* begin «portClassName» specific */ «pclass.userCode.userCode» - «pc.getAllOperations(!conj).operationsImplementation(portClassName)» + «pc.getPortClass(conj).operations.operationsImplementation(portClassName)» /* end «portClassName» specific */ «ENDIF» -- cgit v1.2.3