Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions godot-codegen/src/models/domain_mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,22 @@ impl ClassMethod {
FnQualifier::from_const_static(is_actually_const, method.is_static)
};

// Since Godot 4.4, GDExtension advertises whether virtual methods have a default implementation or are required to be overridden.
#[cfg(before_api = "4.4")]
let is_virtual_required = special_cases::is_virtual_method_required(
&class_name.rust_ty.to_string(),
rust_method_name,
);

#[cfg(since_api = "4.4")]
let is_virtual_required = method.is_virtual
&& method.is_required.unwrap_or_else(|| {
panic!(
"virtual method {}::{} lacks field `is_required`",
class_name.rust_ty, rust_method_name
);
});

Some(Self {
common: FunctionCommon {
name: rust_method_name.to_string(),
Expand All @@ -464,10 +480,7 @@ impl ClassMethod {
return_value: FnReturn::new(&method.return_value, ctx),
is_vararg: method.is_vararg,
is_private,
is_virtual_required: special_cases::is_virtual_method_required(
&class_name.rust_ty.to_string(),
rust_method_name,
),
is_virtual_required,
direction,
},
qualifier,
Expand Down
2 changes: 2 additions & 0 deletions godot-codegen/src/models/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ pub struct JsonClassMethod {
pub is_vararg: bool,
pub is_static: bool,
pub is_virtual: bool,
#[cfg(since_api = "4.4")]
pub is_required: Option<bool>, // Only virtual functions have this field.
pub hash: Option<i64>,
pub return_value: Option<JsonMethodReturn>,
pub arguments: Option<Vec<JsonMethodArg>>,
Expand Down
1 change: 1 addition & 0 deletions godot-codegen/src/special_cases/special_cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ pub fn get_interface_extra_docs(trait_name: &str) -> Option<&'static str> {
}
}

#[cfg(before_api = "4.4")]
pub fn is_virtual_method_required(class_name: &str, method: &str) -> bool {
match (class_name, method) {
("ScriptLanguageExtension", _) => method != "get_doc_comment_delimiters",
Expand Down