Skip to content

Commit

Permalink
Replace alloc with std
Browse files Browse the repository at this point in the history
  • Loading branch information
elbertronnie committed Nov 25, 2022
1 parent 217785b commit a9a1ae4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 34 deletions.
14 changes: 7 additions & 7 deletions crates/bevy_reflect/bevy_reflect_derive/src/impls/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use syn::Fields;
pub(crate) fn impl_enum(reflect_enum: &ReflectEnum) -> TokenStream {
let option = quote!(::core::option::Option);
let any = quote!(::core::any::Any);
let alloc_box = quote!(::alloc::boxed::Box);
let std_box = quote!(::std::boxed::Box);

let bevy_reflect_path = reflect_enum.meta().bevy_reflect_path();
let enum_name = reflect_enum.meta().type_name();
Expand Down Expand Up @@ -192,7 +192,7 @@ pub(crate) fn impl_enum(reflect_enum: &ReflectEnum) -> TokenStream {
}

#[inline]
fn into_any(self: #alloc_box<Self>) -> #alloc_box<dyn #any> {
fn into_any(self: #std_box<Self>) -> #std_box<dyn #any> {
self
}

Expand All @@ -207,7 +207,7 @@ pub(crate) fn impl_enum(reflect_enum: &ReflectEnum) -> TokenStream {
}

#[inline]
fn into_reflect(self: #alloc_box<Self>) -> #alloc_box<dyn #bevy_reflect_path::Reflect> {
fn into_reflect(self: #std_box<Self>) -> #std_box<dyn #bevy_reflect_path::Reflect> {
self
}

Expand All @@ -222,12 +222,12 @@ pub(crate) fn impl_enum(reflect_enum: &ReflectEnum) -> TokenStream {
}

#[inline]
fn clone_value(&self) -> #alloc_box<dyn #bevy_reflect_path::Reflect> {
#alloc_box::new(#bevy_reflect_path::Enum::clone_dynamic(self))
fn clone_value(&self) -> #std_box<dyn #bevy_reflect_path::Reflect> {
#std_box::new(#bevy_reflect_path::Enum::clone_dynamic(self))
}

#[inline]
fn set(&mut self, #ref_value: #alloc_box<dyn #bevy_reflect_path::Reflect>) -> ::core::result::Result<(), #alloc_box<dyn #bevy_reflect_path::Reflect>> {
fn set(&mut self, #ref_value: #std_box<dyn #bevy_reflect_path::Reflect>) -> ::core::result::Result<(), #std_box<dyn #bevy_reflect_path::Reflect>> {
*self = <dyn #bevy_reflect_path::Reflect>::take(#ref_value)?;
Ok(())
}
Expand Down Expand Up @@ -273,7 +273,7 @@ pub(crate) fn impl_enum(reflect_enum: &ReflectEnum) -> TokenStream {
#bevy_reflect_path::ReflectMut::Enum(self)
}

fn reflect_owned(self: #alloc_box<Self>) -> #bevy_reflect_path::ReflectOwned {
fn reflect_owned(self: #std_box<Self>) -> #bevy_reflect_path::ReflectOwned {
#bevy_reflect_path::ReflectOwned::Enum(self)
}

Expand Down
16 changes: 8 additions & 8 deletions crates/bevy_reflect/bevy_reflect_derive/src/impls/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use syn::{Index, Member};
pub(crate) fn impl_struct(reflect_struct: &ReflectStruct) -> TokenStream {
let option = quote!(::core::option::Option);
let any = quote!(::core::any::Any);
let alloc_box = quote!(::alloc::boxed::Box);
let std_box = quote!(::std::boxed::Box);

let bevy_reflect_path = reflect_struct.meta().bevy_reflect_path();
let struct_name = reflect_struct.meta().type_name();
Expand Down Expand Up @@ -155,7 +155,7 @@ pub(crate) fn impl_struct(reflect_struct: &ReflectStruct) -> TokenStream {

fn clone_dynamic(&self) -> #bevy_reflect_path::DynamicStruct {
let mut dynamic: #bevy_reflect_path::DynamicStruct = ::core::default::Default::default();
dynamic.set_name(::alloc::string::ToString::to_string(#bevy_reflect_path::Reflect::type_name(self)));
dynamic.set_name(::std::string::ToString::to_string(#bevy_reflect_path::Reflect::type_name(self)));
#(dynamic.insert_boxed(#field_names, #bevy_reflect_path::Reflect::clone_value(&self.#field_idents));)*
dynamic
}
Expand All @@ -173,7 +173,7 @@ pub(crate) fn impl_struct(reflect_struct: &ReflectStruct) -> TokenStream {
}

#[inline]
fn into_any(self: #alloc_box<Self>) -> #alloc_box<dyn #any> {
fn into_any(self: #std_box<Self>) -> #std_box<dyn #any> {
self
}

Expand All @@ -188,7 +188,7 @@ pub(crate) fn impl_struct(reflect_struct: &ReflectStruct) -> TokenStream {
}

#[inline]
fn into_reflect(self: #alloc_box<Self>) -> #alloc_box<dyn #bevy_reflect_path::Reflect> {
fn into_reflect(self: #std_box<Self>) -> #std_box<dyn #bevy_reflect_path::Reflect> {
self
}

Expand All @@ -203,12 +203,12 @@ pub(crate) fn impl_struct(reflect_struct: &ReflectStruct) -> TokenStream {
}

#[inline]
fn clone_value(&self) -> #alloc_box<dyn #bevy_reflect_path::Reflect> {
#alloc_box::new(#bevy_reflect_path::Struct::clone_dynamic(self))
fn clone_value(&self) -> #std_box<dyn #bevy_reflect_path::Reflect> {
#std_box::new(#bevy_reflect_path::Struct::clone_dynamic(self))
}

#[inline]
fn set(&mut self, value: #alloc_box<dyn #bevy_reflect_path::Reflect>) -> ::core::result::Result<(), #alloc_box<dyn #bevy_reflect_path::Reflect>> {
fn set(&mut self, value: #std_box<dyn #bevy_reflect_path::Reflect>) -> ::core::result::Result<(), #std_box<dyn #bevy_reflect_path::Reflect>> {
*self = <dyn #bevy_reflect_path::Reflect>::take(value)?;
Ok(())
}
Expand All @@ -233,7 +233,7 @@ pub(crate) fn impl_struct(reflect_struct: &ReflectStruct) -> TokenStream {
#bevy_reflect_path::ReflectMut::Struct(self)
}

fn reflect_owned(self: #alloc_box<Self>) -> #bevy_reflect_path::ReflectOwned {
fn reflect_owned(self: #std_box<Self>) -> #bevy_reflect_path::ReflectOwned {
#bevy_reflect_path::ReflectOwned::Struct(self)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use syn::{Index, Member};
pub(crate) fn impl_tuple_struct(reflect_struct: &ReflectStruct) -> TokenStream {
let option = quote!(::core::option::Option);
let any = quote!(::core::any::Any);
let alloc_box = quote!(::alloc::boxed::Box);
let std_box = quote!(::std::boxed::Box);

let bevy_reflect_path = reflect_struct.meta().bevy_reflect_path();
let struct_name = reflect_struct.meta().type_name();
Expand Down Expand Up @@ -117,7 +117,7 @@ pub(crate) fn impl_tuple_struct(reflect_struct: &ReflectStruct) -> TokenStream {

fn clone_dynamic(&self) -> #bevy_reflect_path::DynamicTupleStruct {
let mut dynamic: #bevy_reflect_path::DynamicTupleStruct = ::core::default::Default::default();
dynamic.set_name(::alloc::string::ToString::to_string(#bevy_reflect_path::Reflect::type_name(self)));
dynamic.set_name(::std::string::ToString::to_string(#bevy_reflect_path::Reflect::type_name(self)));
#(dynamic.insert_boxed(#bevy_reflect_path::Reflect::clone_value(&self.#field_idents));)*
dynamic
}
Expand All @@ -135,7 +135,7 @@ pub(crate) fn impl_tuple_struct(reflect_struct: &ReflectStruct) -> TokenStream {
}

#[inline]
fn into_any(self: #alloc_box<Self>) -> #alloc_box<dyn #any> {
fn into_any(self: #std_box<Self>) -> #std_box<dyn #any> {
self
}

Expand All @@ -150,7 +150,7 @@ pub(crate) fn impl_tuple_struct(reflect_struct: &ReflectStruct) -> TokenStream {
}

#[inline]
fn into_reflect(self: #alloc_box<Self>) -> #alloc_box<dyn #bevy_reflect_path::Reflect> {
fn into_reflect(self: #std_box<Self>) -> #std_box<dyn #bevy_reflect_path::Reflect> {
self
}

Expand All @@ -165,12 +165,12 @@ pub(crate) fn impl_tuple_struct(reflect_struct: &ReflectStruct) -> TokenStream {
}

#[inline]
fn clone_value(&self) -> #alloc_box<dyn #bevy_reflect_path::Reflect> {
#alloc_box::new(#bevy_reflect_path::TupleStruct::clone_dynamic(self))
fn clone_value(&self) -> #std_box<dyn #bevy_reflect_path::Reflect> {
#std_box::new(#bevy_reflect_path::TupleStruct::clone_dynamic(self))
}

#[inline]
fn set(&mut self, value: #alloc_box<dyn #bevy_reflect_path::Reflect>) -> ::core::result::Result<(), #alloc_box<dyn #bevy_reflect_path::Reflect>> {
fn set(&mut self, value: #std_box<dyn #bevy_reflect_path::Reflect>) -> ::core::result::Result<(), #std_box<dyn #bevy_reflect_path::Reflect>> {
*self = <dyn #bevy_reflect_path::Reflect>::take(value)?;
Ok(())
}
Expand All @@ -194,7 +194,7 @@ pub(crate) fn impl_tuple_struct(reflect_struct: &ReflectStruct) -> TokenStream {
#bevy_reflect_path::ReflectMut::TupleStruct(self)
}

fn reflect_owned(self: #alloc_box<Self>) -> #bevy_reflect_path::ReflectOwned {
fn reflect_owned(self: #std_box<Self>) -> #bevy_reflect_path::ReflectOwned {
#bevy_reflect_path::ReflectOwned::TupleStruct(self)
}

Expand Down
14 changes: 7 additions & 7 deletions crates/bevy_reflect/bevy_reflect_derive/src/impls/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use quote::quote;
/// Implements `GetTypeRegistration` and `Reflect` for the given type data.
pub(crate) fn impl_value(meta: &ReflectMeta) -> TokenStream {
let any = quote!(::core::any::Any);
let alloc_box = quote!(::alloc::boxed::Box);
let std_box = quote!(::std::boxed::Box);
let clone = quote!(::core::clone::Clone::clone);

let bevy_reflect_path = meta.bevy_reflect_path();
Expand Down Expand Up @@ -54,7 +54,7 @@ pub(crate) fn impl_value(meta: &ReflectMeta) -> TokenStream {
}

#[inline]
fn into_any(self: #alloc_box<Self>) -> #alloc_box<dyn #any> {
fn into_any(self: #std_box<Self>) -> #std_box<dyn #any> {
self
}

Expand All @@ -69,7 +69,7 @@ pub(crate) fn impl_value(meta: &ReflectMeta) -> TokenStream {
}

#[inline]
fn into_reflect(self: #alloc_box<Self>) -> #alloc_box<dyn #bevy_reflect_path::Reflect> {
fn into_reflect(self: #std_box<Self>) -> #std_box<dyn #bevy_reflect_path::Reflect> {
self
}

Expand All @@ -84,8 +84,8 @@ pub(crate) fn impl_value(meta: &ReflectMeta) -> TokenStream {
}

#[inline]
fn clone_value(&self) -> #alloc_box<dyn #bevy_reflect_path::Reflect> {
#alloc_box::new(#clone(self))
fn clone_value(&self) -> #std_box<dyn #bevy_reflect_path::Reflect> {
#std_box::new(#clone(self))
}

#[inline]
Expand All @@ -99,7 +99,7 @@ pub(crate) fn impl_value(meta: &ReflectMeta) -> TokenStream {
}

#[inline]
fn set(&mut self, value: #alloc_box<dyn #bevy_reflect_path::Reflect>) -> ::core::result::Result<(), #alloc_box<dyn #bevy_reflect_path::Reflect>> {
fn set(&mut self, value: #std_box<dyn #bevy_reflect_path::Reflect>) -> ::core::result::Result<(), #std_box<dyn #bevy_reflect_path::Reflect>> {
*self = <dyn #bevy_reflect_path::Reflect>::take(value)?;
Ok(())
}
Expand All @@ -112,7 +112,7 @@ pub(crate) fn impl_value(meta: &ReflectMeta) -> TokenStream {
#bevy_reflect_path::ReflectMut::Value(self)
}

fn reflect_owned(self: #alloc_box<Self>) -> #bevy_reflect_path::ReflectOwned {
fn reflect_owned(self: #std_box<Self>) -> #bevy_reflect_path::ReflectOwned {
#bevy_reflect_path::ReflectOwned::Value(self)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Parse for TraitInfo {
pub(crate) fn reflect_trait(_args: &TokenStream, input: TokenStream) -> TokenStream {
let option = quote!(::core::option::Option);
let result = quote!(::core::result::Result);
let alloc_box = quote!(::alloc::boxed::Box);
let std_box = quote!(::std::boxed::Box);

let trait_info = parse_macro_input!(input as TraitInfo);
let item_trait = &trait_info.item_trait;
Expand Down Expand Up @@ -63,7 +63,7 @@ pub(crate) fn reflect_trait(_args: &TokenStream, input: TokenStream) -> TokenStr
#trait_vis struct #reflect_trait_ident {
get_func: fn(&dyn #bevy_reflect_path::Reflect) -> #option<&dyn #trait_ident>,
get_mut_func: fn(&mut dyn #bevy_reflect_path::Reflect) -> #option<&mut dyn #trait_ident>,
get_boxed_func: fn(#alloc_box<dyn #bevy_reflect_path::Reflect>) -> #result<#alloc_box<dyn #trait_ident>, #alloc_box<dyn #bevy_reflect_path::Reflect>>,
get_boxed_func: fn(#std_box<dyn #bevy_reflect_path::Reflect>) -> #result<#std_box<dyn #trait_ident>, #std_box<dyn #bevy_reflect_path::Reflect>>,
}

impl #reflect_trait_ident {
Expand All @@ -78,7 +78,7 @@ pub(crate) fn reflect_trait(_args: &TokenStream, input: TokenStream) -> TokenStr
}

#[doc = #get_box_doc]
pub fn get_boxed(&self, reflect_value: #alloc_box<dyn #bevy_reflect_path::Reflect>) -> #result<#alloc_box<dyn #trait_ident>, #alloc_box<dyn #bevy_reflect_path::Reflect>> {
pub fn get_boxed(&self, reflect_value: #std_box<dyn #bevy_reflect_path::Reflect>) -> #result<#std_box<dyn #trait_ident>, #std_box<dyn #bevy_reflect_path::Reflect>> {
(self.get_boxed_func)(reflect_value)
}
}
Expand All @@ -93,7 +93,7 @@ pub(crate) fn reflect_trait(_args: &TokenStream, input: TokenStream) -> TokenStr
<dyn #bevy_reflect_path::Reflect>::downcast_mut::<T>(reflect_value).map(|value| value as &mut dyn #trait_ident)
},
get_boxed_func: |reflect_value| {
<dyn #bevy_reflect_path::Reflect>::downcast::<T>(reflect_value).map(|value| value as #alloc_box<dyn #trait_ident>)
<dyn #bevy_reflect_path::Reflect>::downcast::<T>(reflect_value).map(|value| value as #std_box<dyn #trait_ident>)
}
}
}
Expand Down

0 comments on commit a9a1ae4

Please sign in to comment.