Transpiled version (11385L) is out of date.
// example: // sS loadTextFile(File/S file) { ... } svoid tok_multiTypeArguments_v2(LS tok) { int i; // File/S while ((i = jfind(tok, "File/<id> <id>", (_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); } // Graphics2D etc, IIntegralImage etc, ... while ((i = jfind(tok, "<id> etc <id>")) >= 0) { S mainType = tok.get(i); S argName = tok.get(i+4); int iArgEnd = i+6; new LPairS alts; // altType, converter bool v3; if (eq(mainType, "Graphics2D")) alts.add(pair("BufferedImage", "graphics")); else if (eq(mainType, "File")) alts.add(pair("String", "toFile")); else if (eq(mainType, "BWImage")) alts.add(pair("BufferedImage", "toBWImage")); else if (eq(mainType, "IIntegralImage")) { alts.add(pair("BufferedImage", "IntegralImage")); alts.add(pair("MakesBufferedImage", "IntegralImage")); } else if (eq(mainType, "BufferedImage")) alts.add(pair("MakesBufferedImage", "toBufferedImage")); else if (eq(mainType, "Runnable")) alts.add(pair("IF0", "if0ToRunnable")); else if (eq(mainType, "Component")) alts.add(pair("Swingable", "toComponent")); else if (eq(mainType, "JComponent")) alts.add(pair("Swingable", "toJComponent")); else if (eq(mainType, "WidthAndHeight")) { alts.add(pair("Dimension", "toWidthAndHeight")); alts.add(pair("int \*argName*/_w, int \*argName*/_h", "widthAndHeight(\*argName*/_w, \*argName*/_h)")); set v3; } else if (eq(mainType, "Pt")) { alts.add(pair("int \*argName*/_x, int \*argName*/_y", "pt(\*argName*/_x, \*argName*/_y)")); set v3; } else if (eqOneOf(mainType, "DoublePt", "IDoublePt")) { alts.add(pair("double \*argName*/_x, double \*argName*/_y", "doublePt(\*argName*/_x, \*argName*/_y)")); set v3; } if (empty(alts)) fail("Unknown multi-type: " + joinSubList(tok, i, iArgEnd)); if (v3) tok_expandMultiTypeArgument_v3(tok, i, iArgEnd, argName, mainType, alts); else tok_expandMultiTypeArgument_v2(tok, i, iArgEnd, argName, mainType, alts); } // Iterable<X> or X[], Iterable<> or X... IntRange r; for (S modifier : ll("[]", "...")) while ((r = jfind_range(tok, "Iterable<<id>> or <id>" + modifier + " <id>")) != null) { i = r.start+1; S mainType = joinSubList(tok, i, i+7); S altType = joinSubList(tok, i+10, r.end-3); S argName = tok.get(r.end-2); S converter = "asList"; S expr = converter + "(" + argName + ")"; tok_expandMultiTypeArgument(tok, i, r.end, argName, mainType, altType, expr); } // Iterable or O[], Iterable or X..., Cl/O[], etc for (S modifier : ll("[]", "...")) while ((r = jfind_range(tok, "<id> * *" + modifier + " <id>", func(LS tok, int nIdx) { eqOneOf(tok.get(nIdx+1), "Iterable", "Collection", "Cl", "List", "L") && eqGetOneOf(tok, nIdx+3, "or", "/") && eqGetOneOf(tok, nIdx+5, "O", "Object") })) != null) { i = r.start+1; S mainType = tok.get(i); S altType = joinSubList(tok, i+4, r.end-3); S argName = tok.get(r.end-2); S converter = "asList"; S expr = converter + "(" + argName + ")"; tok_expandMultiTypeArgument(tok, i, r.end, argName, mainType, altType, expr); } }
Began life as a copy of #1031905
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
Snippet ID: | #1032173 |
Snippet name: | tok_multiTypeArguments_v2 [certain multi-typed arguments for functions, run after most JavaX translations, LIVE] |
Eternal ID of this version: | #1032173/36 |
Text MD5: | e1bb6231943cf0303950d48ea79fbd0f |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-12-17 15:01:08 |
Source code size: | 3790 bytes / 111 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 338 / 530 |
Version history: | 35 change(s) |
Referenced in: | [show references] |