diff options
author | Thomas Herzog <thomas.herzog@mail.com> | 2017-11-25 00:26:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-25 00:26:36 +0100 |
commit | ee4729cc07b904f92501d55d985ee2d325ba6e89 (patch) | |
tree | bd388b6570402fdde2732dd92217ee53981209cf /src/core/GodotGlobal.cpp | |
parent | e72f4beec1b091edf6f16a0fe27d5ed13ca450c2 (diff) | |
parent | d8faa4ec76bc73ca17b8e5dd72220d16996423c3 (diff) | |
download | redot-cpp-ee4729cc07b904f92501d55d985ee2d325ba6e89.tar.gz |
Merge pull request #52 from BastiaanOlij/change_to_new_extensions
Update bindings to use new Api extensions and rename Rect3->AABB
Diffstat (limited to 'src/core/GodotGlobal.cpp')
-rw-r--r-- | src/core/GodotGlobal.cpp | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/src/core/GodotGlobal.cpp b/src/core/GodotGlobal.cpp index dc21389..8566481 100644 --- a/src/core/GodotGlobal.cpp +++ b/src/core/GodotGlobal.cpp @@ -5,7 +5,8 @@ namespace godot { void *_RegisterState::nativescript_handle; -const godot_gdnative_api_struct *api = NULL; +const godot_gdnative_core_api_struct *api = NULL; +const godot_gdnative_ext_nativescript_api_struct *nativescript_api = NULL; void Godot::print(const String& message) { @@ -14,12 +15,36 @@ void Godot::print(const String& message) void Godot::print_warning(const String& description, const String& function, const String& file, int line) { - godot::api->godot_print_warning(description.c_string(), function.c_string(), file.c_string(), line); + int len; + + char * c_desc = description.alloc_c_string(); + char * c_func = function.alloc_c_string(); + char * c_file = file.alloc_c_string(); + + if (c_desc != NULL && c_func !=NULL && c_file != NULL) { + godot::api->godot_print_warning(c_desc, c_func, c_file, line); + }; + + if (c_desc != NULL) godot::api->godot_free(c_desc); + if (c_func != NULL) godot::api->godot_free(c_func); + if (c_file != NULL) godot::api->godot_free(c_file); } void Godot::print_error(const String& description, const String& function, const String& file, int line) { - godot::api->godot_print_error(description.c_string(), function.c_string(), file.c_string(), line); + int len; + + char * c_desc = description.alloc_c_string(); + char * c_func = function.alloc_c_string(); + char * c_file = file.alloc_c_string(); + + if (c_desc != NULL && c_func !=NULL && c_file != NULL) { + godot::api->godot_print_error(c_desc, c_func, c_file, line); + }; + + if (c_desc != NULL) godot::api->godot_free(c_desc); + if (c_func != NULL) godot::api->godot_free(c_func); + if (c_file != NULL) godot::api->godot_free(c_file); } }; @@ -28,6 +53,17 @@ void gdnative_init(godot_gdnative_init_options *options); extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *options) { godot::api = options->api_struct; + + // now find our extensions + for (int i = 0; i < godot::api->num_extensions; i++) { + switch (godot::api->extensions[i]->type) { + case GDNATIVE_EXT_NATIVESCRIPT: { + godot::nativescript_api = (godot_gdnative_ext_nativescript_api_struct *)godot::api->extensions[i]; + }; break; + default: break; + }; + }; + gdnative_init(options); } |