[GDNative] removed native_raw_call

This commit is contained in:
Karroffel 2017-10-14 15:42:10 +02:00
parent e82a3f0168
commit e568f80e6e
8 changed files with 80 additions and 204 deletions

View file

@ -438,7 +438,7 @@ NativeScript::~NativeScript() {
#endif
}
////// ScriptInstance stuff
////// ScriptInstance stuff
#define GET_SCRIPT_DESC() script->get_script_desc()
@ -1010,17 +1010,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 +1048,15 @@ 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 != OK) {
ERR_PRINT((String("No godot_gdnative_init in \"" + L->get()->get_library()->get_active_library_path()) + "\" found").utf8().get_data());
} else {
((void (*)())proc_ptr)();
}
}
}
}
@ -1142,12 +1139,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()) {