1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

Merge pull request #100674 from dsnopek/gdextension-virtual-method-compat

GDExtension: Add compatibility system for virtual methods
This commit is contained in:
Rémi Verschelde
2025-01-11 22:29:38 +01:00
9 changed files with 202 additions and 53 deletions

View File

@@ -165,6 +165,38 @@ MethodInfo MethodInfo::from_dict(const Dictionary &p_dict) {
return mi;
}
// This was copied from MethodBind::get_hash() so that the compatibility hashes for virtual and non-virtual methods would be the same.
uint32_t MethodInfo::get_compatibility_hash() const {
bool has_return = (return_val.type != Variant::NIL) || (return_val.usage & PROPERTY_USAGE_NIL_IS_VARIANT);
uint32_t hash = hash_murmur3_one_32(has_return);
hash = hash_murmur3_one_32(arguments.size(), hash);
if (has_return) {
hash = hash_murmur3_one_32(return_val.type, hash);
if (return_val.class_name != StringName()) {
hash = hash_murmur3_one_32(return_val.class_name.hash(), hash);
}
}
for (const PropertyInfo &arg : arguments) {
hash = hash_murmur3_one_32(arg.type, hash);
if (arg.class_name != StringName()) {
hash = hash_murmur3_one_32(arg.class_name.hash(), hash);
}
}
hash = hash_murmur3_one_32(default_arguments.size(), hash);
for (const Variant &v : default_arguments) {
hash = hash_murmur3_one_32(v.hash(), hash);
}
hash = hash_murmur3_one_32(flags & METHOD_FLAG_CONST ? 1 : 0, hash);
hash = hash_murmur3_one_32(flags & METHOD_FLAG_VARARG ? 1 : 0, hash);
return hash_fmix32(hash);
}
Object::Connection::operator Variant() const {
Dictionary d;
d["signal"] = signal;