/* event change; => transient L onChange; selfType onChange(Runnable r) { onChange = syncAddOrCreate(onChange, r); this; } void change() { pcallFAll(onChange); } */ static void tok_eventFunctions(L tok) { int i; while ((i = jfind(tok, "event ")) >= 0) { int iSemicolon = i+4; S args = ""; if (eqGet(tok, i+4, "(")) { int argsFrom = i+6; int argsTo = findCodeTokens(tok, argsFrom, false, ")"); args = joinSubList(tok, argsFrom, argsTo-1); iSemicolon = argsTo+2; fail("TODO: event with args"); } assertEquals(";", get(tok, iSemicolon)); S change = tok.get(i+2); S onChange = "on" + firstToUpper(change); replaceTokens_reTok(tok, i, iSemicolon+1, "transient L \*onChange*/;\n" + "selfType \*onChange*/(Runnable r) { \*onChange*/ = syncAddOrCreate(\*onChange*/, r); this; }\n" + "void \*change*/() { pcallFAll(\*onChange*/); }"); } }