summaryrefslogtreecommitdiff
path: root/modules/gdnative
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-11-16 23:00:07 +0100
committerGitHub <noreply@github.com>2019-11-16 23:00:07 +0100
commit3c831377712ec7b37d8f22739538e6abb3c7741f (patch)
tree41df7b5b2afcc0ad83b5569a7cd1dea77419309a /modules/gdnative
parente9f905dcccb0bd2492f6bd22cb274055f5a8032f (diff)
parent03e1568aeb5ba82b106fedf4599cb56ee8e7fe69 (diff)
Merge pull request #33662 from touilleMan/issue-30577
Add singleton_name field to autogenerated json api
Diffstat (limited to 'modules/gdnative')
-rw-r--r--modules/gdnative/nativescript/api_generator.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp
index e0cf990f83..eace195c33 100644
--- a/modules/gdnative/nativescript/api_generator.cpp
+++ b/modules/gdnative/nativescript/api_generator.cpp
@@ -108,6 +108,7 @@ struct ClassAPI {
ClassDB::APIType api_type;
bool is_singleton;
+ String singleton_name;
bool is_instanciable;
// @Unclear
bool is_reference;
@@ -183,6 +184,7 @@ List<ClassAPI> generate_c_api_classes() {
global_constants_api.class_name = L"GlobalConstants";
global_constants_api.api_type = ClassDB::API_CORE;
global_constants_api.is_singleton = true;
+ global_constants_api.singleton_name = L"GlobalConstants";
global_constants_api.is_instanciable = false;
const int constants_count = GlobalConstants::get_global_constant_count();
for (int i = 0; i < constants_count; ++i) {
@@ -208,6 +210,9 @@ List<ClassAPI> generate_c_api_classes() {
name.remove(0);
}
class_api.is_singleton = Engine::get_singleton()->has_singleton(name);
+ if (class_api.is_singleton) {
+ class_api.singleton_name = name;
+ }
}
class_api.is_instanciable = !class_api.is_singleton && ClassDB::can_instance(class_name);
@@ -421,6 +426,7 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) {
source.push_back("\t\t\"base_class\": \"" + api.super_class_name + "\",\n");
source.push_back(String("\t\t\"api_type\": \"") + (api.api_type == ClassDB::API_CORE ? "core" : (api.api_type == ClassDB::API_EDITOR ? "tools" : "none")) + "\",\n");
source.push_back(String("\t\t\"singleton\": ") + (api.is_singleton ? "true" : "false") + ",\n");
+ source.push_back("\t\t\"singleton_name\": \"" + api.singleton_name + "\",\n");
source.push_back(String("\t\t\"instanciable\": ") + (api.is_instanciable ? "true" : "false") + ",\n");
source.push_back(String("\t\t\"is_reference\": ") + (api.is_reference ? "true" : "false") + ",\n");
// @Unclear