// only one multi-type argument per declaration for now // also allows only one combo right now (File/S with newFile) // example: // sS loadTextFile(File/S file) { ... } svoid tok_multiTypeArguments_v2(LS tok) { int i; while ((i = jfind(tok, "File/ ", (_tok, nIdx) -> eqGetOneOf(_tok, nIdx+5, "S", "String"))) >= 0) { S argName = tok.get(i+6); S mainType = tok.get(i), altType = tok.get(i+4); S converter = "newFile"; S expr = converter + "(" + argName + ")"; tok_expandMultiTypeArgument(tok, i, i+8, argName, mainType, altType, expr); } while ((i = jfind(tok, " etc ")) >= 0) { S mainType = tok.get(i); S argName = tok.get(i+4); int iArgEnd = i+6; S altType, converter; if (eq(mainType, "Graphics2D")) { altType = "BufferedImage"; converter = "graphics"; } else if (eq(mainType, "IIntegralImage")) { altType = "BufferedImage"; converter = "IntegralImage"; } else if (eq(mainType, "BufferedImage")) { altType = "MakesBufferedImage"; converter = "toBufferedImage"; } else fail("Unknown multi-type: " + joinSubList(tok, i, iArgEnd)); S expr = converter + "(" + argName + ")"; tok_expandMultiTypeArgument(tok, i, iArgEnd, argName, mainType, altType, expr); } }