22
33use super :: {
44 from:: { Mut , Ref , Union , Val } ,
5- script_function:: FunctionCallContext ,
5+ script_function:: FunctionCallContext , DynamicScriptFunction , DynamicScriptFunctionMut ,
66} ;
7- use crate :: {
8- bindings:: { ReflectReference , WorldGuard } ,
9- error:: InteropError , private:: { no_type_dependencies, self_type_dependency_only} ,
10- } ;
11- use crate :: { bindings:: { ReflectReference , ScriptValue } , error:: InteropError } ;
7+ use crate ::
8+ bindings:: { ReflectReference , ScriptValue }
9+ ;
1210use bevy:: reflect:: { FromReflect , GetTypeRegistration , TypeRegistry , Typed } ;
1311use bevy_mod_scripting_derive:: impl_get_type_dependencies;
1412use std:: { collections:: HashMap , ffi:: OsString , hash:: Hash , path:: PathBuf } ;
1513
16- /// Functionally identical to [`GetTypeRegistration`] but without the 'static bound
17- pub trait GetTypeDependencies {
18- /// In the majority of the implementations, this will be `Self`
19- /// However some types might be `facades` for other types, in which case this will be the underlying type
20- type Underlying ;
2114
22- /// Registers the type dependencies of the implementing type with the given [`TypeRegistry`].
23- fn register_type_dependencies ( registry : & mut TypeRegistry ) ;
15+
16+ macro_rules! impl_get_type_dependencies_primitives {
17+ ( $( $ty: ty) ,* ) => {
18+ $(
19+ impl_get_type_dependencies!(
20+ #[ derive( GetTypeDependencies ) ]
21+ #[ get_type_dependencies( bms_core_path="crate" ) ]
22+ struct $ty where { }
23+ ) ;
24+ ) *
25+ } ;
2426}
2527
28+ impl_get_type_dependencies_primitives ! (
29+ i8 , i16 , i32 , i64 , i128 , u8 , u16 , u32 , u64 , u128 , usize , isize , f32 , f64 , bool ,
30+ ScriptValue , DynamicScriptFunction , DynamicScriptFunctionMut ,
31+ String , PathBuf , OsString , char
32+ ) ;
33+
2634
2735impl GetTypeDependencies for ( ) {
2836 type Underlying = ( ) ;
@@ -31,6 +39,23 @@ impl GetTypeDependencies for () {
3139 }
3240}
3341
42+ impl GetTypeDependencies for & ' static str {
43+ type Underlying = & ' static str ;
44+ fn register_type_dependencies ( registry : & mut TypeRegistry ) {
45+ registry. register :: < & ' static str > ( ) ;
46+ }
47+ }
48+
49+ /// Functionally identical to [`GetTypeRegistration`] but without the 'static bound
50+ pub trait GetTypeDependencies {
51+ /// In the majority of the implementations, this will be `Self`
52+ /// However some types might be `facades` for other types, in which case this will be the underlying type
53+ type Underlying ;
54+
55+ /// Registers the type dependencies of the implementing type with the given [`TypeRegistry`].
56+ fn register_type_dependencies ( registry : & mut TypeRegistry ) ;
57+ }
58+
3459impl_get_type_dependencies ! (
3560 #[ derive( GetTypeDependencies ) ]
3661 #[ get_type_dependencies( bms_core_path="crate" ) ]
0 commit comments