svoid test_tok_eventFunctions() { // no args testTranspilationFunction tok_eventFunctions( "event blubb;", [[ transient Set onBlubb; public selfType onBlubb(Runnable r) { onBlubb = createOrAddToSyncLinkedHashSet(onBlubb, r); this; } public selfType removeBlubbListener(Runnable r) { main remove(onBlubb, r); this; } public void blubb() { if (onBlubb != null) for (listener : onBlubb) pcallF_typed(listener); } ]]); // with args testTranspilationFunction tok_eventFunctions( "event newX(X x);", [[ transient Set> onNewX; public selfType onNewX(IVF1 f) { onNewX = createOrAddToSyncLinkedHashSet(onNewX, f); this; } public selfType removeNewXListener(IVF1 f) { main remove(onNewX, f); this; } public void newX(X x) { if (onNewX != null) for (listener : onNewX) pcallF_typed(listener, x); } ]]); // "on" prefix handled correctly testTranspilationFunction tok_eventFunctions( "event onBlubb;", [[ transient Set onBlubb; public selfType onBlubb(Runnable r) { onBlubb = createOrAddToSyncLinkedHashSet(onBlubb, r); this; } public selfType removeBlubbListener(Runnable r) { main remove(onBlubb, r); this; } public void blubb() { if (onBlubb != null) for (listener : onBlubb) pcallF_typed(listener); } ]]); // "fire" prefix handled correctly testTranspilationFunction tok_eventFunctions( "event fireBlubb;", [[ transient Set onBlubb; public selfType onBlubb(Runnable r) { onBlubb = createOrAddToSyncLinkedHashSet(onBlubb, r); this; } public selfType removeBlubbListener(Runnable r) { main remove(onBlubb, r); this; } public void fireBlubb() { if (onBlubb != null) for (listener : onBlubb) pcallF_typed(listener); } ]]); // firing functions can now have a body testTranspilationFunction tok_eventFunctions( "event newX(X x) { bla; }", [[ transient Set> onNewX; public selfType onNewX(IVF1 f) { onNewX = createOrAddToSyncLinkedHashSet(onNewX, f); this; } public selfType removeNewXListener(IVF1 f) { main remove(onNewX, f); this; } public void newX(X x) { bla; if (onNewX != null) for (listener : onNewX) pcallF_typed(listener, x); } ]]); // static event testTranspilationFunction tok_eventFunctions( "static event blubb;", [[ static transient Set onBlubb; public static selfType onBlubb(Runnable r) { onBlubb = createOrAddToSyncLinkedHashSet(onBlubb, r); this; } public static selfType removeBlubbListener(Runnable r) { main remove(onBlubb, r); this; } public static void blubb() { if (onBlubb != null) for (listener : onBlubb) pcallF_typed(listener); } ]]); S s = "void event aka setEvent() {}"; testTranspilationFunction tok_eventFunctions(s, s); }