Don't add a method + vmethod twice to the api.json, when a class defines a vmethod, and implements it.

This commit is contained in:
Relintai 2023-05-31 15:35:41 +02:00
parent 435b0bb31e
commit 16bb10a8e9
1 changed files with 13 additions and 3 deletions

View File

@ -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<ClassAPI> generate_c_api_classes() {
List<MethodInfo> methods;
ClassDB::get_method_list(class_name, &methods, true);
methods.sort_custom<MethodInfoComparator>();
RBSet<String> virtual_method_set;
for (List<MethodInfo>::Element *m = methods.front(); m != nullptr; m = m->next()) {
MethodAPI method_api;
@ -339,6 +341,14 @@ List<ClassAPI> 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++) {