File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
godot-codegen/src/generator
itest/rust/src/object_tests Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -322,8 +322,8 @@ pub(crate) fn make_params_exprs<'a>(
322
322
let param_name = & param. name ;
323
323
let param_ty = & param. type_ ;
324
324
325
- // Objects (Gd<T>) use implicit conversions via AsObjectArg. Only use in non-virtual functions.
326
325
match & param. type_ {
326
+ // Non-virtual functions: Objects (Gd<T>) use implicit conversions via AsObjectArg.
327
327
RustTy :: EngineClass {
328
328
object_arg,
329
329
impl_as_object_arg,
@@ -346,6 +346,14 @@ pub(crate) fn make_params_exprs<'a>(
346
346
param_types. push ( quote ! { #object_arg } ) ;
347
347
}
348
348
349
+ // Virtual methods accept Option<Gd<T>>, since we don't know whether objects are nullable or required.
350
+ RustTy :: EngineClass { .. } if is_virtual => {
351
+ params. push ( quote ! { #param_name: Option <#param_ty> } ) ;
352
+ arg_names. push ( quote ! { #param_name } ) ;
353
+ param_types. push ( quote ! { #param_ty } ) ;
354
+ }
355
+
356
+ // All other methods and parameter types: standard handling.
349
357
_ => {
350
358
params. push ( quote ! { #param_name: #param_ty } ) ;
351
359
arg_names. push ( quote ! { #param_name } ) ;
Original file line number Diff line number Diff line change @@ -153,12 +153,12 @@ impl IPrimitiveMesh for VirtualReturnTest {
153
153
fn surface_get_format ( & self , _index : i32 ) -> u32 { unreachable ! ( ) }
154
154
fn surface_get_primitive_type ( & self , _index : i32 ) -> u32 { unreachable ! ( ) }
155
155
#[ cfg( feature = "codegen-full" ) ]
156
- fn surface_set_material ( & mut self , _index : i32 , _material : Gd < Material > ) { unreachable ! ( ) }
156
+ fn surface_set_material ( & mut self , _index : i32 , _material : Option < Gd < Material > > ) { unreachable ! ( ) }
157
157
#[ cfg( feature = "codegen-full" ) ]
158
158
fn surface_get_material ( & self , _index : i32 ) -> Option < Gd < Material > > { unreachable ! ( ) }
159
159
fn get_blend_shape_count ( & self ) -> i32 { unreachable ! ( ) }
160
160
fn get_blend_shape_name ( & self , _index : i32 ) -> StringName { unreachable ! ( ) }
161
- fn set_blend_shape_name ( & mut self , _index : i32 , _namee : StringName ) { unreachable ! ( ) }
161
+ fn set_blend_shape_name ( & mut self , _index : i32 , _name : StringName ) { unreachable ! ( ) }
162
162
fn get_aabb ( & self ) -> godot:: prelude:: Aabb { unreachable ! ( ) }
163
163
}
164
164
You can’t perform that action at this time.
0 commit comments