diff options
Diffstat (limited to 'modules/gdnative/nativescript/nativescript.cpp')
-rw-r--r-- | modules/gdnative/nativescript/nativescript.cpp | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index b9bd65af53..52379560b3 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -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(); @@ -1010,17 +1009,12 @@ void NativeScriptLanguage::init_library(const Ref<GDNativeLibrary> &lib) { if (!library_script_users.has(lib_path)) library_script_users.insert(lib_path, Set<NativeScript *>()); - void *args[1] = { - (void *)&lib_path - }; + void *proc_ptr; + + gdn->get_symbol(_init_call_name, proc_ptr); + + ((void (*)(godot_string *))proc_ptr)((godot_string *)&lib_path); - // here the library registers all the classes and stuff. - gdn->call_native_raw(_init_call_type, - _init_call_name, - NULL, - 1, - args, - NULL); } else { // already initialized. Nice. } @@ -1053,13 +1047,13 @@ void NativeScriptLanguage::call_libraries_cb(const StringName &name) { // library_gdnatives is modified only from the main thread, so it's safe not to use mutex here for (Map<String, Ref<GDNative> >::Element *L = library_gdnatives.front(); L; L = L->next()) { if (L->get()->is_initialized()) { - L->get()->call_native_raw( - _noarg_call_type, - name, - NULL, - 0, - NULL, - NULL); + + void *proc_ptr; + Error err = L->get()->get_symbol(name, proc_ptr); + + if (!err) { + ((void (*)())proc_ptr)(); + } } } } @@ -1142,12 +1136,11 @@ void NativeReloadNode::_notification(int p_what) { }; // here the library registers all the classes and stuff. - L->get()->call_native_raw(NSL->_init_call_type, - NSL->_init_call_name, - NULL, - 1, - args, - NULL); + + void *proc_ptr; + L->get()->get_symbol("godot_nativescript_init", proc_ptr); + + ((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()) { |