You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-05 17:15:09 +00:00
Revert removal of GDNativeExtensionScriptInstanceInfo::get_property_type_func in GDExtension
This function pointer is needed to stay close to internal Godot's ScriptInstance class. Besides, by removing this function pointer, we had to do property list create/free each time we want to access type which is quadratic complexity :/
This commit is contained in:
@@ -681,21 +681,15 @@ public:
|
||||
}
|
||||
}
|
||||
virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const override {
|
||||
Variant::Type type = Variant::Type::NIL;
|
||||
if (native_info->get_property_list_func) {
|
||||
uint32_t pcount;
|
||||
const GDNativePropertyInfo *pinfo = native_info->get_property_list_func(instance, &pcount);
|
||||
for (uint32_t i = 0; i < pcount; i++) {
|
||||
if (p_name == *reinterpret_cast<StringName *>(pinfo->name)) {
|
||||
type = Variant::Type(pinfo->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (native_info->free_property_list_func) {
|
||||
native_info->free_property_list_func(instance, pinfo);
|
||||
if (native_info->get_property_type_func) {
|
||||
GDNativeBool is_valid = 0;
|
||||
GDNativeVariantType type = native_info->get_property_type_func(instance, (const GDNativeStringNamePtr)&p_name, &is_valid);
|
||||
if (r_is_valid) {
|
||||
*r_is_valid = is_valid != 0;
|
||||
}
|
||||
return Variant::Type(type);
|
||||
}
|
||||
return type;
|
||||
return Variant::NIL;
|
||||
}
|
||||
|
||||
virtual bool property_can_revert(const StringName &p_name) const override {
|
||||
|
||||
Reference in New Issue
Block a user