You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
GDExtension: Add compatibility system for virtual methods
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user