Skip to content

Commit 60e48ff

Browse files
committed
Minimal changes to make PR mergeable before upstream virtual-compat is ready
Reduces the surface for merge conflicts. Either this commit can be individually reverted later, or locations with TODO(v0.3,virtual-compat) can be sought out.
1 parent 5628cc0 commit 60e48ff

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

godot-codegen/src/models/domain_mapping.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,15 @@ impl ClassMethod {
424424
let direction = FnDirection::Virtual {
425425
#[cfg(since_api = "4.4")]
426426
hash: {
427-
let hash_i64 = method.hash.unwrap_or_else(|| {
427+
// TODO(v0.3,virtual-compat): re-enable this in favor of 0 fallback.
428+
/*let hash_i64 = method.hash.unwrap_or_else(|| {
428429
panic!(
429430
"virtual class methods must have a hash since Godot 4.4; missing: {}.{}",
430431
class_name.godot_ty, method.name
431432
)
432-
});
433+
});*/
434+
// Temporarily use hash 0 until upstream PR is merged.
435+
let hash_i64 = method.hash.unwrap_or(0);
433436

434437
// TODO see if we can use u32 everywhere.
435438
hash_i64.try_into().unwrap_or_else(|_| {

godot-core/src/registry/callbacks.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,15 @@ pub unsafe extern "C" fn free<T: GodotClass>(
113113
pub unsafe extern "C" fn get_virtual<T: cap::ImplementsGodotVirtual>(
114114
_class_user_data: *mut std::ffi::c_void,
115115
name: sys::GDExtensionConstStringNamePtr,
116-
hash: u32,
116+
// TODO(v0.3,virtual-compat): re-enable parameter
117+
//hash: u32,
117118
) -> sys::GDExtensionClassCallVirtual {
118119
// This string is not ours, so we cannot call the destructor on it.
119120
let borrowed_string = StringName::borrow_string_sys(name);
120121
let method_name = borrowed_string.to_string();
121122

123+
// TODO(v0.3,virtual-compat): remove local var
124+
let hash = 0;
122125
T::__virtual_call(method_name.as_str(), hash)
123126
}
124127

@@ -130,20 +133,22 @@ pub unsafe extern "C" fn get_virtual<T: cap::ImplementsGodotVirtual>(
130133
// This string is not ours, so we cannot call the destructor on it.
131134
let borrowed_string = StringName::borrow_string_sys(name);
132135
let method_name = borrowed_string.to_string();
133-
134136
T::__virtual_call(method_name.as_str())
135137
}
136138

137139
#[cfg(since_api = "4.4")]
138140
pub unsafe extern "C" fn default_get_virtual<T: UserClass>(
139141
_class_user_data: *mut std::ffi::c_void,
140142
name: sys::GDExtensionConstStringNamePtr,
141-
hash: u32,
143+
// TODO(v0.3,virtual-compat): re-enable parameter
144+
// hash: u32,
142145
) -> sys::GDExtensionClassCallVirtual {
143146
// This string is not ours, so we cannot call the destructor on it.
144147
let borrowed_string = StringName::borrow_string_sys(name);
145148
let method_name = borrowed_string.to_string();
146149

150+
// TODO(v0.3,virtual-compat): remove local var
151+
let hash = 0;
147152
T::__default_virtual_call(method_name.as_str(), hash)
148153
}
149154

godot-core/src/registry/class.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,11 @@ type GodotCreationInfo = sys::GDExtensionClassCreationInfo4;
8686

8787
#[cfg(before_api = "4.4")]
8888
pub(crate) type GodotGetVirtual = <sys::GDExtensionClassGetVirtual as sys::Inner>::FnPtr;
89+
// TODO(v0.3,virtual-compat): re-enable this to use GetVirtual2
90+
// #[cfg(since_api = "4.4")]
91+
// pub(crate) type GodotGetVirtual = <sys::GDExtensionClassGetVirtual2 as sys::Inner>::FnPtr;
8992
#[cfg(since_api = "4.4")]
90-
pub(crate) type GodotGetVirtual = <sys::GDExtensionClassGetVirtual2 as sys::Inner>::FnPtr;
93+
pub(crate) type GodotGetVirtual = <sys::GDExtensionClassGetVirtual as sys::Inner>::FnPtr;
9194

9295
#[derive(Debug)]
9396
struct ClassRegistrationInfo {

0 commit comments

Comments
 (0)