From fc1fe720c35d2669750079e7523b5436a01582a9 Mon Sep 17 00:00:00 2001 From: Bastiaan Olij Date: Mon, 12 Aug 2019 19:55:29 +1000 Subject: [PATCH] Store all main entry points to the currently available APIs --- include/core/GodotGlobal.hpp | 8 ++++++++ src/core/GodotGlobal.cpp | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/include/core/GodotGlobal.hpp b/include/core/GodotGlobal.hpp index 12f8801f..70f71573 100644 --- a/include/core/GodotGlobal.hpp +++ b/include/core/GodotGlobal.hpp @@ -9,8 +9,16 @@ namespace godot { extern "C" const godot_gdnative_core_api_struct *api; extern "C" const godot_gdnative_core_1_1_api_struct *core_1_1_api; +extern "C" const godot_gdnative_core_1_2_api_struct *core_1_2_api; + extern "C" const godot_gdnative_ext_nativescript_api_struct *nativescript_api; extern "C" const godot_gdnative_ext_nativescript_1_1_api_struct *nativescript_1_1_api; +extern "C" const godot_gdnative_ext_pluginscript_api_struct *pluginscript_api; +extern "C" const godot_gdnative_ext_android_api_struct *android_api; +extern "C" const godot_gdnative_ext_arvr_api_struct *arvr_api; +extern "C" const godot_gdnative_ext_videodecoder_api_struct *videodecoder_api; +extern "C" const godot_gdnative_ext_net_api_struct *net_api; +extern "C" const godot_gdnative_ext_net_3_2_api_struct *net_3_2_api; extern "C" const void *gdnlib; diff --git a/src/core/GodotGlobal.cpp b/src/core/GodotGlobal.cpp index e01b2825..31be6c81 100644 --- a/src/core/GodotGlobal.cpp +++ b/src/core/GodotGlobal.cpp @@ -27,9 +27,16 @@ int _RegisterState::language_index; const godot_gdnative_core_api_struct *api = nullptr; const godot_gdnative_core_1_1_api_struct *core_1_1_api = nullptr; +const godot_gdnative_core_1_2_api_struct *core_1_2_api = nullptr; const godot_gdnative_ext_nativescript_api_struct *nativescript_api = nullptr; const godot_gdnative_ext_nativescript_1_1_api_struct *nativescript_1_1_api = nullptr; +const godot_gdnative_ext_pluginscript_api_struct *pluginscript_api = nullptr; +const godot_gdnative_ext_android_api_struct *android_api = nullptr; +const godot_gdnative_ext_arvr_api_struct *arvr_api = nullptr; +const godot_gdnative_ext_videodecoder_api_struct *videodecoder_api = nullptr; +const godot_gdnative_ext_net_api_struct *net_api = nullptr; +const godot_gdnative_ext_net_3_2_api_struct *net_3_2_api = nullptr; const void *gdnlib = NULL; @@ -81,6 +88,8 @@ void Godot::gdnative_init(godot_gdnative_init_options *options) { while (core_extension) { if (core_extension->version.major == 1 && core_extension->version.minor == 1) { godot::core_1_1_api = (const godot_gdnative_core_1_1_api_struct *)core_extension; + } else if (core_extension->version.major == 1 && core_extension->version.minor == 2) { + godot::core_1_2_api = (const godot_gdnative_core_1_2_api_struct *)core_extension; } core_extension = core_extension->next; } @@ -101,6 +110,32 @@ void Godot::gdnative_init(godot_gdnative_init_options *options) { extension = extension->next; } } break; + case GDNATIVE_EXT_PLUGINSCRIPT: { + godot::pluginscript_api = (const godot_gdnative_ext_pluginscript_api_struct *)godot::api->extensions[i]; + } break; + case GDNATIVE_EXT_ANDROID: { + godot::android_api = (const godot_gdnative_ext_android_api_struct *)godot::api->extensions[i]; + } break; + case GDNATIVE_EXT_ARVR: { + godot::arvr_api = (const godot_gdnative_ext_arvr_api_struct *)godot::api->extensions[i]; + } break; + case GDNATIVE_EXT_VIDEODECODER: { + godot::videodecoder_api = (const godot_gdnative_ext_videodecoder_api_struct *)godot::api->extensions[i]; + } break; + case GDNATIVE_EXT_NET: { + godot::net_api = (const godot_gdnative_ext_net_api_struct *)godot::api->extensions[i]; + + const godot_gdnative_api_struct *extension = godot::net_api->next; + + while (extension) { + if (extension->version.major == 3 && extension->version.minor == 2) { + godot::net_3_2_api = (const godot_gdnative_ext_net_3_2_api_struct *)extension; + } + + extension = extension->next; + } + } break; + default: break; } }