From 19e0a0527b1ccb103398df25fe52a12b0714d30d Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Thu, 22 Jul 2021 18:43:27 +0100 Subject: [PATCH] Use syn crate rather than litrs --- agb-image-converter/Cargo.lock | 11 +---------- agb-image-converter/Cargo.toml | 2 +- agb-image-converter/src/lib.rs | 10 +++------- agb/Cargo.lock | 11 +---------- 4 files changed, 6 insertions(+), 28 deletions(-) diff --git a/agb-image-converter/Cargo.lock b/agb-image-converter/Cargo.lock index a90c496a..fb990437 100644 --- a/agb-image-converter/Cargo.lock +++ b/agb-image-converter/Cargo.lock @@ -13,8 +13,8 @@ name = "agb_image_converter" version = "0.4.0" dependencies = [ "image", - "litrs", "serde", + "syn", "toml", ] @@ -88,15 +88,6 @@ dependencies = [ "png", ] -[[package]] -name = "litrs" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9275e0933cf8bb20f008924c0cb07a0692fe54d8064996520bf998de9eb79aa" -dependencies = [ - "proc-macro2", -] - [[package]] name = "miniz_oxide" version = "0.3.7" diff --git a/agb-image-converter/Cargo.toml b/agb-image-converter/Cargo.toml index c8e15621..95326b63 100644 --- a/agb-image-converter/Cargo.toml +++ b/agb-image-converter/Cargo.toml @@ -13,4 +13,4 @@ proc-macro = true image = { version = "0.23.14", default-features = false, features = [ "png", "bmp" ] } toml = "0.5.8" serde = { version = "1.0", features = ["derive"] } -litrs = "0.2.3" \ No newline at end of file +syn = "1.0.73" \ No newline at end of file diff --git a/agb-image-converter/src/lib.rs b/agb-image-converter/src/lib.rs index 797df419..cad79bae 100644 --- a/agb-image-converter/src/lib.rs +++ b/agb-image-converter/src/lib.rs @@ -1,7 +1,6 @@ -use litrs::StringLit; use proc_macro::TokenStream; +use syn::parse_macro_input; -use std::convert::TryFrom; use std::fmt::Write; use std::path::Path; @@ -32,12 +31,9 @@ impl TileSize { #[proc_macro] pub fn include_gfx(input: TokenStream) -> TokenStream { - let first_token = input.into_iter().next().expect("no input"); + let input = parse_macro_input!(input as syn::LitStr); - let filename = match StringLit::try_from(first_token) { - Err(e) => return e.to_compile_error(), - Ok(filename) => filename.into_value(), - }; + let filename = input.value(); let root = std::env::var("CARGO_MANIFEST_DIR").expect("Failed to get cargo manifest dir"); let path = Path::new(&root).join(&*filename); diff --git a/agb/Cargo.lock b/agb/Cargo.lock index bd2fd9a1..aa2dd606 100644 --- a/agb/Cargo.lock +++ b/agb/Cargo.lock @@ -21,8 +21,8 @@ name = "agb_image_converter" version = "0.4.0" dependencies = [ "image", - "litrs", "serde", + "syn", "toml", ] @@ -96,15 +96,6 @@ dependencies = [ "png", ] -[[package]] -name = "litrs" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9275e0933cf8bb20f008924c0cb07a0692fe54d8064996520bf998de9eb79aa" -dependencies = [ - "proc-macro2", -] - [[package]] name = "miniz_oxide" version = "0.3.7"