@@ -22,6 +22,7 @@ use godot_cell::panicking::{GdCell, MutGuard, RefGuard};
2222
2323use crate :: builtin:: { GString , StringName , Variant , VariantType } ;
2424use crate :: classes:: { Object , Script , ScriptLanguage } ;
25+ use crate :: meta:: error:: CallErrorType ;
2526use crate :: meta:: { MethodInfo , PropertyInfo } ;
2627use crate :: obj:: { Base , Gd , GodotClass } ;
2728use crate :: sys;
@@ -113,12 +114,11 @@ pub trait ScriptInstance: Sized {
113114 /// mutable method calls like rust.
114115 ///
115116 /// It's important that the script does not cause a second call to this function while executing a method call. This would result in a panic.
116- // TODO: map the sys::GDExtensionCallErrorType to some public API type.
117117 fn call (
118118 this : SiMut < Self > ,
119119 method : StringName ,
120120 args : & [ & Variant ] ,
121- ) -> Result < Variant , sys :: GDExtensionCallErrorType > ;
121+ ) -> Result < Variant , CallErrorType > ;
122122
123123 /// Identifies the script instance as a placeholder, routing property writes to a fallback if applicable.
124124 ///
@@ -400,7 +400,9 @@ impl<'a, T: ScriptInstance> SiMut<'a, T> {
400400 /// # use godot::classes::{ScriptLanguage, Script};
401401 /// # use godot::obj::script::{ScriptInstance, SiMut};
402402 /// # use godot::meta::{MethodInfo, PropertyInfo};
403+ /// # use godot::meta::error::CallErrorType;
403404 /// # use godot::sys;
405+ ///
404406 /// struct ExampleScriptInstance;
405407 ///
406408 /// impl ScriptInstance for ExampleScriptInstance {
@@ -410,7 +412,7 @@ impl<'a, T: ScriptInstance> SiMut<'a, T> {
410412 /// this: SiMut<Self>,
411413 /// method: StringName,
412414 /// args: &[&Variant],
413- /// ) -> Result<Variant, sys::GDExtensionCallErrorType >{
415+ /// ) -> Result<Variant, CallErrorType >{
414416 /// let name = this.base().get_name();
415417 /// godot_print!("name is {name}");
416418 /// // However, we cannot call methods that require `&mut Base`, such as:
@@ -456,7 +458,9 @@ impl<'a, T: ScriptInstance> SiMut<'a, T> {
456458 /// # use godot::classes::{ScriptLanguage, Script};
457459 /// # use godot::obj::script::{ScriptInstance, SiMut};
458460 /// # use godot::meta::{MethodInfo, PropertyInfo};
461+ /// # use godot::meta::error::CallErrorType;
459462 /// # use godot::sys;
463+ ///
460464 /// struct ExampleScriptInstance;
461465 ///
462466 /// impl ScriptInstance for ExampleScriptInstance {
@@ -466,7 +470,7 @@ impl<'a, T: ScriptInstance> SiMut<'a, T> {
466470 /// mut this: SiMut<Self>,
467471 /// method: StringName,
468472 /// args: &[&Variant],
469- /// ) -> Result<Variant, sys::GDExtensionCallErrorType > {
473+ /// ) -> Result<Variant, CallErrorType > {
470474 /// // Check whether method is available on this script
471475 /// if method == StringName::from("script_method") {
472476 /// godot_print!("script_method called!");
@@ -817,7 +821,8 @@ mod script_instance_info {
817821 ) {
818822 // SAFETY: `p_method` is a valid [`StringName`] pointer.
819823 let method = unsafe { StringName :: new_from_string_sys ( p_method) } ;
820- // SAFETY: `p_args` is a valid array of length `p_argument_count`
824+
825+ // SAFETY: `p_args` is a valid array of length `p_argument_count`.
821826 let args = unsafe {
822827 Variant :: borrow_ref_slice (
823828 p_args,
@@ -845,7 +850,7 @@ mod script_instance_info {
845850 sys:: GDEXTENSION_CALL_OK
846851 }
847852
848- Ok ( Err ( err) ) => err,
853+ Ok ( Err ( err) ) => err. to_sys ( ) ,
849854
850855 Err ( _) => sys:: GDEXTENSION_CALL_ERROR_INVALID_METHOD ,
851856 } ;
0 commit comments