2
2
3
3
use super :: {
4
4
from:: { Mut , Ref , Union , Val } ,
5
- script_function:: FunctionCallContext ,
5
+ script_function:: FunctionCallContext , DynamicScriptFunction , DynamicScriptFunctionMut ,
6
6
} ;
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
+ ;
12
10
use bevy:: reflect:: { FromReflect , GetTypeRegistration , TypeRegistry , Typed } ;
13
11
use bevy_mod_scripting_derive:: impl_get_type_dependencies;
14
12
use std:: { collections:: HashMap , ffi:: OsString , hash:: Hash , path:: PathBuf } ;
15
13
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 ;
21
14
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
+ } ;
24
26
}
25
27
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
+
26
34
27
35
impl GetTypeDependencies for ( ) {
28
36
type Underlying = ( ) ;
@@ -31,6 +39,23 @@ impl GetTypeDependencies for () {
31
39
}
32
40
}
33
41
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
+
34
59
impl_get_type_dependencies ! (
35
60
#[ derive( GetTypeDependencies ) ]
36
61
#[ get_type_dependencies( bms_core_path="crate" ) ]
0 commit comments