You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-12 13:20:55 +00:00
Ignore fake properties in classes when generating extension_api.json
In extension_api.json we want to expose properties that are meant to access a class attribute from script (i.e. `Node2D.position`). However property system is also used in Godot to declare attributes accessible from the node editor: - property with '/' in their name - property array with NIL type that represents an array
This commit is contained in:
@@ -52,6 +52,9 @@ static String get_type_name(const PropertyInfo &p_info) {
|
|||||||
if (p_info.type == Variant::INT && (p_info.usage & (PROPERTY_USAGE_CLASS_IS_BITFIELD))) {
|
if (p_info.type == Variant::INT && (p_info.usage & (PROPERTY_USAGE_CLASS_IS_BITFIELD))) {
|
||||||
return String("bitfield::") + String(p_info.class_name);
|
return String("bitfield::") + String(p_info.class_name);
|
||||||
}
|
}
|
||||||
|
if (p_info.type == Variant::INT && (p_info.usage & PROPERTY_USAGE_ARRAY)) {
|
||||||
|
return "int";
|
||||||
|
}
|
||||||
if (p_info.class_name != StringName()) {
|
if (p_info.class_name != StringName()) {
|
||||||
return p_info.class_name;
|
return p_info.class_name;
|
||||||
}
|
}
|
||||||
@@ -840,12 +843,16 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
|
|||||||
List<PropertyInfo> property_list;
|
List<PropertyInfo> property_list;
|
||||||
ClassDB::get_property_list(class_name, &property_list, true);
|
ClassDB::get_property_list(class_name, &property_list, true);
|
||||||
for (const PropertyInfo &F : property_list) {
|
for (const PropertyInfo &F : property_list) {
|
||||||
if (F.usage & PROPERTY_USAGE_CATEGORY || F.usage & PROPERTY_USAGE_GROUP || F.usage & PROPERTY_USAGE_SUBGROUP) {
|
if (F.usage & PROPERTY_USAGE_CATEGORY || F.usage & PROPERTY_USAGE_GROUP || F.usage & PROPERTY_USAGE_SUBGROUP || (F.type == Variant::NIL && F.usage & PROPERTY_USAGE_ARRAY)) {
|
||||||
continue; //not real properties
|
continue; //not real properties
|
||||||
}
|
}
|
||||||
if (F.name.begins_with("_")) {
|
if (F.name.begins_with("_")) {
|
||||||
continue; //hidden property
|
continue; //hidden property
|
||||||
}
|
}
|
||||||
|
if (F.name.find("/") >= 0) {
|
||||||
|
// Ignore properties with '/' (slash) in the name. These are only meant for use in the inspector.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
StringName property_name = F.name;
|
StringName property_name = F.name;
|
||||||
Dictionary d2;
|
Dictionary d2;
|
||||||
d2["type"] = get_type_name(F);
|
d2["type"] = get_type_name(F);
|
||||||
|
|||||||
Reference in New Issue
Block a user