@@ -10,7 +10,7 @@ use crate::models::domain::{
10
10
BuildConfiguration , BuiltinClass , BuiltinMethod , BuiltinSize , BuiltinVariant , Class ,
11
11
ClassCommons , ClassConstant , ClassConstantValue , ClassMethod , ClassSignal , Constructor , Enum ,
12
12
Enumerator , EnumeratorValue , ExtensionApi , FnDirection , FnParam , FnQualifier , FnReturn ,
13
- FunctionCommon , GodotApiVersion , ModName , NativeStructure , Operator , Singleton , TyName ,
13
+ FunctionCommon , GodotApiVersion , ModName , NativeStructure , Operator , RustTy , Singleton , TyName ,
14
14
UtilityFunction ,
15
15
} ;
16
16
use crate :: models:: json:: {
@@ -374,6 +374,7 @@ impl BuiltinMethod {
374
374
is_vararg : method. is_vararg ,
375
375
is_private : false , // See 'exposed' below. Could be special_cases::is_method_private(builtin_name, &method.name),
376
376
is_virtual_required : false ,
377
+ is_unsafe : false , // Builtin methods don't use raw pointers.
377
378
direction : FnDirection :: Outbound {
378
379
hash : method. hash . expect ( "hash absent for builtin method" ) ,
379
380
} ,
@@ -507,15 +508,20 @@ impl ClassMethod {
507
508
is_required_in_json
508
509
} ;
509
510
511
+ let parameters = FnParam :: new_range ( & method. arguments , ctx) ;
512
+ let return_value = FnReturn :: new ( & method. return_value , ctx) ;
513
+ let is_unsafe = Self :: function_uses_pointers ( & parameters, & return_value) ;
514
+
510
515
Some ( Self {
511
516
common : FunctionCommon {
512
517
name : rust_method_name. to_string ( ) ,
513
518
godot_name : godot_method_name,
514
- parameters : FnParam :: new_range ( & method . arguments , ctx ) ,
515
- return_value : FnReturn :: new ( & method . return_value , ctx ) ,
519
+ parameters,
520
+ return_value,
516
521
is_vararg : method. is_vararg ,
517
522
is_private,
518
523
is_virtual_required,
524
+ is_unsafe,
519
525
direction,
520
526
} ,
521
527
qualifier,
@@ -531,6 +537,17 @@ impl ClassMethod {
531
537
532
538
special_cases:: maybe_rename_virtual_method ( class_name, method_name)
533
539
}
540
+
541
+ fn function_uses_pointers ( parameters : & [ FnParam ] , return_value : & FnReturn ) -> bool {
542
+ let has_pointer_params = parameters
543
+ . iter ( )
544
+ . any ( |param| matches ! ( param. type_, RustTy :: RawPointer { .. } ) ) ;
545
+
546
+ let has_pointer_return = matches ! ( return_value. type_, Some ( RustTy :: RawPointer { .. } ) ) ;
547
+
548
+ // No short-circuiting due to variable decls, but that's fine.
549
+ has_pointer_params || has_pointer_return
550
+ }
534
551
}
535
552
536
553
impl ClassSignal {
@@ -584,6 +601,7 @@ impl UtilityFunction {
584
601
is_vararg : function. is_vararg ,
585
602
is_private,
586
603
is_virtual_required : false ,
604
+ is_unsafe : false , // Utility functions don't use raw pointers.
587
605
direction : FnDirection :: Outbound {
588
606
hash : function. hash ,
589
607
} ,
0 commit comments