aboutsummaryrefslogtreecommitdiff
path: root/modules/gdnative/register_types.cpp
diff options
context:
space:
mode:
authorKarroffel2017-10-14 15:42:10 +0200
committerKarroffel2017-10-14 15:50:55 +0200
commite568f80e6ee61407dfe7f403f123679ec55b1e53 (patch)
treeab40bc64dac71bbf3179d85704a0507acf509c6f /modules/gdnative/register_types.cpp
parente82a3f0168de499c86a62a4b8699da2b18e95195 (diff)
downloadgodot-e568f80e6ee61407dfe7f403f123679ec55b1e53.tar.gz
godot-e568f80e6ee61407dfe7f403f123679ec55b1e53.tar.zst
godot-e568f80e6ee61407dfe7f403f123679ec55b1e53.zip
[GDNative] removed native_raw_call
Diffstat (limited to 'modules/gdnative/register_types.cpp')
-rw-r--r--modules/gdnative/register_types.cpp70
1 files changed, 13 insertions, 57 deletions
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index 8f4eed091..8e5f58524 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -128,57 +128,12 @@ static void editor_init_callback() {
#endif
-godot_variant cb_standard_varcall(void *handle, godot_string *p_procedure, godot_array *p_args) {
- if (handle == NULL) {
- ERR_PRINT("No valid library handle, can't call standard varcall procedure");
- godot_variant ret;
- godot_variant_new_nil(&ret);
- return ret;
- }
-
- void *library_proc;
- Error err = OS::get_singleton()->get_dynamic_library_symbol_handle(
- handle,
- *(String *)p_procedure,
- library_proc,
- true); // we roll our own message
- if (err != OK) {
- ERR_PRINT((String("GDNative procedure \"" + *(String *)p_procedure) + "\" does not exists and can't be called").utf8().get_data());
- godot_variant ret;
- godot_variant_new_nil(&ret);
- return ret;
- }
+godot_variant cb_standard_varcall(void *p_procedure_handle, godot_array *p_args) {
godot_gdnative_procedure_fn proc;
- proc = (godot_gdnative_procedure_fn)library_proc;
-
- return proc(NULL, p_args);
-}
-
-void cb_singleton_call(
- void *p_handle,
- godot_string *p_proc_name,
- void *p_data,
- int p_num_args,
- void **p_args,
- void *r_return) {
- if (p_handle == NULL) {
- ERR_PRINT("No valid library handle, can't call singleton procedure");
- return;
- }
+ proc = (godot_gdnative_procedure_fn)p_procedure_handle;
- void *singleton_proc;
- Error err = OS::get_singleton()->get_dynamic_library_symbol_handle(
- p_handle,
- *(String *)p_proc_name,
- singleton_proc);
-
- if (err != OK) {
- return;
- }
-
- void (*singleton_procedure_ptr)() = (void (*)())singleton_proc;
- singleton_procedure_ptr();
+ return proc(p_args);
}
GDNativeCallRegistry *GDNativeCallRegistry::singleton;
@@ -201,8 +156,6 @@ void register_gdnative_types() {
GDNativeCallRegistry::singleton->register_native_call_type("standard_varcall", cb_standard_varcall);
- GDNativeCallRegistry::singleton->register_native_raw_call_type("gdnative_singleton_call", cb_singleton_call);
-
register_nativearvr_types();
register_nativescript_types();
@@ -225,13 +178,16 @@ void register_gdnative_types() {
continue;
}
- singleton_gdnatives[i]->call_native_raw(
- "gdnative_singleton_call",
+ void *proc_ptr;
+ Error err = singleton_gdnatives[i]->get_symbol(
"godot_gdnative_singleton",
- NULL,
- 0,
- NULL,
- NULL);
+ proc_ptr);
+
+ if (err != OK) {
+ ERR_PRINT((String("No godot_gdnative_singleton in \"" + singleton_gdnatives[i]->get_library()->get_active_library_path()) + "\" found").utf8().get_data());
+ } else {
+ ((void (*)())proc_ptr)();
+ }
}
}
@@ -283,4 +239,4 @@ void unregister_gdnative_types() {
print_line(String("vector2:\t") + itos(sizeof(Vector2)));
print_line(String("vector3:\t") + itos(sizeof(Vector3)));
*/
-} \ No newline at end of file
+}