3
3
use std:: { borrow:: Cow , collections:: HashMap , ffi:: OsString , path:: PathBuf } ;
4
4
use bevy:: reflect:: Reflect ;
5
5
6
- use crate :: { bindings:: { ReflectReference , ScriptValue , WorldGuard } , error:: InteropError , private :: self_type_dependency_only } ;
6
+ use crate :: { bindings:: { ReflectReference , ScriptValue , WorldGuard } , error:: InteropError } ;
7
7
use super :: { DynamicScriptFunction , DynamicScriptFunctionMut , Val } ;
8
8
9
9
/// Converts a value into a [`ScriptValue`].
@@ -26,14 +26,13 @@ impl IntoScript for ScriptValue {
26
26
}
27
27
}
28
28
29
- self_type_dependency_only ! ( ScriptValue ) ;
30
29
31
30
impl IntoScript for ( ) {
32
31
fn into_script ( self , _world : WorldGuard ) -> Result < ScriptValue , InteropError > {
33
32
Ok ( ScriptValue :: Unit )
34
33
}
35
34
}
36
- self_type_dependency_only ! ( ( ) ) ;
35
+
37
36
38
37
impl IntoScript for DynamicScriptFunctionMut {
39
38
fn into_script ( self , _world : WorldGuard ) -> Result < ScriptValue , InteropError > {
@@ -47,14 +46,12 @@ impl IntoScript for DynamicScriptFunction {
47
46
}
48
47
}
49
48
50
- self_type_dependency_only ! ( DynamicScriptFunctionMut , DynamicScriptFunction ) ;
51
49
52
50
impl IntoScript for bool {
53
51
fn into_script ( self , _world : WorldGuard ) -> Result < ScriptValue , InteropError > {
54
52
Ok ( ScriptValue :: Bool ( self ) )
55
53
}
56
54
}
57
- self_type_dependency_only ! ( bool ) ;
58
55
59
56
macro_rules! impl_into_with_downcast {
60
57
( $variant: tt as $cast: ty [ $( $ty: ty) ,* ] ) => {
@@ -71,9 +68,7 @@ macro_rules! impl_into_with_downcast {
71
68
72
69
impl_into_with_downcast ! ( Integer as i64 [ i8 , i16 , i32 , i64 , i128 , u8 , u16 , u32 , u64 , u128 , usize , isize ] ) ;
73
70
impl_into_with_downcast ! ( Float as f64 [ f32 , f64 ] ) ;
74
- self_type_dependency_only ! (
75
- i8 , i16 , i32 , i64 , i128 , u8 , u16 , u32 , u64 , u128 , usize , isize , f32 , f64
76
- ) ;
71
+
77
72
78
73
macro_rules! impl_into_stringlike {
79
74
( $id: ident, [ $( ( $ty: ty => $conversion: expr) ) ,* ] ) => {
@@ -99,15 +94,14 @@ impl_into_stringlike!(
99
94
]
100
95
) ;
101
96
102
- self_type_dependency_only ! ( String , char , PathBuf , OsString ) ;
103
97
104
98
impl IntoScript for & ' static str {
105
99
fn into_script ( self , _world : WorldGuard ) -> Result < ScriptValue , InteropError > {
106
100
Ok ( ScriptValue :: String ( Cow :: Borrowed ( self ) ) )
107
101
}
108
102
}
109
103
110
- self_type_dependency_only ! ( & ' static str ) ;
104
+
111
105
112
106
impl IntoScript for ReflectReference {
113
107
fn into_script ( self , _world : WorldGuard ) -> Result < ScriptValue , InteropError > {
@@ -156,6 +150,15 @@ impl<T: IntoScript, const N: usize> IntoScript for [T; N] {
156
150
}
157
151
}
158
152
153
+ impl < T1 : IntoScript , T2 : IntoScript > IntoScript for Union < T1 , T2 > {
154
+ fn into_script ( self , world : WorldGuard ) -> Result < ScriptValue , InteropError > {
155
+ match self . into_left ( ) {
156
+ Ok ( left) => left. into_script ( world) ,
157
+ Err ( right) => right. into_script ( world) ,
158
+ }
159
+ }
160
+ }
161
+
159
162
impl < V : IntoScript > IntoScript for HashMap < String , V > {
160
163
fn into_script ( self , world : WorldGuard ) -> Result < ScriptValue , InteropError > {
161
164
let mut map = HashMap :: new ( ) ;
0 commit comments