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»''') ),