< prev index next >

make/jdk/src/classes/build/tools/generateemojidata/GenerateEmojiData.java

Print this page

        

*** 65,96 **** } list.add(r); }, ArrayList<Range>::addAll); - // make the code point conditions ! // only very few codepoints below 0x2000 are "emojis", so separate them ! // out to generate a fast-path check that can be efficiently inlined ! String lowExtPictCodePoints = extPictRanges.stream() ! .takeWhile(r -> r.last < 0x2000) ! .map(r -> rangeToString(r)) ! .collect(Collectors.joining(" ||\n", "", ";\n")); ! ! String highExtPictCodePoints = extPictRanges.stream() ! .dropWhile(r -> r.last < 0x2000) ! .map(r -> rangeToString(r)) ! .collect(Collectors.joining(" ||\n", "", ";\n")); // Generate EmojiData.java file Files.write(Paths.get(args[2]), Files.lines(Paths.get(args[0])) .flatMap(l -> { ! if (l.equals("%%%EXTPICT_LOW%%%")) { ! return Stream.of(lowExtPictCodePoints); ! } else if (l.equals("%%%EXTPICT_HIGH%%%")) { ! return Stream.of(highExtPictCodePoints); } else { return Stream.of(l); } }) .collect(Collectors.toList()), --- 65,95 ---- } list.add(r); }, ArrayList<Range>::addAll); // make the code point conditions ! String extPictCodePoints = extPictRanges.stream() ! .map(r -> { ! if (r.start == r.last) { ! return (" ".repeat(12) + "cp == 0x" + toHexString(r.start)); ! } else if (r.start == r.last - 1) { ! return " ".repeat(12) + "cp == 0x" + toHexString(r.start) + " ||\n" + ! " ".repeat(12) + "cp == 0x" + toHexString(r.last); ! } else { ! return " ".repeat(11) + "(cp >= 0x" + toHexString(r.start) + ! " && cp <= 0x" + toHexString(r.last) + ")"; ! } ! }) ! .collect(Collectors.joining(" ||\n")) + ";\n"; // Generate EmojiData.java file Files.write(Paths.get(args[2]), Files.lines(Paths.get(args[0])) .flatMap(l -> { ! if (l.equals("%%%EXTPICT%%%")) { ! return Stream.of(extPictCodePoints); } else { return Stream.of(l); } }) .collect(Collectors.toList()),
*** 98,119 **** } catch (IOException e) { e.printStackTrace(); } } - static String rangeToString(Range r) { - if (r.start == r.last) { - return (" ".repeat(16) + "cp == 0x" + toHexString(r.start)); - } else if (r.start == r.last - 1) { - return " ".repeat(16) + "cp == 0x" + toHexString(r.start) + " ||\n" + - " ".repeat(16) + "cp == 0x" + toHexString(r.last); - } else { - return " ".repeat(15) + "(cp >= 0x" + toHexString(r.start) + - " && cp <= 0x" + toHexString(r.last) + ")"; - } - } - static int toInt(String hexStr) { return Integer.parseUnsignedInt(hexStr, 16); } static String toHexString(int cp) { --- 97,106 ----
< prev index next >