summaryrefslogtreecommitdiff
path: root/modules/gdnative
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdnative')
-rw-r--r--modules/gdnative/SCsub47
-rw-r--r--modules/gdnative/arvr/arvr_interface_gdnative.cpp4
-rw-r--r--modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml2
-rw-r--r--modules/gdnative/doc_classes/GDNative.xml16
-rw-r--r--modules/gdnative/doc_classes/GDNativeLibrary.xml50
-rw-r--r--modules/gdnative/doc_classes/NativeScript.xml30
-rw-r--r--modules/gdnative/doc_classes/PluginScript.xml2
-rw-r--r--modules/gdnative/gdnative.cpp61
-rw-r--r--modules/gdnative/gdnative.h14
-rw-r--r--modules/gdnative/gdnative/aabb.cpp217
-rw-r--r--modules/gdnative/gdnative/array.cpp11
-rw-r--r--modules/gdnative/gdnative/basis.cpp2
-rw-r--r--modules/gdnative/gdnative/gdnative.cpp36
-rw-r--r--modules/gdnative/gdnative/node_path.cpp4
-rw-r--r--modules/gdnative/gdnative/quat.cpp2
-rw-r--r--modules/gdnative/gdnative/rect3.cpp217
-rw-r--r--modules/gdnative/gdnative/string.cpp5
-rw-r--r--modules/gdnative/gdnative/transform.cpp16
-rw-r--r--modules/gdnative/gdnative/variant.cpp12
-rw-r--r--modules/gdnative/gdnative/vector2.cpp2
-rw-r--r--modules/gdnative/gdnative/vector3.cpp2
-rw-r--r--modules/gdnative/gdnative_api.json197
-rw-r--r--modules/gdnative/include/gdnative/aabb.h117
-rw-r--r--modules/gdnative/include/gdnative/array.h4
-rw-r--r--modules/gdnative/include/gdnative/basis.h2
-rw-r--r--modules/gdnative/include/gdnative/gdnative.h32
-rw-r--r--modules/gdnative/include/gdnative/node_path.h2
-rw-r--r--modules/gdnative/include/gdnative/quat.h2
-rw-r--r--modules/gdnative/include/gdnative/rect3.h117
-rw-r--r--modules/gdnative/include/gdnative/string.h2
-rw-r--r--modules/gdnative/include/gdnative/transform.h4
-rw-r--r--modules/gdnative/include/gdnative/variant.h8
-rw-r--r--modules/gdnative/include/gdnative/vector2.h2
-rw-r--r--modules/gdnative/include/gdnative/vector3.h2
-rw-r--r--modules/gdnative/nativescript/api_generator.cpp2
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp10
-rw-r--r--modules/gdnative/nativescript/nativescript.h12
-rw-r--r--modules/gdnative/pluginscript/pluginscript_language.cpp4
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.cpp7
-rw-r--r--modules/gdnative/register_types.cpp116
40 files changed, 688 insertions, 706 deletions
diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub
index 66b8d5cbdd..fd11c8d094 100644
--- a/modules/gdnative/SCsub
+++ b/modules/gdnative/SCsub
@@ -19,19 +19,27 @@ def _spaced(e):
return e if e[-1] == '*' else e + ' '
def _build_gdnative_api_struct_header(api):
- ext_wrappers = ''
+ gdnative_api_init_macro = [
+ '\textern const godot_gdnative_core_api_struct *_gdnative_wrapper_api_struct;'
+ ]
for name in api['extensions']:
- ext_wrappers += ' extern const godot_gdnative_ext_' + name + '_api_struct *_gdnative_wrapper_' + name + '_api_struct;'
+ gdnative_api_init_macro.append(
+ '\textern const godot_gdnative_ext_{0}_api_struct *_gdnative_wrapper_{0}_api_struct;'.format(name))
- ext_init = 'for (int i = 0; i < _gdnative_wrapper_api_struct->num_extensions; i++) { '
- ext_init += 'switch (_gdnative_wrapper_api_struct->extensions[i]->type) {'
+ gdnative_api_init_macro.append('\t_gdnative_wrapper_api_struct = options->api_struct;')
+ gdnative_api_init_macro.append('\tfor (int i = 0; i < _gdnative_wrapper_api_struct->num_extensions; i++) { ')
+ gdnative_api_init_macro.append('\t\tswitch (_gdnative_wrapper_api_struct->extensions[i]->type) {')
for name in api['extensions']:
- ext_init += 'case GDNATIVE_EXT_' + api['extensions'][name]['type'] + ': '
- ext_init += '_gdnative_wrapper_' + name + '_api_struct = (' + 'godot_gdnative_ext_' + name + '_api_struct *) _gdnative_wrapper_api_struct->extensions[i]; break;'
-
- ext_init += '}'
+ gdnative_api_init_macro.append(
+ '\t\t\tcase GDNATIVE_EXT_%s:' % api['extensions'][name]['type'])
+ gdnative_api_init_macro.append(
+ '\t\t\t\t_gdnative_wrapper_{0}_api_struct = (godot_gdnative_ext_{0}_api_struct *)'
+ ' _gdnative_wrapper_api_struct->extensions[i];'.format(name))
+ gdnative_api_init_macro.append('\t\t\t\tbreak;')
+ gdnative_api_init_macro.append('\t\t}')
+ gdnative_api_init_macro.append('\t}')
out = [
'/* THIS FILE IS GENERATED DO NOT EDIT */',
@@ -43,25 +51,12 @@ def _build_gdnative_api_struct_header(api):
'#include <nativescript/godot_nativescript.h>',
'#include <pluginscript/godot_pluginscript.h>',
'',
- '#define GDNATIVE_API_INIT(options) do { extern const godot_gdnative_api_struct *_gdnative_wrapper_api_struct;' + ext_wrappers + ' _gdnative_wrapper_api_struct = options->api_struct; ' + ext_init + ' } while (0)',
+ '#define GDNATIVE_API_INIT(options) do { \\\n' + ' \\\n'.join(gdnative_api_init_macro) + ' \\\n } while (0)',
'',
'#ifdef __cplusplus',
'extern "C" {',
'#endif',
'',
- 'typedef struct godot_gdnative_api_version {',
- '\tunsigned int major;',
- '\tunsigned int minor;',
- '} godot_gdnative_api_version;',
- '',
- 'typedef struct godot_gdnative_api_struct godot_gdnative_api_struct;',
- '',
- 'struct godot_gdnative_api_struct {',
- '\tunsigned int type;',
- '\tgodot_gdnative_api_version version;',
- '\tconst godot_gdnative_api_struct *next;',
- '};',
- '',
'enum GDNATIVE_API_TYPES {',
'\tGDNATIVE_' + api['core']['type'] + ','
]
@@ -192,7 +187,7 @@ def _build_gdnative_wrapper_code(api):
]
for name in api['extensions']:
- out.append('godot_gdnative_ext_' + name + '_api_struct *_gdnative_wrapper_' + name + '_api_struct;')
+ out.append('godot_gdnative_ext_' + name + '_api_struct *_gdnative_wrapper_' + name + '_api_struct = 0;')
out += ['']
@@ -250,7 +245,7 @@ if ARGUMENTS.get('gdnative_wrapper', False):
gd_wrapper_env = env.Clone()
gd_wrapper_env.Append(CPPPATH=['#modules/gdnative/include/'])
- # I think this doesn't work on MSVC yet...
- gd_wrapper_env.Append(CCFLAGS=['-fPIC'])
+ if not env.msvc:
+ gd_wrapper_env.Append(CCFLAGS=['-fPIC'])
- gd_wrapper_env.Library("#bin/gdnative_wrapper_code", [gensource])
+ lib = gd_wrapper_env.add_library("#bin/gdnative_wrapper_code", [gensource])
diff --git a/modules/gdnative/arvr/arvr_interface_gdnative.cpp b/modules/gdnative/arvr/arvr_interface_gdnative.cpp
index 02f2ee7424..29e4775e62 100644
--- a/modules/gdnative/arvr/arvr_interface_gdnative.cpp
+++ b/modules/gdnative/arvr/arvr_interface_gdnative.cpp
@@ -219,7 +219,7 @@ extern "C" {
void GDAPI godot_arvr_register_interface(const godot_arvr_interface_gdnative *p_interface) {
Ref<ARVRInterfaceGDNative> new_interface;
new_interface.instance();
- new_interface->set_interface((godot_arvr_interface_gdnative * const)p_interface);
+ new_interface->set_interface((godot_arvr_interface_gdnative *const)p_interface);
ARVRServer::get_singleton()->add_interface(new_interface);
}
@@ -344,7 +344,7 @@ void GDAPI godot_arvr_set_controller_transform(godot_int p_controller_id, godot_
tracker->set_orientation(transform->basis);
}
if (p_tracks_position) {
- tracker->set_position(transform->origin);
+ tracker->set_rw_position(transform->origin);
}
}
}
diff --git a/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml b/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml
index 10957a3394..e4ffa76d36 100644
--- a/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml
+++ b/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="ARVRInterfaceGDNative" inherits="ARVRInterface" category="Core" version="3.0-alpha">
+<class name="ARVRInterfaceGDNative" inherits="ARVRInterface" category="Core" version="3.0-beta">
<brief_description>
GDNative wrapper for an ARVR interface
</brief_description>
diff --git a/modules/gdnative/doc_classes/GDNative.xml b/modules/gdnative/doc_classes/GDNative.xml
index 7a36d09aec..83953cef49 100644
--- a/modules/gdnative/doc_classes/GDNative.xml
+++ b/modules/gdnative/doc_classes/GDNative.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GDNative" inherits="Reference" category="Core" version="3.0-alpha">
+<class name="GDNative" inherits="Reference" category="Core" version="3.0-beta">
<brief_description>
</brief_description>
<description>
@@ -21,26 +21,12 @@
<description>
</description>
</method>
- <method name="get_library">
- <return type="GDNativeLibrary">
- </return>
- <description>
- </description>
- </method>
<method name="initialize">
<return type="bool">
</return>
<description>
</description>
</method>
- <method name="set_library">
- <return type="void">
- </return>
- <argument index="0" name="library" type="GDNativeLibrary">
- </argument>
- <description>
- </description>
- </method>
<method name="terminate">
<return type="bool">
</return>
diff --git a/modules/gdnative/doc_classes/GDNativeLibrary.xml b/modules/gdnative/doc_classes/GDNativeLibrary.xml
index e271665fd4..647d27929f 100644
--- a/modules/gdnative/doc_classes/GDNativeLibrary.xml
+++ b/modules/gdnative/doc_classes/GDNativeLibrary.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GDNativeLibrary" inherits="Resource" category="Core" version="3.0-alpha">
+<class name="GDNativeLibrary" inherits="Resource" category="Core" version="3.0-beta">
<brief_description>
</brief_description>
<description>
@@ -27,54 +27,6 @@
<description>
</description>
</method>
- <method name="get_symbol_prefix" qualifiers="const">
- <return type="String">
- </return>
- <description>
- </description>
- </method>
- <method name="is_current_library_statically_linked" qualifiers="const">
- <return type="bool">
- </return>
- <description>
- </description>
- </method>
- <method name="is_singleton" qualifiers="const">
- <return type="bool">
- </return>
- <description>
- </description>
- </method>
- <method name="set_load_once">
- <return type="void">
- </return>
- <argument index="0" name="load_once" type="bool">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_singleton">
- <return type="void">
- </return>
- <argument index="0" name="singleton" type="bool">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_symbol_prefix">
- <return type="void">
- </return>
- <argument index="0" name="symbol_prefix" type="String">
- </argument>
- <description>
- </description>
- </method>
- <method name="should_load_once" qualifiers="const">
- <return type="bool">
- </return>
- <description>
- </description>
- </method>
</methods>
<members>
<member name="load_once" type="bool" setter="set_load_once" getter="should_load_once">
diff --git a/modules/gdnative/doc_classes/NativeScript.xml b/modules/gdnative/doc_classes/NativeScript.xml
index eb4e13f748..3f6025d02f 100644
--- a/modules/gdnative/doc_classes/NativeScript.xml
+++ b/modules/gdnative/doc_classes/NativeScript.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="NativeScript" inherits="Script" category="Core" version="3.0-alpha">
+<class name="NativeScript" inherits="Script" category="Core" version="3.0-beta">
<brief_description>
</brief_description>
<description>
@@ -9,40 +9,12 @@
<demos>
</demos>
<methods>
- <method name="get_class_name" qualifiers="const">
- <return type="String">
- </return>
- <description>
- </description>
- </method>
- <method name="get_library" qualifiers="const">
- <return type="GDNativeLibrary">
- </return>
- <description>
- </description>
- </method>
<method name="new" qualifiers="vararg">
<return type="Object">
</return>
<description>
</description>
</method>
- <method name="set_class_name">
- <return type="void">
- </return>
- <argument index="0" name="class_name" type="String">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_library">
- <return type="void">
- </return>
- <argument index="0" name="library" type="GDNativeLibrary">
- </argument>
- <description>
- </description>
- </method>
</methods>
<members>
<member name="class_name" type="String" setter="set_class_name" getter="get_class_name">
diff --git a/modules/gdnative/doc_classes/PluginScript.xml b/modules/gdnative/doc_classes/PluginScript.xml
index a5ab422d3c..1a2141247a 100644
--- a/modules/gdnative/doc_classes/PluginScript.xml
+++ b/modules/gdnative/doc_classes/PluginScript.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="PluginScript" inherits="Script" category="Core" version="3.0-alpha">
+<class name="PluginScript" inherits="Script" category="Core" version="3.0-beta">
<brief_description>
</brief_description>
<description>
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index 44d6dffc85..9c0041cbe0 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -64,7 +64,6 @@ void GDNativeLibrary::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_current_library_path"), &GDNativeLibrary::get_current_library_path);
ClassDB::bind_method(D_METHOD("get_current_dependencies"), &GDNativeLibrary::get_current_dependencies);
- ClassDB::bind_method(D_METHOD("is_current_library_statically_linked"), &GDNativeLibrary::is_current_library_statically_linked);
ClassDB::bind_method(D_METHOD("should_load_once"), &GDNativeLibrary::should_load_once);
ClassDB::bind_method(D_METHOD("is_singleton"), &GDNativeLibrary::is_singleton);
@@ -109,6 +108,9 @@ Ref<GDNativeLibrary> GDNative::get_library() {
return library;
}
+extern "C" void _gdnative_report_version_mismatch(const godot_object *p_library, const char *p_ext, godot_gdnative_api_version p_want, godot_gdnative_api_version p_have);
+extern "C" void _gdnative_report_loading_error(const godot_object *p_library, const char *p_what);
+
bool GDNative::initialize() {
if (library.is_null()) {
ERR_PRINT("No library set, can't initialize GDNative object");
@@ -116,12 +118,18 @@ bool GDNative::initialize() {
}
String lib_path = library->get_current_library_path();
- if (lib_path.empty() && !library->is_current_library_statically_linked()) {
+ if (lib_path.empty()) {
ERR_PRINT("No library set for this platform");
return false;
}
#ifdef IPHONE_ENABLED
- String path = lib_path.replace("res://", "dylibs/");
+ // on iOS we use static linking
+ String path = "";
+#elif defined(ANDROID_ENABLED)
+ // On Android dynamic libraries are located separately from resource assets,
+ // we should pass library name to dlopen(). The library name is flattened
+ // during export.
+ String path = lib_path.get_file();
#else
String path = ProjectSettings::get_singleton()->globalize_path(lib_path);
#endif
@@ -136,8 +144,8 @@ bool GDNative::initialize() {
}
}
- Error err = OS::get_singleton()->open_dynamic_library(path, native_handle);
- if (err != OK && !library->is_current_library_statically_linked()) {
+ Error err = OS::get_singleton()->open_dynamic_library(path, native_handle, true);
+ if (err != OK) {
return false;
}
@@ -146,13 +154,12 @@ bool GDNative::initialize() {
// we cheat here a little bit. you saw nothing
initialized = true;
- err = get_symbol(library->get_symbol_prefix() + init_symbol, library_init);
+ err = get_symbol(library->get_symbol_prefix() + init_symbol, library_init, false);
initialized = false;
if (err || !library_init) {
- if (!library->is_current_library_statically_linked())
- OS::get_singleton()->close_dynamic_library(native_handle);
+ OS::get_singleton()->close_dynamic_library(native_handle);
native_handle = NULL;
ERR_PRINT("Failed to obtain godot_gdnative_init symbol");
return false;
@@ -168,6 +175,8 @@ bool GDNative::initialize() {
options.core_api_hash = ClassDB::get_api_hash(ClassDB::API_CORE);
options.editor_api_hash = ClassDB::get_api_hash(ClassDB::API_EDITOR);
options.no_api_hash = ClassDB::get_api_hash(ClassDB::API_NONE);
+ options.report_version_mismatch = &_gdnative_report_version_mismatch;
+ options.report_loading_error = &_gdnative_report_loading_error;
options.gd_native_library = (godot_object *)(get_library().ptr());
options.active_library_path = (godot_string *)&path;
@@ -277,7 +286,7 @@ Variant GDNative::call_native(StringName p_native_call_type, StringName p_proced
return *(Variant *)&result;
}
-Error GDNative::get_symbol(StringName p_procedure_name, void *&r_handle) {
+Error GDNative::get_symbol(StringName p_procedure_name, void *&r_handle, bool p_optional) {
if (!initialized) {
ERR_PRINT("No valid library handle, can't get symbol from GDNative object");
@@ -288,7 +297,7 @@ Error GDNative::get_symbol(StringName p_procedure_name, void *&r_handle) {
native_handle,
p_procedure_name,
r_handle,
- true);
+ p_optional);
return result;
}
@@ -369,40 +378,8 @@ RES GDNativeLibraryResourceLoader::load(const String &p_path, const String &p_or
}
}
- bool is_statically_linked = false;
- {
-
- List<String> static_linking_keys;
- config->get_section_keys("static_linking", &static_linking_keys);
-
- for (List<String>::Element *E = static_linking_keys.front(); E; E = E->next()) {
- String key = E->get();
-
- Vector<String> tags = key.split(".");
-
- bool skip = false;
-
- for (int i = 0; i < tags.size(); i++) {
- bool has_feature = OS::get_singleton()->has_feature(tags[i]);
-
- if (!has_feature) {
- skip = true;
- break;
- }
- }
-
- if (skip) {
- continue;
- }
-
- is_statically_linked = config->get_value("static_linking", key);
- break;
- }
- }
-
lib->current_library_path = entry_lib_path;
lib->current_dependencies = dependency_paths;
- lib->current_library_statically_linked = is_statically_linked;
return lib;
}
diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h
index 061dff9267..993cd0ece7 100644
--- a/modules/gdnative/gdnative.h
+++ b/modules/gdnative/gdnative.h
@@ -55,7 +55,6 @@ class GDNativeLibrary : public Resource {
String current_library_path;
Vector<String> current_dependencies;
- bool current_library_statically_linked;
bool singleton;
bool load_once;
@@ -75,9 +74,6 @@ public:
_FORCE_INLINE_ Vector<String> get_current_dependencies() const {
return current_dependencies;
}
- _FORCE_INLINE_ bool is_current_library_statically_linked() const {
- return current_library_statically_linked;
- }
// things that are a property of the library itself, not platform specific
_FORCE_INLINE_ bool should_load_once() const {
@@ -103,17 +99,15 @@ public:
static void _bind_methods();
};
-typedef godot_variant (*native_call_cb)(void *, godot_array *);
-
struct GDNativeCallRegistry {
static GDNativeCallRegistry *singleton;
- inline GDNativeCallRegistry *get_singleton() {
+ inline static GDNativeCallRegistry *get_singleton() {
return singleton;
}
- inline GDNativeCallRegistry()
- : native_calls() {}
+ inline GDNativeCallRegistry() :
+ native_calls() {}
Map<StringName, native_call_cb> native_calls;
@@ -147,7 +141,7 @@ public:
Variant call_native(StringName p_native_call_type, StringName p_procedure_name, Array p_arguments = Array());
- Error get_symbol(StringName p_procedure_name, void *&r_handle);
+ Error get_symbol(StringName p_procedure_name, void *&r_handle, bool p_optional = true);
};
class GDNativeLibraryResourceLoader : public ResourceFormatLoader {
diff --git a/modules/gdnative/gdnative/aabb.cpp b/modules/gdnative/gdnative/aabb.cpp
new file mode 100644
index 0000000000..6c89bcdceb
--- /dev/null
+++ b/modules/gdnative/gdnative/aabb.cpp
@@ -0,0 +1,217 @@
+/*************************************************************************/
+/* aabb.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "gdnative/aabb.h"
+
+#include "core/math/aabb.h"
+#include "core/variant.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void GDAPI godot_aabb_new(godot_aabb *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size) {
+ const Vector3 *pos = (const Vector3 *)p_pos;
+ const Vector3 *size = (const Vector3 *)p_size;
+ AABB *dest = (AABB *)r_dest;
+ *dest = AABB(*pos, *size);
+}
+
+godot_vector3 GDAPI godot_aabb_get_position(const godot_aabb *p_self) {
+ godot_vector3 raw_ret;
+ const AABB *self = (const AABB *)p_self;
+ Vector3 *ret = (Vector3 *)&raw_ret;
+ *ret = self->position;
+ return raw_ret;
+}
+
+void GDAPI godot_aabb_set_position(const godot_aabb *p_self, const godot_vector3 *p_v) {
+ AABB *self = (AABB *)p_self;
+ const Vector3 *v = (const Vector3 *)p_v;
+ self->position = *v;
+}
+
+godot_vector3 GDAPI godot_aabb_get_size(const godot_aabb *p_self) {
+ godot_vector3 raw_ret;
+ const AABB *self = (const AABB *)p_self;
+ Vector3 *ret = (Vector3 *)&raw_ret;
+ *ret = self->size;
+ return raw_ret;
+}
+
+void GDAPI godot_aabb_set_size(const godot_aabb *p_self, const godot_vector3 *p_v) {
+ AABB *self = (AABB *)p_self;
+ const Vector3 *v = (const Vector3 *)p_v;
+ self->size = *v;
+}
+
+godot_string GDAPI godot_aabb_as_string(const godot_aabb *p_self) {
+ godot_string ret;
+ const AABB *self = (const AABB *)p_self;
+ memnew_placement(&ret, String(*self));
+ return ret;
+}
+
+godot_real GDAPI godot_aabb_get_area(const godot_aabb *p_self) {
+ const AABB *self = (const AABB *)p_self;
+ return self->get_area();
+}
+
+godot_bool GDAPI godot_aabb_has_no_area(const godot_aabb *p_self) {
+ const AABB *self = (const AABB *)p_self;
+ return self->has_no_area();
+}
+
+godot_bool GDAPI godot_aabb_has_no_surface(const godot_aabb *p_self) {
+ const AABB *self = (const AABB *)p_self;
+ return self->has_no_surface();
+}
+
+godot_bool GDAPI godot_aabb_intersects(const godot_aabb *p_self, const godot_aabb *p_with) {
+ const AABB *self = (const AABB *)p_self;
+ const AABB *with = (const AABB *)p_with;
+ return self->intersects(*with);
+}
+
+godot_bool GDAPI godot_aabb_encloses(const godot_aabb *p_self, const godot_aabb *p_with) {
+ const AABB *self = (const AABB *)p_self;
+ const AABB *with = (const AABB *)p_with;
+ return self->encloses(*with);
+}
+
+godot_aabb GDAPI godot_aabb_merge(const godot_aabb *p_self, const godot_aabb *p_with) {
+ godot_aabb dest;
+ const AABB *self = (const AABB *)p_self;
+ const AABB *with = (const AABB *)p_with;
+ *((AABB *)&dest) = self->merge(*with);
+ return dest;
+}
+
+godot_aabb GDAPI godot_aabb_intersection(const godot_aabb *p_self, const godot_aabb *p_with) {
+ godot_aabb dest;
+ const AABB *self = (const AABB *)p_self;
+ const AABB *with = (const AABB *)p_with;
+ *((AABB *)&dest) = self->intersection(*with);
+ return dest;
+}
+
+godot_bool GDAPI godot_aabb_intersects_plane(const godot_aabb *p_self, const godot_plane *p_plane) {
+ const AABB *self = (const AABB *)p_self;
+ const Plane *plane = (const Plane *)p_plane;
+ return self->intersects_plane(*plane);
+}
+
+godot_bool GDAPI godot_aabb_intersects_segment(const godot_aabb *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to) {
+ const AABB *self = (const AABB *)p_self;
+ const Vector3 *from = (const Vector3 *)p_from;
+ const Vector3 *to = (const Vector3 *)p_to;
+ return self->intersects_segment(*from, *to);
+}
+
+godot_bool GDAPI godot_aabb_has_point(const godot_aabb *p_self, const godot_vector3 *p_point) {
+ const AABB *self = (const AABB *)p_self;
+ const Vector3 *point = (const Vector3 *)p_point;
+ return self->has_point(*point);
+}
+
+godot_vector3 GDAPI godot_aabb_get_support(const godot_aabb *p_self, const godot_vector3 *p_dir) {
+ godot_vector3 dest;
+ const AABB *self = (const AABB *)p_self;
+ const Vector3 *dir = (const Vector3 *)p_dir;
+ *((Vector3 *)&dest) = self->get_support(*dir);
+ return dest;
+}
+
+godot_vector3 GDAPI godot_aabb_get_longest_axis(const godot_aabb *p_self) {
+ godot_vector3 dest;
+ const AABB *self = (const AABB *)p_self;
+ *((Vector3 *)&dest) = self->get_longest_axis();
+ return dest;
+}
+
+godot_int GDAPI godot_aabb_get_longest_axis_index(const godot_aabb *p_self) {
+ const AABB *self = (const AABB *)p_self;
+ return self->get_longest_axis_index();
+}
+
+godot_real GDAPI godot_aabb_get_longest_axis_size(const godot_aabb *p_self) {
+ const AABB *self = (const AABB *)p_self;
+ return self->get_longest_axis_size();
+}
+
+godot_vector3 GDAPI godot_aabb_get_shortest_axis(const godot_aabb *p_self) {
+ godot_vector3 dest;
+ const AABB *self = (const AABB *)p_self;
+ *((Vector3 *)&dest) = self->get_shortest_axis();
+ return dest;
+}
+
+godot_int GDAPI godot_aabb_get_shortest_axis_index(const godot_aabb *p_self) {
+ const AABB *self = (const AABB *)p_self;
+ return self->get_shortest_axis_index();
+}
+
+godot_real GDAPI godot_aabb_get_shortest_axis_size(const godot_aabb *p_self) {
+ const AABB *self = (const AABB *)p_self;
+ return self->get_shortest_axis_size();
+}
+
+godot_aabb GDAPI godot_aabb_expand(const godot_aabb *p_self, const godot_vector3 *p_to_point) {
+ godot_aabb dest;
+ const AABB *self = (const AABB *)p_self;
+ const Vector3 *to_point = (const Vector3 *)p_to_point;
+ *((AABB *)&dest) = self->expand(*to_point);
+ return dest;
+}
+
+godot_aabb GDAPI godot_aabb_grow(const godot_aabb *p_self, const godot_real p_by) {
+ godot_aabb dest;
+ const AABB *self = (const AABB *)p_self;
+
+ *((AABB *)&dest) = self->grow(p_by);
+ return dest;
+}
+
+godot_vector3 GDAPI godot_aabb_get_endpoint(const godot_aabb *p_self, const godot_int p_idx) {
+ godot_vector3 dest;
+ const AABB *self = (const AABB *)p_self;
+
+ *((Vector3 *)&dest) = self->get_endpoint(p_idx);
+ return dest;
+}
+
+godot_bool GDAPI godot_aabb_operator_equal(const godot_aabb *p_self, const godot_aabb *p_b) {
+ const AABB *self = (const AABB *)p_self;
+ const AABB *b = (const AABB *)p_b;
+ return *self == *b;
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/modules/gdnative/gdnative/array.cpp b/modules/gdnative/gdnative/array.cpp
index e0d9514985..8351c43574 100644
--- a/modules/gdnative/gdnative/array.cpp
+++ b/modules/gdnative/gdnative/array.cpp
@@ -302,6 +302,17 @@ void GDAPI godot_array_sort_custom(godot_array *p_self, godot_object *p_obj, con
self->sort_custom((Object *)p_obj, *func);
}
+godot_int GDAPI godot_array_bsearch(godot_array *p_self, const godot_variant *p_value, const godot_bool p_before) {
+ Array *self = (Array *)p_self;
+ return self->bsearch((const Variant *)p_value, p_before);
+}
+
+godot_int GDAPI godot_array_bsearch_custom(godot_array *p_self, const godot_variant *p_value, godot_object *p_obj, const godot_string *p_func, const godot_bool p_before) {
+ Array *self = (Array *)p_self;
+ const String *func = (const String *)p_func;
+ return self->bsearch_custom((const Variant *)p_value, (Object *)p_obj, *func, p_before);
+}
+
void GDAPI godot_array_destroy(godot_array *p_self) {
((Array *)p_self)->~Array();
}
diff --git a/modules/gdnative/gdnative/basis.cpp b/modules/gdnative/gdnative/basis.cpp
index 39ca754dc7..7a65996036 100644
--- a/modules/gdnative/gdnative/basis.cpp
+++ b/modules/gdnative/gdnative/basis.cpp
@@ -221,7 +221,7 @@ godot_basis GDAPI godot_basis_operator_add(const godot_basis *p_self, const godo
return raw_dest;
}
-godot_basis GDAPI godot_basis_operator_substract(const godot_basis *p_self, const godot_basis *p_b) {
+godot_basis GDAPI godot_basis_operator_subtract(const godot_basis *p_self, const godot_basis *p_b) {
godot_basis raw_dest;
Basis *dest = (Basis *)&raw_dest;
const Basis *self = (const Basis *)p_self;
diff --git a/modules/gdnative/gdnative/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp
index 6dfa7ec20b..8ff67b10b1 100644
--- a/modules/gdnative/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative/gdnative.cpp
@@ -36,6 +36,8 @@
#include "os/os.h"
#include "variant.h"
+#include "modules/gdnative/gdnative.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -50,10 +52,6 @@ godot_object GDAPI *godot_global_get_singleton(char *p_name) {
return (godot_object *)Engine::get_singleton()->get_singleton_object(String(p_name));
} // result shouldn't be freed
-void GDAPI *godot_get_stack_bottom() {
- return OS::get_singleton()->get_stack_bottom();
-}
-
// MethodBind API
godot_method_bind GDAPI *godot_method_bind_get_method(const char *p_classname, const char *p_methodname) {
@@ -113,6 +111,10 @@ godot_dictionary GDAPI godot_get_global_constants() {
}
// System functions
+void GDAPI godot_register_native_call_type(const char *p_call_type, native_call_cb p_callback) {
+ GDNativeCallRegistry::get_singleton()->register_native_call_type(StringName(p_call_type), p_callback);
+}
+
void GDAPI *godot_alloc(int p_bytes) {
return memalloc(p_bytes);
}
@@ -137,6 +139,32 @@ void GDAPI godot_print(const godot_string *p_message) {
print_line(*(String *)p_message);
}
+void _gdnative_report_version_mismatch(const godot_object *p_library, const char *p_ext, godot_gdnative_api_version p_want, godot_gdnative_api_version p_have) {
+ String message = "Error loading GDNative file ";
+ GDNativeLibrary *library = (GDNativeLibrary *)p_library;
+
+ message += library->get_current_library_path() + ": Extension \"" + p_ext + "\" can't be loaded.\n";
+
+ Dictionary versions;
+ versions["have_major"] = p_have.major;
+ versions["have_minor"] = p_have.minor;
+ versions["want_major"] = p_want.major;
+ versions["want_minor"] = p_want.minor;
+
+ message += String("Got version {have_major}.{have_minor} but needs {want_major}.{want_minor}!").format(versions);
+
+ _err_print_error("gdnative_init", library->get_current_library_path().utf8().ptr(), 0, message.utf8().ptr());
+}
+
+void _gdnative_report_loading_error(const godot_object *p_library, const char *p_what) {
+ String message = "Error loading GDNative file ";
+ GDNativeLibrary *library = (GDNativeLibrary *)p_library;
+
+ message += library->get_current_library_path() + ": " + p_what;
+
+ _err_print_error("gdnative_init", library->get_current_library_path().utf8().ptr(), 0, message.utf8().ptr());
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/modules/gdnative/gdnative/node_path.cpp b/modules/gdnative/gdnative/node_path.cpp
index 2bd278e050..8dfe151f91 100644
--- a/modules/gdnative/gdnative/node_path.cpp
+++ b/modules/gdnative/gdnative/node_path.cpp
@@ -91,10 +91,10 @@ godot_string GDAPI godot_node_path_get_subname(const godot_node_path *p_self, co
return dest;
}
-godot_string GDAPI godot_node_path_get_property(const godot_node_path *p_self) {
+godot_string GDAPI godot_node_path_get_concatenated_subnames(const godot_node_path *p_self) {
godot_string dest;
const NodePath *self = (const NodePath *)p_self;
- memnew_placement(&dest, String(self->get_property()));
+ memnew_placement(&dest, String(self->get_concatenated_subnames()));
return dest;
}
diff --git a/modules/gdnative/gdnative/quat.cpp b/modules/gdnative/gdnative/quat.cpp
index 2d012c069f..c308e5973d 100644
--- a/modules/gdnative/gdnative/quat.cpp
+++ b/modules/gdnative/gdnative/quat.cpp
@@ -181,7 +181,7 @@ godot_quat GDAPI godot_quat_operator_add(const godot_quat *p_self, const godot_q
return raw_dest;
}
-godot_quat GDAPI godot_quat_operator_substract(const godot_quat *p_self, const godot_quat *p_b) {
+godot_quat GDAPI godot_quat_operator_subtract(const godot_quat *p_self, const godot_quat *p_b) {
godot_quat raw_dest;
Quat *dest = (Quat *)&raw_dest;
const Quat *self = (const Quat *)p_self;
diff --git a/modules/gdnative/gdnative/rect3.cpp b/modules/gdnative/gdnative/rect3.cpp
deleted file mode 100644
index 8e088743b4..0000000000
--- a/modules/gdnative/gdnative/rect3.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/*************************************************************************/
-/* rect3.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "gdnative/rect3.h"
-
-#include "core/math/rect3.h"
-#include "core/variant.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void GDAPI godot_rect3_new(godot_rect3 *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size) {
- const Vector3 *pos = (const Vector3 *)p_pos;
- const Vector3 *size = (const Vector3 *)p_size;
- Rect3 *dest = (Rect3 *)r_dest;
- *dest = Rect3(*pos, *size);
-}
-
-godot_vector3 GDAPI godot_rect3_get_position(const godot_rect3 *p_self) {
- godot_vector3 raw_ret;
- const Rect3 *self = (const Rect3 *)p_self;
- Vector3 *ret = (Vector3 *)&raw_ret;
- *ret = self->position;
- return raw_ret;
-}
-
-void GDAPI godot_rect3_set_position(const godot_rect3 *p_self, const godot_vector3 *p_v) {
- Rect3 *self = (Rect3 *)p_self;
- const Vector3 *v = (const Vector3 *)p_v;
- self->position = *v;
-}
-
-godot_vector3 GDAPI godot_rect3_get_size(const godot_rect3 *p_self) {
- godot_vector3 raw_ret;
- const Rect3 *self = (const Rect3 *)p_self;
- Vector3 *ret = (Vector3 *)&raw_ret;
- *ret = self->size;
- return raw_ret;
-}
-
-void GDAPI godot_rect3_set_size(const godot_rect3 *p_self, const godot_vector3 *p_v) {
- Rect3 *self = (Rect3 *)p_self;
- const Vector3 *v = (const Vector3 *)p_v;
- self->size = *v;
-}
-
-godot_string GDAPI godot_rect3_as_string(const godot_rect3 *p_self) {
- godot_string ret;
- const Rect3 *self = (const Rect3 *)p_self;
- memnew_placement(&ret, String(*self));
- return ret;
-}
-
-godot_real GDAPI godot_rect3_get_area(const godot_rect3 *p_self) {
- const Rect3 *self = (const Rect3 *)p_self;
- return self->get_area();
-}
-
-godot_bool GDAPI godot_rect3_has_no_area(const godot_rect3 *p_self) {
- const Rect3 *self = (const Rect3 *)p_self;
- return self->has_no_area();
-}
-
-godot_bool GDAPI godot_rect3_has_no_surface(const godot_rect3 *p_self) {
- const Rect3 *self = (const Rect3 *)p_self;
- return self->has_no_surface();
-}
-
-godot_bool GDAPI godot_rect3_intersects(const godot_rect3 *p_self, const godot_rect3 *p_with) {
- const Rect3 *self = (const Rect3 *)p_self;
- const Rect3 *with = (const Rect3 *)p_with;
- return self->intersects(*with);
-}
-
-godot_bool GDAPI godot_rect3_encloses(const godot_rect3 *p_self, const godot_rect3 *p_with) {
- const Rect3 *self = (const Rect3 *)p_self;
- const Rect3 *with = (const Rect3 *)p_with;
- return self->encloses(*with);
-}
-
-godot_rect3 GDAPI godot_rect3_merge(const godot_rect3 *p_self, const godot_rect3 *p_with) {
- godot_rect3 dest;
- const Rect3 *self = (const Rect3 *)p_self;
- const Rect3 *with = (const Rect3 *)p_with;
- *((Rect3 *)&dest) = self->merge(*with);
- return dest;
-}
-
-godot_rect3 GDAPI godot_rect3_intersection(const godot_rect3 *p_self, const godot_rect3 *p_with) {
- godot_rect3 dest;
- const Rect3 *self = (const Rect3 *)p_self;
- const Rect3 *with = (const Rect3 *)p_with;
- *((Rect3 *)&dest) = self->intersection(*with);
- return dest;
-}
-
-godot_bool GDAPI godot_rect3_intersects_plane(const godot_rect3 *p_self, const godot_plane *p_plane) {
- const Rect3 *self = (const Rect3 *)p_self;
- const Plane *plane = (const Plane *)p_plane;
- return self->intersects_plane(*plane);
-}
-
-godot_bool GDAPI godot_rect3_intersects_segment(const godot_rect3 *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to) {
- const Rect3 *self = (const Rect3 *)p_self;
- const Vector3 *from = (const Vector3 *)p_from;
- const Vector3 *to = (const Vector3 *)p_to;
- return self->intersects_segment(*from, *to);
-}
-
-godot_bool GDAPI godot_rect3_has_point(const godot_rect3 *p_self, const godot_vector3 *p_point) {
- const Rect3 *self = (const Rect3 *)p_self;
- const Vector3 *point = (const Vector3 *)p_point;
- return self->has_point(*point);
-}
-
-godot_vector3 GDAPI godot_rect3_get_support(const godot_rect3 *p_self, const godot_vector3 *p_dir) {
- godot_vector3 dest;
- const Rect3 *self = (const Rect3 *)p_self;
- const Vector3 *dir = (const Vector3 *)p_dir;
- *((Vector3 *)&dest) = self->get_support(*dir);
- return dest;
-}
-
-godot_vector3 GDAPI godot_rect3_get_longest_axis(const godot_rect3 *p_self) {
- godot_vector3 dest;
- const Rect3 *self = (const Rect3 *)p_self;
- *((Vector3 *)&dest) = self->get_longest_axis();
- return dest;
-}
-
-godot_int GDAPI godot_rect3_get_longest_axis_index(const godot_rect3 *p_self) {
- const Rect3 *self = (const Rect3 *)p_self;
- return self->get_longest_axis_index();
-}
-
-godot_real GDAPI godot_rect3_get_longest_axis_size(const godot_rect3 *p_self) {
- const Rect3 *self = (const Rect3 *)p_self;
- return self->get_longest_axis_size();
-}
-
-godot_vector3 GDAPI godot_rect3_get_shortest_axis(const godot_rect3 *p_self) {
- godot_vector3 dest;
- const Rect3 *self = (const Rect3 *)p_self;
- *((Vector3 *)&dest) = self->get_shortest_axis();
- return dest;
-}
-
-godot_int GDAPI godot_rect3_get_shortest_axis_index(const godot_rect3 *p_self) {
- const Rect3 *self = (const Rect3 *)p_self;
- return self->get_shortest_axis_index();
-}
-
-godot_real GDAPI godot_rect3_get_shortest_axis_size(const godot_rect3 *p_self) {
- const Rect3 *self = (const Rect3 *)p_self;
- return self->get_shortest_axis_size();
-}
-
-godot_rect3 GDAPI godot_rect3_expand(const godot_rect3 *p_self, const godot_vector3 *p_to_point) {
- godot_rect3 dest;
- const Rect3 *self = (const Rect3 *)p_self;
- const Vector3 *to_point = (const Vector3 *)p_to_point;
- *((Rect3 *)&dest) = self->expand(*to_point);
- return dest;
-}
-
-godot_rect3 GDAPI godot_rect3_grow(const godot_rect3 *p_self, const godot_real p_by) {
- godot_rect3 dest;
- const Rect3 *self = (const Rect3 *)p_self;
-
- *((Rect3 *)&dest) = self->grow(p_by);
- return dest;
-}
-
-godot_vector3 GDAPI godot_rect3_get_endpoint(const godot_rect3 *p_self, const godot_int p_idx) {
- godot_vector3 dest;
- const Rect3 *self = (const Rect3 *)p_self;
-
- *((Vector3 *)&dest) = self->get_endpoint(p_idx);
- return dest;
-}
-
-godot_bool GDAPI godot_rect3_operator_equal(const godot_rect3 *p_self, const godot_rect3 *p_b) {
- const Rect3 *self = (const Rect3 *)p_self;
- const Rect3 *b = (const Rect3 *)p_b;
- return *self == *b;
-}
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/modules/gdnative/gdnative/string.cpp b/modules/gdnative/gdnative/string.cpp
index 781b8754bd..67a037736c 100644
--- a/modules/gdnative/gdnative/string.cpp
+++ b/modules/gdnative/gdnative/string.cpp
@@ -89,11 +89,6 @@ wchar_t GDAPI godot_string_operator_index_const(const godot_string *p_self, cons
return self->operator[](p_idx);
}
-const char GDAPI *godot_string_c_str(const godot_string *p_self) {
- const String *self = (const String *)p_self;
- return self->utf8().get_data();
-}
-
const wchar_t GDAPI *godot_string_unicode_str(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->c_str();
diff --git a/modules/gdnative/gdnative/transform.cpp b/modules/gdnative/gdnative/transform.cpp
index 96b2ec8a7a..b07fcffcb6 100644
--- a/modules/gdnative/gdnative/transform.cpp
+++ b/modules/gdnative/gdnative/transform.cpp
@@ -198,20 +198,20 @@ godot_vector3 GDAPI godot_transform_xform_inv_vector3(const godot_transform *p_s
return raw_dest;
}
-godot_rect3 GDAPI godot_transform_xform_rect3(const godot_transform *p_self, const godot_rect3 *p_v) {
- godot_rect3 raw_dest;
- Rect3 *dest = (Rect3 *)&raw_dest;
+godot_aabb GDAPI godot_transform_xform_aabb(const godot_transform *p_self, const godot_aabb *p_v) {
+ godot_aabb raw_dest;
+ AABB *dest = (AABB *)&raw_dest;
const Transform *self = (const Transform *)p_self;
- const Rect3 *v = (const Rect3 *)p_v;
+ const AABB *v = (const AABB *)p_v;
*dest = self->xform(*v);
return raw_dest;
}
-godot_rect3 GDAPI godot_transform_xform_inv_rect3(const godot_transform *p_self, const godot_rect3 *p_v) {
- godot_rect3 raw_dest;
- Rect3 *dest = (Rect3 *)&raw_dest;
+godot_aabb GDAPI godot_transform_xform_inv_aabb(const godot_transform *p_self, const godot_aabb *p_v) {
+ godot_aabb raw_dest;
+ AABB *dest = (AABB *)&raw_dest;
const Transform *self = (const Transform *)p_self;
- const Rect3 *v = (const Rect3 *)p_v;
+ const AABB *v = (const AABB *)p_v;
*dest = self->xform_inv(*v);
return raw_dest;
}
diff --git a/modules/gdnative/gdnative/variant.cpp b/modules/gdnative/gdnative/variant.cpp
index 0c31bc643c..6483d19d74 100644
--- a/modules/gdnative/gdnative/variant.cpp
+++ b/modules/gdnative/gdnative/variant.cpp
@@ -118,10 +118,10 @@ void GDAPI godot_variant_new_quat(godot_variant *r_dest, const godot_quat *p_qua
memnew_placement_custom(dest, Variant, Variant(*quat));
}
-void GDAPI godot_variant_new_rect3(godot_variant *r_dest, const godot_rect3 *p_rect3) {
+void GDAPI godot_variant_new_aabb(godot_variant *r_dest, const godot_aabb *p_aabb) {
Variant *dest = (Variant *)r_dest;
- Rect3 *rect3 = (Rect3 *)p_rect3;
- memnew_placement_custom(dest, Variant, Variant(*rect3));
+ AABB *aabb = (AABB *)p_aabb;
+ memnew_placement_custom(dest, Variant, Variant(*aabb));
}
void GDAPI godot_variant_new_basis(godot_variant *r_dest, const godot_basis *p_basis) {
@@ -304,10 +304,10 @@ godot_quat GDAPI godot_variant_as_quat(const godot_variant *p_self) {
return raw_dest;
}
-godot_rect3 GDAPI godot_variant_as_rect3(const godot_variant *p_self) {
- godot_rect3 raw_dest;
+godot_aabb GDAPI godot_variant_as_aabb(const godot_variant *p_self) {
+ godot_aabb raw_dest;
const Variant *self = (const Variant *)p_self;
- Rect3 *dest = (Rect3 *)&raw_dest;
+ AABB *dest = (AABB *)&raw_dest;
*dest = *self;
return raw_dest;
}
diff --git a/modules/gdnative/gdnative/vector2.cpp b/modules/gdnative/gdnative/vector2.cpp
index 7a5b29e0c4..7be08929b1 100644
--- a/modules/gdnative/gdnative/vector2.cpp
+++ b/modules/gdnative/gdnative/vector2.cpp
@@ -207,7 +207,7 @@ godot_vector2 GDAPI godot_vector2_operator_add(const godot_vector2 *p_self, cons
return raw_dest;
}
-godot_vector2 GDAPI godot_vector2_operator_substract(const godot_vector2 *p_self, const godot_vector2 *p_b) {
+godot_vector2 GDAPI godot_vector2_operator_subtract(const godot_vector2 *p_self, const godot_vector2 *p_b) {
godot_vector2 raw_dest;
Vector2 *dest = (Vector2 *)&raw_dest;
const Vector2 *self = (const Vector2 *)p_self;
diff --git a/modules/gdnative/gdnative/vector3.cpp b/modules/gdnative/gdnative/vector3.cpp
index 11ffb3320b..0027d236f2 100644
--- a/modules/gdnative/gdnative/vector3.cpp
+++ b/modules/gdnative/gdnative/vector3.cpp
@@ -224,7 +224,7 @@ godot_vector3 GDAPI godot_vector3_operator_add(const godot_vector3 *p_self, cons
return raw_dest;
}
-godot_vector3 GDAPI godot_vector3_operator_substract(const godot_vector3 *p_self, const godot_vector3 *p_b) {
+godot_vector3 GDAPI godot_vector3_operator_subtract(const godot_vector3 *p_self, const godot_vector3 *p_b) {
godot_vector3 raw_dest;
Vector3 *dest = (Vector3 *)&raw_dest;
Vector3 *self = (Vector3 *)p_self;
diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json
index 770fb429c7..06c6e9f410 100644
--- a/modules/gdnative/gdnative_api.json
+++ b/modules/gdnative/gdnative_api.json
@@ -387,7 +387,7 @@
]
},
{
- "name": "godot_vector2_operator_substract",
+ "name": "godot_vector2_operator_subtract",
"return_type": "godot_vector2",
"arguments": [
["const godot_vector2 *", "p_self"],
@@ -663,7 +663,7 @@
]
},
{
- "name": "godot_quat_operator_substract",
+ "name": "godot_quat_operator_subtract",
"return_type": "godot_quat",
"arguments": [
["const godot_quat *", "p_self"],
@@ -907,7 +907,7 @@
]
},
{
- "name": "godot_basis_operator_substract",
+ "name": "godot_basis_operator_subtract",
"return_type": "godot_basis",
"arguments": [
["const godot_basis *", "p_self"],
@@ -1142,7 +1142,7 @@
]
},
{
- "name": "godot_vector3_operator_substract",
+ "name": "godot_vector3_operator_subtract",
"return_type": "godot_vector3",
"arguments": [
["const godot_vector3 *", "p_self"],
@@ -2680,6 +2680,26 @@
]
},
{
+ "name": "godot_array_bsearch",
+ "return_type": "godot_int",
+ "arguments": [
+ ["godot_array *", "p_self"],
+ ["const godot_variant *", "p_value"],
+ ["const godot_bool", "p_before"]
+ ]
+ },
+ {
+ "name": "godot_array_bsearch_custom",
+ "return_type": "godot_int",
+ "arguments": [
+ ["godot_array *", "p_self"],
+ ["const godot_variant *", "p_value"],
+ ["godot_object *", "p_obj"],
+ ["const godot_string *", "p_func"],
+ ["const godot_bool", "p_before"]
+ ]
+ },
+ {
"name": "godot_array_destroy",
"return_type": "void",
"arguments": [
@@ -2898,7 +2918,7 @@
]
},
{
- "name": "godot_node_path_get_property",
+ "name": "godot_node_path_get_concatenated_subnames",
"return_type": "godot_string",
"arguments": [
["const godot_node_path *", "p_self"]
@@ -3221,209 +3241,209 @@
]
},
{
- "name": "godot_rect3_new",
+ "name": "godot_aabb_new",
"return_type": "void",
"arguments": [
- ["godot_rect3 *", "r_dest"],
+ ["godot_aabb *", "r_dest"],
["const godot_vector3 *", "p_pos"],
["const godot_vector3 *", "p_size"]
]
},
{
- "name": "godot_rect3_get_position",
+ "name": "godot_aabb_get_position",
"return_type": "godot_vector3",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_set_position",
+ "name": "godot_aabb_set_position",
"return_type": "void",
"arguments": [
- ["const godot_rect3 *", "p_self"],
+ ["const godot_aabb *", "p_self"],
["const godot_vector3 *", "p_v"]
]
},
{
- "name": "godot_rect3_get_size",
+ "name": "godot_aabb_get_size",
"return_type": "godot_vector3",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_set_size",
+ "name": "godot_aabb_set_size",
"return_type": "void",
"arguments": [
- ["const godot_rect3 *", "p_self"],
+ ["const godot_aabb *", "p_self"],
["const godot_vector3 *", "p_v"]
]
},
{
- "name": "godot_rect3_as_string",
+ "name": "godot_aabb_as_string",
"return_type": "godot_string",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_get_area",
+ "name": "godot_aabb_get_area",
"return_type": "godot_real",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_has_no_area",
+ "name": "godot_aabb_has_no_area",
"return_type": "godot_bool",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_has_no_surface",
+ "name": "godot_aabb_has_no_surface",
"return_type": "godot_bool",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_intersects",
+ "name": "godot_aabb_intersects",
"return_type": "godot_bool",
"arguments": [
- ["const godot_rect3 *", "p_self"],
- ["const godot_rect3 *", "p_with"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_aabb *", "p_with"]
]
},
{
- "name": "godot_rect3_encloses",
+ "name": "godot_aabb_encloses",
"return_type": "godot_bool",
"arguments": [
- ["const godot_rect3 *", "p_self"],
- ["const godot_rect3 *", "p_with"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_aabb *", "p_with"]
]
},
{
- "name": "godot_rect3_merge",
- "return_type": "godot_rect3",
+ "name": "godot_aabb_merge",
+ "return_type": "godot_aabb",
"arguments": [
- ["const godot_rect3 *", "p_self"],
- ["const godot_rect3 *", "p_with"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_aabb *", "p_with"]
]
},
{
- "name": "godot_rect3_intersection",
- "return_type": "godot_rect3",
+ "name": "godot_aabb_intersection",
+ "return_type": "godot_aabb",
"arguments": [
- ["const godot_rect3 *", "p_self"],
- ["const godot_rect3 *", "p_with"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_aabb *", "p_with"]
]
},
{
- "name": "godot_rect3_intersects_plane",
+ "name": "godot_aabb_intersects_plane",
"return_type": "godot_bool",
"arguments": [
- ["const godot_rect3 *", "p_self"],
+ ["const godot_aabb *", "p_self"],
["const godot_plane *", "p_plane"]
]
},
{
- "name": "godot_rect3_intersects_segment",
+ "name": "godot_aabb_intersects_segment",
"return_type": "godot_bool",
"arguments": [
- ["const godot_rect3 *", "p_self"],
+ ["const godot_aabb *", "p_self"],
["const godot_vector3 *", "p_from"],
["const godot_vector3 *", "p_to"]
]
},
{
- "name": "godot_rect3_has_point",
+ "name": "godot_aabb_has_point",
"return_type": "godot_bool",
"arguments": [
- ["const godot_rect3 *", "p_self"],
+ ["const godot_aabb *", "p_self"],
["const godot_vector3 *", "p_point"]
]
},
{
- "name": "godot_rect3_get_support",
+ "name": "godot_aabb_get_support",
"return_type": "godot_vector3",
"arguments": [
- ["const godot_rect3 *", "p_self"],
+ ["const godot_aabb *", "p_self"],
["const godot_vector3 *", "p_dir"]
]
},
{
- "name": "godot_rect3_get_longest_axis",
+ "name": "godot_aabb_get_longest_axis",
"return_type": "godot_vector3",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_get_longest_axis_index",
+ "name": "godot_aabb_get_longest_axis_index",
"return_type": "godot_int",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_get_longest_axis_size",
+ "name": "godot_aabb_get_longest_axis_size",
"return_type": "godot_real",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_get_shortest_axis",
+ "name": "godot_aabb_get_shortest_axis",
"return_type": "godot_vector3",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_get_shortest_axis_index",
+ "name": "godot_aabb_get_shortest_axis_index",
"return_type": "godot_int",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_get_shortest_axis_size",
+ "name": "godot_aabb_get_shortest_axis_size",
"return_type": "godot_real",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_expand",
- "return_type": "godot_rect3",
+ "name": "godot_aabb_expand",
+ "return_type": "godot_aabb",
"arguments": [
- ["const godot_rect3 *", "p_self"],
+ ["const godot_aabb *", "p_self"],
["const godot_vector3 *", "p_to_point"]
]
},
{
- "name": "godot_rect3_grow",
- "return_type": "godot_rect3",
+ "name": "godot_aabb_grow",
+ "return_type": "godot_aabb",
"arguments": [
- ["const godot_rect3 *", "p_self"],
+ ["const godot_aabb *", "p_self"],
["const godot_real", "p_by"]
]
},
{
- "name": "godot_rect3_get_endpoint",
+ "name": "godot_aabb_get_endpoint",
"return_type": "godot_vector3",
"arguments": [
- ["const godot_rect3 *", "p_self"],
+ ["const godot_aabb *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
- "name": "godot_rect3_operator_equal",
+ "name": "godot_aabb_operator_equal",
"return_type": "godot_bool",
"arguments": [
- ["const godot_rect3 *", "p_self"],
- ["const godot_rect3 *", "p_b"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_aabb *", "p_b"]
]
},
{
@@ -3632,19 +3652,19 @@
]
},
{
- "name": "godot_transform_xform_rect3",
- "return_type": "godot_rect3",
+ "name": "godot_transform_xform_aabb",
+ "return_type": "godot_aabb",
"arguments": [
["const godot_transform *", "p_self"],
- ["const godot_rect3 *", "p_v"]
+ ["const godot_aabb *", "p_v"]
]
},
{
- "name": "godot_transform_xform_inv_rect3",
- "return_type": "godot_rect3",
+ "name": "godot_transform_xform_inv_aabb",
+ "return_type": "godot_aabb",
"arguments": [
["const godot_transform *", "p_self"],
- ["const godot_rect3 *", "p_v"]
+ ["const godot_aabb *", "p_v"]
]
},
{
@@ -3930,11 +3950,11 @@
]
},
{
- "name": "godot_variant_new_rect3",
+ "name": "godot_variant_new_aabb",
"return_type": "void",
"arguments": [
["godot_variant *", "r_dest"],
- ["const godot_rect3 *", "p_rect3"]
+ ["const godot_aabb *", "p_aabb"]
]
},
{
@@ -4135,8 +4155,8 @@
]
},
{
- "name": "godot_variant_as_rect3",
- "return_type": "godot_rect3",
+ "name": "godot_variant_as_aabb",
+ "return_type": "godot_aabb",
"arguments": [
["const godot_variant *", "p_self"]
]
@@ -4362,13 +4382,6 @@
]
},
{
- "name": "godot_string_c_str",
- "return_type": "const char *",
- "arguments": [
- ["const godot_string *", "p_self"]
- ]
- },
- {
"name": "godot_string_unicode_str",
"return_type": "const wchar_t *",
"arguments": [
@@ -5556,6 +5569,20 @@
]
},
{
+ "name": "godot_get_global_constants",
+ "return_type": "godot_dictionary",
+ "arguments": [
+ ]
+ },
+ {
+ "name": "godot_register_native_call_type",
+ "return_type": "void",
+ "arguments": [
+ ["const char *", "call_type"],
+ ["native_call_cb", "p_callback"]
+ ]
+ },
+ {
"name": "godot_alloc",
"return_type": "void *",
"arguments": [
diff --git a/modules/gdnative/include/gdnative/aabb.h b/modules/gdnative/include/gdnative/aabb.h
new file mode 100644
index 0000000000..34339fa242
--- /dev/null
+++ b/modules/gdnative/include/gdnative/aabb.h
@@ -0,0 +1,117 @@
+/*************************************************************************/
+/* aabb.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef GODOT_AABB_H
+#define GODOT_AABB_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+#define GODOT_AABB_SIZE 24
+
+#ifndef GODOT_CORE_API_GODOT_AABB_TYPE_DEFINED
+#define GODOT_CORE_API_GODOT_AABB_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_AABB_SIZE];
+} godot_aabb;
+#endif
+
+// reduce extern "C" nesting for VS2013
+#ifdef __cplusplus
+}
+#endif
+
+#include <gdnative/gdnative.h>
+#include <gdnative/plane.h>
+#include <gdnative/vector3.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void GDAPI godot_aabb_new(godot_aabb *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size);
+
+godot_vector3 GDAPI godot_aabb_get_position(const godot_aabb *p_self);
+void GDAPI godot_aabb_set_position(const godot_aabb *p_self, const godot_vector3 *p_v);
+
+godot_vector3 GDAPI godot_aabb_get_size(const godot_aabb *p_self);
+void GDAPI godot_aabb_set_size(const godot_aabb *p_self, const godot_vector3 *p_v);
+
+godot_string GDAPI godot_aabb_as_string(const godot_aabb *p_self);
+
+godot_real GDAPI godot_aabb_get_area(const godot_aabb *p_self);
+
+godot_bool GDAPI godot_aabb_has_no_area(const godot_aabb *p_self);
+
+godot_bool GDAPI godot_aabb_has_no_surface(const godot_aabb *p_self);
+
+godot_bool GDAPI godot_aabb_intersects(const godot_aabb *p_self, const godot_aabb *p_with);
+
+godot_bool GDAPI godot_aabb_encloses(const godot_aabb *p_self, const godot_aabb *p_with);
+
+godot_aabb GDAPI godot_aabb_merge(const godot_aabb *p_self, const godot_aabb *p_with);
+
+godot_aabb GDAPI godot_aabb_intersection(const godot_aabb *p_self, const godot_aabb *p_with);
+
+godot_bool GDAPI godot_aabb_intersects_plane(const godot_aabb *p_self, const godot_plane *p_plane);
+
+godot_bool GDAPI godot_aabb_intersects_segment(const godot_aabb *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to);
+
+godot_bool GDAPI godot_aabb_has_point(const godot_aabb *p_self, const godot_vector3 *p_point);
+
+godot_vector3 GDAPI godot_aabb_get_support(const godot_aabb *p_self, const godot_vector3 *p_dir);
+
+godot_vector3 GDAPI godot_aabb_get_longest_axis(const godot_aabb *p_self);
+
+godot_int GDAPI godot_aabb_get_longest_axis_index(const godot_aabb *p_self);
+
+godot_real GDAPI godot_aabb_get_longest_axis_size(const godot_aabb *p_self);
+
+godot_vector3 GDAPI godot_aabb_get_shortest_axis(const godot_aabb *p_self);
+
+godot_int GDAPI godot_aabb_get_shortest_axis_index(const godot_aabb *p_self);
+
+godot_real GDAPI godot_aabb_get_shortest_axis_size(const godot_aabb *p_self);
+
+godot_aabb GDAPI godot_aabb_expand(const godot_aabb *p_self, const godot_vector3 *p_to_point);
+
+godot_aabb GDAPI godot_aabb_grow(const godot_aabb *p_self, const godot_real p_by);
+
+godot_vector3 GDAPI godot_aabb_get_endpoint(const godot_aabb *p_self, const godot_int p_idx);
+
+godot_bool GDAPI godot_aabb_operator_equal(const godot_aabb *p_self, const godot_aabb *p_b);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // GODOT_AABB_H
diff --git a/modules/gdnative/include/gdnative/array.h b/modules/gdnative/include/gdnative/array.h
index 01ae61e280..484ffd10ba 100644
--- a/modules/gdnative/include/gdnative/array.h
+++ b/modules/gdnative/include/gdnative/array.h
@@ -124,6 +124,10 @@ void GDAPI godot_array_sort(godot_array *p_self);
void GDAPI godot_array_sort_custom(godot_array *p_self, godot_object *p_obj, const godot_string *p_func);
+godot_int GDAPI godot_array_bsearch(godot_array *p_self, const godot_variant *p_value, const godot_bool p_before);
+
+godot_int GDAPI godot_array_bsearch_custom(godot_array *p_self, const godot_variant *p_value, godot_object *p_obj, const godot_string *p_func, const godot_bool p_before);
+
void GDAPI godot_array_destroy(godot_array *p_self);
#ifdef __cplusplus
diff --git a/modules/gdnative/include/gdnative/basis.h b/modules/gdnative/include/gdnative/basis.h
index 49ca765a01..4898eab24c 100644
--- a/modules/gdnative/include/gdnative/basis.h
+++ b/modules/gdnative/include/gdnative/basis.h
@@ -111,7 +111,7 @@ godot_bool GDAPI godot_basis_operator_equal(const godot_basis *p_self, const god
godot_basis GDAPI godot_basis_operator_add(const godot_basis *p_self, const godot_basis *p_b);
-godot_basis GDAPI godot_basis_operator_substract(const godot_basis *p_self, const godot_basis *p_b);
+godot_basis GDAPI godot_basis_operator_subtract(const godot_basis *p_self, const godot_basis *p_b);
godot_basis GDAPI godot_basis_operator_multiply_vector(const godot_basis *p_self, const godot_basis *p_b);
diff --git a/modules/gdnative/include/gdnative/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h
index a479eced16..9d7829a51f 100644
--- a/modules/gdnative/include/gdnative/gdnative.h
+++ b/modules/gdnative/include/gdnative/gdnative.h
@@ -53,7 +53,7 @@ extern "C" {
// This is for libraries *using* the header, NOT GODOT EXPOSING STUFF!!
#ifdef _WIN32
-#define GDN_EXPORT
+#define GDN_EXPORT __declspec(dllexport)
#else
#define GDN_EXPORT
#endif
@@ -115,8 +115,6 @@ typedef enum {
GODOT_ERR_HELP, ///< user requested help!!
GODOT_ERR_BUG, ///< a bug in the software certainly happened, due to a double check failing or unexpected behavior.
GODOT_ERR_PRINTER_ON_FIRE, /// the parallel port printer is engulfed in flames
- GODOT_ERR_OMFG_THIS_IS_VERY_VERY_BAD, ///< shit happens, has never been used, though
- GODOT_ERR_WTF = GODOT_ERR_OMFG_THIS_IS_VERY_VERY_BAD ///< short version of the above
} godot_error;
////// bool
@@ -169,9 +167,9 @@ typedef void godot_object;
#include <gdnative/quat.h>
-/////// Rect3
+/////// AABB
-#include <gdnative/rect3.h>
+#include <gdnative/aabb.h>
/////// Basis
@@ -214,10 +212,6 @@ void GDAPI godot_object_destroy(godot_object *p_o);
godot_object GDAPI *godot_global_get_singleton(char *p_name); // result shouldn't be freed
-////// OS API
-
-void GDAPI *godot_get_stack_bottom(); // returns stack bottom of the main thread
-
////// MethodBind API
typedef struct {
@@ -229,13 +223,28 @@ void GDAPI godot_method_bind_ptrcall(godot_method_bind *p_method_bind, godot_obj
godot_variant GDAPI godot_method_bind_call(godot_method_bind *p_method_bind, godot_object *p_instance, const godot_variant **p_args, const int p_arg_count, godot_variant_call_error *p_call_error);
////// Script API
-struct godot_gdnative_api_struct; // Forward declaration
+typedef struct godot_gdnative_api_version {
+ unsigned int major;
+ unsigned int minor;
+} godot_gdnative_api_version;
+
+typedef struct godot_gdnative_api_struct godot_gdnative_api_struct;
+
+struct godot_gdnative_api_struct {
+ unsigned int type;
+ godot_gdnative_api_version version;
+ const godot_gdnative_api_struct *next;
+};
+
+#define GDNATIVE_VERSION_COMPATIBLE(want, have) (want.major == have.major && want.minor <= have.minor)
typedef struct {
godot_bool in_editor;
uint64_t core_api_hash;
uint64_t editor_api_hash;
uint64_t no_api_hash;
+ void (*report_version_mismatch)(const godot_object *p_library, const char *p_what, godot_gdnative_api_version p_want, godot_gdnative_api_version p_have);
+ void (*report_loading_error)(const godot_object *p_library, const char *p_what);
godot_object *gd_native_library; // pointer to GDNativeLibrary that is being initialized
const struct godot_gdnative_core_api_struct *api_struct;
const godot_string *active_library_path;
@@ -259,6 +268,9 @@ typedef godot_variant (*godot_gdnative_procedure_fn)(godot_array *);
////// System Functions
+typedef godot_variant (*native_call_cb)(void *, godot_array *);
+void GDAPI godot_register_native_call_type(const char *p_call_type, native_call_cb p_callback);
+
//using these will help Godot track how much memory is in use in debug mode
void GDAPI *godot_alloc(int p_bytes);
void GDAPI *godot_realloc(void *p_ptr, int p_bytes);
diff --git a/modules/gdnative/include/gdnative/node_path.h b/modules/gdnative/include/gdnative/node_path.h
index 42446175d8..b5a59fd325 100644
--- a/modules/gdnative/include/gdnative/node_path.h
+++ b/modules/gdnative/include/gdnative/node_path.h
@@ -73,7 +73,7 @@ godot_int GDAPI godot_node_path_get_subname_count(const godot_node_path *p_self)
godot_string GDAPI godot_node_path_get_subname(const godot_node_path *p_self, const godot_int p_idx);
-godot_string GDAPI godot_node_path_get_property(const godot_node_path *p_self);
+godot_string GDAPI godot_node_path_get_concatenated_subnames(const godot_node_path *p_self);
godot_bool GDAPI godot_node_path_is_empty(const godot_node_path *p_self);
diff --git a/modules/gdnative/include/gdnative/quat.h b/modules/gdnative/include/gdnative/quat.h
index acae6e3e90..2be9d8849d 100644
--- a/modules/gdnative/include/gdnative/quat.h
+++ b/modules/gdnative/include/gdnative/quat.h
@@ -98,7 +98,7 @@ godot_quat GDAPI godot_quat_operator_multiply(const godot_quat *p_self, const go
godot_quat GDAPI godot_quat_operator_add(const godot_quat *p_self, const godot_quat *p_b);
-godot_quat GDAPI godot_quat_operator_substract(const godot_quat *p_self, const godot_quat *p_b);
+godot_quat GDAPI godot_quat_operator_subtract(const godot_quat *p_self, const godot_quat *p_b);
godot_quat GDAPI godot_quat_operator_divide(const godot_quat *p_self, const godot_real p_b);
diff --git a/modules/gdnative/include/gdnative/rect3.h b/modules/gdnative/include/gdnative/rect3.h
deleted file mode 100644
index f603a9268a..0000000000
--- a/modules/gdnative/include/gdnative/rect3.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*************************************************************************/
-/* rect3.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef GODOT_RECT3_H
-#define GODOT_RECT3_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdint.h>
-
-#define GODOT_RECT3_SIZE 24
-
-#ifndef GODOT_CORE_API_GODOT_RECT3_TYPE_DEFINED
-#define GODOT_CORE_API_GODOT_RECT3_TYPE_DEFINED
-typedef struct {
- uint8_t _dont_touch_that[GODOT_RECT3_SIZE];
-} godot_rect3;
-#endif
-
-// reduce extern "C" nesting for VS2013
-#ifdef __cplusplus
-}
-#endif
-
-#include <gdnative/gdnative.h>
-#include <gdnative/plane.h>
-#include <gdnative/vector3.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void GDAPI godot_rect3_new(godot_rect3 *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size);
-
-godot_vector3 GDAPI godot_rect3_get_position(const godot_rect3 *p_self);
-void GDAPI godot_rect3_set_position(const godot_rect3 *p_self, const godot_vector3 *p_v);
-
-godot_vector3 GDAPI godot_rect3_get_size(const godot_rect3 *p_self);
-void GDAPI godot_rect3_set_size(const godot_rect3 *p_self, const godot_vector3 *p_v);
-
-godot_string GDAPI godot_rect3_as_string(const godot_rect3 *p_self);
-
-godot_real GDAPI godot_rect3_get_area(const godot_rect3 *p_self);
-
-godot_bool GDAPI godot_rect3_has_no_area(const godot_rect3 *p_self);
-
-godot_bool GDAPI godot_rect3_has_no_surface(const godot_rect3 *p_self);
-
-godot_bool GDAPI godot_rect3_intersects(const godot_rect3 *p_self, const godot_rect3 *p_with);
-
-godot_bool GDAPI godot_rect3_encloses(const godot_rect3 *p_self, const godot_rect3 *p_with);
-
-godot_rect3 GDAPI godot_rect3_merge(const godot_rect3 *p_self, const godot_rect3 *p_with);
-
-godot_rect3 GDAPI godot_rect3_intersection(const godot_rect3 *p_self, const godot_rect3 *p_with);
-
-godot_bool GDAPI godot_rect3_intersects_plane(const godot_rect3 *p_self, const godot_plane *p_plane);
-
-godot_bool GDAPI godot_rect3_intersects_segment(const godot_rect3 *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to);
-
-godot_bool GDAPI godot_rect3_has_point(const godot_rect3 *p_self, const godot_vector3 *p_point);
-
-godot_vector3 GDAPI godot_rect3_get_support(const godot_rect3 *p_self, const godot_vector3 *p_dir);
-
-godot_vector3 GDAPI godot_rect3_get_longest_axis(const godot_rect3 *p_self);
-
-godot_int GDAPI godot_rect3_get_longest_axis_index(const godot_rect3 *p_self);
-
-godot_real GDAPI godot_rect3_get_longest_axis_size(const godot_rect3 *p_self);
-
-godot_vector3 GDAPI godot_rect3_get_shortest_axis(const godot_rect3 *p_self);
-
-godot_int GDAPI godot_rect3_get_shortest_axis_index(const godot_rect3 *p_self);
-
-godot_real GDAPI godot_rect3_get_shortest_axis_size(const godot_rect3 *p_self);
-
-godot_rect3 GDAPI godot_rect3_expand(const godot_rect3 *p_self, const godot_vector3 *p_to_point);
-
-godot_rect3 GDAPI godot_rect3_grow(const godot_rect3 *p_self, const godot_real p_by);
-
-godot_vector3 GDAPI godot_rect3_get_endpoint(const godot_rect3 *p_self, const godot_int p_idx);
-
-godot_bool GDAPI godot_rect3_operator_equal(const godot_rect3 *p_self, const godot_rect3 *p_b);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // GODOT_RECT3_H
diff --git a/modules/gdnative/include/gdnative/string.h b/modules/gdnative/include/gdnative/string.h
index 29510313c9..10358ceade 100644
--- a/modules/gdnative/include/gdnative/string.h
+++ b/modules/gdnative/include/gdnative/string.h
@@ -51,6 +51,7 @@ typedef struct {
}
#endif
+#include <gdnative/array.h>
#include <gdnative/gdnative.h>
#include <gdnative/variant.h>
@@ -67,7 +68,6 @@ void GDAPI godot_string_get_data(const godot_string *p_self, char *p_dest, int *
wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx);
wchar_t GDAPI godot_string_operator_index_const(const godot_string *p_self, const godot_int p_idx);
-const char GDAPI *godot_string_c_str(const godot_string *p_self);
const wchar_t GDAPI *godot_string_unicode_str(const godot_string *p_self);
godot_bool GDAPI godot_string_operator_equal(const godot_string *p_self, const godot_string *p_b);
diff --git a/modules/gdnative/include/gdnative/transform.h b/modules/gdnative/include/gdnative/transform.h
index 8f50b01fb5..3b5c189bdf 100644
--- a/modules/gdnative/include/gdnative/transform.h
+++ b/modules/gdnative/include/gdnative/transform.h
@@ -98,9 +98,9 @@ godot_vector3 GDAPI godot_transform_xform_vector3(const godot_transform *p_self,
godot_vector3 GDAPI godot_transform_xform_inv_vector3(const godot_transform *p_self, const godot_vector3 *p_v);
-godot_rect3 GDAPI godot_transform_xform_rect3(const godot_transform *p_self, const godot_rect3 *p_v);
+godot_aabb GDAPI godot_transform_xform_aabb(const godot_transform *p_self, const godot_aabb *p_v);
-godot_rect3 GDAPI godot_transform_xform_inv_rect3(const godot_transform *p_self, const godot_rect3 *p_v);
+godot_aabb GDAPI godot_transform_xform_inv_aabb(const godot_transform *p_self, const godot_aabb *p_v);
#ifdef __cplusplus
}
diff --git a/modules/gdnative/include/gdnative/variant.h b/modules/gdnative/include/gdnative/variant.h
index 3d744ef1f2..06cafcfa63 100644
--- a/modules/gdnative/include/gdnative/variant.h
+++ b/modules/gdnative/include/gdnative/variant.h
@@ -62,7 +62,7 @@ typedef enum godot_variant_type {
GODOT_VARIANT_TYPE_TRANSFORM2D,
GODOT_VARIANT_TYPE_PLANE,
GODOT_VARIANT_TYPE_QUAT, // 10
- GODOT_VARIANT_TYPE_RECT3,
+ GODOT_VARIANT_TYPE_AABB,
GODOT_VARIANT_TYPE_BASIS,
GODOT_VARIANT_TYPE_TRANSFORM,
@@ -104,6 +104,7 @@ typedef struct godot_variant_call_error {
}
#endif
+#include <gdnative/aabb.h>
#include <gdnative/array.h>
#include <gdnative/basis.h>
#include <gdnative/color.h>
@@ -113,7 +114,6 @@ typedef struct godot_variant_call_error {
#include <gdnative/pool_arrays.h>
#include <gdnative/quat.h>
#include <gdnative/rect2.h>
-#include <gdnative/rect3.h>
#include <gdnative/rid.h>
#include <gdnative/string.h>
#include <gdnative/transform.h>
@@ -145,7 +145,7 @@ void GDAPI godot_variant_new_vector3(godot_variant *r_dest, const godot_vector3
void GDAPI godot_variant_new_transform2d(godot_variant *r_dest, const godot_transform2d *p_t2d);
void GDAPI godot_variant_new_plane(godot_variant *r_dest, const godot_plane *p_plane);
void GDAPI godot_variant_new_quat(godot_variant *r_dest, const godot_quat *p_quat);
-void GDAPI godot_variant_new_rect3(godot_variant *r_dest, const godot_rect3 *p_rect3);
+void GDAPI godot_variant_new_aabb(godot_variant *r_dest, const godot_aabb *p_aabb);
void GDAPI godot_variant_new_basis(godot_variant *r_dest, const godot_basis *p_basis);
void GDAPI godot_variant_new_transform(godot_variant *r_dest, const godot_transform *p_trans);
void GDAPI godot_variant_new_color(godot_variant *r_dest, const godot_color *p_color);
@@ -173,7 +173,7 @@ godot_vector3 GDAPI godot_variant_as_vector3(const godot_variant *p_self);
godot_transform2d GDAPI godot_variant_as_transform2d(const godot_variant *p_self);
godot_plane GDAPI godot_variant_as_plane(const godot_variant *p_self);
godot_quat GDAPI godot_variant_as_quat(const godot_variant *p_self);
-godot_rect3 GDAPI godot_variant_as_rect3(const godot_variant *p_self);
+godot_aabb GDAPI godot_variant_as_aabb(const godot_variant *p_self);
godot_basis GDAPI godot_variant_as_basis(const godot_variant *p_self);
godot_transform GDAPI godot_variant_as_transform(const godot_variant *p_self);
godot_color GDAPI godot_variant_as_color(const godot_variant *p_self);
diff --git a/modules/gdnative/include/gdnative/vector2.h b/modules/gdnative/include/gdnative/vector2.h
index 07105abaf2..4d1117e3aa 100644
--- a/modules/gdnative/include/gdnative/vector2.h
+++ b/modules/gdnative/include/gdnative/vector2.h
@@ -106,7 +106,7 @@ godot_vector2 GDAPI godot_vector2_clamped(const godot_vector2 *p_self, const god
godot_vector2 GDAPI godot_vector2_operator_add(const godot_vector2 *p_self, const godot_vector2 *p_b);
-godot_vector2 GDAPI godot_vector2_operator_substract(const godot_vector2 *p_self, const godot_vector2 *p_b);
+godot_vector2 GDAPI godot_vector2_operator_subtract(const godot_vector2 *p_self, const godot_vector2 *p_b);
godot_vector2 GDAPI godot_vector2_operator_multiply_vector(const godot_vector2 *p_self, const godot_vector2 *p_b);
diff --git a/modules/gdnative/include/gdnative/vector3.h b/modules/gdnative/include/gdnative/vector3.h
index 3ed23778ec..135a13acc8 100644
--- a/modules/gdnative/include/gdnative/vector3.h
+++ b/modules/gdnative/include/gdnative/vector3.h
@@ -117,7 +117,7 @@ godot_vector3 GDAPI godot_vector3_reflect(const godot_vector3 *p_self, const god
godot_vector3 GDAPI godot_vector3_operator_add(const godot_vector3 *p_self, const godot_vector3 *p_b);
-godot_vector3 GDAPI godot_vector3_operator_substract(const godot_vector3 *p_self, const godot_vector3 *p_b);
+godot_vector3 GDAPI godot_vector3_operator_subtract(const godot_vector3 *p_self, const godot_vector3 *p_b);
godot_vector3 GDAPI godot_vector3_operator_multiply_vector(const godot_vector3 *p_self, const godot_vector3 *p_b);
diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp
index f9d699fb59..653445c2db 100644
--- a/modules/gdnative/nativescript/api_generator.cpp
+++ b/modules/gdnative/nativescript/api_generator.cpp
@@ -468,8 +468,6 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) {
return source;
}
-//
-
#endif
/*
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index c2c7c27f25..965de062e3 100644
--- a/modules/gdnative/nativescript/nativescript.cpp
+++ b/modules/gdnative/nativescript/nativescript.cpp
@@ -437,11 +437,11 @@ NativeScript::~NativeScript() {
#endif
}
-//
-//
-// ScriptInstance stuff
-//
-//
+ //
+ //
+ // ScriptInstance stuff
+ //
+ //
#define GET_SCRIPT_DESC() script->get_script_desc()
diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h
index f0f14e2f30..30fa400cb0 100644
--- a/modules/gdnative/nativescript/nativescript.h
+++ b/modules/gdnative/nativescript/nativescript.h
@@ -76,12 +76,12 @@ struct NativeScriptDesc {
bool is_tool;
- inline NativeScriptDesc()
- : methods(),
- properties(),
- signals_(),
- base(),
- base_native_type() {
+ inline NativeScriptDesc() :
+ methods(),
+ properties(),
+ signals_(),
+ base(),
+ base_native_type() {
zeromem(&create_func, sizeof(godot_instance_create_func));
zeromem(&destroy_func, sizeof(godot_instance_destroy_func));
}
diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp
index 40feb5ae43..e358c2fb69 100644
--- a/modules/gdnative/pluginscript/pluginscript_language.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_language.cpp
@@ -410,8 +410,8 @@ void PluginScriptLanguage::unlock() {
#endif
}
-PluginScriptLanguage::PluginScriptLanguage(const godot_pluginscript_language_desc *desc)
- : _desc(*desc) {
+PluginScriptLanguage::PluginScriptLanguage(const godot_pluginscript_language_desc *desc) :
+ _desc(*desc) {
_resource_loader = memnew(ResourceFormatLoaderPluginScript(this));
_resource_saver = memnew(ResourceFormatSaverPluginScript(this));
diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp
index 4169b07f63..0b71b3b10d 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_script.cpp
@@ -423,8 +423,11 @@ ScriptInstance::RPCMode PluginScript::get_rset_mode(const StringName &p_variable
}
}
-PluginScript::PluginScript()
- : _data(NULL), _tool(false), _valid(false), _script_list(this) {
+PluginScript::PluginScript() :
+ _data(NULL),
+ _tool(false),
+ _valid(false),
+ _script_list(this) {
}
void PluginScript::init(PluginScriptLanguage *language) {
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index 29b0a6719c..1cb35ec006 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -99,20 +99,41 @@ static Set<String> get_gdnative_singletons(EditorFileSystemDirectory *p_dir) {
}
static void actual_discoverer_handler() {
+
EditorFileSystemDirectory *dir = EditorFileSystem::get_singleton()->get_filesystem();
Set<String> file_paths = get_gdnative_singletons(dir);
+ bool changed = false;
+ Array current_files;
+ if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons")) {
+ current_files = ProjectSettings::get_singleton()->get("gdnative/singletons");
+ }
Array files;
files.resize(file_paths.size());
int i = 0;
for (Set<String>::Element *E = file_paths.front(); E; i++, E = E->next()) {
+ if (!current_files.has(E->get())) {
+ changed = true;
+ }
files.set(i, E->get());
}
- ProjectSettings::get_singleton()->set("gdnative/singletons", files);
+ // Check for removed files
+ if (!changed) {
+ for (int i = 0; i < current_files.size(); i++) {
+ if (!file_paths.has(current_files[i])) {
+ changed = true;
+ break;
+ }
+ }
+ }
- ProjectSettings::get_singleton()->save();
+ if (changed) {
+
+ ProjectSettings::get_singleton()->set("gdnative/singletons", files);
+ ProjectSettings::get_singleton()->save();
+ }
}
static GDNativeSingletonDiscover *discoverer = NULL;
@@ -123,6 +144,11 @@ protected:
virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features);
};
+struct LibrarySymbol {
+ char *name;
+ bool is_required;
+};
+
void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_type, const Set<String> &p_features) {
if (p_type != "GDNativeLibrary") {
return;
@@ -136,7 +162,6 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty
Ref<ConfigFile> config = lib->get_config_file();
- String entry_lib_path;
{
List<String> entry_keys;
@@ -161,14 +186,12 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty
continue;
}
- entry_lib_path = config->get_value("entry", key);
- break;
+ String entry_lib_path = config->get_value("entry", key);
+ add_shared_object(entry_lib_path, tags);
}
}
- Vector<String> dependency_paths;
{
-
List<String> dependency_keys;
config->get_section_keys("dependencies", &dependency_keys);
@@ -191,47 +214,54 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty
continue;
}
- dependency_paths = config->get_value("dependencies", key);
- break;
+ Vector<String> dependency_paths = config->get_value("dependencies", key);
+ for (int i = 0; i < dependency_paths.size(); i++) {
+ add_shared_object(dependency_paths[i], tags);
+ }
}
}
- bool is_statically_linked = false;
- {
-
- List<String> static_linking_keys;
- config->get_section_keys("static_linking", &static_linking_keys);
-
- for (List<String>::Element *E = static_linking_keys.front(); E; E = E->next()) {
- String key = E->get();
-
- Vector<String> tags = key.split(".");
-
- bool skip = false;
-
- for (int i = 0; i < tags.size(); i++) {
- bool has_feature = p_features.has(tags[i]);
-
- if (!has_feature) {
- skip = true;
- break;
+ if (p_features.has("iOS")) {
+ // Register symbols in the "fake" dynamic lookup table, because dlsym does not work well on iOS.
+ LibrarySymbol expected_symbols[] = {
+ { "gdnative_init", true },
+ { "gdnative_terminate", false },
+ { "nativescript_init", false },
+ { "nativescript_frame", false },
+ { "nativescript_thread_enter", false },
+ { "nativescript_thread_exit", false },
+ { "gdnative_singleton", false }
+ };
+ String declare_pattern = "extern \"C\" void $name(void)$weak;\n";
+ String additional_code = "extern void register_dynamic_symbol(char *name, void *address);\n"
+ "extern void add_ios_init_callback(void (*cb)());\n";
+ String linker_flags = "";
+ for (int i = 0; i < sizeof(expected_symbols) / sizeof(expected_symbols[0]); ++i) {
+ String full_name = lib->get_symbol_prefix() + expected_symbols[i].name;
+ String code = declare_pattern.replace("$name", full_name);
+ code = code.replace("$weak", expected_symbols[i].is_required ? "" : " __attribute__((weak))");
+ additional_code += code;
+
+ if (!expected_symbols[i].is_required) {
+ if (linker_flags.length() > 0) {
+ linker_flags += " ";
}
+ linker_flags += "-Wl,-U,_" + full_name;
}
-
- if (skip) {
- continue;
- }
-
- is_statically_linked = config->get_value("static_linking", key);
- break;
}
- }
- if (!is_statically_linked)
- add_shared_object(entry_lib_path);
+ additional_code += String("void $prefixinit() {\n").replace("$prefix", lib->get_symbol_prefix());
+ String register_pattern = " if (&$name) register_dynamic_symbol((char *)\"$name\", (void *)$name);\n";
+ for (int i = 0; i < sizeof(expected_symbols) / sizeof(expected_symbols[0]); ++i) {
+ String full_name = lib->get_symbol_prefix() + expected_symbols[i].name;
+ additional_code += register_pattern.replace("$name", full_name);
+ }
+ additional_code += "}\n";
+ additional_code += String("struct $prefixstruct {$prefixstruct() {add_ios_init_callback($prefixinit);}};\n").replace("$prefix", lib->get_symbol_prefix());
+ additional_code += String("$prefixstruct $prefixstruct_instance;\n").replace("$prefix", lib->get_symbol_prefix());
- for (int i = 0; i < dependency_paths.size(); i++) {
- add_shared_object(dependency_paths[i]);
+ add_ios_cpp_code(additional_code);
+ add_ios_linker_flags(linker_flags);
}
}
@@ -271,9 +301,7 @@ void register_gdnative_types() {
#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint()) {
- EditorNode::add_init_callback(editor_init_callback);
- }
+ EditorNode::add_init_callback(editor_init_callback);
#endif
ClassDB::register_class<GDNativeLibrary>();
@@ -371,7 +399,7 @@ void unregister_gdnative_types() {
print_line(String("poolarray:\t") + itos(sizeof(PoolByteArray)));
print_line(String("quat:\t") + itos(sizeof(Quat)));
print_line(String("rect2:\t") + itos(sizeof(Rect2)));
- print_line(String("rect3:\t") + itos(sizeof(Rect3)));
+ print_line(String("aabb:\t") + itos(sizeof(AABB)));
print_line(String("rid:\t") + itos(sizeof(RID)));
print_line(String("string:\t") + itos(sizeof(String)));
print_line(String("transform:\t") + itos(sizeof(Transform)));