remove external_type_uuid macro (#4018)

# Objective

- Macro `external_type_uuid` seems unused
- https://docs.rs/bevy/latest/bevy/reflect/macro.external_type_uuid.html

## Solution

- Remove it and see if it was? There is a derive for the same trait that is used everywhere (`#[derive(TypeUuid)]`) and is a better api
This commit is contained in:
François 2022-02-22 23:21:39 +00:00
parent e4203c3925
commit b3a2cbbc98
2 changed files with 1 additions and 41 deletions

View file

@ -732,11 +732,6 @@ pub fn type_uuid_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStre
type_uuid::type_uuid_derive(input)
}
#[proc_macro]
pub fn external_type_uuid(tokens: proc_macro::TokenStream) -> proc_macro::TokenStream {
type_uuid::external_type_uuid(tokens)
}
#[proc_macro_attribute]
pub fn reflect_trait(args: TokenStream, input: TokenStream) -> TokenStream {
reflect_trait::reflect_trait(&args, input)

View file

@ -2,7 +2,7 @@ extern crate proc_macro;
use bevy_macro_utils::BevyManifest;
use quote::{quote, ToTokens};
use syn::{parse::*, *};
use syn::*;
use uuid::Uuid;
pub fn type_uuid_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
@ -65,38 +65,3 @@ pub fn type_uuid_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStre
};
gen.into()
}
struct ExternalDeriveInput {
path: ExprPath,
uuid_str: LitStr,
}
impl Parse for ExternalDeriveInput {
fn parse(input: ParseStream) -> Result<Self> {
let path = input.parse()?;
input.parse::<Token![,]>()?;
let uuid_str = input.parse()?;
Ok(Self { path, uuid_str })
}
}
pub fn external_type_uuid(tokens: proc_macro::TokenStream) -> proc_macro::TokenStream {
let ExternalDeriveInput { path, uuid_str } = parse_macro_input!(tokens as ExternalDeriveInput);
let uuid = Uuid::parse_str(&uuid_str.value()).expect("Value was not a valid UUID.");
let bytes = uuid
.as_bytes()
.iter()
.map(|byte| format!("{:#X}", byte))
.map(|byte_str| syn::parse_str::<LitInt>(&byte_str).unwrap());
let gen = quote! {
impl crate::TypeUuid for #path {
const TYPE_UUID: Uuid = uuid::Uuid::from_bytes([
#( #bytes ),*
]);
}
};
gen.into()
}