Rollup merge of #66889 - dtolnay:fmt6, r=rkruppe
Make python-generated source files compatible with rustfmt This PR adjusts the generators for src/libcore/num/dec2flt/table.rs, src/libcore/unicode/printable.rs, and src/libcore/unicode/tables.rs to make it so running `rustfmt` on the generated files no longer needs to apply any changes. This involves tweaking the python scripts where reasonable to better match rustfmt's style, and adding `#[rustfmt::skip]` to big constant tables that there's no point having rustfmt rewrap. r? @Dylan-DPC
This commit is contained in:
11
src/etc/dec2flt_table.py
Normal file → Executable file
11
src/etc/dec2flt_table.py
Normal file → Executable file
@@ -111,14 +111,18 @@ def print_proper_powers():
|
|||||||
print("pub const MIN_E: i16 = {};".format(MIN_E))
|
print("pub const MIN_E: i16 = {};".format(MIN_E))
|
||||||
print("pub const MAX_E: i16 = {};".format(MAX_E))
|
print("pub const MAX_E: i16 = {};".format(MAX_E))
|
||||||
print()
|
print()
|
||||||
|
print("#[rustfmt::skip]")
|
||||||
typ = "([u64; {0}], [i16; {0}])".format(len(powers))
|
typ = "([u64; {0}], [i16; {0}])".format(len(powers))
|
||||||
print("pub const POWERS: ", typ, " = ([", sep='')
|
print("pub const POWERS: ", typ, " = (", sep='')
|
||||||
|
print(" [")
|
||||||
for z in powers:
|
for z in powers:
|
||||||
print(" 0x{:x},".format(z.sig))
|
print(" 0x{:x},".format(z.sig))
|
||||||
print("], [")
|
print(" ],")
|
||||||
|
print(" [")
|
||||||
for z in powers:
|
for z in powers:
|
||||||
print(" {},".format(z.exp))
|
print(" {},".format(z.exp))
|
||||||
print("]);")
|
print(" ],")
|
||||||
|
print(");")
|
||||||
|
|
||||||
|
|
||||||
def print_short_powers(num_bits, significand_size):
|
def print_short_powers(num_bits, significand_size):
|
||||||
@@ -127,6 +131,7 @@ def print_short_powers(num_bits, significand_size):
|
|||||||
max_e = int(ceil(log(max_sig, 5)))
|
max_e = int(ceil(log(max_sig, 5)))
|
||||||
e_range = range(max_e)
|
e_range = range(max_e)
|
||||||
typ = "[f{}; {}]".format(num_bits, len(e_range))
|
typ = "[f{}; {}]".format(num_bits, len(e_range))
|
||||||
|
print("#[rustfmt::skip]")
|
||||||
print("pub const F", num_bits, "_SHORT_POWERS: ", typ, " = [", sep='')
|
print("pub const F", num_bits, "_SHORT_POWERS: ", typ, " = [", sep='')
|
||||||
for e in e_range:
|
for e in e_range:
|
||||||
print(" 1e{},".format(e))
|
print(" 1e{},".format(e))
|
||||||
|
|||||||
@@ -4,7 +4,9 @@
|
|||||||
pub const MIN_E: i16 = -305;
|
pub const MIN_E: i16 = -305;
|
||||||
pub const MAX_E: i16 = 305;
|
pub const MAX_E: i16 = 305;
|
||||||
|
|
||||||
pub const POWERS: ([u64; 611], [i16; 611]) = ([
|
#[rustfmt::skip]
|
||||||
|
pub const POWERS: ([u64; 611], [i16; 611]) = (
|
||||||
|
[
|
||||||
0xe0b62e2929aba83c,
|
0xe0b62e2929aba83c,
|
||||||
0x8c71dcd9ba0b4926,
|
0x8c71dcd9ba0b4926,
|
||||||
0xaf8e5410288e1b6f,
|
0xaf8e5410288e1b6f,
|
||||||
@@ -616,7 +618,8 @@ pub const POWERS: ([u64; 611], [i16; 611]) = ([
|
|||||||
0xbaa718e68396cffe,
|
0xbaa718e68396cffe,
|
||||||
0xe950df20247c83fd,
|
0xe950df20247c83fd,
|
||||||
0x91d28b7416cdd27e,
|
0x91d28b7416cdd27e,
|
||||||
], [
|
],
|
||||||
|
[
|
||||||
-1077,
|
-1077,
|
||||||
-1073,
|
-1073,
|
||||||
-1070,
|
-1070,
|
||||||
@@ -1228,8 +1231,10 @@ pub const POWERS: ([u64; 611], [i16; 611]) = ([
|
|||||||
943,
|
943,
|
||||||
946,
|
946,
|
||||||
950,
|
950,
|
||||||
]);
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
pub const F32_SHORT_POWERS: [f32; 11] = [
|
pub const F32_SHORT_POWERS: [f32; 11] = [
|
||||||
1e0,
|
1e0,
|
||||||
1e1,
|
1e1,
|
||||||
@@ -1244,6 +1249,7 @@ pub const F32_SHORT_POWERS: [f32; 11] = [
|
|||||||
1e10,
|
1e10,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
pub const F64_SHORT_POWERS: [f64; 23] = [
|
pub const F64_SHORT_POWERS: [f64; 23] = [
|
||||||
1e0,
|
1e0,
|
||||||
1e1,
|
1e1,
|
||||||
|
|||||||
6
src/libcore/unicode/printable.py
Normal file → Executable file
6
src/libcore/unicode/printable.py
Normal file → Executable file
@@ -111,16 +111,19 @@ def compress_normal(normal):
|
|||||||
return compressed
|
return compressed
|
||||||
|
|
||||||
def print_singletons(uppers, lowers, uppersname, lowersname):
|
def print_singletons(uppers, lowers, uppersname, lowersname):
|
||||||
|
print("#[rustfmt::skip]")
|
||||||
print("const {}: &[(u8, u8)] = &[".format(uppersname))
|
print("const {}: &[(u8, u8)] = &[".format(uppersname))
|
||||||
for u, c in uppers:
|
for u, c in uppers:
|
||||||
print(" ({:#04x}, {}),".format(u, c))
|
print(" ({:#04x}, {}),".format(u, c))
|
||||||
print("];")
|
print("];")
|
||||||
|
print("#[rustfmt::skip]")
|
||||||
print("const {}: &[u8] = &[".format(lowersname))
|
print("const {}: &[u8] = &[".format(lowersname))
|
||||||
for i in range(0, len(lowers), 8):
|
for i in range(0, len(lowers), 8):
|
||||||
print(" {}".format(" ".join("{:#04x},".format(l) for l in lowers[i:i+8])))
|
print(" {}".format(" ".join("{:#04x},".format(l) for l in lowers[i:i+8])))
|
||||||
print("];")
|
print("];")
|
||||||
|
|
||||||
def print_normal(normal, normalname):
|
def print_normal(normal, normalname):
|
||||||
|
print("#[rustfmt::skip]")
|
||||||
print("const {}: &[u8] = &[".format(normalname))
|
print("const {}: &[u8] = &[".format(normalname))
|
||||||
for v in normal:
|
for v in normal:
|
||||||
print(" {}".format(" ".join("{:#04x},".format(i) for i in v)))
|
print(" {}".format(" ".join("{:#04x},".format(i) for i in v)))
|
||||||
@@ -170,8 +173,7 @@ def main():
|
|||||||
// NOTE: The following code was generated by "src/libcore/unicode/printable.py",
|
// NOTE: The following code was generated by "src/libcore/unicode/printable.py",
|
||||||
// do not edit directly!
|
// do not edit directly!
|
||||||
|
|
||||||
fn check(x: u16, singletonuppers: &[(u8, u8)], singletonlowers: &[u8],
|
fn check(x: u16, singletonuppers: &[(u8, u8)], singletonlowers: &[u8], normal: &[u8]) -> bool {
|
||||||
normal: &[u8]) -> bool {
|
|
||||||
let xupper = (x >> 8) as u8;
|
let xupper = (x >> 8) as u8;
|
||||||
let mut lowerstart = 0;
|
let mut lowerstart = 0;
|
||||||
for &(upper, lowercount) in singletonuppers {
|
for &(upper, lowercount) in singletonuppers {
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
// NOTE: The following code was generated by "src/libcore/unicode/printable.py",
|
// NOTE: The following code was generated by "src/libcore/unicode/printable.py",
|
||||||
// do not edit directly!
|
// do not edit directly!
|
||||||
|
|
||||||
fn check(x: u16, singletonuppers: &[(u8, u8)], singletonlowers: &[u8],
|
fn check(x: u16, singletonuppers: &[(u8, u8)], singletonlowers: &[u8], normal: &[u8]) -> bool {
|
||||||
normal: &[u8]) -> bool {
|
|
||||||
let xupper = (x >> 8) as u8;
|
let xupper = (x >> 8) as u8;
|
||||||
let mut lowerstart = 0;
|
let mut lowerstart = 0;
|
||||||
for &(upper, lowercount) in singletonuppers {
|
for &(upper, lowercount) in singletonuppers {
|
||||||
@@ -70,6 +69,7 @@ pub(crate) fn is_printable(x: char) -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
const SINGLETONS0U: &[(u8, u8)] = &[
|
const SINGLETONS0U: &[(u8, u8)] = &[
|
||||||
(0x00, 1),
|
(0x00, 1),
|
||||||
(0x03, 5),
|
(0x03, 5),
|
||||||
@@ -113,6 +113,7 @@ const SINGLETONS0U: &[(u8, u8)] = &[
|
|||||||
(0xfe, 3),
|
(0xfe, 3),
|
||||||
(0xff, 9),
|
(0xff, 9),
|
||||||
];
|
];
|
||||||
|
#[rustfmt::skip]
|
||||||
const SINGLETONS0L: &[u8] = &[
|
const SINGLETONS0L: &[u8] = &[
|
||||||
0xad, 0x78, 0x79, 0x8b, 0x8d, 0xa2, 0x30, 0x57,
|
0xad, 0x78, 0x79, 0x8b, 0x8d, 0xa2, 0x30, 0x57,
|
||||||
0x58, 0x8b, 0x8c, 0x90, 0x1c, 0x1d, 0xdd, 0x0e,
|
0x58, 0x8b, 0x8c, 0x90, 0x1c, 0x1d, 0xdd, 0x0e,
|
||||||
@@ -152,6 +153,7 @@ const SINGLETONS0L: &[u8] = &[
|
|||||||
0xff, 0x53, 0x67, 0x75, 0xc8, 0xc9, 0xd0, 0xd1,
|
0xff, 0x53, 0x67, 0x75, 0xc8, 0xc9, 0xd0, 0xd1,
|
||||||
0xd8, 0xd9, 0xe7, 0xfe, 0xff,
|
0xd8, 0xd9, 0xe7, 0xfe, 0xff,
|
||||||
];
|
];
|
||||||
|
#[rustfmt::skip]
|
||||||
const SINGLETONS1U: &[(u8, u8)] = &[
|
const SINGLETONS1U: &[(u8, u8)] = &[
|
||||||
(0x00, 6),
|
(0x00, 6),
|
||||||
(0x01, 1),
|
(0x01, 1),
|
||||||
@@ -189,6 +191,7 @@ const SINGLETONS1U: &[(u8, u8)] = &[
|
|||||||
(0xf9, 6),
|
(0xf9, 6),
|
||||||
(0xfa, 2),
|
(0xfa, 2),
|
||||||
];
|
];
|
||||||
|
#[rustfmt::skip]
|
||||||
const SINGLETONS1L: &[u8] = &[
|
const SINGLETONS1L: &[u8] = &[
|
||||||
0x0c, 0x27, 0x3b, 0x3e, 0x4e, 0x4f, 0x8f, 0x9e,
|
0x0c, 0x27, 0x3b, 0x3e, 0x4e, 0x4f, 0x8f, 0x9e,
|
||||||
0x9e, 0x9f, 0x06, 0x07, 0x09, 0x36, 0x3d, 0x3e,
|
0x9e, 0x9f, 0x06, 0x07, 0x09, 0x36, 0x3d, 0x3e,
|
||||||
@@ -212,6 +215,7 @@ const SINGLETONS1L: &[u8] = &[
|
|||||||
0xa4, 0xaa, 0xaf, 0xb0, 0xc0, 0xd0, 0x0c, 0x72,
|
0xa4, 0xaa, 0xaf, 0xb0, 0xc0, 0xd0, 0x0c, 0x72,
|
||||||
0xa3, 0xa4, 0xcb, 0xcc, 0x6e, 0x6f,
|
0xa3, 0xa4, 0xcb, 0xcc, 0x6e, 0x6f,
|
||||||
];
|
];
|
||||||
|
#[rustfmt::skip]
|
||||||
const NORMAL0: &[u8] = &[
|
const NORMAL0: &[u8] = &[
|
||||||
0x00, 0x20,
|
0x00, 0x20,
|
||||||
0x5f, 0x22,
|
0x5f, 0x22,
|
||||||
@@ -355,6 +359,7 @@ const NORMAL0: &[u8] = &[
|
|||||||
0x1b, 0x03,
|
0x1b, 0x03,
|
||||||
0x0f, 0x0d,
|
0x0f, 0x0d,
|
||||||
];
|
];
|
||||||
|
#[rustfmt::skip]
|
||||||
const NORMAL1: &[u8] = &[
|
const NORMAL1: &[u8] = &[
|
||||||
0x5e, 0x22,
|
0x5e, 0x22,
|
||||||
0x7b, 0x05,
|
0x7b, 0x05,
|
||||||
|
|||||||
@@ -2,19 +2,16 @@
|
|||||||
|
|
||||||
#![allow(missing_docs, non_upper_case_globals, non_snake_case, clippy::unreadable_literal)]
|
#![allow(missing_docs, non_upper_case_globals, non_snake_case, clippy::unreadable_literal)]
|
||||||
|
|
||||||
use crate::unicode::version::UnicodeVersion;
|
|
||||||
use crate::unicode::bool_trie::{BoolTrie, SmallBoolTrie};
|
use crate::unicode::bool_trie::{BoolTrie, SmallBoolTrie};
|
||||||
|
use crate::unicode::version::UnicodeVersion;
|
||||||
|
|
||||||
/// The version of [Unicode](http://www.unicode.org/) that the Unicode parts of
|
/// The version of [Unicode](http://www.unicode.org/) that the Unicode parts of
|
||||||
/// `char` and `str` methods are based on.
|
/// `char` and `str` methods are based on.
|
||||||
#[unstable(feature = "unicode_version", issue = "49726")]
|
#[unstable(feature = "unicode_version", issue = "49726")]
|
||||||
pub const UNICODE_VERSION: UnicodeVersion = UnicodeVersion {
|
pub const UNICODE_VERSION: UnicodeVersion =
|
||||||
major: 12,
|
UnicodeVersion { major: 12, minor: 1, micro: 0, _priv: () };
|
||||||
minor: 1,
|
|
||||||
micro: 0,
|
|
||||||
_priv: (),
|
|
||||||
};
|
|
||||||
pub(crate) mod general_category {
|
pub(crate) mod general_category {
|
||||||
|
#[rustfmt::skip]
|
||||||
const Cc_table: &super::SmallBoolTrie = &super::SmallBoolTrie {
|
const Cc_table: &super::SmallBoolTrie = &super::SmallBoolTrie {
|
||||||
r1: &[
|
r1: &[
|
||||||
0, 1, 0
|
0, 1, 0
|
||||||
@@ -28,6 +25,7 @@ pub(crate) mod general_category {
|
|||||||
Cc_table.lookup(c)
|
Cc_table.lookup(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
const N_table: &super::BoolTrie = &super::BoolTrie {
|
const N_table: &super::BoolTrie = &super::BoolTrie {
|
||||||
r1: [
|
r1: [
|
||||||
0x03ff000000000000, 0x0000000000000000, 0x720c000000000000, 0x0000000000000000,
|
0x03ff000000000000, 0x0000000000000000, 0x720c000000000000, 0x0000000000000000,
|
||||||
@@ -138,10 +136,10 @@ pub(crate) mod general_category {
|
|||||||
pub fn N(c: char) -> bool {
|
pub fn N(c: char) -> bool {
|
||||||
N_table.lookup(c)
|
N_table.lookup(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) mod derived_property {
|
pub(crate) mod derived_property {
|
||||||
|
#[rustfmt::skip]
|
||||||
const Alphabetic_table: &super::BoolTrie = &super::BoolTrie {
|
const Alphabetic_table: &super::BoolTrie = &super::BoolTrie {
|
||||||
r1: [
|
r1: [
|
||||||
0x0000000000000000, 0x07fffffe07fffffe, 0x0420040000000000, 0xff7fffffff7fffff,
|
0x0000000000000000, 0x07fffffe07fffffe, 0x0420040000000000, 0xff7fffffff7fffff,
|
||||||
@@ -327,6 +325,7 @@ pub(crate) mod derived_property {
|
|||||||
Alphabetic_table.lookup(c)
|
Alphabetic_table.lookup(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
const Case_Ignorable_table: &super::BoolTrie = &super::BoolTrie {
|
const Case_Ignorable_table: &super::BoolTrie = &super::BoolTrie {
|
||||||
r1: [
|
r1: [
|
||||||
0x0400408000000000, 0x0000000140000000, 0x0190a10000000000, 0x0000000000000000,
|
0x0400408000000000, 0x0000000140000000, 0x0190a10000000000, 0x0000000000000000,
|
||||||
@@ -464,6 +463,7 @@ pub(crate) mod derived_property {
|
|||||||
Case_Ignorable_table.lookup(c)
|
Case_Ignorable_table.lookup(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
const Cased_table: &super::BoolTrie = &super::BoolTrie {
|
const Cased_table: &super::BoolTrie = &super::BoolTrie {
|
||||||
r1: [
|
r1: [
|
||||||
0x0000000000000000, 0x07fffffe07fffffe, 0x0420040000000000, 0xff7fffffff7fffff,
|
0x0000000000000000, 0x07fffffe07fffffe, 0x0420040000000000, 0xff7fffffff7fffff,
|
||||||
@@ -565,6 +565,7 @@ pub(crate) mod derived_property {
|
|||||||
Cased_table.lookup(c)
|
Cased_table.lookup(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
const Grapheme_Extend_table: &super::BoolTrie = &super::BoolTrie {
|
const Grapheme_Extend_table: &super::BoolTrie = &super::BoolTrie {
|
||||||
r1: [
|
r1: [
|
||||||
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
|
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
|
||||||
@@ -689,6 +690,7 @@ pub(crate) mod derived_property {
|
|||||||
Grapheme_Extend_table.lookup(c)
|
Grapheme_Extend_table.lookup(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
const Lowercase_table: &super::BoolTrie = &super::BoolTrie {
|
const Lowercase_table: &super::BoolTrie = &super::BoolTrie {
|
||||||
r1: [
|
r1: [
|
||||||
0x0000000000000000, 0x07fffffe00000000, 0x0420040000000000, 0xff7fffff80000000,
|
0x0000000000000000, 0x07fffffe00000000, 0x0420040000000000, 0xff7fffff80000000,
|
||||||
@@ -789,6 +791,7 @@ pub(crate) mod derived_property {
|
|||||||
Lowercase_table.lookup(c)
|
Lowercase_table.lookup(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
const Uppercase_table: &super::BoolTrie = &super::BoolTrie {
|
const Uppercase_table: &super::BoolTrie = &super::BoolTrie {
|
||||||
r1: [
|
r1: [
|
||||||
0x0000000000000000, 0x0000000007fffffe, 0x0000000000000000, 0x000000007f7fffff,
|
0x0000000000000000, 0x0000000007fffffe, 0x0000000000000000, 0x000000007f7fffff,
|
||||||
@@ -889,10 +892,10 @@ pub(crate) mod derived_property {
|
|||||||
pub fn Uppercase(c: char) -> bool {
|
pub fn Uppercase(c: char) -> bool {
|
||||||
Uppercase_table.lookup(c)
|
Uppercase_table.lookup(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) mod property {
|
pub(crate) mod property {
|
||||||
|
#[rustfmt::skip]
|
||||||
const White_Space_table: &super::SmallBoolTrie = &super::SmallBoolTrie {
|
const White_Space_table: &super::SmallBoolTrie = &super::SmallBoolTrie {
|
||||||
r1: &[
|
r1: &[
|
||||||
0, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
0, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
@@ -912,7 +915,6 @@ pub(crate) mod property {
|
|||||||
pub fn White_Space(c: char) -> bool {
|
pub fn White_Space(c: char) -> bool {
|
||||||
White_Space_table.lookup(c)
|
White_Space_table.lookup(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) mod conversions {
|
pub(crate) mod conversions {
|
||||||
@@ -934,6 +936,7 @@ pub(crate) mod conversions {
|
|||||||
table.binary_search_by(|&(key, _)| key.cmp(&c)).ok()
|
table.binary_search_by(|&(key, _)| key.cmp(&c)).ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
const to_lowercase_table: &[(char, [char; 3])] = &[
|
const to_lowercase_table: &[(char, [char; 3])] = &[
|
||||||
('\u{41}', ['\u{61}', '\0', '\0']), ('\u{42}', ['\u{62}', '\0', '\0']), ('\u{43}',
|
('\u{41}', ['\u{61}', '\0', '\0']), ('\u{42}', ['\u{62}', '\0', '\0']), ('\u{43}',
|
||||||
['\u{63}', '\0', '\0']), ('\u{44}', ['\u{64}', '\0', '\0']), ('\u{45}', ['\u{65}', '\0',
|
['\u{63}', '\0', '\0']), ('\u{44}', ['\u{64}', '\0', '\0']), ('\u{45}', ['\u{65}', '\0',
|
||||||
@@ -1558,6 +1561,7 @@ pub(crate) mod conversions {
|
|||||||
('\u{1e920}', ['\u{1e942}', '\0', '\0']), ('\u{1e921}', ['\u{1e943}', '\0', '\0'])
|
('\u{1e920}', ['\u{1e942}', '\0', '\0']), ('\u{1e921}', ['\u{1e943}', '\0', '\0'])
|
||||||
];
|
];
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
const to_uppercase_table: &[(char, [char; 3])] = &[
|
const to_uppercase_table: &[(char, [char; 3])] = &[
|
||||||
('\u{61}', ['\u{41}', '\0', '\0']), ('\u{62}', ['\u{42}', '\0', '\0']), ('\u{63}',
|
('\u{61}', ['\u{41}', '\0', '\0']), ('\u{62}', ['\u{42}', '\0', '\0']), ('\u{63}',
|
||||||
['\u{43}', '\0', '\0']), ('\u{64}', ['\u{44}', '\0', '\0']), ('\u{65}', ['\u{45}', '\0',
|
['\u{43}', '\0', '\0']), ('\u{64}', ['\u{44}', '\0', '\0']), ('\u{65}', ['\u{45}', '\0',
|
||||||
@@ -2228,5 +2232,4 @@ pub(crate) mod conversions {
|
|||||||
('\u{1e940}', ['\u{1e91e}', '\0', '\0']), ('\u{1e941}', ['\u{1e91f}', '\0', '\0']),
|
('\u{1e940}', ['\u{1e91e}', '\0', '\0']), ('\u{1e941}', ['\u{1e91f}', '\0', '\0']),
|
||||||
('\u{1e942}', ['\u{1e920}', '\0', '\0']), ('\u{1e943}', ['\u{1e921}', '\0', '\0'])
|
('\u{1e942}', ['\u{1e920}', '\0', '\0']), ('\u{1e943}', ['\u{1e921}', '\0', '\0'])
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ PREAMBLE = """\
|
|||||||
|
|
||||||
#![allow(missing_docs, non_upper_case_globals, non_snake_case, clippy::unreadable_literal)]
|
#![allow(missing_docs, non_upper_case_globals, non_snake_case, clippy::unreadable_literal)]
|
||||||
|
|
||||||
use crate::unicode::version::UnicodeVersion;
|
|
||||||
use crate::unicode::bool_trie::{{BoolTrie, SmallBoolTrie}};
|
use crate::unicode::bool_trie::{{BoolTrie, SmallBoolTrie}};
|
||||||
|
use crate::unicode::version::UnicodeVersion;
|
||||||
""".format(year=datetime.datetime.now().year)
|
""".format(year=datetime.datetime.now().year)
|
||||||
|
|
||||||
# Mapping taken from Table 12 from:
|
# Mapping taken from Table 12 from:
|
||||||
@@ -555,6 +555,8 @@ def generate_table(
|
|||||||
if is_pub:
|
if is_pub:
|
||||||
pub_string = "pub "
|
pub_string = "pub "
|
||||||
|
|
||||||
|
yield "\n"
|
||||||
|
yield " #[rustfmt::skip]\n"
|
||||||
yield " %sconst %s: %s = &[\n" % (pub_string, name, decl_type)
|
yield " %sconst %s: %s = &[\n" % (pub_string, name, decl_type)
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
@@ -568,7 +570,7 @@ def generate_table(
|
|||||||
for table_line in generate_table_lines("".join(data).split(","), 8):
|
for table_line in generate_table_lines("".join(data).split(","), 8):
|
||||||
yield table_line
|
yield table_line
|
||||||
|
|
||||||
yield "\n ];\n\n"
|
yield "\n ];\n"
|
||||||
|
|
||||||
|
|
||||||
def compute_trie(raw_data, chunk_size):
|
def compute_trie(raw_data, chunk_size):
|
||||||
@@ -634,6 +636,9 @@ def generate_bool_trie(name, codepoint_ranges, is_pub=False):
|
|||||||
pub_string = ""
|
pub_string = ""
|
||||||
if is_pub:
|
if is_pub:
|
||||||
pub_string = "pub "
|
pub_string = "pub "
|
||||||
|
|
||||||
|
yield "\n"
|
||||||
|
yield " #[rustfmt::skip]\n"
|
||||||
yield " %sconst %s: &super::BoolTrie = &super::BoolTrie {\n" % (pub_string, name)
|
yield " %sconst %s: &super::BoolTrie = &super::BoolTrie {\n" % (pub_string, name)
|
||||||
yield " r1: [\n"
|
yield " r1: [\n"
|
||||||
data = ("0x%016x" % chunk for chunk in chunks[:0x800 // chunk_size])
|
data = ("0x%016x" % chunk for chunk in chunks[:0x800 // chunk_size])
|
||||||
@@ -678,7 +683,7 @@ def generate_bool_trie(name, codepoint_ranges, is_pub=False):
|
|||||||
yield fragment
|
yield fragment
|
||||||
yield "\n ],\n"
|
yield "\n ],\n"
|
||||||
|
|
||||||
yield " };\n\n"
|
yield " };\n"
|
||||||
|
|
||||||
|
|
||||||
def generate_small_bool_trie(name, codepoint_ranges, is_pub=False):
|
def generate_small_bool_trie(name, codepoint_ranges, is_pub=False):
|
||||||
@@ -700,6 +705,8 @@ def generate_small_bool_trie(name, codepoint_ranges, is_pub=False):
|
|||||||
if is_pub:
|
if is_pub:
|
||||||
pub_string = "pub "
|
pub_string = "pub "
|
||||||
|
|
||||||
|
yield "\n"
|
||||||
|
yield " #[rustfmt::skip]\n"
|
||||||
yield (" %sconst %s: &super::SmallBoolTrie = &super::SmallBoolTrie {\n"
|
yield (" %sconst %s: &super::SmallBoolTrie = &super::SmallBoolTrie {\n"
|
||||||
% (pub_string, name))
|
% (pub_string, name))
|
||||||
|
|
||||||
@@ -717,7 +724,7 @@ def generate_small_bool_trie(name, codepoint_ranges, is_pub=False):
|
|||||||
yield fragment
|
yield fragment
|
||||||
yield "\n ],\n"
|
yield "\n ],\n"
|
||||||
|
|
||||||
yield " };\n\n"
|
yield " };\n"
|
||||||
|
|
||||||
|
|
||||||
def generate_property_module(mod, grouped_categories, category_subset):
|
def generate_property_module(mod, grouped_categories, category_subset):
|
||||||
@@ -726,7 +733,7 @@ def generate_property_module(mod, grouped_categories, category_subset):
|
|||||||
Generate Rust code for module defining properties.
|
Generate Rust code for module defining properties.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
yield "pub(crate) mod %s {\n" % mod
|
yield "pub(crate) mod %s {" % mod
|
||||||
for cat in sorted(category_subset):
|
for cat in sorted(category_subset):
|
||||||
if cat in ("Cc", "White_Space"):
|
if cat in ("Cc", "White_Space"):
|
||||||
generator = generate_small_bool_trie("%s_table" % cat, grouped_categories[cat])
|
generator = generate_small_bool_trie("%s_table" % cat, grouped_categories[cat])
|
||||||
@@ -736,9 +743,10 @@ def generate_property_module(mod, grouped_categories, category_subset):
|
|||||||
for fragment in generator:
|
for fragment in generator:
|
||||||
yield fragment
|
yield fragment
|
||||||
|
|
||||||
|
yield "\n"
|
||||||
yield " pub fn %s(c: char) -> bool {\n" % cat
|
yield " pub fn %s(c: char) -> bool {\n" % cat
|
||||||
yield " %s_table.lookup(c)\n" % cat
|
yield " %s_table.lookup(c)\n" % cat
|
||||||
yield " }\n\n"
|
yield " }\n"
|
||||||
|
|
||||||
yield "}\n\n"
|
yield "}\n\n"
|
||||||
|
|
||||||
@@ -767,7 +775,7 @@ def generate_conversions_module(unicode_data):
|
|||||||
|
|
||||||
fn bsearch_case_table(c: char, table: &[(char, [char; 3])]) -> Option<usize> {
|
fn bsearch_case_table(c: char, table: &[(char, [char; 3])]) -> Option<usize> {
|
||||||
table.binary_search_by(|&(key, _)| key.cmp(&c)).ok()
|
table.binary_search_by(|&(key, _)| key.cmp(&c)).ok()
|
||||||
}\n\n"""
|
}\n"""
|
||||||
|
|
||||||
decl_type = "&[(char, [char; 3])]"
|
decl_type = "&[(char, [char; 3])]"
|
||||||
format_conversion = lambda x: "({},[{},{},{}])".format(*(
|
format_conversion = lambda x: "({},[{},{},{}])".format(*(
|
||||||
@@ -827,13 +835,9 @@ def main():
|
|||||||
/// The version of [Unicode](http://www.unicode.org/) that the Unicode parts of
|
/// The version of [Unicode](http://www.unicode.org/) that the Unicode parts of
|
||||||
/// `char` and `str` methods are based on.
|
/// `char` and `str` methods are based on.
|
||||||
#[unstable(feature = "unicode_version", issue = "49726")]
|
#[unstable(feature = "unicode_version", issue = "49726")]
|
||||||
pub const UNICODE_VERSION: UnicodeVersion = UnicodeVersion {{
|
pub const UNICODE_VERSION: UnicodeVersion =
|
||||||
major: {version.major},
|
UnicodeVersion {{ major: {v.major}, minor: {v.minor}, micro: {v.micro}, _priv: () }};
|
||||||
minor: {version.minor},
|
""").format(v=unicode_version)
|
||||||
micro: {version.micro},
|
|
||||||
_priv: (),
|
|
||||||
}};
|
|
||||||
""").format(version=unicode_version)
|
|
||||||
buf.write(unicode_version_notice)
|
buf.write(unicode_version_notice)
|
||||||
|
|
||||||
get_path = lambda f: get_unicode_file_path(unicode_version, f)
|
get_path = lambda f: get_unicode_file_path(unicode_version, f)
|
||||||
|
|||||||
Reference in New Issue
Block a user