summaryrefslogtreecommitdiff
path: root/modules/gdnative
diff options
context:
space:
mode:
authorThomas Herzog <thomas.herzog@mail.com>2017-07-24 04:51:34 +0200
committerGitHub <noreply@github.com>2017-07-24 04:51:34 +0200
commitb31973b64de038a1d2dfaa1fcea0c72ee5ce012b (patch)
tree0d299c22cbffc2a353c126372a44f067914b71d0 /modules/gdnative
parent85aa0adeef6ab89e98105fdaa49f441e5763d970 (diff)
parent534d62d2f4ea1ff4be11b50bc79684b5780e4615 (diff)
Merge pull request #9804 from karroffel/gdnative-rewrite
[GDNative] new GDNative API
Diffstat (limited to 'modules/gdnative')
-rw-r--r--modules/gdnative/api_generator.cpp444
-rw-r--r--modules/gdnative/api_generator.h38
-rw-r--r--modules/gdnative/gdnative.cpp1362
-rw-r--r--modules/gdnative/gdnative.h396
-rw-r--r--modules/gdnative/godot/array.cpp (renamed from modules/gdnative/godot/godot_array.cpp)4
-rw-r--r--modules/gdnative/godot/array.h (renamed from modules/gdnative/godot/godot_array.h)15
-rw-r--r--modules/gdnative/godot/basis.cpp (renamed from modules/gdnative/godot/godot_basis.cpp)4
-rw-r--r--modules/gdnative/godot/basis.h (renamed from modules/gdnative/godot/godot_basis.h)13
-rw-r--r--modules/gdnative/godot/color.cpp (renamed from modules/gdnative/godot/godot_color.cpp)4
-rw-r--r--modules/gdnative/godot/color.h (renamed from modules/gdnative/godot/godot_color.h)12
-rw-r--r--modules/gdnative/godot/dictionary.cpp (renamed from modules/gdnative/godot/godot_dictionary.cpp)4
-rw-r--r--modules/gdnative/godot/dictionary.h (renamed from modules/gdnative/godot/godot_dictionary.h)14
-rw-r--r--modules/gdnative/godot/gdnative.cpp (renamed from modules/gdnative/godot.cpp)70
-rw-r--r--modules/gdnative/godot/gdnative.h (renamed from modules/gdnative/godot.h)208
-rw-r--r--modules/gdnative/godot/icon.png.import23
-rw-r--r--modules/gdnative/godot/node_path.cpp (renamed from modules/gdnative/godot/godot_node_path.cpp)4
-rw-r--r--modules/gdnative/godot/node_path.h (renamed from modules/gdnative/godot/godot_node_path.h)12
-rw-r--r--modules/gdnative/godot/plane.cpp (renamed from modules/gdnative/godot/godot_plane.cpp)4
-rw-r--r--modules/gdnative/godot/plane.h (renamed from modules/gdnative/godot/godot_plane.h)12
-rw-r--r--modules/gdnative/godot/pool_arrays.cpp (renamed from modules/gdnative/godot/godot_pool_arrays.cpp)10
-rw-r--r--modules/gdnative/godot/pool_arrays.h (renamed from modules/gdnative/godot/godot_pool_arrays.h)61
-rw-r--r--modules/gdnative/godot/quat.cpp (renamed from modules/gdnative/godot/godot_quat.cpp)4
-rw-r--r--modules/gdnative/godot/quat.h (renamed from modules/gdnative/godot/godot_quat.h)12
-rw-r--r--modules/gdnative/godot/rect2.cpp (renamed from modules/gdnative/godot/godot_rect2.cpp)4
-rw-r--r--modules/gdnative/godot/rect2.h (renamed from modules/gdnative/godot/godot_rect2.h)6
-rw-r--r--modules/gdnative/godot/rect3.cpp (renamed from modules/gdnative/godot/godot_rect3.cpp)4
-rw-r--r--modules/gdnative/godot/rect3.h (renamed from modules/gdnative/godot/godot_rect3.h)14
-rw-r--r--modules/gdnative/godot/rid.cpp (renamed from modules/gdnative/godot/godot_rid.cpp)4
-rw-r--r--modules/gdnative/godot/rid.h (renamed from modules/gdnative/godot/godot_rid.h)10
-rw-r--r--modules/gdnative/godot/string.cpp (renamed from modules/gdnative/godot/godot_string.cpp)4
-rw-r--r--modules/gdnative/godot/string.h (renamed from modules/gdnative/godot/godot_string.h)11
-rw-r--r--modules/gdnative/godot/transform.cpp (renamed from modules/gdnative/godot/godot_transform.cpp)4
-rw-r--r--modules/gdnative/godot/transform.h (renamed from modules/gdnative/godot/godot_transform.h)16
-rw-r--r--modules/gdnative/godot/transform2d.cpp (renamed from modules/gdnative/godot/godot_transform2d.cpp)4
-rw-r--r--modules/gdnative/godot/transform2d.h (renamed from modules/gdnative/godot/godot_transform2d.h)14
-rw-r--r--modules/gdnative/godot/variant.cpp (renamed from modules/gdnative/godot/godot_variant.cpp)4
-rw-r--r--modules/gdnative/godot/variant.h (renamed from modules/gdnative/godot/godot_variant.h)47
-rw-r--r--modules/gdnative/godot/vector2.cpp (renamed from modules/gdnative/godot/godot_vector2.cpp)4
-rw-r--r--modules/gdnative/godot/vector2.h (renamed from modules/gdnative/godot/godot_vector2.h)10
-rw-r--r--modules/gdnative/godot/vector3.cpp (renamed from modules/gdnative/godot/godot_vector3.cpp)4
-rw-r--r--modules/gdnative/godot/vector3.h (renamed from modules/gdnative/godot/godot_vector3.h)12
-rw-r--r--modules/gdnative/register_types.cpp54
42 files changed, 536 insertions, 2424 deletions
diff --git a/modules/gdnative/api_generator.cpp b/modules/gdnative/api_generator.cpp
deleted file mode 100644
index 47162bfc49..0000000000
--- a/modules/gdnative/api_generator.cpp
+++ /dev/null
@@ -1,444 +0,0 @@
-/*************************************************************************/
-/* api_generator.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.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 "api_generator.h"
-
-#ifdef TOOLS_ENABLED
-
-#include "class_db.h"
-#include "core/global_constants.h"
-#include "core/project_settings.h"
-#include "os/file_access.h"
-
-// helper stuff
-
-static Error save_file(const String &p_path, const List<String> &p_content) {
-
- FileAccessRef file = FileAccess::open(p_path, FileAccess::WRITE);
-
- ERR_FAIL_COND_V(!file, ERR_FILE_CANT_WRITE);
-
- for (const List<String>::Element *e = p_content.front(); e != NULL; e = e->next()) {
- file->store_string(e->get());
- }
-
- file->close();
-
- return OK;
-}
-
-// helper stuff end
-
-struct MethodAPI {
- String method_name;
- String return_type;
-
- List<String> argument_types;
- List<String> argument_names;
-
- Map<int, Variant> default_arguments;
-
- int argument_count;
- bool has_varargs;
- bool is_editor;
- bool is_noscript;
- bool is_const;
- bool is_reverse;
- bool is_virtual;
- bool is_from_script;
-};
-
-struct PropertyAPI {
- String name;
- String getter;
- String setter;
- String type;
-};
-
-struct ConstantAPI {
- String constant_name;
- int constant_value;
-};
-
-struct SignalAPI {
- String name;
- List<String> argument_types;
- List<String> argument_names;
- Map<int, Variant> default_arguments;
-};
-
-struct ClassAPI {
- String class_name;
- String super_class_name;
-
- ClassDB::APIType api_type;
-
- bool is_singleton;
- bool is_instanciable;
- // @Unclear
- bool is_creatable;
- bool is_reference;
-
- List<MethodAPI> methods;
- List<PropertyAPI> properties;
- List<ConstantAPI> constants;
- List<SignalAPI> signals_;
-};
-
-/*
- * Reads the entire Godot API to a list
- */
-List<ClassAPI> generate_c_api_classes() {
-
- List<ClassAPI> api;
-
- List<StringName> classes;
- ClassDB::get_class_list(&classes);
-
- // Register global constants as a fake GlobalConstants singleton class
- {
- ClassAPI global_constants_api;
- global_constants_api.class_name = L"GlobalConstants";
- global_constants_api.api_type = ClassDB::API_CORE;
- global_constants_api.is_singleton = true;
- global_constants_api.is_instanciable = false;
- const int constants_count = GlobalConstants::get_global_constant_count();
- for (int i = 0; i < constants_count; ++i) {
- ConstantAPI constant_api;
- constant_api.constant_name = GlobalConstants::get_global_constant_name(i);
- constant_api.constant_value = GlobalConstants::get_global_constant_value(i);
- global_constants_api.constants.push_back(constant_api);
- }
- api.push_back(global_constants_api);
- }
-
- for (List<StringName>::Element *e = classes.front(); e != NULL; e = e->next()) {
- StringName class_name = e->get();
-
- ClassAPI class_api;
- class_api.api_type = ClassDB::get_api_type(e->get());
- class_api.class_name = class_name;
- class_api.super_class_name = ClassDB::get_parent_class(class_name);
- {
- String name = class_name;
- if (name.begins_with("_")) {
- name.remove(0);
- }
- class_api.is_singleton = ProjectSettings::get_singleton()->has_singleton(name);
- }
- class_api.is_instanciable = !class_api.is_singleton && ClassDB::can_instance(class_name);
-
- {
- bool is_reference = false;
- List<StringName> inheriters;
- ClassDB::get_inheriters_from_class("Reference", &inheriters);
- is_reference = !!inheriters.find(class_name);
- // @Unclear
- class_api.is_reference = !class_api.is_singleton && is_reference;
- }
-
- // constants
- {
- List<String> constant;
- ClassDB::get_integer_constant_list(class_name, &constant, true);
- for (List<String>::Element *c = constant.front(); c != NULL; c = c->next()) {
- ConstantAPI constant_api;
- constant_api.constant_name = c->get();
- constant_api.constant_value = ClassDB::get_integer_constant(class_name, c->get());
-
- class_api.constants.push_back(constant_api);
- }
- }
-
- // signals
- {
- List<MethodInfo> signals_;
- ClassDB::get_signal_list(class_name, &signals_, true);
-
- for (int i = 0; i < signals_.size(); i++) {
- SignalAPI signal;
-
- MethodInfo method_info = signals_[i];
- signal.name = method_info.name;
-
- for (int j = 0; j < method_info.arguments.size(); j++) {
- PropertyInfo argument = method_info.arguments[j];
- String type;
- String name = argument.name;
-
- if (argument.name.find(":") != -1) {
- type = argument.name.get_slice(":", 1);
- name = argument.name.get_slice(":", 0);
- } else if (argument.hint == PROPERTY_HINT_RESOURCE_TYPE) {
- type = argument.hint_string;
- } else if (argument.type == Variant::NIL) {
- type = "Variant";
- } else {
- type = Variant::get_type_name(argument.type);
- }
-
- signal.argument_names.push_back(name);
- signal.argument_types.push_back(type);
- }
-
- Vector<Variant> default_arguments = method_info.default_arguments;
-
- int default_start = signal.argument_names.size() - default_arguments.size();
-
- for (int j = 0; j < default_arguments.size(); j++) {
- signal.default_arguments[default_start + j] = default_arguments[j];
- }
-
- class_api.signals_.push_back(signal);
- }
- }
-
- //properties
- {
- List<PropertyInfo> properties;
- ClassDB::get_property_list(class_name, &properties, true);
-
- for (List<PropertyInfo>::Element *p = properties.front(); p != NULL; p = p->next()) {
- PropertyAPI property_api;
-
- property_api.name = p->get().name;
- property_api.getter = ClassDB::get_property_getter(class_name, p->get().name);
- property_api.setter = ClassDB::get_property_setter(class_name, p->get().name);
-
- if (p->get().name.find(":") != -1) {
- property_api.type = p->get().name.get_slice(":", 1);
- property_api.name = p->get().name.get_slice(":", 0);
- } else if (p->get().hint == PROPERTY_HINT_RESOURCE_TYPE) {
- property_api.type = p->get().hint_string;
- } else if (p->get().type == Variant::NIL) {
- property_api.type = "Variant";
- } else {
- property_api.type = Variant::get_type_name(p->get().type);
- }
-
- if (!property_api.setter.empty() || !property_api.getter.empty()) {
- class_api.properties.push_back(property_api);
- }
- }
- }
-
- //methods
- {
- List<MethodInfo> methods;
- ClassDB::get_method_list(class_name, &methods, true);
-
- for (List<MethodInfo>::Element *m = methods.front(); m != NULL; m = m->next()) {
- MethodAPI method_api;
- MethodBind *method_bind = ClassDB::get_method(class_name, m->get().name);
- MethodInfo &method_info = m->get();
-
- //method name
- method_api.method_name = m->get().name;
- //method return type
- if (method_bind && method_bind->get_return_type() != StringName()) {
- method_api.return_type = method_bind->get_return_type();
- } else if (method_api.method_name.find(":") != -1) {
- method_api.return_type = method_api.method_name.get_slice(":", 1);
- method_api.method_name = method_api.method_name.get_slice(":", 0);
- } else if (m->get().return_val.type != Variant::NIL) {
- method_api.return_type = m->get().return_val.hint == PROPERTY_HINT_RESOURCE_TYPE ? m->get().return_val.hint_string : Variant::get_type_name(m->get().return_val.type);
- } else if (m->get().return_val.name != "") {
- method_api.return_type = m->get().return_val.name;
- } else {
- method_api.return_type = "void";
- }
-
- method_api.argument_count = method_info.arguments.size();
- method_api.has_varargs = method_bind && method_bind->is_vararg();
-
- // Method flags
- if (method_info.flags) {
- const uint32_t flags = method_info.flags;
- method_api.is_editor = flags & METHOD_FLAG_EDITOR;
- method_api.is_noscript = flags & METHOD_FLAG_NOSCRIPT;
- method_api.is_const = flags & METHOD_FLAG_CONST;
- method_api.is_reverse = flags & METHOD_FLAG_REVERSE;
- method_api.is_virtual = flags & METHOD_FLAG_VIRTUAL;
- method_api.is_from_script = flags & METHOD_FLAG_FROM_SCRIPT;
- }
-
- method_api.is_virtual = method_api.is_virtual || method_api.method_name[0] == '_';
-
- // method argument name and type
-
- for (int i = 0; i < method_api.argument_count; i++) {
- String arg_name;
- String arg_type;
- PropertyInfo arg_info = method_info.arguments[i];
-
- arg_name = arg_info.name;
-
- if (arg_info.name.find(":") != -1) {
- arg_type = arg_info.name.get_slice(":", 1);
- arg_name = arg_info.name.get_slice(":", 0);
- } else if (arg_info.hint == PROPERTY_HINT_RESOURCE_TYPE) {
- arg_type = arg_info.hint_string;
- } else if (arg_info.type == Variant::NIL) {
- arg_type = "Variant";
- } else {
- arg_type = Variant::get_type_name(arg_info.type);
- }
-
- method_api.argument_names.push_back(arg_name);
- method_api.argument_types.push_back(arg_type);
-
- if (method_bind && method_bind->has_default_argument(i)) {
- method_api.default_arguments[i] = method_bind->get_default_argument(i);
- }
- }
-
- class_api.methods.push_back(method_api);
- }
- }
-
- api.push_back(class_api);
- }
-
- return api;
-}
-
-/*
- * Generates the JSON source from the API in p_api
- */
-static List<String> generate_c_api_json(const List<ClassAPI> &p_api) {
-
- // I'm sorry for the \t mess
-
- List<String> source;
-
- source.push_back("[\n");
-
- for (const List<ClassAPI>::Element *c = p_api.front(); c != NULL; c = c->next()) {
- ClassAPI api = c->get();
-
- source.push_back("\t{\n");
-
- source.push_back("\t\t\"name\": \"" + api.class_name + "\",\n");
- source.push_back("\t\t\"base_class\": \"" + api.super_class_name + "\",\n");
- source.push_back(String("\t\t\"api_type\": \"") + (api.api_type == ClassDB::API_CORE ? "core" : (api.api_type == ClassDB::API_EDITOR ? "tools" : "none")) + "\",\n");
- source.push_back(String("\t\t\"singleton\": ") + (api.is_singleton ? "true" : "false") + ",\n");
- source.push_back(String("\t\t\"instanciable\": ") + (api.is_instanciable ? "true" : "false") + ",\n");
- source.push_back(String("\t\t\"is_reference\": ") + (api.is_reference ? "true" : "false") + ",\n");
- // @Unclear
- // source.push_back(String("\t\t\"createable\": ") + (api.is_creatable ? "true" : "false") + ",\n");
-
- source.push_back("\t\t\"constants\": {\n");
- for (List<ConstantAPI>::Element *e = api.constants.front(); e; e = e->next()) {
- source.push_back("\t\t\t\"" + e->get().constant_name + "\": " + String::num_int64(e->get().constant_value) + (e->next() ? "," : "") + "\n");
- }
- source.push_back("\t\t},\n");
-
- source.push_back("\t\t\"properties\": [\n");
- for (List<PropertyAPI>::Element *e = api.properties.front(); e; e = e->next()) {
- source.push_back("\t\t\t{\n");
- source.push_back("\t\t\t\t\"name\": \"" + e->get().name + "\",\n");
- source.push_back("\t\t\t\t\"type\": \"" + e->get().type + "\",\n");
- source.push_back("\t\t\t\t\"getter\": \"" + e->get().getter + "\",\n");
- source.push_back("\t\t\t\t\"setter\": \"" + e->get().setter + "\"\n");
- source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n");
- }
- source.push_back("\t\t],\n");
-
- source.push_back("\t\t\"signals\": [\n");
- for (List<SignalAPI>::Element *e = api.signals_.front(); e; e = e->next()) {
- source.push_back("\t\t\t{\n");
- source.push_back("\t\t\t\t\"name\": \"" + e->get().name + "\",\n");
- source.push_back("\t\t\t\t\"arguments\": [\n");
- for (int i = 0; i < e->get().argument_names.size(); i++) {
- source.push_back("\t\t\t\t\t{\n");
- source.push_back("\t\t\t\t\t\t\"name\": \"" + e->get().argument_names[i] + "\",\n");
- source.push_back("\t\t\t\t\t\t\"type\": \"" + e->get().argument_types[i] + "\",\n");
- source.push_back("\t\t\t\t\t\t\"default_value\": \"" + (e->get().default_arguments.has(i) ? (String)e->get().default_arguments[i] : "") + "\"\n");
- source.push_back(String("\t\t\t\t\t}") + ((i < e->get().argument_names.size() - 1) ? "," : "") + "\n");
- }
- source.push_back("\t\t\t\t]\n");
- source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n");
- }
- source.push_back("\t\t],\n");
-
- source.push_back("\t\t\"methods\": [\n");
- for (List<MethodAPI>::Element *e = api.methods.front(); e; e = e->next()) {
- source.push_back("\t\t\t{\n");
- source.push_back("\t\t\t\t\"name\": \"" + e->get().method_name + "\",\n");
- source.push_back("\t\t\t\t\"return_type\": \"" + e->get().return_type + "\",\n");
- source.push_back(String("\t\t\t\t\"is_editor\": ") + (e->get().is_editor ? "true" : "false") + ",\n");
- source.push_back(String("\t\t\t\t\"is_noscript\": ") + (e->get().is_noscript ? "true" : "false") + ",\n");
- source.push_back(String("\t\t\t\t\"is_const\": ") + (e->get().is_const ? "true" : "false") + ",\n");
- source.push_back(String("\t\t\t\t\"is_reverse\": ") + (e->get().is_reverse ? "true" : "false") + ",\n");
- source.push_back(String("\t\t\t\t\"is_virtual\": ") + (e->get().is_virtual ? "true" : "false") + ",\n");
- source.push_back(String("\t\t\t\t\"has_varargs\": ") + (e->get().has_varargs ? "true" : "false") + ",\n");
- source.push_back(String("\t\t\t\t\"is_from_script\": ") + (e->get().is_from_script ? "true" : "false") + ",\n");
- source.push_back("\t\t\t\t\"arguments\": [\n");
- for (int i = 0; i < e->get().argument_names.size(); i++) {
- source.push_back("\t\t\t\t\t{\n");
- source.push_back("\t\t\t\t\t\t\"name\": \"" + e->get().argument_names[i] + "\",\n");
- source.push_back("\t\t\t\t\t\t\"type\": \"" + e->get().argument_types[i] + "\",\n");
- source.push_back(String("\t\t\t\t\t\t\"has_default_value\": ") + (e->get().default_arguments.has(i) ? "true" : "false") + ",\n");
- source.push_back("\t\t\t\t\t\t\"default_value\": \"" + (e->get().default_arguments.has(i) ? (String)e->get().default_arguments[i] : "") + "\"\n");
- source.push_back(String("\t\t\t\t\t}") + ((i < e->get().argument_names.size() - 1) ? "," : "") + "\n");
- }
- source.push_back("\t\t\t\t]\n");
- source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n");
- }
- source.push_back("\t\t]\n");
-
- source.push_back(String("\t}") + (c->next() ? "," : "") + "\n");
- }
-
- source.push_back("]");
-
- return source;
-}
-
-//
-
-#endif
-
-/*
- * Saves the whole Godot API to a JSON file located at
- * p_path
- */
-Error generate_c_api(const String &p_path) {
-
-#ifndef TOOLS_ENABLED
- return ERR_BUG;
-#else
-
- List<ClassAPI> api = generate_c_api_classes();
-
- List<String> json_source = generate_c_api_json(api);
-
- return save_file(p_path, json_source);
-#endif
-}
diff --git a/modules/gdnative/api_generator.h b/modules/gdnative/api_generator.h
deleted file mode 100644
index a108d7a7b6..0000000000
--- a/modules/gdnative/api_generator.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*************************************************************************/
-/* api_generator.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.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 API_GENERATOR_H
-#define API_GENERATOR_H
-
-#include "core/ustring.h"
-#include "typedefs.h"
-
-Error generate_c_api(const String &p_path);
-
-#endif // API_GENERATOR_H
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index 214164ef89..65bfbb0ff7 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -36,725 +36,54 @@
#include "project_settings.h"
#include "scene/main/scene_tree.h"
-#include "scene/resources/scene_format_text.h"
-#if defined(TOOLS_ENABLED) && defined(DEBUG_METHODS_ENABLED)
-#include "api_generator.h"
-#endif
+const String init_symbol = "godot_gdnative_init";
+const String terminate_symbol = "godot_gdnative_terminate";
-#ifdef TOOLS_ENABLED
-#include "editor/editor_node.h"
-#endif
+String GDNativeLibrary::platform_names[NUM_PLATFORMS] = {
+ "X11_32bit",
+ "X11_64bit",
+ "Windows_32bit",
+ "Windows_64bit",
+ "OSX",
-Error NativeLibrary::initialize(NativeLibrary *&p_native_lib, const StringName p_path) {
+ "Android",
+ "iOS",
- if (GDNativeScriptLanguage::get_singleton()->initialized_libraries.has(p_path)) {
- p_native_lib = GDNativeScriptLanguage::get_singleton()->initialized_libraries[p_path];
- return OK;
- }
-
- NativeLibrary *lib = memnew(NativeLibrary);
- lib->path = p_path;
-
- p_native_lib = lib;
-
- // Open the file
-
- Error error;
- error = OS::get_singleton()->open_dynamic_library(p_path, lib->handle);
- if (error) return error;
- ERR_FAIL_COND_V(!lib->handle, ERR_BUG);
-
- // Get the method
-
- void *library_init;
- error = OS::get_singleton()->get_dynamic_library_symbol_handle(lib->handle, GDNativeScriptLanguage::get_init_symbol_name(), library_init);
- if (error) return error;
- ERR_FAIL_COND_V(!library_init, ERR_BUG);
-
- void (*library_init_fpointer)(godot_native_init_options *) = (void (*)(godot_native_init_options *))library_init;
-
- godot_native_init_options options;
-
- options.in_editor = SceneTree::get_singleton()->is_editor_hint();
- 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);
-
- library_init_fpointer(&options); // Catch errors?
-
- GDNativeScriptLanguage::get_singleton()->initialized_libraries[p_path] = lib;
-
- return OK;
-}
-
-Error NativeLibrary::terminate(NativeLibrary *&p_native_lib) {
-
- if (!GDNativeScriptLanguage::get_singleton()->initialized_libraries.has(p_native_lib->path)) {
- OS::get_singleton()->close_dynamic_library(p_native_lib->handle);
- p_native_lib->handle = 0;
- return OK;
- }
-
- Error error = OK;
- void *library_terminate;
- error = OS::get_singleton()->get_dynamic_library_symbol_handle(p_native_lib->handle, GDNativeScriptLanguage::get_terminate_symbol_name(), library_terminate);
- if (!error) {
-
- void (*library_terminate_pointer)(godot_native_terminate_options *) = (void (*)(godot_native_terminate_options *))library_terminate;
-
- godot_native_terminate_options options;
- options.in_editor = SceneTree::get_singleton()->is_editor_hint();
-
- library_terminate_pointer(&options);
- }
-
- GDNativeScriptLanguage::get_singleton()->initialized_libraries.erase(p_native_lib->path);
-
- OS::get_singleton()->close_dynamic_library(p_native_lib->handle);
- p_native_lib->handle = 0;
-
- return OK;
-}
-
-// Script
-#ifdef TOOLS_ENABLED
-
-void GDNativeScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) {
- ERR_FAIL_COND(!script_data);
-
- List<PropertyInfo> pinfo;
- Map<StringName, Variant> values;
-
- for (Map<StringName, GDNativeScriptData::Property>::Element *E = script_data->properties.front(); E; E = E->next()) {
- PropertyInfo p = E->get().info;
- p.name = String(E->key());
- pinfo.push_back(p);
- values[p.name] = E->get().default_value;
- }
-
- p_placeholder->update(pinfo, values);
-}
-
-void GDNativeScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) {
-
- placeholders.erase(p_placeholder);
-}
-
-#endif
-
-bool GDNativeScript::can_instance() const {
-#ifdef TOOLS_ENABLED
- return script_data || (!is_tool() && !ScriptServer::is_scripting_enabled());
-#else
- // allow defaultlibrary without editor features
- if (!library.is_valid()) {
- String path = GLOBAL_GET("gdnative/default_gdnativelibrary");
-
- RES lib = ResourceLoader::load(path);
-
- if (lib.is_valid() && lib->cast_to<GDNativeLibrary>()) {
- return true;
- }
- }
-
- return script_data;
-#endif
- //return script_data || (!tool && !ScriptServer::is_scripting_enabled());
- // change to true enable in editor stuff.
-}
-
-Ref<Script> GDNativeScript::get_base_script() const {
- Ref<GDNativeScript> base_script;
- base_script->library = library;
- base_script->script_data = script_data;
- base_script->script_name = script_data->base;
- return base_script;
-}
-
-StringName GDNativeScript::get_instance_base_type() const {
- return script_data->base_native_type;
-}
-
-ScriptInstance *GDNativeScript::instance_create(Object *p_this) {
-
-#ifdef TOOLS_ENABLED
-
- // find a good way to initialize stuff in the editor
- if (!ScriptServer::is_scripting_enabled() && !is_tool()) {
- // placeholder, for nodes. But for tools we want the real thing
-
- PlaceHolderScriptInstance *sins = memnew(PlaceHolderScriptInstance(GDNativeScriptLanguage::singleton, Ref<Script>((Script *)this), p_this));
- placeholders.insert(sins);
-
- if (!library.is_valid())
- return sins;
-
- if (!library->native_library) {
- Error err = library->_initialize();
- if (err != OK) {
- return sins;
- }
- }
-
- if (!script_data) {
- script_data = library->get_script_data(script_name);
- }
- if (script_data && script_data->create_func.create_func) {
- script_data->create_func.create_func((godot_object *)p_this, script_data->create_func.method_data);
- }
-
- _update_placeholder(sins);
-
- return sins;
- }
-
-#endif
-
- if (!library.is_valid()) {
- String path = GLOBAL_GET("gdnative/default_gdnativelibrary");
-
- RES lib = ResourceLoader::load(path);
-
- if (lib.is_valid() && lib->cast_to<GDNativeLibrary>()) {
- set_library(lib);
- }
- }
-
- GDNativeInstance *new_instance = memnew(GDNativeInstance);
-
- new_instance->owner = p_this;
- new_instance->script = Ref<GDNativeScript>(this);
-
-#ifndef TOOLS_ENABLED
- if (!ScriptServer::is_scripting_enabled()) {
- new_instance->userdata = 0;
- } else {
- new_instance->userdata = script_data->create_func.create_func((godot_object *)p_this, script_data->create_func.method_data);
- }
-#else
- new_instance->userdata = script_data->create_func.create_func((godot_object *)p_this, script_data->create_func.method_data);
-#endif
-
- instances.insert(p_this);
- return new_instance;
-}
-
-bool GDNativeScript::instance_has(const Object *p_this) const {
- return instances.has((Object *)p_this); // TODO
-}
-
-bool GDNativeScript::has_source_code() const {
- return false;
-}
-
-String GDNativeScript::get_source_code() const {
- return "";
-}
-
-Error GDNativeScript::reload(bool p_keep_state) {
- return FAILED;
-}
-
-bool GDNativeScript::has_method(const StringName &p_method) const {
- if (!script_data)
- return false;
- GDNativeScriptData *data = script_data;
-
- while (data) {
- if (data->methods.has(p_method))
- return true;
-
- data = data->base_data;
- }
-
- return false;
-}
-
-MethodInfo GDNativeScript::get_method_info(const StringName &p_method) const {
- if (!script_data)
- return MethodInfo();
- GDNativeScriptData *data = script_data;
-
- while (data) {
- if (data->methods.has(p_method))
- return data->methods[p_method].info;
-
- data = data->base_data;
- }
-
- ERR_FAIL_COND_V(!script_data->methods.has(p_method), MethodInfo());
- return MethodInfo();
-}
-
-void GDNativeScript::get_script_method_list(List<MethodInfo> *p_list) const {
- if (!script_data) return;
-
- Set<MethodInfo> methods;
- GDNativeScriptData *data = script_data;
-
- while (data) {
- for (Map<StringName, GDNativeScriptData::Method>::Element *E = data->methods.front(); E; E = E->next()) {
- methods.insert(E->get().info);
- }
- data = data->base_data;
- }
-
- for (Set<MethodInfo>::Element *E = methods.front(); E; E = E->next()) {
- p_list->push_back(E->get());
- }
-}
-
-void GDNativeScript::get_script_property_list(List<PropertyInfo> *p_list) const {
- if (!script_data) return;
-
- Set<PropertyInfo> properties;
- GDNativeScriptData *data = script_data;
-
- while (data) {
- for (Map<StringName, GDNativeScriptData::Property>::Element *E = data->properties.front(); E; E = E->next()) {
- properties.insert(E->get().info);
- }
- data = data->base_data;
- }
-
- for (Set<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
- p_list->push_back(E->get());
- }
-}
-
-bool GDNativeScript::get_property_default_value(const StringName &p_property, Variant &r_value) const {
- if (!script_data) return false;
-
- GDNativeScriptData *data = script_data;
-
- while (data) {
- if (data->properties.has(p_property)) {
- r_value = data->properties[p_property].default_value;
- return true;
- }
-
- data = data->base_data;
- }
-
- return false;
-}
-
-bool GDNativeScript::is_tool() const {
- ERR_FAIL_COND_V(!script_data, false);
- return script_data->is_tool;
-}
-
-String GDNativeScript::get_node_type() const {
- return ""; // ?
-}
-
-ScriptLanguage *GDNativeScript::get_language() const {
- return GDNativeScriptLanguage::singleton;
-}
-
-bool GDNativeScript::has_script_signal(const StringName &p_signal) const {
- if (!script_data)
- return false;
-
- GDNativeScriptData *data = script_data;
-
- while (data) {
- if (data->signals_.has(p_signal)) {
- return true;
- }
-
- data = data->base_data;
- }
-
- return false;
-}
-
-void GDNativeScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
- if (!script_data)
- return;
-
- Set<MethodInfo> signals_;
- GDNativeScriptData *data = script_data;
-
- while (data) {
-
- for (Map<StringName, GDNativeScriptData::Signal>::Element *S = data->signals_.front(); S; S = S->next()) {
- signals_.insert(S->get().signal);
- }
-
- data = data->base_data;
- }
-
- for (Set<MethodInfo>::Element *E = signals_.front(); E; E = E->next()) {
- r_signals->push_back(E->get());
- }
-}
-
-Variant GDNativeScript::_new(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
-
- /* STEP 1, CREATE */
-
- if (!library.is_valid() || ((String)script_name).empty() || !script_data) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
- return Variant();
- }
-
- r_error.error = Variant::CallError::CALL_OK;
- REF ref;
- Object *owner = NULL;
-
- GDNativeScriptData *_baseptr = script_data;
- while (_baseptr->base_data) {
- _baseptr = _baseptr->base_data;
- }
-
- if (!(_baseptr->base_native_type == "")) {
- owner = ClassDB::instance(_baseptr->base_native_type);
- } else {
- owner = memnew(Reference); //by default, no base means use reference
- }
-
- Reference *r = owner->cast_to<Reference>();
- if (r) {
- ref = REF(r);
- }
-
- // GDScript does it like this: _create_instance(p_args, p_argcount, owner, r != NULL, r_error);
- // @Todo support varargs for constructors.
- GDNativeInstance *instance = (GDNativeInstance *)instance_create(owner);
-
- owner->set_script_instance(instance);
- if (!instance) {
- if (ref.is_null()) {
- memdelete(owner); //no owner, sorry
- }
- return Variant();
- }
-
- if (ref.is_valid()) {
- return ref;
- } else {
- return owner;
- }
-}
-
-Ref<GDNativeLibrary> GDNativeScript::get_library() const {
- return library;
-}
-
-void GDNativeScript::set_library(Ref<GDNativeLibrary> p_library) {
- library = p_library;
-
-#ifdef TOOLS_ENABLED
- if (!ScriptServer::is_scripting_enabled())
- return;
-#endif
- if (library.is_valid()) {
- Error initalize_status = library->_initialize();
- ERR_FAIL_COND(initalize_status != OK);
- if (script_name) {
- script_data = library->native_library->scripts[script_name];
- ERR_FAIL_COND(!script_data);
- }
- }
-}
-
-StringName GDNativeScript::get_script_name() const {
- return script_name;
-}
-
-void GDNativeScript::set_script_name(StringName p_script_name) {
- script_name = p_script_name;
-
- if (library.is_valid()) {
-#ifdef TOOLS_ENABLED
- if (!library->native_library) {
- library->_initialize();
- }
-#endif
- if (library->native_library) {
- script_data = library->get_script_data(script_name);
- ERR_FAIL_COND(!script_data);
- }
- }
-}
-
-void GDNativeScript::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_library:GDNativeLibrary"), &GDNativeScript::get_library);
- ClassDB::bind_method(D_METHOD("set_library", "library:GDNativeLibrary"), &GDNativeScript::set_library);
- ClassDB::bind_method(D_METHOD("get_script_name"), &GDNativeScript::get_script_name);
- ClassDB::bind_method(D_METHOD("set_script_name", "script_name"), &GDNativeScript::set_script_name);
-
- ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "new", &GDNativeScript::_new, MethodInfo(Variant::OBJECT, "new"));
-
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "GDNativeLibrary"), "set_library", "get_library");
- ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "script_name"), "set_script_name", "get_script_name");
-}
-
-GDNativeScript::GDNativeScript() {
- script_data = NULL;
- GDNativeScriptLanguage::get_singleton()->script_list.insert(this);
-}
-
-GDNativeScript::~GDNativeScript() {
- //hmm
- GDNativeScriptLanguage::get_singleton()->script_list.erase(this);
-}
-
-// Library
-
-GDNativeLibrary *GDNativeLibrary::currently_initialized_library = NULL;
-
-GDNativeLibrary *GDNativeLibrary::get_currently_initialized_library() {
- return currently_initialized_library;
-}
-
-static const char *_dl_platforms_info[] = {
- "|unix|so|Unix",
- "unix|x11|so|X11",
- "unix|server|so|Server",
- "unix|android|so|Android",
- "unix|haiku|so|Haiku", // Right?
- "|mac|dylib|Mac",
- "mac|ios|dylib|iOS",
- "mac|osx|dylib|OSX",
- "|html5|js|HTML5",
- "|windows|dll|Windows",
- "windows|uwp|dll|UWP",
- NULL // Finishing condition
+ "WebAssembly"
};
+String GDNativeLibrary::platform_lib_ext[NUM_PLATFORMS] = {
+ "so",
+ "so",
+ "dll",
+ "dll",
+ "dylib",
-void GDNativeLibrary::set_platform_file(StringName p_platform, String p_file) {
- if (p_file.empty()) {
- platform_files.erase(p_platform);
- } else {
- platform_files[p_platform] = p_file;
- }
-}
-
-String GDNativeLibrary::get_platform_file(StringName p_platform) const {
- if (platform_files.has(p_platform)) {
- return platform_files[p_platform];
- } else {
- return "";
- }
-}
-
-Error GDNativeLibrary::_initialize() {
- _THREAD_SAFE_METHOD_
-
- // Get the file
-
- const String platform_name = OS::get_singleton()->get_name();
- String platform_file("");
- char **platform_info = (char **)_dl_platforms_info;
-
- if (platform_files.has(platform_name.to_lower())) {
- platform_file = platform_files[platform_name.to_lower()];
- }
-
- while (*platform_info) {
- String platform_info_string(*platform_info);
-
- if (platform_name == platform_info_string.get_slicec('|', 3)) {
- String platform_key = platform_info_string.get_slicec('|', 1);
- String fallback_platform_key = platform_info_string.get_slicec('|', 0);
-
- if (platform_files.has(platform_key)) {
- platform_file = platform_files[platform_key];
- } else if (!fallback_platform_key.empty() && platform_files.has(fallback_platform_key)) {
- platform_file = platform_files[fallback_platform_key];
- } else {
- return ERR_UNAVAILABLE;
- }
- }
- platform_info++;
- }
- ERR_FAIL_COND_V(platform_file == "", ERR_DOES_NOT_EXIST);
-
- StringName path = ProjectSettings::get_singleton()->globalize_path(platform_file);
-
- GDNativeLibrary::currently_initialized_library = this;
-
- Error ret = NativeLibrary::initialize(native_library, path);
- native_library->dllib = this;
-
- GDNativeLibrary::currently_initialized_library = NULL;
+ "so",
+ "dylib",
- return ret;
-}
-
-Error GDNativeLibrary::_terminate() {
- ERR_FAIL_COND_V(!native_library, ERR_BUG);
- ERR_FAIL_COND_V(!native_library->handle, ERR_BUG);
-
- // de-init stuff
-
- for (Map<StringName, GDNativeScriptData *>::Element *E = native_library->scripts.front(); E; E = E->next()) {
- for (Map<StringName, GDNativeScriptData::Method>::Element *M = E->get()->methods.front(); M; M = M->next()) {
- if (M->get().method.free_func) {
- M->get().method.free_func(M->get().method.method_data);
- }
- }
- if (E->get()->create_func.free_func) {
- E->get()->create_func.free_func(E->get()->create_func.method_data);
- }
- if (E->get()->destroy_func.free_func) {
- E->get()->destroy_func.free_func(E->get()->destroy_func.method_data);
- }
-
- for (Set<GDNativeScript *>::Element *S = GDNativeScriptLanguage::get_singleton()->script_list.front(); S; S = S->next()) {
- if (S->get()->script_data == E->get()) {
- S->get()->script_data = NULL;
- }
- }
-
- memdelete(E->get());
- }
-
- Error ret = NativeLibrary::terminate(native_library);
- native_library->scripts.clear();
-
- return ret;
-}
-
-void GDNativeLibrary::_register_script(const StringName p_name, const StringName p_base, godot_instance_create_func p_instance_func, godot_instance_destroy_func p_destroy_func) {
- ERR_FAIL_COND(!native_library);
- ERR_FAIL_COND(native_library->scripts.has(p_name));
-
- GDNativeScriptData *s = memnew(GDNativeScriptData);
- s->base = p_base;
- s->create_func = p_instance_func;
- s->destroy_func = p_destroy_func;
- Map<StringName, GDNativeScriptData *>::Element *E = native_library->scripts.find(p_base);
- if (E) {
- s->base_data = E->get();
- s->base_native_type = s->base_data->base_native_type;
- } else {
- if (!ClassDB::class_exists(p_base)) {
- memdelete(s);
- ERR_EXPLAIN("Invalid base for registered type '" + p_name + "'");
- ERR_FAIL();
- }
- s->base_native_type = p_base;
- }
-
- native_library->scripts.insert(p_name, s);
-}
-
-void GDNativeLibrary::_register_tool_script(const StringName p_name, const StringName p_base, godot_instance_create_func p_instance_func, godot_instance_destroy_func p_destroy_func) {
- ERR_FAIL_COND(!native_library);
- ERR_FAIL_COND(native_library->scripts.has(p_name));
-
- GDNativeScriptData *s = memnew(GDNativeScriptData);
- s->base = p_base;
- s->create_func = p_instance_func;
- s->destroy_func = p_destroy_func;
- s->is_tool = true;
- Map<StringName, GDNativeScriptData *>::Element *E = native_library->scripts.find(p_base);
- if (E) {
- s->base_data = E->get();
- s->base_native_type = s->base_data->base_native_type;
- } else {
- if (!ClassDB::class_exists(p_base)) {
- memdelete(s);
- ERR_EXPLAIN("Invalid base for registered type '" + p_name + "'");
- ERR_FAIL();
- }
- s->base_native_type = p_base;
- }
-
- native_library->scripts.insert(p_name, s);
-}
-
-void GDNativeLibrary::_register_script_method(const StringName p_name, const StringName p_method, godot_method_attributes p_attr, godot_instance_method p_func, MethodInfo p_info) {
- ERR_FAIL_COND(!native_library);
- ERR_FAIL_COND(!native_library->scripts.has(p_name));
-
- p_info.name = p_method;
- GDNativeScriptData::Method method;
-
- method = GDNativeScriptData::Method(p_func, p_info, p_attr.rpc_type);
-
- native_library->scripts[p_name]->methods.insert(p_method, method);
-}
-
-void GDNativeLibrary::_register_script_property(const StringName p_name, const String p_path, godot_property_attributes *p_attr, godot_property_set_func p_setter, godot_property_get_func p_getter) {
- ERR_FAIL_COND(!native_library);
- ERR_FAIL_COND(!native_library->scripts.has(p_name));
-
- GDNativeScriptData::Property p;
-
- PropertyInfo pi;
- pi.name = p_path;
-
- if (p_attr != NULL) {
- pi = PropertyInfo((Variant::Type)p_attr->type, p_path, (PropertyHint)p_attr->hint, *(String *)&p_attr->hint_string, p_attr->usage);
+ "wasm"
+};
- p = GDNativeScriptData::Property(p_setter, p_getter, pi, *(Variant *)&p_attr->default_value, p_attr->rset_type);
- }
+// TODO(karroffel): make this actually do something lol.
+GDNativeLibrary::Platform GDNativeLibrary::current_platform = X11_64BIT;
- native_library->scripts[p_name]->properties.insert(p_path, p);
+GDNativeLibrary::GDNativeLibrary()
+ : library_paths() {
}
-void GDNativeLibrary::_register_script_signal(const StringName p_name, const godot_signal *p_signal) {
- ERR_FAIL_COND(!native_library);
- ERR_FAIL_COND(!native_library->scripts.has(p_name));
- ERR_FAIL_COND(!p_signal);
-
- GDNativeScriptData::Signal signal;
-
- signal.signal.name = *(String *)&p_signal->name;
-
- {
- List<PropertyInfo> arguments;
- for (int i = 0; i < p_signal->num_args; i++) {
- PropertyInfo info;
- godot_signal_argument attrib = p_signal->args[i];
-
- String *name = (String *)&attrib.name;
- info.name = *name;
- info.type = (Variant::Type)attrib.type;
- info.hint = (PropertyHint)attrib.hint;
- info.hint_string = *(String *)&attrib.hint_string;
- info.usage = attrib.usage;
-
- arguments.push_back(info);
- }
-
- signal.signal.arguments = arguments;
- }
-
- {
- Vector<Variant> default_arguments;
- for (int i = 0; i < p_signal->num_default_args; i++) {
- Variant *v;
- godot_signal_argument attrib = p_signal->args[i];
-
- v = (Variant *)&attrib.default_value;
-
- default_arguments.push_back(*v);
- }
-
- signal.signal.default_arguments = default_arguments;
- }
-
- native_library->scripts[p_name]->signals_.insert(*(String *)&p_signal->name, signal);
+GDNativeLibrary::~GDNativeLibrary() {
}
-GDNativeScriptData *GDNativeLibrary::get_script_data(const StringName p_name) {
- ERR_FAIL_COND_V(!native_library, NULL);
-
- ERR_FAIL_COND_V(!native_library->scripts.has(p_name), NULL);
-
- return native_library->scripts[p_name];
+void GDNativeLibrary::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_library_path", "platform", "path"), &GDNativeLibrary::set_library_path);
+ ClassDB::bind_method(D_METHOD("get_library_path", "platform"), &GDNativeLibrary::get_library_path);
}
bool GDNativeLibrary::_set(const StringName &p_name, const Variant &p_value) {
String name = p_name;
if (name.begins_with("platform/")) {
- set_platform_file(name.get_slice("/", 1), p_value);
+ set_library_path(name.get_slice("/", 1), p_value);
return true;
}
return false;
@@ -763,582 +92,231 @@ bool GDNativeLibrary::_set(const StringName &p_name, const Variant &p_value) {
bool GDNativeLibrary::_get(const StringName &p_name, Variant &r_ret) const {
String name = p_name;
if (name.begins_with("platform/")) {
- r_ret = get_platform_file(name.get_slice("/", 1));
+ r_ret = get_library_path(name.get_slice("/", 1));
return true;
}
return false;
}
void GDNativeLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
- char **platform_info = (char **)_dl_platforms_info;
-
- Set<String> registered_platform_names;
- {
- List<StringName> ep;
- // ep.push_back("X11");
- // EditorImportExport::get_singleton()->get_export_platforms(&ep);
-
- // @Todo
- // get export platforms with the new export system somehow.
- for (List<StringName>::Element *E = ep.front(); E; E = E->next()) {
- registered_platform_names.insert(String(E->get()).to_lower());
- }
- }
-
- while (*platform_info) {
- String platform_info_string(*platform_info);
- String fallback_platform_key = platform_info_string.get_slicec('|', 0);
- String platform_key = platform_info_string.get_slicec('|', 1);
- String platform_extension = platform_info_string.get_slicec('|', 2);
- String platform_name = platform_info_string.get_slicec('|', 3);
-
- registered_platform_names.erase(platform_name);
-
- if (fallback_platform_key.empty()) {
- p_list->push_back(PropertyInfo(Variant::STRING, "platform/" + platform_key, PROPERTY_HINT_FILE, "*." + platform_extension));
-
- } else {
- if (platform_files.has(platform_key)) {
- p_list->push_back(PropertyInfo(Variant::STRING, "platform/" + platform_key, PROPERTY_HINT_FILE, "*." + platform_extension, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CHECKABLE | PROPERTY_USAGE_CHECKED));
- } else {
- p_list->push_back(PropertyInfo(Variant::STRING, "platform/" + platform_key, PROPERTY_HINT_FILE, "*." + platform_extension, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CHECKABLE));
- }
- }
- platform_info++;
- }
-
- while (registered_platform_names.size()) {
- const String platform_name = registered_platform_names.front()->get();
- registered_platform_names.erase(platform_name);
- p_list->push_back(PropertyInfo(Variant::STRING, "platform/" + platform_name.to_lower(), PROPERTY_HINT_FILE, "*"));
- }
-}
-
-void GDNativeLibrary::_notification(int what) {
- // TODO
-}
-
-void GDNativeLibrary::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_platform_file", "platform", "file"), &GDNativeLibrary::set_platform_file);
- ClassDB::bind_method(D_METHOD("get_platform_file", "platform"), &GDNativeLibrary::get_platform_file);
-}
-
-GDNativeLibrary::GDNativeLibrary() {
- native_library = NULL;
-}
-
-GDNativeLibrary::~GDNativeLibrary() {
-
- if (!native_library) {
- return;
- }
-
- if (native_library->handle) {
- _terminate();
+ for (int i = 0; i < NUM_PLATFORMS; i++) {
+ p_list->push_back(PropertyInfo(Variant::STRING,
+ "platform/" + platform_names[i],
+ PROPERTY_HINT_FILE,
+ "*." + platform_lib_ext[i]));
}
}
-// Instance
-
-bool GDNativeInstance::set(const StringName &p_name, const Variant &p_value) {
- if (!script->script_data)
- return false;
- if (script->script_data->properties.has(p_name)) {
- script->script_data->properties[p_name].setter.set_func((godot_object *)owner, script->script_data->properties[p_name].setter.method_data, userdata, *(godot_variant *)&p_value);
- return true;
+void GDNativeLibrary::set_library_path(StringName p_platform, String p_path) {
+ int i;
+ for (i = 0; i <= NUM_PLATFORMS; i++) {
+ if (i == NUM_PLATFORMS) break;
+ if (platform_names[i] == p_platform) {
+ break;
+ }
}
- Map<StringName, GDNativeScriptData::Method>::Element *E = script->script_data->methods.find("_set");
- if (E) {
- Variant name = p_name;
- const Variant *args[2] = { &name, &p_value };
-
- E->get().method.method((godot_object *)owner, E->get().method.method_data, userdata, 2, (godot_variant **)args);
- return true;
+ if (i == NUM_PLATFORMS) {
+ ERR_EXPLAIN(String("No such platform: ") + p_platform);
+ ERR_FAIL();
}
- return false;
+ library_paths[i] = p_path;
}
-bool GDNativeInstance::get(const StringName &p_name, Variant &r_ret) const {
- if (!script->script_data)
- return false;
- if (script->script_data->properties.has(p_name)) {
- godot_variant value = script->script_data->properties[p_name].getter.get_func((godot_object *)owner, script->script_data->properties[p_name].getter.method_data, userdata);
- r_ret = *(Variant *)&value;
- godot_variant_destroy(&value);
- return true;
- }
-
- Map<StringName, GDNativeScriptData::Method>::Element *E = script->script_data->methods.find("_get");
- if (E) {
- Variant name = p_name;
- const Variant *args[1] = { &name };
-
- godot_variant result = E->get().method.method((godot_object *)owner, E->get().method.method_data, userdata, 1, (godot_variant **)args);
- if (((Variant *)&result)->get_type() != Variant::NIL) {
- r_ret = *(Variant *)&result;
- godot_variant_destroy(&result);
- return true;
+String GDNativeLibrary::get_library_path(StringName p_platform) const {
+ int i;
+ for (i = 0; i <= NUM_PLATFORMS; i++) {
+ if (i == NUM_PLATFORMS) break;
+ if (platform_names[i] == p_platform) {
+ break;
}
- godot_variant_destroy(&result);
}
- return false;
-}
-
-void GDNativeInstance::get_property_list(List<PropertyInfo> *p_properties) const {
- script->get_script_property_list(p_properties);
- // TODO: dynamic properties
-
- Map<StringName, GDNativeScriptData::Method>::Element *E = script->script_data->methods.find("_get_property_list");
- if (E) {
- godot_variant result = E->get().method.method((godot_object *)owner, E->get().method.method_data, userdata, 0, NULL);
- Variant ret = *(Variant *)&result;
- godot_variant_destroy(&result);
-
- if (ret.get_type() != Variant::ARRAY) {
- ERR_EXPLAIN("Wrong type for _get_property_list, must be an array of dictionaries.");
- ERR_FAIL();
- }
-
- Array arr = ret;
- for (int i = 0; i < arr.size(); i++) {
- Dictionary d = arr[i];
- ERR_CONTINUE(!d.has("name"))
- ERR_CONTINUE(!d.has("type"))
-
- PropertyInfo pinfo;
-
- pinfo.type = Variant::Type(d["type"].operator int());
- ERR_CONTINUE(pinfo.type < 0 || pinfo.type >= Variant::VARIANT_MAX);
-
- pinfo.name = d["name"];
- ERR_CONTINUE(pinfo.name == "");
-
- if (d.has("hint")) {
- pinfo.hint = PropertyHint(d["hint"].operator int());
- }
- if (d.has("hint_string")) {
- pinfo.hint_string = d["hint_string"];
- }
- if (d.has("usage")) {
- pinfo.usage = d["usage"];
- }
-
- p_properties->push_back(pinfo);
- }
+ if (i == NUM_PLATFORMS) {
+ ERR_EXPLAIN(String("No such platform: ") + p_platform);
+ ERR_FAIL_V("");
}
-}
-Variant::Type GDNativeInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const {
- if (script->script_data->properties.has(p_name)) {
- *r_is_valid = true;
- return script->script_data->properties[p_name].info.type;
- }
- *r_is_valid = false;
- return Variant::NIL;
+ return library_paths[i];
}
-void GDNativeInstance::get_method_list(List<MethodInfo> *p_list) const {
- script->get_script_method_list(p_list);
+String GDNativeLibrary::get_active_library_path() const {
+ return library_paths[GDNativeLibrary::current_platform];
}
-bool GDNativeInstance::has_method(const StringName &p_method) const {
- return script->has_method(p_method);
+GDNative::GDNative() {
+ initialized = false;
+ native_handle = NULL;
}
-Variant GDNativeInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
- // TODO: validated methods & errors
-
- GDNativeScriptData *data_ptr = script->script_data;
- while (data_ptr) {
- Map<StringName, GDNativeScriptData::Method>::Element *E = data_ptr->methods.find(p_method);
- if (E) {
- godot_variant result = E->get().method.method((godot_object *)owner, E->get().method.method_data, userdata, p_argcount, (godot_variant **)p_args);
- return *(Variant *)&result;
- }
- data_ptr = data_ptr->base_data;
- }
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
- return Variant();
+GDNative::~GDNative() {
+ // TODO(karroffel): implement ALL the things!
}
-void GDNativeInstance::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) {
- // TODO: validated methods & errors
+extern "C" void _api_anchor();
- GDNativeScriptData *data_ptr = script->script_data;
- while (data_ptr) {
- Map<StringName, GDNativeScriptData::Method>::Element *E = data_ptr->methods.find(p_method);
- if (E) {
- E->get().method.method((godot_object *)owner, E->get().method.method_data, userdata, p_argcount, (godot_variant **)p_args);
- }
- data_ptr = data_ptr->base_data;
- }
+void GDNative::_compile_dummy_for_api() {
+ _api_anchor();
}
-void GDNativeInstance::_ml_call_reversed(GDNativeScriptData *data_ptr, const StringName &p_method, const Variant **p_args, int p_argcount) {
- // TODO: validated methods & errors
+void GDNative::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_library", "library:GDNativeLibrary"), &GDNative::set_library);
+ ClassDB::bind_method(D_METHOD("get_library:GDNativeLibrary"), &GDNative::get_library);
- if (data_ptr->base_data)
- _ml_call_reversed(data_ptr->base_data, p_method, p_args, p_argcount);
+ ClassDB::bind_method(D_METHOD("initialize"), &GDNative::initialize);
+ ClassDB::bind_method(D_METHOD("terminate"), &GDNative::terminate);
- // Variant::CallError ce;
+ // TODO(karroffel): get_native_(raw_)call_types binding?
- Map<StringName, GDNativeScriptData::Method>::Element *E = data_ptr->methods.find(p_method);
- if (E) {
- E->get().method.method((godot_object *)owner, E->get().method.method_data, userdata, p_argcount, (godot_variant **)p_args);
- }
-}
-
-void GDNativeInstance::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) {
- if (script.ptr() && script->script_data) {
- _ml_call_reversed(script->script_data, p_method, p_args, p_argcount);
- }
-}
+ // TODO(karroffel): make this a varargs function?
+ ClassDB::bind_method(D_METHOD("call_native:Variant", "procedure_name", "arguments:Array"), &GDNative::call_native);
-void GDNativeInstance::notification(int p_notification) {
- Variant value = p_notification;
- const Variant *args[1] = { &value };
- call_multilevel(GDNativeScriptLanguage::singleton->strings._notification, args, 1);
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "GDNativeLibrary"), "set_library", "get_library");
}
-Ref<Script> GDNativeInstance::get_script() const {
- return script;
+void GDNative::set_library(Ref<GDNativeLibrary> p_library) {
+ library = p_library;
}
-ScriptLanguage *GDNativeInstance::get_language() {
- return GDNativeScriptLanguage::singleton;
+Ref<GDNativeLibrary> GDNative::get_library() {
+ return library;
}
-ScriptInstance::RPCMode GDNativeInstance::get_rpc_mode(const StringName &p_method) const {
- GDNativeScriptData::Method m = script->script_data->methods[p_method];
- switch (m.rpc_mode) {
- case GODOT_METHOD_RPC_MODE_DISABLED:
- return RPC_MODE_DISABLED;
- case GODOT_METHOD_RPC_MODE_REMOTE:
- return RPC_MODE_REMOTE;
- case GODOT_METHOD_RPC_MODE_SYNC:
- return RPC_MODE_SYNC;
- case GODOT_METHOD_RPC_MODE_MASTER:
- return RPC_MODE_MASTER;
- case GODOT_METHOD_RPC_MODE_SLAVE:
- return RPC_MODE_SLAVE;
- default:
- return RPC_MODE_DISABLED;
+bool GDNative::initialize() {
+ if (library.is_null()) {
+ ERR_PRINT("No library set, can't initialize GDNative object");
+ return false;
}
-}
-ScriptInstance::RPCMode GDNativeInstance::get_rset_mode(const StringName &p_variable) const {
- GDNativeScriptData::Property p = script->script_data->properties[p_variable];
- switch (p.rset_mode) {
- case GODOT_METHOD_RPC_MODE_DISABLED:
- return RPC_MODE_DISABLED;
- case GODOT_METHOD_RPC_MODE_REMOTE:
- return RPC_MODE_REMOTE;
- case GODOT_METHOD_RPC_MODE_SYNC:
- return RPC_MODE_SYNC;
- case GODOT_METHOD_RPC_MODE_MASTER:
- return RPC_MODE_MASTER;
- case GODOT_METHOD_RPC_MODE_SLAVE:
- return RPC_MODE_SLAVE;
- default:
- return RPC_MODE_DISABLED;
+ String lib_path = library->get_active_library_path();
+ if (lib_path.empty()) {
+ ERR_PRINT("No library set for this platform");
+ return false;
}
-}
-GDNativeInstance::GDNativeInstance() {
- owner = NULL;
- userdata = NULL;
-}
-
-GDNativeInstance::~GDNativeInstance() {
- if (script.is_valid()) {
- if (owner) {
- script->instances.erase(owner);
- }
- if (!script->script_data)
- return;
- script->script_data->destroy_func.destroy_func((godot_object *)owner, script->script_data->destroy_func.method_data, userdata);
- if (script->script_data->destroy_func.free_func)
- script->script_data->destroy_func.free_func(script->script_data->destroy_func.method_data);
- if (script->script_data->create_func.free_func)
- script->script_data->create_func.free_func(script->script_data->create_func.method_data);
+ String path = ProjectSettings::get_singleton()->globalize_path(lib_path);
+ Error err = OS::get_singleton()->open_dynamic_library(path, native_handle);
+ if (err != OK) {
+ return false;
}
-}
-
-// Language
-
-GDNativeScriptLanguage *GDNativeScriptLanguage::singleton = NULL;
-
-String GDNativeScriptLanguage::get_name() const {
- return "Native";
-}
-
-void _add_reload_node() {
-#ifdef TOOLS_ENABLED
- GDNativeReloadNode *rn = memnew(GDNativeReloadNode);
- EditorNode::get_singleton()->add_child(rn);
-#endif
-}
-
-void GDNativeScriptLanguage::init() {
- // TODO: Expose globals
- GLOBAL_DEF("gdnative/default_gdnativelibrary", "");
- PropertyInfo prop_info(Variant::STRING, "gdnative/default_gdnativelibrary", PROPERTY_HINT_FILE, "tres,res,dllib");
- ProjectSettings::get_singleton()->set_custom_property_info("gdnative/default_gdnativelibrary", prop_info);
-
-// generate bindings
-#if defined(TOOLS_ENABLED) && defined(DEBUG_METHODS_ENABLED)
-
- List<String> args = OS::get_singleton()->get_cmdline_args();
- List<String>::Element *E = args.find("--gdnative-generate-json-api");
+ void *library_init;
+ err = OS::get_singleton()->get_dynamic_library_symbol_handle(
+ native_handle,
+ init_symbol,
+ library_init);
- if (E && E->next()) {
- if (generate_c_api(E->next()->get()) != OK) {
- ERR_PRINT("Failed to generate C API\n");
- }
+ if (err || !library_init) {
+ return false;
}
-#endif
-#ifdef TOOLS_ENABLED
- // if (SceneTree::get_singleton()->is_editor_hint()) {
- EditorNode::add_init_callback(&_add_reload_node);
-// }
-#endif
-}
-
-String GDNativeScriptLanguage::get_type() const {
- return "Native";
-}
-
-String GDNativeScriptLanguage::get_extension() const {
- return "gdn";
-}
-
-Error GDNativeScriptLanguage::execute_file(const String &p_path) {
- return OK; // ??
-}
-
-void GDNativeScriptLanguage::finish() {
- // cleanup is for noobs
-}
-
-// scons doesn't want to link in the api source so we need to call a dummy function to cause it to link
-extern "C" void _api_anchor();
-
-void GDNativeScriptLanguage::_compile_dummy_for_the_api() {
- _api_anchor();
-}
+ godot_gdnative_init_fn library_init_fpointer;
+ library_init_fpointer = (godot_gdnative_init_fn)library_init;
-Ref<Script> GDNativeScriptLanguage::get_template(const String &p_class_name, const String &p_base_class_name) const {
- GDNativeScript *src = memnew(GDNativeScript);
- src->set_script_name(p_class_name);
- return Ref<GDNativeScript>(src);
-}
+ godot_gdnative_init_options options;
-bool GDNativeScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions) const {
- return false; // TODO
-}
+ options.in_editor = SceneTree::get_singleton()->is_editor_hint();
+ 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);
-Script *GDNativeScriptLanguage::create_script() const {
- GDNativeScript *scr = memnew(GDNativeScript);
- return scr;
-}
+ library_init_fpointer(&options);
-bool GDNativeScriptLanguage::has_named_classes() const {
return true;
}
-int GDNativeScriptLanguage::find_function(const String &p_function, const String &p_code) const {
- return -1; // No source code!
-}
-
-String GDNativeScriptLanguage::make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const {
- return ""; // No source code!
-}
-
-void GDNativeScriptLanguage::add_global_constant(const StringName &p_variable, const Variant &p_value) {
- // TODO TODO TODO
-}
-
-// TODO: Any debugging? (research)
-String GDNativeScriptLanguage::debug_get_error() const {
- return "";
-}
-
-int GDNativeScriptLanguage::debug_get_stack_level_count() const {
- return 1; // ?
-}
-
-int GDNativeScriptLanguage::debug_get_stack_level_line(int p_level) const {
- return -1;
-}
-
-String GDNativeScriptLanguage::debug_get_stack_level_function(int p_level) const {
- return "[native code]"; // ?
-}
-
-String GDNativeScriptLanguage::debug_get_stack_level_source(int p_level) const {
- return "";
-}
-
-void GDNativeScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {}
+bool GDNative::terminate() {
-void GDNativeScriptLanguage::debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {}
-
-String GDNativeScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) {
- return ""; // ??
-}
-
-void GDNativeScriptLanguage::reload_all_scripts() {
- // @Todo
-}
+ if (native_handle == NULL) {
+ ERR_PRINT("No valid library handle, can't terminate GDNative object");
+ return false;
+ }
-void GDNativeScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) {
- // @Todo
- OS::get_singleton()->print("reload tool scripts\n");
-}
+ Error error = OK;
+ void *library_terminate;
+ error = OS::get_singleton()->get_dynamic_library_symbol_handle(
+ native_handle,
+ terminate_symbol,
+ library_terminate);
+ if (error) {
+ OS::get_singleton()->close_dynamic_library(native_handle);
+ native_handle = NULL;
+ return true;
+ }
-void GDNativeScriptLanguage::get_recognized_extensions(List<String> *p_extensions) const {
- p_extensions->push_back("gdn"); // Container file format
-}
+ godot_gdnative_terminate_fn library_terminate_pointer;
+ library_terminate_pointer = (godot_gdnative_terminate_fn)library_terminate;
-void GDNativeScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const {
-}
+ // TODO(karroffel): remove this? Should be part of NativeScript, not
+ // GDNative IMO
+ godot_gdnative_terminate_options options;
+ options.in_editor = SceneTree::get_singleton()->is_editor_hint();
-void GDNativeScriptLanguage::get_public_constants(List<Pair<String, Variant> > *p_constants) const {
-}
+ library_terminate_pointer(&options);
-// TODO: all profilling
-void GDNativeScriptLanguage::profiling_start() {
-}
+ // GDNativeScriptLanguage::get_singleton()->initialized_libraries.erase(p_native_lib->path);
-void GDNativeScriptLanguage::profiling_stop() {
-}
+ OS::get_singleton()->close_dynamic_library(native_handle);
+ native_handle = NULL;
-int GDNativeScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) {
- return 0;
+ return false;
}
-int GDNativeScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) {
- return 0;
+void GDNativeCallRegistry::register_native_call_type(StringName p_call_type, native_call_cb p_callback) {
+ native_calls.insert(p_call_type, p_callback);
}
-void GDNativeScriptLanguage::frame() {
+void GDNativeCallRegistry::register_native_raw_call_type(StringName p_raw_call_type, native_raw_call_cb p_callback) {
+ native_raw_calls.insert(p_raw_call_type, p_callback);
}
-String GDNativeScriptLanguage::get_init_symbol_name() {
- return "godot_native_init"; // TODO: Maybe make some internal function which would do the actual stuff
-}
+Vector<StringName> GDNativeCallRegistry::get_native_call_types() {
+ Vector<StringName> call_types;
+ call_types.resize(native_calls.size());
-String GDNativeScriptLanguage::get_terminate_symbol_name() {
- return "godot_native_terminate";
-}
+ size_t idx = 0;
+ for (Map<StringName, native_call_cb>::Element *E = native_calls.front(); E; E = E->next(), idx++) {
+ call_types[idx] = E->key();
+ }
-GDNativeScriptLanguage::GDNativeScriptLanguage() {
- ERR_FAIL_COND(singleton);
- strings._notification = StringName("_notification");
- singleton = this;
- initialized_libraries = Map<StringName, NativeLibrary *>();
+ return call_types;
}
-GDNativeScriptLanguage::~GDNativeScriptLanguage() {
- singleton = NULL;
-}
+Vector<StringName> GDNativeCallRegistry::get_native_raw_call_types() {
+ Vector<StringName> call_types;
+ call_types.resize(native_raw_calls.size());
-// DLReloadNode
+ size_t idx = 0;
+ for (Map<StringName, native_raw_call_cb>::Element *E = native_raw_calls.front(); E; E = E->next(), idx++) {
+ call_types[idx] = E->key();
+ }
-void GDNativeReloadNode::_bind_methods() {
- ClassDB::bind_method("_notification", &GDNativeReloadNode::_notification);
+ return call_types;
}
-void GDNativeReloadNode::_notification(int p_what) {
-#ifdef TOOLS_ENABLED
-
- switch (p_what) {
- case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
-
- Set<NativeLibrary *> libs_to_reload;
-
- for (Map<StringName, NativeLibrary *>::Element *L = GDNativeScriptLanguage::get_singleton()->initialized_libraries.front(); L; L = L->next()) {
- // check if file got modified at all
- // @Todo
-
- libs_to_reload.insert(L->get());
- }
-
- for (Set<NativeLibrary *>::Element *L = libs_to_reload.front(); L; L = L->next()) {
-
- GDNativeLibrary *lib = L->get()->dllib;
-
- lib->_terminate();
- lib->_initialize();
-
- // update placeholders (if any)
-
- Set<GDNativeScript *> scripts;
-
- for (Set<GDNativeScript *>::Element *S = GDNativeScriptLanguage::get_singleton()->script_list.front(); S; S = S->next()) {
+Variant GDNative::call_native(StringName p_native_call_type, StringName p_procedure_name, Array p_arguments) {
- if (lib->native_library->scripts.has(S->get()->get_script_name())) {
- GDNativeScript *script = S->get();
- script->script_data = lib->get_script_data(script->get_script_name());
- scripts.insert(script);
- }
- }
-
- for (Set<GDNativeScript *>::Element *S = scripts.front(); S; S = S->next()) {
- GDNativeScript *script = S->get();
- if (script->placeholders.size() == 0)
- continue;
-
- for (Set<PlaceHolderScriptInstance *>::Element *P = script->placeholders.front(); P; P = P->next()) {
- PlaceHolderScriptInstance *p = P->get();
- script->_update_placeholder(p);
- }
- }
- }
-
- } break;
- default: {
- };
+ Map<StringName, native_call_cb>::Element *E = GDNativeCallRegistry::singleton->native_calls.find(p_native_call_type);
+ if (!E) {
+ ERR_PRINT((String("No handler for native call type \"" + p_native_call_type) + "\" found").utf8().get_data());
+ return Variant();
}
-#endif
-}
-
-// Resource loader/saver
-
-RES ResourceFormatLoaderGDNativeScript::load(const String &p_path, const String &p_original_path, Error *r_error) {
- ResourceFormatLoaderText rsflt;
- return rsflt.load(p_path, p_original_path, r_error);
-}
-void ResourceFormatLoaderGDNativeScript::get_recognized_extensions(List<String> *p_extensions) const {
- p_extensions->push_back("gdn");
-}
-bool ResourceFormatLoaderGDNativeScript::handles_type(const String &p_type) const {
- return (p_type == "Script" || p_type == "Native");
-}
-String ResourceFormatLoaderGDNativeScript::get_resource_type(const String &p_path) const {
- String el = p_path.get_extension().to_lower();
- if (el == "gdn")
- return "Native";
- return "";
-}
+ String procedure_name = p_procedure_name;
+ godot_variant result = E->get()(native_handle, (godot_string *)&procedure_name, (godot_array *)&p_arguments);
-Error ResourceFormatSaverGDNativeScript::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
- ResourceFormatSaverText rfst;
- return rfst.save(p_path, p_resource, p_flags);
+ return *(Variant *)&result;
}
-bool ResourceFormatSaverGDNativeScript::recognize(const RES &p_resource) const {
- return p_resource->cast_to<GDNativeScript>() != NULL;
-}
+void GDNative::call_native_raw(StringName p_raw_call_type, StringName p_procedure_name, void *data, int num_args, void **args, void *r_return) {
-void ResourceFormatSaverGDNativeScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
- if (p_resource->cast_to<GDNativeScript>()) {
- p_extensions->push_back("gdn");
+ Map<StringName, native_raw_call_cb>::Element *E = GDNativeCallRegistry::singleton->native_raw_calls.find(p_raw_call_type);
+ if (!E) {
+ ERR_PRINT((String("No handler for native raw call type \"" + p_raw_call_type) + "\" found").utf8().get_data());
+ return;
}
+
+ String procedure_name = p_procedure_name;
+ E->get()(native_handle, (godot_string *)&procedure_name, data, num_args, args, r_return);
}
diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h
index 650f999192..dd845cab7a 100644
--- a/modules/gdnative/gdnative.h
+++ b/modules/gdnative/gdnative.h
@@ -34,382 +34,112 @@
#include "io/resource_saver.h"
#include "os/thread_safe.h"
#include "resource.h"
-#include "scene/main/node.h"
-#include "script_language.h"
-#include "self_list.h"
-#include "godot.h"
+#include "godot/gdnative.h"
-struct GDNativeScriptData;
-class GDNativeLibrary;
-
-struct NativeLibrary {
- StringName path;
- void *handle;
-
- GDNativeLibrary *dllib;
-
- Map<StringName, GDNativeScriptData *> scripts;
-
- static Error initialize(NativeLibrary *&p_native_lib, const StringName p_path);
- static Error terminate(NativeLibrary *&p_native_lib);
-};
-
-struct GDNativeScriptData {
- /* typedef void* (InstanceFunc)(godot_object* instance);
- typedef void (DestroyFunc)(godot_object* instance,void* userdata);
- typedef godot_variant (MethodFunc)(godot_object *instance, void *userdata, void *method_data, int arg_count,godot_variant **args);
- typedef void (MethodDataFreeFunc)(void *method_data);
- typedef void (SetterFunc)(godot_object* instance,void* userdata,godot_variant value);
- typedef godot_variant (GetterFunc)(godot_object* instance,void* userdata);*/
-
- struct Method {
- godot_instance_method method;
- MethodInfo info;
- int rpc_mode;
-
- Method() {
- }
- Method(godot_instance_method p_method, MethodInfo p_info, int p_rpc_mode) {
- method = p_method;
- info = p_info;
- rpc_mode = p_rpc_mode;
- }
- };
- struct Property {
- godot_property_set_func setter;
- godot_property_get_func getter;
- PropertyInfo info;
- Variant default_value;
- int rset_mode;
-
- Property() {
- }
- Property(godot_property_set_func p_setter, godot_property_get_func p_getter) {
- setter = p_setter;
- getter = p_getter;
- }
- Property(godot_property_set_func p_setter, godot_property_get_func p_getter, PropertyInfo p_info, Variant p_default_value, int p_rset_mode) {
- setter = p_setter;
- getter = p_getter;
- info = p_info;
- default_value = p_default_value;
- rset_mode = p_rset_mode;
- }
- };
-
- struct Signal {
- MethodInfo signal;
- };
-
- Map<StringName, Method> methods;
- Map<StringName, Property> properties;
- Map<StringName, Signal> signals_; // QtCreator doesn't like the name signals
- StringName base;
- StringName base_native_type;
- GDNativeScriptData *base_data;
- godot_instance_create_func create_func;
- godot_instance_destroy_func destroy_func;
-
- bool is_tool;
-
- GDNativeScriptData() {
- base = StringName();
- base_data = NULL;
- is_tool = false;
- }
- GDNativeScriptData(StringName p_base, godot_instance_create_func p_instance, godot_instance_destroy_func p_free) {
- base = p_base;
- base_data = NULL;
- create_func = p_instance;
- destroy_func = p_free;
- is_tool = false;
- }
-};
-
-class GDNativeScript : public Script {
- GDCLASS(GDNativeScript, Script);
-
- Ref<GDNativeLibrary> library;
- StringName script_name;
- StringName base_native_type;
- Set<Object *> instances;
- GDNativeScriptData *script_data;
-
-#ifdef TOOLS_ENABLED
- Set<PlaceHolderScriptInstance *> placeholders;
- void _update_placeholder(PlaceHolderScriptInstance *p_placeholder);
- virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder);
-#endif
-
- friend class GDNativeInstance;
- friend class GDNativeScriptLanguage;
- friend class GDNativeReloadNode;
- friend class GDNativeLibrary;
-
-protected:
- static void _bind_methods();
-
-public:
- virtual bool can_instance() const;
-
- virtual Ref<Script> get_base_script() const; //for script inheritance
-
- virtual StringName get_instance_base_type() const; // this may not work in all scripts, will return empty if so
- virtual ScriptInstance *instance_create(Object *p_this);
- virtual bool instance_has(const Object *p_this) const;
-
- virtual bool has_source_code() const;
- virtual String get_source_code() const;
- virtual void set_source_code(const String &p_code) {}
- virtual Error reload(bool p_keep_state = false);
-
- virtual bool has_method(const StringName &p_method) const;
- virtual MethodInfo get_method_info(const StringName &p_method) const;
-
- virtual bool is_tool() const;
-
- virtual String get_node_type() const;
+class GDNativeLibrary : public Resource {
+ GDCLASS(GDNativeLibrary, Resource)
- virtual ScriptLanguage *get_language() const;
+ enum Platform {
+ X11_32BIT,
+ X11_64BIT,
+ WINDOWS_32BIT,
+ WINDOWS_64BIT,
+ // NOTE(karroffel): I heard OSX 32 bit is dead, so 64 only
+ OSX,
- virtual bool has_script_signal(const StringName &p_signal) const;
- virtual void get_script_signal_list(List<MethodInfo> *r_signals) const;
+ // TODO(karroffel): all different android versions and archs
+ ANDROID,
- virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const;
+ // TODO(karroffe): all different iOS versions and archs
+ IOS,
- virtual void update_exports() {} //editor tool
- virtual void get_script_method_list(List<MethodInfo> *p_list) const;
- virtual void get_script_property_list(List<PropertyInfo> *p_list) const;
+ // TODO(karroffel): figure out how to deal with web stuff at all...
+ WASM,
- Variant _new(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ // TODO(karroffel): does UWP have different libs??
+ // UWP,
- Ref<GDNativeLibrary> get_library() const;
- void set_library(Ref<GDNativeLibrary> p_library);
+ NUM_PLATFORMS
- StringName get_script_name() const;
- void set_script_name(StringName p_script_name);
+ };
- GDNativeScript();
- ~GDNativeScript();
-};
+ static String platform_names[NUM_PLATFORMS];
+ static String platform_lib_ext[NUM_PLATFORMS];
-class GDNativeLibrary : public Resource {
- _THREAD_SAFE_CLASS_
+ // TODO(karroffel): make this actually do something lol.
+ static Platform current_platform;
- GDCLASS(GDNativeLibrary, Resource);
- OBJ_SAVE_TYPE(GDNativeLibrary);
-
- Map<StringName, String> platform_files;
- NativeLibrary *native_library;
- static GDNativeLibrary *currently_initialized_library;
+ String library_paths[NUM_PLATFORMS];
protected:
- friend class GDNativeScript;
- friend struct NativeLibrary;
- friend class GDNativeReloadNode;
-
- GDNativeScriptData *get_script_data(const StringName p_name);
-
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
- void _notification(int p_what);
- static void _bind_methods();
public:
- Error _initialize();
- Error _terminate();
-
- static GDNativeLibrary *get_currently_initialized_library();
-
- void _register_script(const StringName p_name, const StringName p_base, godot_instance_create_func p_instance_func, godot_instance_destroy_func p_destroy_func);
- void _register_tool_script(const StringName p_name, const StringName p_base, godot_instance_create_func p_instance_func, godot_instance_destroy_func p_destroy_func);
- void _register_script_method(const StringName p_name, const StringName p_method, godot_method_attributes p_attr, godot_instance_method p_func, MethodInfo p_info);
- void _register_script_property(const StringName p_name, const String p_path, godot_property_attributes *p_attr, godot_property_set_func p_setter, godot_property_get_func p_getter);
- void _register_script_signal(const StringName p_name, const godot_signal *p_signal);
-
- void set_platform_file(StringName p_platform, String p_file);
- String get_platform_file(StringName p_platform) const;
-
GDNativeLibrary();
~GDNativeLibrary();
-};
-
-class GDNativeInstance : public ScriptInstance {
- friend class GDNativeScript;
- Object *owner;
- Ref<GDNativeScript> script;
- void *userdata;
-
- void _ml_call_reversed(GDNativeScriptData *data_ptr, const StringName &p_method, const Variant **p_args, int p_argcount);
-
-public:
- _FORCE_INLINE_ Object *get_owner() { return owner; }
-
- _FORCE_INLINE_ void *get_userdata() { return userdata; }
-
- virtual bool set(const StringName &p_name, const Variant &p_value);
- virtual bool get(const StringName &p_name, Variant &r_ret) const;
- virtual void get_property_list(List<PropertyInfo> *p_properties) const;
- virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = NULL) const;
-
- virtual void get_method_list(List<MethodInfo> *p_list) const;
- virtual bool has_method(const StringName &p_method) const;
- virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error);
- virtual void call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount);
- virtual void call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount);
-
- Variant debug_get_member_by_index(int p_idx) const { return Variant(); }
-
- virtual void notification(int p_notification);
-
- virtual Ref<Script> get_script() const;
-
- virtual ScriptLanguage *get_language();
-
- void set_path(const String &p_path);
-
- void reload_members();
+ static void _bind_methods();
- virtual RPCMode get_rpc_mode(const StringName &p_method) const;
- virtual RPCMode get_rset_mode(const StringName &p_variable) const;
+ void set_library_path(StringName p_platform, String p_path);
+ String get_library_path(StringName p_platform) const;
- GDNativeInstance();
- ~GDNativeInstance();
+ String get_active_library_path() const;
};
-class GDNativeReloadNode;
+typedef godot_variant (*native_call_cb)(void *, godot_string *, godot_array *);
+typedef void (*native_raw_call_cb)(void *, godot_string *, void *, int, void **, void *);
-class GDNativeScriptLanguage : public ScriptLanguage {
- friend class GDNativeScript;
- friend class GDNativeInstance;
- friend class GDNativeReloadNode;
- friend class GDNativeLibrary;
+struct GDNativeCallRegistry {
+ static GDNativeCallRegistry *singleton;
- static GDNativeScriptLanguage *singleton;
+ inline GDNativeCallRegistry *get_singleton() {
+ return singleton;
+ }
- Variant *_global_array; // @Unused necessary?
- Vector<Variant> global_array; // @Unused necessary?
- Map<StringName, int> globals; // @Unused necessary?
+ inline GDNativeCallRegistry()
+ : native_calls(),
+ native_raw_calls() {}
- // @Unused necessary?
- void _add_global(const StringName &p_name, const Variant &p_value);
+ Map<StringName, native_call_cb> native_calls;
+ Map<StringName, native_raw_call_cb> native_raw_calls;
- Mutex *lock;
+ void register_native_call_type(StringName p_call_type, native_call_cb p_callback);
+ void register_native_raw_call_type(StringName p_raw_call_type, native_raw_call_cb p_callback);
- Set<GDNativeScript *> script_list;
+ Vector<StringName> get_native_call_types();
+ Vector<StringName> get_native_raw_call_types();
+};
- bool profiling;
- uint64_t script_frame_time;
+class GDNative : public Reference {
+ GDCLASS(GDNative, Reference)
- struct {
+ Ref<GDNativeLibrary> library;
+ bool initialized;
- StringName _notification;
+ // TODO(karroffel): different platforms? WASM????
+ void *native_handle;
- } strings;
+ void _compile_dummy_for_api();
public:
- Map<StringName, NativeLibrary *> initialized_libraries;
-
- _FORCE_INLINE_ static GDNativeScriptLanguage *get_singleton() { return singleton; }
-
- virtual String get_name() const;
-
- /* LANGUAGE FUNCTIONS */
- virtual void init();
- virtual String get_type() const;
- virtual String get_extension() const;
- virtual Error execute_file(const String &p_path);
- virtual void finish();
-
- /* EDITOR FUNCTIONS */
-
- virtual void get_reserved_words(List<String> *p_words) const {};
- virtual void get_comment_delimiters(List<String> *p_delimiters) const {};
- virtual void get_string_delimiters(List<String> *p_delimiters) const {};
- virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
- virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = NULL) const;
- virtual Script *create_script() const;
- virtual bool has_named_classes() const;
- virtual int find_function(const String &p_function, const String &p_code) const;
- virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
- virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return ERR_UNAVAILABLE; }
- virtual Error complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, String &r_call_hint) { return ERR_UNAVAILABLE; }
-
- virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_base_path, Object *p_owner, LookupResult &r_result) { return ERR_UNAVAILABLE; }
+ GDNative();
+ ~GDNative();
- virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const {};
- virtual void add_global_constant(const StringName &p_variable, const Variant &p_value);
-
- /* MULTITHREAD FUNCTIONS */
-
- //some VMs need to be notified of thread creation/exiting to allocate a stack
- virtual void thread_enter() {}
- virtual void thread_exit() {}
-
- /* DEBUGGER FUNCTIONS */
-
- virtual String debug_get_error() const;
- virtual int debug_get_stack_level_count() const;
- virtual int debug_get_stack_level_line(int p_level) const;
- virtual String debug_get_stack_level_function(int p_level) const;
- virtual String debug_get_stack_level_source(int p_level) const;
- virtual void debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1){};
- virtual void debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1);
- virtual void debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1);
- virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems = -1, int p_max_depth = -1);
-
- virtual Vector<StackInfo> debug_get_current_stack_info() { return Vector<StackInfo>(); }
-
- virtual void reload_all_scripts();
- virtual void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload);
- /* LOADER FUNCTIONS */
-
- virtual void get_recognized_extensions(List<String> *p_extensions) const;
- virtual void get_public_functions(List<MethodInfo> *p_functions) const;
- virtual void get_public_constants(List<Pair<String, Variant> > *p_constants) const;
-
- /* PROFILLER FUNCTIONS */
-
- virtual void profiling_start();
- virtual void profiling_stop();
-
- virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max);
- virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max);
-
- virtual void frame();
-
- static String get_init_symbol_name();
- static String get_terminate_symbol_name();
-
- /* HACKER FUNCTIONS */
- void _compile_dummy_for_the_api();
+ static void _bind_methods();
- GDNativeScriptLanguage();
- ~GDNativeScriptLanguage();
-};
+ void set_library(Ref<GDNativeLibrary> p_library);
+ Ref<GDNativeLibrary> get_library();
-class GDNativeReloadNode : public Node {
- GDCLASS(GDNativeReloadNode, Node)
-public:
- static void _bind_methods();
- void _notification(int p_what);
-};
+ bool is_initialized();
-class ResourceFormatLoaderGDNativeScript : public ResourceFormatLoader {
-public:
- virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
- virtual void get_recognized_extensions(List<String> *p_extensions) const;
- virtual bool handles_type(const String &p_type) const;
- virtual String get_resource_type(const String &p_path) const;
-};
+ bool initialize();
+ bool terminate();
-class ResourceFormatSaverGDNativeScript : public ResourceFormatSaver {
- virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0);
- virtual bool recognize(const RES &p_resource) const;
- virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const;
+ Variant call_native(StringName p_call_type, StringName p_procedure_name, Array p_arguments = Array());
+ void call_native_raw(StringName p_raw_call_type, StringName p_procedure_name, void *data, int num_args, void **args, void *r_return);
};
#endif // GDNATIVE_H
diff --git a/modules/gdnative/godot/godot_array.cpp b/modules/gdnative/godot/array.cpp
index 5497dde520..c068eecf8f 100644
--- a/modules/gdnative/godot/godot_array.cpp
+++ b/modules/gdnative/godot/array.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_array.cpp */
+/* array.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_array.h"
+#include "array.h"
#include "core/array.h"
#include "core/os/memory.h"
diff --git a/modules/gdnative/godot/godot_array.h b/modules/gdnative/godot/array.h
index bf8bc61977..cbdbfbdde3 100644
--- a/modules/gdnative/godot/godot_array.h
+++ b/modules/gdnative/godot/array.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_array.h */
+/* array.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -37,16 +37,19 @@ extern "C" {
#include <stdint.h>
+#define GODOT_ARRAY_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_ARRAY_TYPE_DEFINED
-typedef struct godot_array {
- uint8_t _dont_touch_that[8];
+#define GODOT_CORE_API_GODOT_ARRAY_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_ARRAY_SIZE];
} godot_array;
#endif
-#include "godot_pool_arrays.h"
-#include "godot_variant.h"
+#include "pool_arrays.h"
+#include "variant.h"
-#include "../godot.h"
+#include "gdnative.h"
void GDAPI godot_array_new(godot_array *r_dest);
void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src);
diff --git a/modules/gdnative/godot/godot_basis.cpp b/modules/gdnative/godot/basis.cpp
index 46464932c5..7188215d04 100644
--- a/modules/gdnative/godot/godot_basis.cpp
+++ b/modules/gdnative/godot/basis.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_basis.cpp */
+/* basis.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_basis.h"
+#include "basis.h"
#include "core/variant.h"
#include "core/math/matrix3.h"
diff --git a/modules/gdnative/godot/godot_basis.h b/modules/gdnative/godot/basis.h
index a096a8cc08..79b2b45fdd 100644
--- a/modules/gdnative/godot/godot_basis.h
+++ b/modules/gdnative/godot/basis.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_basis.h */
+/* basis.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,15 +36,18 @@ extern "C" {
#include <stdint.h>
+#define GODOT_BASIS_SIZE 36
+
#ifndef GODOT_CORE_API_GODOT_BASIS_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_BASIS_TYPE_DEFINED
-typedef struct godot_basis {
- uint8_t _dont_touch_that[36];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_BASIS_SIZE];
} godot_basis;
#endif
-#include "../godot.h"
-#include "godot_vector3.h"
+#include "gdnative.h"
+#include "quat.h"
+#include "vector3.h"
void GDAPI godot_basis_new_with_rows(godot_basis *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis);
void GDAPI godot_basis_new_with_axis_and_angle(godot_basis *r_dest, const godot_vector3 *p_axis, const godot_real p_phi);
diff --git a/modules/gdnative/godot/godot_color.cpp b/modules/gdnative/godot/color.cpp
index 6dedf2ab10..eac966ca1f 100644
--- a/modules/gdnative/godot/godot_color.cpp
+++ b/modules/gdnative/godot/color.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_color.cpp */
+/* color.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_color.h"
+#include "color.h"
#include "core/variant.h"
#include "core/color.h"
diff --git a/modules/gdnative/godot/godot_color.h b/modules/gdnative/godot/color.h
index 10dc228b1c..77e709fbe3 100644
--- a/modules/gdnative/godot/godot_color.h
+++ b/modules/gdnative/godot/color.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_color.h */
+/* color.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,15 +36,17 @@ extern "C" {
#include <stdint.h>
+#define GODOT_COLOR_SIZE 16
+
#ifndef GODOT_CORE_API_GODOT_COLOR_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_COLOR_TYPE_DEFINED
-typedef struct godot_color {
- uint8_t _dont_touch_that[16];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_COLOR_SIZE];
} godot_color;
#endif
-#include "../godot.h"
-#include "godot_string.h"
+#include "gdnative.h"
+#include "string.h"
void GDAPI godot_color_new_rgba(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b, const godot_real p_a);
void GDAPI godot_color_new_rgb(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b);
diff --git a/modules/gdnative/godot/godot_dictionary.cpp b/modules/gdnative/godot/dictionary.cpp
index a14a86248b..1c0761edfd 100644
--- a/modules/gdnative/godot/godot_dictionary.cpp
+++ b/modules/gdnative/godot/dictionary.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_dictionary.cpp */
+/* dictionary.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_dictionary.h"
+#include "dictionary.h"
#include "core/variant.h"
#include "core/dictionary.h"
diff --git a/modules/gdnative/godot/godot_dictionary.h b/modules/gdnative/godot/dictionary.h
index 4ded0d38da..a08deb27df 100644
--- a/modules/gdnative/godot/godot_dictionary.h
+++ b/modules/gdnative/godot/dictionary.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_dictionary.h */
+/* dictionary.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,16 +36,18 @@ extern "C" {
#include <stdint.h>
+#define GODOT_DICTIONARY_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_DICTIONARY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_DICTIONARY_TYPE_DEFINED
-typedef struct godot_dictionary {
- uint8_t _dont_touch_that[8];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_DICTIONARY_SIZE];
} godot_dictionary;
#endif
-#include "../godot.h"
-#include "godot_array.h"
-#include "godot_variant.h"
+#include "array.h"
+#include "gdnative.h"
+#include "variant.h"
void GDAPI godot_dictionary_new(godot_dictionary *r_dest);
void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *p_src);
diff --git a/modules/gdnative/godot.cpp b/modules/gdnative/godot/gdnative.cpp
index 764ce7c3ea..7b94b75a52 100644
--- a/modules/gdnative/godot.cpp
+++ b/modules/gdnative/godot/gdnative.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot.cpp */
+/* gdnative.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot.h"
+#include "gdnative.h"
#include "class_db.h"
#include "error_macros.h"
@@ -79,13 +79,6 @@ void _api_anchor() {
_variant_api_anchor();
}
-extern "C++" {
-template <class a, class b>
-_FORCE_INLINE_ a memcast(b v) {
- return *((a *)&v);
-}
-}
-
void GDAPI godot_object_destroy(godot_object *p_o) {
memdelete((Object *)p_o);
}
@@ -142,65 +135,6 @@ void GDAPI godot_method_bind_varcall(godot_method_bind *p_method_bind)
}
*/
-// Script API
-
-void GDAPI godot_script_register_class(const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func) {
- GDNativeLibrary *library = GDNativeLibrary::get_currently_initialized_library();
- if (!library) {
- ERR_EXPLAIN("Attempt to register script after initializing library!");
- ERR_FAIL();
- }
- library->_register_script(p_name, p_base, p_create_func, p_destroy_func);
-}
-
-void GDAPI godot_script_register_tool_class(const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func) {
- GDNativeLibrary *library = GDNativeLibrary::get_currently_initialized_library();
- if (!library) {
- ERR_EXPLAIN("Attempt to register script after initializing library!");
- ERR_FAIL();
- }
- library->_register_tool_script(p_name, p_base, p_create_func, p_destroy_func);
-}
-
-void GDAPI godot_script_register_method(const char *p_name, const char *p_function_name, godot_method_attributes p_attr, godot_instance_method p_method) {
- GDNativeLibrary *library = GDNativeLibrary::get_currently_initialized_library();
- if (!library) {
- ERR_EXPLAIN("Attempt to register script after initializing library!");
- ERR_FAIL();
- }
- library->_register_script_method(p_name, p_function_name, p_attr, p_method, MethodInfo());
-}
-
-void GDAPI godot_script_register_property(const char *p_name, const char *p_path, godot_property_attributes *p_attr, godot_property_set_func p_set_func, godot_property_get_func p_get_func) {
- GDNativeLibrary *library = GDNativeLibrary::get_currently_initialized_library();
- if (!library) {
- ERR_EXPLAIN("Attempt to register script after initializing library!");
- ERR_FAIL();
- }
-
- library->_register_script_property(p_name, p_path, p_attr, p_set_func, p_get_func);
-}
-
-void GDAPI godot_script_register_signal(const char *p_name, const godot_signal *p_signal) {
- GDNativeLibrary *library = GDNativeLibrary::get_currently_initialized_library();
- if (!library) {
- ERR_EXPLAIN("Attempt to register script after initializing library!");
- ERR_FAIL();
- }
-
- library->_register_script_signal(p_name, p_signal);
-}
-
-void GDAPI *godot_native_get_userdata(godot_object *p_instance) {
- Object *instance = (Object *)p_instance;
- if (!instance)
- return NULL;
- if (instance->get_script_instance() && instance->get_script_instance()->get_language() == GDNativeScriptLanguage::get_singleton()) {
- return ((GDNativeInstance *)instance->get_script_instance())->get_userdata();
- }
- return NULL;
-}
-
godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classname) {
ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(StringName(p_classname));
if (class_info)
diff --git a/modules/gdnative/godot.h b/modules/gdnative/godot/gdnative.h
index 1d86998291..4b79706b52 100644
--- a/modules/gdnative/godot.h
+++ b/modules/gdnative/godot/gdnative.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot.h */
+/* gdnative.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,8 +27,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GODOT_C_H
-#define GODOT_C_H
+#ifndef GODOT_GDNATIVE_H
+#define GODOT_GDNATIVE_H
#ifdef __cplusplus
extern "C" {
@@ -74,7 +74,7 @@ extern "C" {
////// Error
-typedef enum godot_error {
+typedef enum {
GODOT_OK,
GODOT_FAILED, ///< Generic fail error
GODOT_ERR_UNAVAILABLE, ///< What is requested is unsupported/unavailable
@@ -147,6 +147,7 @@ typedef float godot_real;
typedef void godot_object;
/////// Brute force forward declarations for the rest
+/*
typedef struct godot_variant godot_variant;
typedef struct godot_string godot_string;
typedef struct godot_vector2 godot_vector2;
@@ -170,75 +171,75 @@ typedef struct godot_pool_string_array godot_pool_string_array;
typedef struct godot_pool_vector2_array godot_pool_vector2_array;
typedef struct godot_pool_vector3_array godot_pool_vector3_array;
typedef struct godot_pool_color_array godot_pool_color_array;
-
+*/
/////// String
-#include "godot/godot_string.h"
+#include "string.h"
////// Vector2
-#include "godot/godot_vector2.h"
+#include "vector2.h"
////// Rect2
-#include "godot/godot_rect2.h"
+#include "rect2.h"
////// Vector3
-#include "godot/godot_vector3.h"
+#include "vector3.h"
////// Transform2D
-#include "godot/godot_transform2d.h"
+#include "transform2d.h"
/////// Plane
-#include "godot/godot_plane.h"
+#include "plane.h"
/////// Quat
-#include "godot/godot_quat.h"
+#include "quat.h"
/////// Rect3
-#include "godot/godot_rect3.h"
+#include "rect3.h"
/////// Basis
-#include "godot/godot_basis.h"
+#include "basis.h"
/////// Transform
-#include "godot/godot_transform.h"
+#include "transform.h"
/////// Color
-#include "godot/godot_color.h"
+#include "color.h"
/////// NodePath
-#include "godot/godot_node_path.h"
+#include "node_path.h"
/////// RID
-#include "godot/godot_rid.h"
+#include "rid.h"
/////// Dictionary
-#include "godot/godot_dictionary.h"
+#include "dictionary.h"
/////// Array
-#include "godot/godot_array.h"
+#include "array.h"
// single API file for Pool*Array
-#include "godot/godot_pool_arrays.h"
+#include "pool_arrays.h"
void GDAPI godot_object_destroy(godot_object *p_o);
////// Variant
-#include "godot/godot_variant.h"
+#include "variant.h"
////// Singleton API
@@ -246,7 +247,7 @@ godot_object GDAPI *godot_global_get_singleton(char *p_name); // result shouldn'
////// MethodBind API
-typedef struct godot_method_bind {
+typedef struct {
uint8_t _dont_touch_that[1]; // TODO
} godot_method_bind;
@@ -255,164 +256,16 @@ 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
-typedef struct godot_native_init_options {
+typedef struct {
godot_bool in_editor;
uint64_t core_api_hash;
uint64_t editor_api_hash;
uint64_t no_api_hash;
-} godot_native_init_options;
+} godot_gdnative_init_options;
-typedef struct godot_native_terminate_options {
+typedef struct {
godot_bool in_editor;
-} godot_native_terminate_options;
-
-typedef enum godot_method_rpc_mode {
- GODOT_METHOD_RPC_MODE_DISABLED,
- GODOT_METHOD_RPC_MODE_REMOTE,
- GODOT_METHOD_RPC_MODE_SYNC,
- GODOT_METHOD_RPC_MODE_MASTER,
- GODOT_METHOD_RPC_MODE_SLAVE,
-} godot_method_rpc_mode;
-
-typedef struct godot_method_attributes {
- godot_method_rpc_mode rpc_type;
-} godot_method_attributes;
-
-typedef enum godot_property_hint {
- GODOT_PROPERTY_HINT_NONE, ///< no hint provided.
- GODOT_PROPERTY_HINT_RANGE, ///< hint_text = "min,max,step,slider; //slider is optional"
- GODOT_PROPERTY_HINT_EXP_RANGE, ///< hint_text = "min,max,step", exponential edit
- GODOT_PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc"
- GODOT_PROPERTY_HINT_EXP_EASING, /// exponential easing funciton (Math::ease)
- GODOT_PROPERTY_HINT_LENGTH, ///< hint_text= "length" (as integer)
- GODOT_PROPERTY_HINT_SPRITE_FRAME,
- GODOT_PROPERTY_HINT_KEY_ACCEL, ///< hint_text= "length" (as integer)
- GODOT_PROPERTY_HINT_FLAGS, ///< hint_text= "flag1,flag2,etc" (as bit flags)
- GODOT_PROPERTY_HINT_LAYERS_2D_RENDER,
- GODOT_PROPERTY_HINT_LAYERS_2D_PHYSICS,
- GODOT_PROPERTY_HINT_LAYERS_3D_RENDER,
- GODOT_PROPERTY_HINT_LAYERS_3D_PHYSICS,
- GODOT_PROPERTY_HINT_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc,"
- GODOT_PROPERTY_HINT_DIR, ///< a directort path must be passed
- GODOT_PROPERTY_HINT_GLOBAL_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc,"
- GODOT_PROPERTY_HINT_GLOBAL_DIR, ///< a directort path must be passed
- GODOT_PROPERTY_HINT_RESOURCE_TYPE, ///< a resource object type
- GODOT_PROPERTY_HINT_MULTILINE_TEXT, ///< used for string properties that can contain multiple lines
- GODOT_PROPERTY_HINT_COLOR_NO_ALPHA, ///< used for ignoring alpha component when editing a color
- GODOT_PROPERTY_HINT_IMAGE_COMPRESS_LOSSY,
- GODOT_PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS,
- GODOT_PROPERTY_HINT_OBJECT_ID,
- GODOT_PROPERTY_HINT_TYPE_STRING, ///< a type string, the hint is the base type to choose
- GODOT_PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE, ///< so something else can provide this (used in scripts)
- GODOT_PROPERTY_HINT_METHOD_OF_VARIANT_TYPE, ///< a method of a type
- GODOT_PROPERTY_HINT_METHOD_OF_BASE_TYPE, ///< a method of a base type
- GODOT_PROPERTY_HINT_METHOD_OF_INSTANCE, ///< a method of an instance
- GODOT_PROPERTY_HINT_METHOD_OF_SCRIPT, ///< a method of a script & base
- GODOT_PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE, ///< a property of a type
- GODOT_PROPERTY_HINT_PROPERTY_OF_BASE_TYPE, ///< a property of a base type
- GODOT_PROPERTY_HINT_PROPERTY_OF_INSTANCE, ///< a property of an instance
- GODOT_PROPERTY_HINT_PROPERTY_OF_SCRIPT, ///< a property of a script & base
- GODOT_PROPERTY_HINT_MAX,
-} godot_property_hint;
-
-typedef enum godot_property_usage_flags {
-
- GODOT_PROPERTY_USAGE_STORAGE = 1,
- GODOT_PROPERTY_USAGE_EDITOR = 2,
- GODOT_PROPERTY_USAGE_NETWORK = 4,
- GODOT_PROPERTY_USAGE_EDITOR_HELPER = 8,
- GODOT_PROPERTY_USAGE_CHECKABLE = 16, //used for editing global variables
- GODOT_PROPERTY_USAGE_CHECKED = 32, //used for editing global variables
- GODOT_PROPERTY_USAGE_INTERNATIONALIZED = 64, //hint for internationalized strings
- GODOT_PROPERTY_USAGE_GROUP = 128, //used for grouping props in the editor
- GODOT_PROPERTY_USAGE_CATEGORY = 256,
- GODOT_PROPERTY_USAGE_STORE_IF_NONZERO = 512, //only store if nonzero
- GODOT_PROPERTY_USAGE_STORE_IF_NONONE = 1024, //only store if false
- GODOT_PROPERTY_USAGE_NO_INSTANCE_STATE = 2048,
- GODOT_PROPERTY_USAGE_RESTART_IF_CHANGED = 4096,
- GODOT_PROPERTY_USAGE_SCRIPT_VARIABLE = 8192,
- GODOT_PROPERTY_USAGE_STORE_IF_NULL = 16384,
- GODOT_PROPERTY_USAGE_ANIMATE_AS_TRIGGER = 32768,
- GODOT_PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED = 65536,
-
- GODOT_PROPERTY_USAGE_DEFAULT = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_EDITOR | GODOT_PROPERTY_USAGE_NETWORK,
- GODOT_PROPERTY_USAGE_DEFAULT_INTL = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_EDITOR | GODOT_PROPERTY_USAGE_NETWORK | GODOT_PROPERTY_USAGE_INTERNATIONALIZED,
- GODOT_PROPERTY_USAGE_NOEDITOR = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_NETWORK,
-} godot_property_usage_flags;
-
-typedef struct godot_property_attributes {
- godot_method_rpc_mode rset_type;
-
- godot_int type;
- godot_property_hint hint;
- godot_string hint_string;
- godot_property_usage_flags usage;
- godot_variant default_value;
-} godot_property_attributes;
-
-typedef struct godot_instance_create_func {
- // instance pointer, method_data - return user data
- GDCALLINGCONV void *(*create_func)(godot_object *, void *);
- void *method_data;
- GDCALLINGCONV void (*free_func)(void *);
-} godot_instance_create_func;
-
-typedef struct godot_instance_destroy_func {
- // instance pointer, method data, user data
- GDCALLINGCONV void (*destroy_func)(godot_object *, void *, void *);
- void *method_data;
- GDCALLINGCONV void (*free_func)(void *);
-} godot_instance_destroy_func;
-
-void GDAPI godot_script_register_class(const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func);
-
-void GDAPI godot_script_register_tool_class(const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func);
-
-typedef struct godot_instance_method {
- // instance pointer, method data, user data, num args, args - return result as varaint
- GDCALLINGCONV godot_variant (*method)(godot_object *, void *, void *, int, godot_variant **);
- void *method_data;
- GDCALLINGCONV void (*free_func)(void *);
-} godot_instance_method;
-
-void GDAPI godot_script_register_method(const char *p_name, const char *p_function_name, godot_method_attributes p_attr, godot_instance_method p_method);
-
-typedef struct godot_property_set_func {
- // instance pointer, method data, user data, value
- GDCALLINGCONV void (*set_func)(godot_object *, void *, void *, godot_variant);
- void *method_data;
- GDCALLINGCONV void (*free_func)(void *);
-} godot_property_set_func;
-
-typedef struct godot_property_get_func {
- // instance pointer, method data, user data, value
- GDCALLINGCONV godot_variant (*get_func)(godot_object *, void *, void *);
- void *method_data;
- GDCALLINGCONV void (*free_func)(void *);
-} godot_property_get_func;
-
-void GDAPI godot_script_register_property(const char *p_name, const char *p_path, godot_property_attributes *p_attr, godot_property_set_func p_set_func, godot_property_get_func p_get_func);
-
-typedef struct godot_signal_argument {
- godot_string name;
- godot_int type;
- godot_property_hint hint;
- godot_string hint_string;
- godot_property_usage_flags usage;
- godot_variant default_value;
-} godot_signal_argument;
-
-typedef struct godot_signal {
- godot_string name;
- int num_args;
- godot_signal_argument *args;
- int num_default_args;
- godot_variant *default_args;
-} godot_signal;
-
-void GDAPI godot_script_register_signal(const char *p_name, const godot_signal *p_signal);
-
-void GDAPI *godot_native_get_userdata(godot_object *p_instance);
+} godot_gdnative_terminate_options;
// Calling convention?
typedef godot_object *(*godot_class_constructor)();
@@ -421,6 +274,11 @@ godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classnam
godot_dictionary GDAPI godot_get_global_constants();
+////// GDNative procedure types
+typedef void (*godot_gdnative_init_fn)(godot_gdnative_init_options *);
+typedef void (*godot_gdnative_terminate_fn)(godot_gdnative_terminate_options *);
+typedef godot_variant (*godot_gdnative_procedure_fn)(void *, godot_array *);
+
////// System Functions
//using these will help Godot track how much memory is in use in debug mode
diff --git a/modules/gdnative/godot/icon.png.import b/modules/gdnative/godot/icon.png.import
new file mode 100644
index 0000000000..27920124f9
--- /dev/null
+++ b/modules/gdnative/godot/icon.png.import
@@ -0,0 +1,23 @@
+[remap]
+
+importer="texture"
+type="StreamTexture"
+path="res://.import/icon.png-aa47d037a37fb38b3b7e7828e4eec407.stex"
+
+[params]
+
+compress/mode=0
+compress/lossy_quality=0.7
+compress/hdr_mode=0
+compress/normal_map=0
+flags/repeat=0
+flags/filter=true
+flags/mipmaps=false
+flags/anisotropic=false
+flags/srgb=2
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/HDR_as_SRGB=false
+stream=false
+size_limit=0
+detect_3d=true
diff --git a/modules/gdnative/godot/godot_node_path.cpp b/modules/gdnative/godot/node_path.cpp
index c8eacd05af..a9edbc8352 100644
--- a/modules/gdnative/godot/godot_node_path.cpp
+++ b/modules/gdnative/godot/node_path.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_node_path.cpp */
+/* node_path.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_node_path.h"
+#include "node_path.h"
#include "core/variant.h"
#include "core/path_db.h"
diff --git a/modules/gdnative/godot/godot_node_path.h b/modules/gdnative/godot/node_path.h
index b0c9d44859..06955a052e 100644
--- a/modules/gdnative/godot/godot_node_path.h
+++ b/modules/gdnative/godot/node_path.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_node_path.h */
+/* node_path.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,15 +36,17 @@ extern "C" {
#include <stdint.h>
+#define GODOT_NODE_PATH_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_NODE_PATH_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_NODE_PATH_TYPE_DEFINED
-typedef struct godot_node_path {
- uint8_t _dont_touch_that[8];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_NODE_PATH_SIZE];
} godot_node_path;
#endif
-#include "../godot.h"
-#include "godot_string.h"
+#include "gdnative.h"
+#include "string.h"
void GDAPI godot_node_path_new(godot_node_path *r_dest, const godot_string *p_from);
void GDAPI godot_node_path_new_copy(godot_node_path *r_dest, const godot_node_path *p_src);
diff --git a/modules/gdnative/godot/godot_plane.cpp b/modules/gdnative/godot/plane.cpp
index 68adbd4a98..e9e659e5da 100644
--- a/modules/gdnative/godot/godot_plane.cpp
+++ b/modules/gdnative/godot/plane.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_plane.cpp */
+/* plane.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_plane.h"
+#include "plane.h"
#include "core/variant.h"
#include "core/math/plane.h"
diff --git a/modules/gdnative/godot/godot_plane.h b/modules/gdnative/godot/plane.h
index cfc955f277..e9e3b71e03 100644
--- a/modules/gdnative/godot/godot_plane.h
+++ b/modules/gdnative/godot/plane.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_plane.h */
+/* plane.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,15 +36,17 @@ extern "C" {
#include <stdint.h>
+#define GODOT_PLANE_SIZE 16
+
#ifndef GODOT_CORE_API_GODOT_PLANE_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_PLANE_TYPE_DEFINED
-typedef struct godot_plane {
- uint8_t _dont_touch_that[16];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_PLANE_SIZE];
} godot_plane;
#endif
-#include "../godot.h"
-#include "godot_vector3.h"
+#include "gdnative.h"
+#include "vector3.h"
void GDAPI godot_plane_new_with_reals(godot_plane *r_dest, const godot_real p_a, const godot_real p_b, const godot_real p_c, const godot_real p_d);
void GDAPI godot_plane_new_with_vectors(godot_plane *r_dest, const godot_vector3 *p_v1, const godot_vector3 *p_v2, const godot_vector3 *p_v3);
diff --git a/modules/gdnative/godot/godot_pool_arrays.cpp b/modules/gdnative/godot/pool_arrays.cpp
index ea9aceea81..6a6ee0f126 100644
--- a/modules/gdnative/godot/godot_pool_arrays.cpp
+++ b/modules/gdnative/godot/pool_arrays.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_pool_arrays.cpp */
+/* pool_arrays.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,11 +27,15 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_pool_arrays.h"
+#include "pool_arrays.h"
#include "array.h"
+#include "core/variant.h"
#include "dvector.h"
-#include "variant.h"
+
+#include "core/color.h"
+#include "core/math/math_2d.h"
+#include "core/math/vector3.h"
#ifdef __cplusplus
extern "C" {
diff --git a/modules/gdnative/godot/godot_pool_arrays.h b/modules/gdnative/godot/pool_arrays.h
index a794d03f01..1e2916cea9 100644
--- a/modules/gdnative/godot/godot_pool_arrays.h
+++ b/modules/gdnative/godot/pool_arrays.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_pool_arrays.h */
+/* pool_arrays.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -38,66 +38,87 @@ extern "C" {
/////// PoolByteArray
+#define GODOT_POOL_BYTE_ARRAY_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_POOL_BYTE_ARRAY_TYPE_DEFINED
-typedef struct godot_pool_byte_array {
- uint8_t _dont_touch_that[8];
+#define GODOT_CORE_API_GODOT_POOL_BYTE_ARRAY_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_POOL_BYTE_ARRAY_SIZE];
} godot_pool_byte_array;
#endif
/////// PoolIntArray
+#define GODOT_POOL_INT_ARRAY_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_POOL_INT_ARRAY_TYPE_DEFINED
-typedef struct godot_pool_int_array {
- uint8_t _dont_touch_that[8];
+#define GODOT_CORE_API_GODOT_POOL_INT_ARRAY_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_POOL_INT_ARRAY_SIZE];
} godot_pool_int_array;
#endif
/////// PoolRealArray
+#define GODOT_POOL_REAL_ARRAY_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_POOL_REAL_ARRAY_TYPE_DEFINED
-typedef struct godot_pool_real_array {
- uint8_t _dont_touch_that[8];
+#define GODOT_CORE_API_GODOT_POOL_REAL_ARRAY_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_POOL_REAL_ARRAY_SIZE];
} godot_pool_real_array;
#endif
/////// PoolStringArray
+#define GODOT_POOL_STRING_ARRAY_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_POOL_STRING_ARRAY_TYPE_DEFINED
-typedef struct godot_pool_string_array {
- uint8_t _dont_touch_that[8];
+#define GODOT_CORE_API_GODOT_POOL_STRING_ARRAY_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_POOL_STRING_ARRAY_SIZE];
} godot_pool_string_array;
#endif
/////// PoolVector2Array
+#define GODOT_POOL_VECTOR2_ARRAY_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_POOL_VECTOR2_ARRAY_TYPE_DEFINED
-typedef struct godot_pool_vector2_array {
- uint8_t _dont_touch_that[8];
+#define GODOT_CORE_API_GODOT_POOL_VECTOR2_ARRAY_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_POOL_VECTOR2_ARRAY_SIZE];
} godot_pool_vector2_array;
#endif
/////// PoolVector3Array
+#define GODOT_POOL_VECTOR3_ARRAY_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_POOL_VECTOR3_ARRAY_TYPE_DEFINED
-typedef struct godot_pool_vector3_array {
- uint8_t _dont_touch_that[8];
+#define GODOT_CORE_API_GODOT_POOL_VECTOR3_ARRAY_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_POOL_VECTOR3_ARRAY_SIZE];
} godot_pool_vector3_array;
#endif
/////// PoolColorArray
+#define GODOT_POOL_COLOR_ARRAY_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_POOL_COLOR_ARRAY_TYPE_DEFINED
-typedef struct godot_pool_color_array {
- uint8_t _dont_touch_that[8];
+#define GODOT_CORE_API_GODOT_POOL_COLOR_ARRAY_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_POOL_COLOR_ARRAY_SIZE];
} godot_pool_color_array;
#endif
-#include "godot_array.h"
-#include "godot_color.h"
-#include "godot_vector2.h"
-#include "godot_vector3.h"
+#include "array.h"
+#include "color.h"
+#include "vector2.h"
+#include "vector3.h"
-#include "../godot.h"
+#include "gdnative.h"
// byte
diff --git a/modules/gdnative/godot/godot_quat.cpp b/modules/gdnative/godot/quat.cpp
index 7235e4fcec..6800f7fc7e 100644
--- a/modules/gdnative/godot/godot_quat.cpp
+++ b/modules/gdnative/godot/quat.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_quat.cpp */
+/* quat.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_quat.h"
+#include "quat.h"
#include "core/variant.h"
#include "core/math/quat.h"
diff --git a/modules/gdnative/godot/godot_quat.h b/modules/gdnative/godot/quat.h
index 2289b6cbab..b86cbacc62 100644
--- a/modules/gdnative/godot/godot_quat.h
+++ b/modules/gdnative/godot/quat.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_quat.h */
+/* quat.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,15 +36,17 @@ extern "C" {
#include <stdint.h>
+#define GODOT_QUAT_SIZE 16
+
#ifndef GODOT_CORE_API_GODOT_QUAT_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_QUAT_TYPE_DEFINED
-typedef struct godot_quat {
- uint8_t _dont_touch_that[16];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_QUAT_SIZE];
} godot_quat;
#endif
-#include "../godot.h"
-#include "godot_vector3.h"
+#include "gdnative.h"
+#include "vector3.h"
void GDAPI godot_quat_new(godot_quat *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z, const godot_real p_w);
void GDAPI godot_quat_new_with_axis_angle(godot_quat *r_dest, const godot_vector3 *p_axis, const godot_real p_angle);
diff --git a/modules/gdnative/godot/godot_rect2.cpp b/modules/gdnative/godot/rect2.cpp
index 0e456ea3ba..830d7bb496 100644
--- a/modules/gdnative/godot/godot_rect2.cpp
+++ b/modules/gdnative/godot/rect2.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_rect2.cpp */
+/* rect2.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_rect2.h"
+#include "rect2.h"
#include "core/variant.h"
#include "core/math/math_2d.h"
diff --git a/modules/gdnative/godot/godot_rect2.h b/modules/gdnative/godot/rect2.h
index 488a1204f7..7b6613d9dd 100644
--- a/modules/gdnative/godot/godot_rect2.h
+++ b/modules/gdnative/godot/rect2.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_rect2.h */
+/* rect2.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -43,8 +43,8 @@ typedef struct godot_rect2 {
} godot_rect2;
#endif
-#include "../godot.h"
-#include "godot_vector2.h"
+#include "gdnative.h"
+#include "vector2.h"
void GDAPI godot_rect2_new_with_position_and_size(godot_rect2 *r_dest, const godot_vector2 *p_pos, const godot_vector2 *p_size);
void GDAPI godot_rect2_new(godot_rect2 *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_width, const godot_real p_height);
diff --git a/modules/gdnative/godot/godot_rect3.cpp b/modules/gdnative/godot/rect3.cpp
index e524fa8463..0fabba5b7b 100644
--- a/modules/gdnative/godot/godot_rect3.cpp
+++ b/modules/gdnative/godot/rect3.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_rect3.cpp */
+/* rect3.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_rect3.h"
+#include "rect3.h"
#include "core/variant.h"
#include "core/math/rect3.h"
diff --git a/modules/gdnative/godot/godot_rect3.h b/modules/gdnative/godot/rect3.h
index 9e9a49ac27..638d89f76f 100644
--- a/modules/gdnative/godot/godot_rect3.h
+++ b/modules/gdnative/godot/rect3.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_rect3.h */
+/* rect3.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,16 +36,18 @@ extern "C" {
#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 godot_rect3 {
- uint8_t _dont_touch_that[24];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_RECT3_SIZE];
} godot_rect3;
#endif
-#include "../godot.h"
-#include "godot_plane.h"
-#include "godot_vector3.h"
+#include "gdnative.h"
+#include "plane.h"
+#include "vector3.h"
void GDAPI godot_rect3_new(godot_rect3 *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size);
diff --git a/modules/gdnative/godot/godot_rid.cpp b/modules/gdnative/godot/rid.cpp
index 343c004bff..2b724e554d 100644
--- a/modules/gdnative/godot/godot_rid.cpp
+++ b/modules/gdnative/godot/rid.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_rid.cpp */
+/* rid.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_rid.h"
+#include "rid.h"
#include "core/variant.h"
#include "core/resource.h"
diff --git a/modules/gdnative/godot/godot_rid.h b/modules/gdnative/godot/rid.h
index 25dc8d965e..92e101fd2e 100644
--- a/modules/gdnative/godot/godot_rid.h
+++ b/modules/gdnative/godot/rid.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_rid.h */
+/* rid.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,14 +36,16 @@ extern "C" {
#include <stdint.h>
+#define GODOT_RID_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_RID_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_RID_TYPE_DEFINED
-typedef struct godot_rid {
- uint8_t _dont_touch_that[8];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_RID_SIZE];
} godot_rid;
#endif
-#include "../godot.h"
+#include "gdnative.h"
void GDAPI godot_rid_new(godot_rid *r_dest);
diff --git a/modules/gdnative/godot/godot_string.cpp b/modules/gdnative/godot/string.cpp
index 679011e715..e54ef3655f 100644
--- a/modules/gdnative/godot/godot_string.cpp
+++ b/modules/gdnative/godot/string.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_string.cpp */
+/* string.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_string.h"
+#include "string.h"
#include "string_db.h"
#include "ustring.h"
diff --git a/modules/gdnative/godot/godot_string.h b/modules/gdnative/godot/string.h
index df848abb76..d4d6d6c1d0 100644
--- a/modules/gdnative/godot/godot_string.h
+++ b/modules/gdnative/godot/string.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_string.h */
+/* string.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -37,13 +37,16 @@ extern "C" {
#include <stdint.h>
#include <wchar.h>
+#define GODOT_STRING_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED
-typedef struct godot_string {
- uint8_t _dont_touch_that[8];
+#define GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_STRING_SIZE];
} godot_string;
#endif
-#include "../godot.h"
+#include "gdnative.h"
void GDAPI godot_string_new(godot_string *r_dest);
void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src);
diff --git a/modules/gdnative/godot/godot_transform.cpp b/modules/gdnative/godot/transform.cpp
index eb9e1e207b..e566ed0b6e 100644
--- a/modules/gdnative/godot/godot_transform.cpp
+++ b/modules/gdnative/godot/transform.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_transform.cpp */
+/* transform.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_transform.h"
+#include "transform.h"
#include "core/variant.h"
#include "core/math/transform.h"
diff --git a/modules/gdnative/godot/godot_transform.h b/modules/gdnative/godot/transform.h
index ee87e1d33f..d14190ec49 100644
--- a/modules/gdnative/godot/godot_transform.h
+++ b/modules/gdnative/godot/transform.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_transform.h */
+/* transform.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,17 +36,19 @@ extern "C" {
#include <stdint.h>
+#define GODOT_TRANSFORM_SIZE 48
+
#ifndef GODOT_CORE_API_GODOT_TRANSFORM_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_TRANSFORM_TYPE_DEFINED
-typedef struct godot_transform {
- uint8_t _dont_touch_that[48];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_TRANSFORM_SIZE];
} godot_transform;
#endif
-#include "../godot.h"
-#include "godot_basis.h"
-#include "godot_variant.h"
-#include "godot_vector3.h"
+#include "basis.h"
+#include "gdnative.h"
+#include "variant.h"
+#include "vector3.h"
void GDAPI godot_transform_new_with_axis_origin(godot_transform *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis, const godot_vector3 *p_origin);
void GDAPI godot_transform_new(godot_transform *r_dest, const godot_basis *p_basis, const godot_vector3 *p_origin);
diff --git a/modules/gdnative/godot/godot_transform2d.cpp b/modules/gdnative/godot/transform2d.cpp
index bdb5476f7d..01db3f7ae0 100644
--- a/modules/gdnative/godot/godot_transform2d.cpp
+++ b/modules/gdnative/godot/transform2d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_transform2d.cpp */
+/* transform2d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_transform2d.h"
+#include "transform2d.h"
#include "core/variant.h"
#include "core/math/math_2d.h"
diff --git a/modules/gdnative/godot/godot_transform2d.h b/modules/gdnative/godot/transform2d.h
index c375e90af7..7171e528f2 100644
--- a/modules/gdnative/godot/godot_transform2d.h
+++ b/modules/gdnative/godot/transform2d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_transform2d.h */
+/* transform2d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,16 +36,18 @@ extern "C" {
#include <stdint.h>
+#define GODOT_TRANSFORM2D_SIZE 24
+
#ifndef GODOT_CORE_API_GODOT_TRANSFORM2D_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_TRANSFORM2D_TYPE_DEFINED
-typedef struct godot_transform2d {
- uint8_t _dont_touch_that[24];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_TRANSFORM2D_SIZE];
} godot_transform2d;
#endif
-#include "../godot.h"
-#include "godot_variant.h"
-#include "godot_vector2.h"
+#include "gdnative.h"
+#include "variant.h"
+#include "vector2.h"
void GDAPI godot_transform2d_new(godot_transform2d *r_dest, const godot_real p_rot, const godot_vector2 *p_pos);
void GDAPI godot_transform2d_new_axis_origin(godot_transform2d *r_dest, const godot_vector2 *p_x_axis, const godot_vector2 *p_y_axis, const godot_vector2 *p_origin);
diff --git a/modules/gdnative/godot/godot_variant.cpp b/modules/gdnative/godot/variant.cpp
index c9607fb21a..3469058cfd 100644
--- a/modules/gdnative/godot/godot_variant.cpp
+++ b/modules/gdnative/godot/variant.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_variant.cpp */
+/* variant.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_variant.h"
+#include "variant.h"
#include "core/variant.h"
#ifdef __cplusplus
diff --git a/modules/gdnative/godot/godot_variant.h b/modules/gdnative/godot/variant.h
index 9b6d287249..b56d5824fa 100644
--- a/modules/gdnative/godot/godot_variant.h
+++ b/modules/gdnative/godot/variant.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_variant.h */
+/* variant.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,9 +36,12 @@ extern "C" {
#include <stdint.h>
+#define GODOT_VARIANT_SIZE 24
+
#ifndef GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED
-typedef struct godot_variant {
- uint8_t _dont_touch_that[24];
+#define GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_VARIANT_SIZE];
} godot_variant;
#endif
@@ -96,25 +99,25 @@ typedef struct godot_variant_call_error {
godot_variant_type expected;
} godot_variant_call_error;
-#include "godot_array.h"
-#include "godot_basis.h"
-#include "godot_color.h"
-#include "godot_dictionary.h"
-#include "godot_node_path.h"
-#include "godot_plane.h"
-#include "godot_pool_arrays.h"
-#include "godot_quat.h"
-#include "godot_rect2.h"
-#include "godot_rect3.h"
-#include "godot_rid.h"
-#include "godot_string.h"
-#include "godot_transform.h"
-#include "godot_transform2d.h"
-#include "godot_variant.h"
-#include "godot_vector2.h"
-#include "godot_vector3.h"
-
-#include "../godot.h"
+#include "array.h"
+#include "basis.h"
+#include "color.h"
+#include "dictionary.h"
+#include "node_path.h"
+#include "plane.h"
+#include "pool_arrays.h"
+#include "quat.h"
+#include "rect2.h"
+#include "rect3.h"
+#include "rid.h"
+#include "string.h"
+#include "transform.h"
+#include "transform2d.h"
+#include "variant.h"
+#include "vector2.h"
+#include "vector3.h"
+
+#include "gdnative.h"
godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_v);
diff --git a/modules/gdnative/godot/godot_vector2.cpp b/modules/gdnative/godot/vector2.cpp
index 0ced800872..6b40e31a89 100644
--- a/modules/gdnative/godot/godot_vector2.cpp
+++ b/modules/gdnative/godot/vector2.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_vector2.cpp */
+/* vector2.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_vector2.h"
+#include "vector2.h"
#include "core/variant.h"
#include "core/math/math_2d.h"
diff --git a/modules/gdnative/godot/godot_vector2.h b/modules/gdnative/godot/vector2.h
index 9c7590fedf..9934ddadbb 100644
--- a/modules/gdnative/godot/godot_vector2.h
+++ b/modules/gdnative/godot/vector2.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_vector2.h */
+/* vector2.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,14 +36,16 @@ extern "C" {
#include <stdint.h>
+#define GODOT_VECTOR2_SIZE 8
+
#ifndef GODOT_CORE_API_GODOT_VECTOR2_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_VECTOR2_TYPE_DEFINED
-typedef struct godot_vector2 {
- uint8_t _dont_touch_that[8];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_VECTOR2_SIZE];
} godot_vector2;
#endif
-#include "../godot.h"
+#include "gdnative.h"
void GDAPI godot_vector2_new(godot_vector2 *r_dest, const godot_real p_x, const godot_real p_y);
diff --git a/modules/gdnative/godot/godot_vector3.cpp b/modules/gdnative/godot/vector3.cpp
index adca0d1e2a..904cdad9d0 100644
--- a/modules/gdnative/godot/godot_vector3.cpp
+++ b/modules/gdnative/godot/vector3.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_vector3.cpp */
+/* vector3.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_vector3.h"
+#include "vector3.h"
#include "core/variant.h"
#include "core/vector.h"
diff --git a/modules/gdnative/godot/godot_vector3.h b/modules/gdnative/godot/vector3.h
index 98d9ddf6ac..b5f8d0f49a 100644
--- a/modules/gdnative/godot/godot_vector3.h
+++ b/modules/gdnative/godot/vector3.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_vector3.h */
+/* vector3.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,15 +36,17 @@ extern "C" {
#include <stdint.h>
+#define GODOT_VECTOR3_SIZE 12
+
#ifndef GODOT_CORE_API_GODOT_VECTOR3_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_VECTOR3_TYPE_DEFINED
-typedef struct godot_vector3 {
- uint8_t _dont_touch_that[12];
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_VECTOR3_SIZE];
} godot_vector3;
#endif
-#include "../godot.h"
-#include "godot_basis.h"
+#include "basis.h"
+#include "gdnative.h"
typedef enum {
GODOT_VECTOR3_AXIS_X,
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index 8789c9a267..20ac1ecc0c 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -33,34 +33,46 @@
#include "io/resource_loader.h"
#include "io/resource_saver.h"
-GDNativeScriptLanguage *script_language_gdn = NULL;
-ResourceFormatLoaderGDNativeScript *resource_loader_gdn = NULL;
-ResourceFormatSaverGDNativeScript *resource_saver_gdn = NULL;
-//ResourceFormatLoaderDLLibrary *resource_loader_dllib=NULL;
+#include "core/os/os.h"
-void register_gdnative_types() {
+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;
+ }
- ClassDB::register_class<GDNativeLibrary>();
- ClassDB::register_class<GDNativeScript>();
+ void *library_proc;
+ Error err = OS::get_singleton()->get_dynamic_library_symbol_handle(
+ handle,
+ *(String *)p_procedure,
+ library_proc);
+ 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_gdnative_procedure_fn proc;
+ proc = (godot_gdnative_procedure_fn)library_proc;
- script_language_gdn = memnew(GDNativeScriptLanguage);
- ScriptServer::register_language(script_language_gdn);
- resource_loader_gdn = memnew(ResourceFormatLoaderGDNativeScript);
- ResourceLoader::add_resource_format_loader(resource_loader_gdn);
- resource_saver_gdn = memnew(ResourceFormatSaverGDNativeScript);
- ResourceSaver::add_resource_format_saver(resource_saver_gdn);
+ return proc(NULL, p_args);
}
-void unregister_gdnative_types() {
+GDNativeCallRegistry *GDNativeCallRegistry::singleton;
- ScriptServer::unregister_language(script_language_gdn);
+void register_gdnative_types() {
- if (script_language_gdn)
- memdelete(script_language_gdn);
+ ClassDB::register_class<GDNativeLibrary>();
+ ClassDB::register_class<GDNative>();
+
+ GDNativeCallRegistry::singleton = memnew(GDNativeCallRegistry);
- if (resource_loader_gdn)
- memdelete(resource_loader_gdn);
+ GDNativeCallRegistry::singleton->register_native_call_type("standard_varcall", cb_standard_varcall);
+}
- if (resource_saver_gdn)
- memdelete(resource_saver_gdn);
+void unregister_gdnative_types() {
+ memdelete(GDNativeCallRegistry::singleton);
}