File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -456,6 +456,22 @@ impl ClassMethod {
456456 FnQualifier :: from_const_static ( is_actually_const, method. is_static )
457457 } ;
458458
459+ // Since Godot 4.4, GDExtension advertises whether virtual methods have a default implementation or are required to be overridden.
460+ #[ cfg( before_api = "4.4" ) ]
461+ let is_virtual_required = special_cases:: is_virtual_method_required (
462+ & class_name. rust_ty . to_string ( ) ,
463+ rust_method_name,
464+ ) ;
465+
466+ #[ cfg( since_api = "4.4" ) ]
467+ let is_virtual_required = method. is_virtual
468+ && method. is_required . unwrap_or_else ( || {
469+ panic ! (
470+ "virtual method {}::{} lacks field `is_required`" ,
471+ class_name. rust_ty, rust_method_name
472+ ) ;
473+ } ) ;
474+
459475 Some ( Self {
460476 common : FunctionCommon {
461477 name : rust_method_name. to_string ( ) ,
@@ -464,10 +480,7 @@ impl ClassMethod {
464480 return_value : FnReturn :: new ( & method. return_value , ctx) ,
465481 is_vararg : method. is_vararg ,
466482 is_private,
467- is_virtual_required : special_cases:: is_virtual_method_required (
468- & class_name. rust_ty . to_string ( ) ,
469- rust_method_name,
470- ) ,
483+ is_virtual_required,
471484 direction,
472485 } ,
473486 qualifier,
Original file line number Diff line number Diff line change @@ -220,6 +220,8 @@ pub struct JsonClassMethod {
220220 pub is_vararg : bool ,
221221 pub is_static : bool ,
222222 pub is_virtual : bool ,
223+ #[ cfg( since_api = "4.4" ) ]
224+ pub is_required : Option < bool > , // Only virtual functions have this field.
223225 pub hash : Option < i64 > ,
224226 pub return_value : Option < JsonMethodReturn > ,
225227 pub arguments : Option < Vec < JsonMethodArg > > ,
Original file line number Diff line number Diff line change @@ -389,6 +389,7 @@ pub fn get_interface_extra_docs(trait_name: &str) -> Option<&'static str> {
389389 }
390390}
391391
392+ #[ cfg( before_api = "4.4" ) ]
392393pub fn is_virtual_method_required ( class_name : & str , method : & str ) -> bool {
393394 match ( class_name, method) {
394395 ( "ScriptLanguageExtension" , _) => method != "get_doc_comment_delimiters" ,
You can’t perform that action at this time.
0 commit comments