From f662355760bf64afa40633938a4c6b4139756e28 Mon Sep 17 00:00:00 2001 From: Simon Wegendt Date: Mon, 11 Nov 2019 12:55:44 +0100 Subject: [PATCH] Fix ringbuffers that are not consumed: they need to have events pushed regardless --- .../platform/x86/platform/StartupGenerator.xtend | 14 +++++++------- .../platform/xdk110/sensors/ButtonGenerator.xtend | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/platforms/org.eclipse.mita.platform.x86/src/org/eclipse/mita/platform/x86/platform/StartupGenerator.xtend b/platforms/org.eclipse.mita.platform.x86/src/org/eclipse/mita/platform/x86/platform/StartupGenerator.xtend index 2187ba64..bc5bb07d 100644 --- a/platforms/org.eclipse.mita.platform.x86/src/org/eclipse/mita/platform/x86/platform/StartupGenerator.xtend +++ b/platforms/org.eclipse.mita.platform.x86/src/org/eclipse/mita/platform/x86/platform/StartupGenerator.xtend @@ -43,23 +43,23 @@ class StartupGenerator implements IPlatformStartupGenerator { StdlibTypeRegistry typeRegistry override generateMain(CompilationContext context) { - val startupEventHandlers = context.allEventHandlers + val startupEventHandlersAndEvents = context.allEventHandlers .map[it -> it.event] .filter[it.value instanceof SystemEventSource] .map[it.key -> it.value as SystemEventSource] .map[it.key -> it.value.source] .filter[it.value.name == "startup"] - .map[it.key] - .filter[it.payload !== null]; return codeFragmentProvider.create(''' Mita_initialize(); Mita_goLive(); int32_t exception = 0; - «FOR startupEventHandler: startupEventHandlers» + «FOR startupEventHandler_event: startupEventHandlersAndEvents» + «val startupEventHandler = startupEventHandler_event.key» + «val event = startupEventHandler_event.value» «pushGenerator.generate( startupEventHandler, new CodeWithContext( - RingbufferGenerator.wrapInRingbuffer(typeRegistry, startupEventHandler, BaseUtils.getType(startupEventHandler.payload)), + RingbufferGenerator.wrapInRingbuffer(typeRegistry, startupEventHandler, BaseUtils.getType(event)), Optional.empty, codeFragmentProvider.create('''rb_«startupEventHandler.baseName»''') ), @@ -89,8 +89,8 @@ class StartupGenerator implements IPlatformStartupGenerator { return 0; ''') .setPreamble(''' - «FOR startupEventHandler: startupEventHandlers» - extern ringbuffer_int32_t rb_«startupEventHandler.baseName»; + «FOR startupEventHandler_event: startupEventHandlersAndEvents» + extern ringbuffer_int32_t rb_«startupEventHandler_event.key.baseName»; «ENDFOR» ''') .addHeader('time.h', true) diff --git a/platforms/org.eclipse.mita.platform.xdk110/src/org/eclipse/mita/platform/xdk110/sensors/ButtonGenerator.xtend b/platforms/org.eclipse.mita.platform.xdk110/src/org/eclipse/mita/platform/xdk110/sensors/ButtonGenerator.xtend index 13137e02..3bc32dc6 100644 --- a/platforms/org.eclipse.mita.platform.xdk110/src/org/eclipse/mita/platform/xdk110/sensors/ButtonGenerator.xtend +++ b/platforms/org.eclipse.mita.platform.xdk110/src/org/eclipse/mita/platform/xdk110/sensors/ButtonGenerator.xtend @@ -30,6 +30,7 @@ import org.eclipse.mita.program.generator.CodeWithContext import org.eclipse.mita.library.stdlib.RingbufferGenerator import org.eclipse.mita.base.util.BaseUtils import java.util.Optional +import static extension org.eclipse.mita.base.util.BaseUtils.castOrNull; class ButtonGenerator extends AbstractSystemResourceGenerator { @@ -80,7 +81,7 @@ class ButtonGenerator extends AbstractSystemResourceGenerator { «pushGenerator.generate( changedHandler, new CodeWithContext( - RingbufferGenerator.wrapInRingbuffer(typeRegistry, changedHandler, BaseUtils.getType(changedHandler.payload)), + RingbufferGenerator.wrapInRingbuffer(typeRegistry, changedHandler, BaseUtils.getType(changedHandler.event.castOrNull(SystemEventSource).source)), Optional.empty, codeFragmentProvider.create('''rb_«changedHandler.baseName»''') ),