Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull out static generated file heading into one string literal #16

Merged
merged 1 commit into from Oct 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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