summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/dlscript/api_generator.cpp18
-rw-r--r--modules/dlscript/godot.cpp4
2 files changed, 20 insertions, 2 deletions
diff --git a/modules/dlscript/api_generator.cpp b/modules/dlscript/api_generator.cpp
index c8e38ca9a3..7729359ded 100644
--- a/modules/dlscript/api_generator.cpp
+++ b/modules/dlscript/api_generator.cpp
@@ -4,6 +4,7 @@
#include "class_db.h"
#include "core/global_config.h"
+#include "core/global_constants.h"
#include "os/file_access.h"
// helper stuff
@@ -92,6 +93,23 @@ List<ClassAPI> generate_c_api_classes() {
List<StringName> classes;
ClassDB::get_class_list(&classes);
+ // Register global constants as a fake GlobalConstants singleton class
+ {
+ ClassAPI global_constants_api;
+ global_constants_api.class_name = L"GlobalConstants";
+ global_constants_api.api_type = ClassDB::API_CORE;
+ global_constants_api.is_singleton = true;
+ global_constants_api.is_instanciable = false;
+ const int constants_count = GlobalConstants::get_global_constant_count();
+ for (int i = 0; i < constants_count; ++i) {
+ ConstantAPI constant_api;
+ constant_api.constant_name = GlobalConstants::get_global_constant_name(i);
+ constant_api.constant_value = GlobalConstants::get_global_constant_value(i);
+ global_constants_api.constants.push_back(constant_api);
+ }
+ api.push_back(global_constants_api);
+ }
+
for (List<StringName>::Element *e = classes.front(); e != NULL; e = e->next()) {
StringName class_name = e->get();
diff --git a/modules/dlscript/godot.cpp b/modules/dlscript/godot.cpp
index 0b7935a735..fccf3a29bd 100644
--- a/modules/dlscript/godot.cpp
+++ b/modules/dlscript/godot.cpp
@@ -183,8 +183,8 @@ void GDAPI *godot_dlinstance_get_userdata(godot_object *p_instance) {
void GDAPI godot_get_global_constants(godot_dictionary *p_constants) {
Dictionary *constants = (Dictionary *)p_constants;
- const int constants_cont = GlobalConstants::get_global_constant_count();
- for (int i = 0; i < constants_cont; ++i) {
+ const int constants_count = GlobalConstants::get_global_constant_count();
+ for (int i = 0; i < constants_count; ++i) {
const char *name = GlobalConstants::get_global_constant_name(i);
int value = GlobalConstants::get_global_constant_value(i);
(*constants)[name] = value;