From 16bb10a8e934d85af6e87e5a910ad6aeb20570c4 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 31 May 2023 15:35:41 +0200 Subject: [PATCH] Don't add a method + vmethod twice to the api.json, when a class defines a vmethod, and implements it. --- nativescript/api_generator.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/nativescript/api_generator.cpp b/nativescript/api_generator.cpp index ddccfe8..96be820 100644 --- a/nativescript/api_generator.cpp +++ b/nativescript/api_generator.cpp @@ -32,11 +32,12 @@ #ifdef TOOLS_ENABLED -#include "core/object/class_db.h" #include "core/config/engine.h" -#include "core/global_constants.h" -#include "core/os/file_access.h" #include "core/containers/pair.h" +#include "core/containers/rb_set.h" +#include "core/global_constants.h" +#include "core/object/class_db.h" +#include "core/os/file_access.h" // helper stuff @@ -306,6 +307,7 @@ List generate_c_api_classes() { List methods; ClassDB::get_method_list(class_name, &methods, true); methods.sort_custom(); + RBSet virtual_method_set; for (List::Element *m = methods.front(); m != nullptr; m = m->next()) { MethodAPI method_api; @@ -339,6 +341,14 @@ List generate_c_api_classes() { method_api.is_virtual = method_api.is_virtual || method_api.method_name[0] == '_'; + if (method_api.is_virtual) { + if (virtual_method_set.has(method_api.method_name)) { + continue; + } + + virtual_method_set.insert(method_api.method_name); + } + // method argument name and type for (int i = 0; i < method_api.argument_count; i++) {