Merge pull request #16 from dtolnay/write

Pull out static generated file heading into one string literal
This commit is contained in:
David Tolnay 2022-10-08 12:23:24 -07:00 committed by GitHub
commit 38acd92a4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,30 +1,25 @@
use crate::output::Output;
use crate::{is_xid_continue, is_xid_start, CHUNK};
const HEAD: &str = "\
// \x40generated by ../generate. To regenerate, run the following in the repo root:
//
// $ curl -LO https://www.unicode.org/Public/zipped/14.0.0/UCD.zip
// $ unzip UCD.zip -d UCD
// $ cargo run --manifest-path generate/Cargo.toml
const T: bool = true;
const F: bool = false;
#[repr(C, align(8))]
pub(crate) struct Align8<T>(pub(crate) T);
#[repr(C, align(64))]
pub(crate) struct Align64<T>(pub(crate) T);
";
pub fn output(index_start: &[u8], index_continue: &[u8], halfdense: &[u8]) -> Output {
let mut out = Output::new();
writeln!(
out,
"// \x40generated by ../generate. To regenerate, run the following in the repo root:",
);
writeln!(out, "//");
writeln!(
out,
"// $ curl -LO https://www.unicode.org/Public/zipped/14.0.0/UCD.zip",
);
writeln!(out, "// $ unzip UCD.zip -d UCD");
writeln!(out, "// $ cargo run --manifest-path generate/Cargo.toml");
writeln!(out);
writeln!(out, "const T: bool = true;");
writeln!(out, "const F: bool = false;");
writeln!(out);
writeln!(out, "#[repr(C, align(8))]");
writeln!(out, "pub(crate) struct Align8<T>(pub(crate) T);");
writeln!(out, "#[repr(C, align(64))]");
writeln!(out, "pub(crate) struct Align64<T>(pub(crate) T);");
writeln!(out);
writeln!(out, "{}", HEAD);
writeln!(
out,