Skip to content

Commit

Permalink
Merge pull request #16 from dtolnay/write
Browse files Browse the repository at this point in the history
Pull out static generated file heading into one string literal
  • Loading branch information
dtolnay committed Oct 8, 2022
2 parents a040895 + 9150ce2 commit 38acd92
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions generate/src/write.rs
@@ -1,30 +1,25 @@
use crate::output::Output;
use crate::{is_xid_continue, is_xid_start, CHUNK};

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);
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
writeln!(out, "const T: bool = true;");
writeln!(out, "const F: bool = false;");
writeln!(out);
const T: bool = true;
const F: bool = false;
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);
#[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, "{}", HEAD);

writeln!(
out,
Expand Down

0 comments on commit 38acd92

Please sign in to comment.