From 6f3fffecb390aacb8cac1f20f0a3fe0665e226e4 Mon Sep 17 00:00:00 2001 From: sheepandshepherd Date: Sun, 8 Oct 2017 23:51:24 +0200 Subject: [PATCH] Include property index in GDNative class API Needed by properties that share set/get functions. Fixes #10329. --- modules/gdnative/nativescript/api_generator.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp index fdd5a2ea198..9a956ff594c 100644 --- a/modules/gdnative/nativescript/api_generator.cpp +++ b/modules/gdnative/nativescript/api_generator.cpp @@ -80,6 +80,7 @@ struct PropertyAPI { String getter; String setter; String type; + int index; }; struct ConstantAPI { @@ -259,6 +260,8 @@ List generate_c_api_classes() { property_api.type = get_type_name(p->get()); } + property_api.index = ClassDB::get_property_index(class_name, p->get().name); + if (!property_api.setter.empty() || !property_api.getter.empty()) { class_api.properties.push_back(property_api); } @@ -395,7 +398,8 @@ static List generate_c_api_json(const List &p_api) { source.push_back("\t\t\t\t\"name\": \"" + e->get().name + "\",\n"); source.push_back("\t\t\t\t\"type\": \"" + e->get().type + "\",\n"); source.push_back("\t\t\t\t\"getter\": \"" + e->get().getter + "\",\n"); - source.push_back("\t\t\t\t\"setter\": \"" + e->get().setter + "\"\n"); + source.push_back("\t\t\t\t\"setter\": \"" + e->get().setter + "\",\n"); + source.push_back(String("\t\t\t\t\"index\": ") + itos(e->get().index) + "\n"); source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n"); } source.push_back("\t\t],\n");