@@ -22,6 +22,7 @@ use godot_cell::panicking::{GdCell, MutGuard, RefGuard};
22
22
23
23
use crate :: builtin:: { GString , StringName , Variant , VariantType } ;
24
24
use crate :: classes:: { Object , Script , ScriptLanguage } ;
25
+ use crate :: meta:: error:: CallErrorType ;
25
26
use crate :: meta:: { MethodInfo , PropertyInfo } ;
26
27
use crate :: obj:: { Base , Gd , GodotClass } ;
27
28
use crate :: sys;
@@ -113,12 +114,11 @@ pub trait ScriptInstance: Sized {
113
114
/// mutable method calls like rust.
114
115
///
115
116
/// 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.
117
117
fn call (
118
118
this : SiMut < Self > ,
119
119
method : StringName ,
120
120
args : & [ & Variant ] ,
121
- ) -> Result < Variant , sys :: GDExtensionCallErrorType > ;
121
+ ) -> Result < Variant , CallErrorType > ;
122
122
123
123
/// Identifies the script instance as a placeholder, routing property writes to a fallback if applicable.
124
124
///
@@ -400,7 +400,9 @@ impl<'a, T: ScriptInstance> SiMut<'a, T> {
400
400
/// # use godot::classes::{ScriptLanguage, Script};
401
401
/// # use godot::obj::script::{ScriptInstance, SiMut};
402
402
/// # use godot::meta::{MethodInfo, PropertyInfo};
403
+ /// # use godot::meta::error::CallErrorType;
403
404
/// # use godot::sys;
405
+ ///
404
406
/// struct ExampleScriptInstance;
405
407
///
406
408
/// impl ScriptInstance for ExampleScriptInstance {
@@ -410,7 +412,7 @@ impl<'a, T: ScriptInstance> SiMut<'a, T> {
410
412
/// this: SiMut<Self>,
411
413
/// method: StringName,
412
414
/// args: &[&Variant],
413
- /// ) -> Result<Variant, sys::GDExtensionCallErrorType >{
415
+ /// ) -> Result<Variant, CallErrorType >{
414
416
/// let name = this.base().get_name();
415
417
/// godot_print!("name is {name}");
416
418
/// // However, we cannot call methods that require `&mut Base`, such as:
@@ -456,7 +458,9 @@ impl<'a, T: ScriptInstance> SiMut<'a, T> {
456
458
/// # use godot::classes::{ScriptLanguage, Script};
457
459
/// # use godot::obj::script::{ScriptInstance, SiMut};
458
460
/// # use godot::meta::{MethodInfo, PropertyInfo};
461
+ /// # use godot::meta::error::CallErrorType;
459
462
/// # use godot::sys;
463
+ ///
460
464
/// struct ExampleScriptInstance;
461
465
///
462
466
/// impl ScriptInstance for ExampleScriptInstance {
@@ -466,7 +470,7 @@ impl<'a, T: ScriptInstance> SiMut<'a, T> {
466
470
/// mut this: SiMut<Self>,
467
471
/// method: StringName,
468
472
/// args: &[&Variant],
469
- /// ) -> Result<Variant, sys::GDExtensionCallErrorType > {
473
+ /// ) -> Result<Variant, CallErrorType > {
470
474
/// // Check whether method is available on this script
471
475
/// if method == StringName::from("script_method") {
472
476
/// godot_print!("script_method called!");
@@ -817,7 +821,8 @@ mod script_instance_info {
817
821
) {
818
822
// SAFETY: `p_method` is a valid [`StringName`] pointer.
819
823
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`.
821
826
let args = unsafe {
822
827
Variant :: borrow_ref_slice (
823
828
p_args,
@@ -845,7 +850,7 @@ mod script_instance_info {
845
850
sys:: GDEXTENSION_CALL_OK
846
851
}
847
852
848
- Ok ( Err ( err) ) => err,
853
+ Ok ( Err ( err) ) => err. to_sys ( ) ,
849
854
850
855
Err ( _) => sys:: GDEXTENSION_CALL_ERROR_INVALID_METHOD ,
851
856
} ;
0 commit comments