GDExtension: Add system for builtin method compatibility
This commit is contained in:
@ -797,6 +797,17 @@ Dictionary GDExtensionAPIDump::generate_extension_api(bool p_include_docs) {
|
||||
d2["is_static"] = Variant::is_builtin_method_static(type, method_name);
|
||||
d2["hash"] = Variant::get_builtin_method_hash(type, method_name);
|
||||
|
||||
Vector<uint32_t> compat_hashes = Variant::get_builtin_method_compatibility_hashes(type, method_name);
|
||||
Array compatibility;
|
||||
if (compat_hashes.size()) {
|
||||
for (int j = 0; j < compat_hashes.size(); j++) {
|
||||
compatibility.push_back(compat_hashes[j]);
|
||||
}
|
||||
}
|
||||
if (compatibility.size() > 0) {
|
||||
d2["hash_compatibility"] = compatibility;
|
||||
}
|
||||
|
||||
Vector<Variant> default_args = Variant::get_builtin_method_default_arguments(type, method_name);
|
||||
|
||||
Array arguments;
|
||||
|
||||
@ -817,13 +817,11 @@ static GDExtensionPtrOperatorEvaluator gdextension_variant_get_ptr_operator_eval
|
||||
}
|
||||
static GDExtensionPtrBuiltInMethod gdextension_variant_get_ptr_builtin_method(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, GDExtensionInt p_hash) {
|
||||
const StringName method = *reinterpret_cast<const StringName *>(p_method);
|
||||
uint32_t hash = Variant::get_builtin_method_hash(Variant::Type(p_type), method);
|
||||
if (hash != p_hash) {
|
||||
ERR_PRINT_ONCE("Error getting method " + method + ", hash mismatch.");
|
||||
return nullptr;
|
||||
GDExtensionPtrBuiltInMethod ptr = (GDExtensionPtrBuiltInMethod)Variant::get_ptr_builtin_method_with_compatibility(Variant::Type(p_type), method, p_hash);
|
||||
if (!ptr) {
|
||||
ERR_PRINT("Error getting method " + method + ", missing or hash mismatch.");
|
||||
}
|
||||
|
||||
return (GDExtensionPtrBuiltInMethod)Variant::get_ptr_builtin_method(Variant::Type(p_type), method);
|
||||
return ptr;
|
||||
}
|
||||
static GDExtensionPtrConstructor gdextension_variant_get_ptr_constructor(GDExtensionVariantType p_type, int32_t p_constructor) {
|
||||
return (GDExtensionPtrConstructor)Variant::get_ptr_constructor(Variant::Type(p_type), p_constructor);
|
||||
|
||||
Reference in New Issue
Block a user