@@ -12,11 +12,13 @@ use std::marker::PhantomData;
1212use std:: ops:: { Deref , DerefMut } ;
1313use std:: { collections:: HashMap , fmt:: Debug } ;
1414
15- use godot:: meta:: { FromGodot , GodotConvert , ToGodot } ;
15+ use godot:: meta:: error:: CallErrorType ;
16+ use godot:: meta:: { ByValue , FromGodot , GodotConvert , ToGodot } ;
1617use godot:: obj:: Inherits ;
1718use godot:: prelude:: { ConvertError , Gd , Object , StringName , Variant } ;
1819
1920pub use crate :: runtime:: Context ;
21+ use crate :: runtime:: RustScript ;
2022
2123pub use export:: GodotScriptExport ;
2224pub use on_editor:: OnEditor ;
@@ -35,7 +37,7 @@ pub trait GodotScript: Debug + GodotScriptImpl<ImplBase = Self::Base> {
3537 method : StringName ,
3638 args : & [ & Variant ] ,
3739 context : Context < ' _ , Self > ,
38- ) -> Result < Variant , godot :: sys :: GDExtensionCallErrorType > ;
40+ ) -> Result < Variant , CallErrorType > ;
3941
4042 fn to_string ( & self ) -> String ;
4143 fn property_state ( & self ) -> HashMap < StringName , Variant > ;
@@ -51,7 +53,7 @@ pub trait GodotScriptImpl {
5153 name : StringName ,
5254 args : & [ & Variant ] ,
5355 context : Context < Self > ,
54- ) -> Result < Variant , godot:: sys :: GDExtensionCallErrorType > ;
56+ ) -> Result < Variant , godot:: meta :: error :: CallErrorType > ;
5557}
5658
5759#[ derive( Debug ) ]
@@ -72,7 +74,8 @@ impl<T: GodotScript> RsRef<T> {
7274 let script = owner
7375 . upcast_ref :: < Object > ( )
7476 . get_script ( )
75- . try_to :: < Option < Gd < crate :: runtime:: RustScript > > > ( ) ;
77+ . map ( |script| script. try_cast :: < RustScript > ( ) )
78+ . transpose ( ) ;
7679
7780 let Ok ( script) = script else {
7881 return Some ( GodotScriptCastError :: NotRustScript ) ;
@@ -127,20 +130,16 @@ where
127130}
128131
129132impl < T : GodotScript > ToGodot for RsRef < T > {
130- type ToVia < ' v >
131- = Gd < T :: Base >
132- where
133- Self : ' v ;
133+ type Pass = ByValue ;
134134
135- fn to_godot ( & self ) -> Self :: ToVia < ' _ > {
135+ fn to_godot ( & self ) -> Self :: Via {
136136 self . deref ( ) . clone ( )
137137 }
138138}
139139
140- impl < ' v , T : GodotScript > :: godot:: prelude:: Var for RsRef < T >
140+ impl < T : GodotScript > :: godot:: prelude:: Var for RsRef < T >
141141where
142- Self : GodotConvert < Via = <Self as ToGodot >:: ToVia < ' v > > ,
143- Self : ' v ,
142+ Self : GodotConvert ,
144143{
145144 fn get_property ( & self ) -> Self :: Via {
146145 <Self as ToGodot >:: to_godot ( self )
@@ -193,7 +192,7 @@ impl<T: GodotScript, B: Inherits<T::Base> + Inherits<Object>> CastToScript<T> fo
193192 self . try_to_script ( ) . unwrap_or_else ( |err| {
194193 panic ! (
195194 "`{}` was assumed to have rust script `{}`, but this was not the case at runtime!\n Error: {}" ,
196- B :: class_name ( ) ,
195+ B :: class_id ( ) ,
197196 T :: CLASS_NAME ,
198197 err,
199198 ) ;
@@ -204,7 +203,7 @@ impl<T: GodotScript, B: Inherits<T::Base> + Inherits<Object>> CastToScript<T> fo
204203 self . try_into_script ( ) . unwrap_or_else ( |err| {
205204 panic ! (
206205 "`{}` was assumed to have rust script `{}`, but this was not the case at runtime!\n Error: {}" ,
207- B :: class_name ( ) ,
206+ B :: class_id ( ) ,
208207 T :: CLASS_NAME ,
209208 err
210209 ) ;
0 commit comments