diff options
Diffstat (limited to 'modules/gdnative/nativescript/nativescript.cpp')
-rw-r--r-- | modules/gdnative/nativescript/nativescript.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 7e3a7c8e9e..aa1fdc32da 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -31,11 +31,11 @@ #include "gdnative/gdnative.h" -#include "global_constants.h" +#include "core/global_constants.h" +#include "core/project_settings.h" #include "io/file_access_encrypted.h" #include "os/file_access.h" #include "os/os.h" -#include "project_settings.h" #include "scene/main/scene_tree.h" #include "scene/resources/scene_format_text.h" @@ -137,7 +137,6 @@ bool NativeScript::can_instance() const { #endif } -// TODO(karroffel): implement this Ref<Script> NativeScript::get_base_script() const { NativeScriptDesc *script_data = get_script_desc(); @@ -1012,10 +1011,13 @@ void NativeScriptLanguage::init_library(const Ref<GDNativeLibrary> &lib) { void *proc_ptr; - gdn->get_symbol(_init_call_name, proc_ptr); - - ((void (*)(godot_string *))proc_ptr)((godot_string *)&lib_path); + Error err = gdn->get_symbol(_init_call_name, proc_ptr); + if (err != OK) { + ERR_PRINT(String("No " + _init_call_name + " in \"" + lib_path + "\" found").utf8().get_data()); + } else { + ((void (*)(godot_string *))proc_ptr)((godot_string *)&lib_path); + } } else { // already initialized. Nice. } @@ -1052,9 +1054,7 @@ void NativeScriptLanguage::call_libraries_cb(const StringName &name) { void *proc_ptr; Error err = L->get()->get_symbol(name, proc_ptr); - if (err != OK) { - ERR_PRINT((String("No godot_gdnative_init in \"" + L->get()->get_library()->get_active_library_path()) + "\" found").utf8().get_data()); - } else { + if (!err) { ((void (*)())proc_ptr)(); } } @@ -1141,9 +1141,12 @@ void NativeReloadNode::_notification(int p_what) { // here the library registers all the classes and stuff. void *proc_ptr; - L->get()->get_symbol("godot_nativescript_init", proc_ptr); - - ((void (*)(void *))proc_ptr)((void *)&L->key()); + Error err = L->get()->get_symbol("godot_nativescript_init", proc_ptr); + if (err != OK) { + ERR_PRINT(String("No godot_nativescript_init in \"" + L->key() + "\" found").utf8().get_data()); + } else { + ((void (*)(void *))proc_ptr)((void *)&L->key()); + } for (Map<String, Set<NativeScript *> >::Element *U = NSL->library_script_users.front(); U; U = U->next()) { for (Set<NativeScript *>::Element *S = U->get().front(); S; S = S->next()) { |