diff options
Diffstat (limited to 'modules/gdnative')
93 files changed, 0 insertions, 19759 deletions
diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub deleted file mode 100644 index f7f21a433e..0000000000 --- a/modules/gdnative/SCsub +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env python - -Import("env") -Import("env_modules") - -env_gdnative = env_modules.Clone() -env_gdnative.add_source_files(env.modules_sources, "gdnative.cpp") -env_gdnative.add_source_files(env.modules_sources, "register_types.cpp") -env_gdnative.add_source_files(env.modules_sources, "android/*.cpp") -env_gdnative.add_source_files(env.modules_sources, "gdnative/*.cpp") -env_gdnative.add_source_files(env.modules_sources, "nativescript/*.cpp") -env_gdnative.add_source_files(env.modules_sources, "gdnative_library_singleton_editor.cpp") -env_gdnative.add_source_files(env.modules_sources, "gdnative_library_editor_plugin.cpp") - -env_gdnative.Prepend(CPPPATH=["#modules/gdnative/include/"]) - -Export("env_gdnative") - -SConscript("pluginscript/SCsub") -SConscript("videodecoder/SCsub") - - -import gdnative_builders - -_, gensource = env_gdnative.CommandNoCache( - ["include/gdnative_api_struct.gen.h", "gdnative_api_struct.gen.cpp"], - "gdnative_api.json", - env.Run(gdnative_builders.build_gdnative_api_struct, "Generating GDNative API."), -) -env_gdnative.add_source_files(env.modules_sources, [gensource]) diff --git a/modules/gdnative/android/android_gdn.cpp b/modules/gdnative/android/android_gdn.cpp deleted file mode 100644 index 7411fc4031..0000000000 --- a/modules/gdnative/android/android_gdn.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/*************************************************************************/ -/* android_gdn.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 "modules/gdnative/gdnative.h" - -// Code by Paritosh97 with minor tweaks by Mux213 -// These entry points are only for the android platform and are simple stubs in all others. - -#ifdef __ANDROID__ -#include "platform/android/java_godot_wrapper.h" -#include "platform/android/os_android.h" -#include "platform/android/thread_jandroid.h" -#else -#define JNIEnv void -#define jobject void * -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -JNIEnv *GDAPI godot_android_get_env() { -#ifdef __ANDROID__ - return get_jni_env(); -#else - return nullptr; -#endif -} - -jobject GDAPI godot_android_get_activity() { -#ifdef __ANDROID__ - OS_Android *os_android = (OS_Android *)OS::get_singleton(); - return os_android->get_godot_java()->get_activity(); -#else - return nullptr; -#endif -} - -jobject GDAPI godot_android_get_surface() { -#ifdef __ANDROID__ - OS_Android *os_android = (OS_Android *)OS::get_singleton(); - return os_android->get_godot_java()->get_surface(); -#else - return nullptr; -#endif -} - -bool GDAPI godot_android_is_activity_resumed() { -#ifdef __ANDROID__ - OS_Android *os_android = (OS_Android *)OS::get_singleton(); - return os_android->get_godot_java()->is_activity_resumed(); -#else - return false; -#endif -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/config.py b/modules/gdnative/config.py deleted file mode 100644 index 026a84a70f..0000000000 --- a/modules/gdnative/config.py +++ /dev/null @@ -1,20 +0,0 @@ -def can_build(env, platform): - return True - - -def configure(env): - pass - - -def get_doc_classes(): - return [ - "GDNative", - "GDNativeLibrary", - "NativeScript", - "PluginScript", - "VideoStreamGDNative", - ] - - -def get_doc_path(): - return "doc_classes" diff --git a/modules/gdnative/doc_classes/GDNative.xml b/modules/gdnative/doc_classes/GDNative.xml deleted file mode 100644 index 405365ad68..0000000000 --- a/modules/gdnative/doc_classes/GDNative.xml +++ /dev/null @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="GDNative" inherits="RefCounted" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> - <brief_description> - </brief_description> - <description> - </description> - <tutorials> - </tutorials> - <methods> - <method name="call_native"> - <return type="Variant" /> - <argument index="0" name="calling_type" type="StringName" /> - <argument index="1" name="procedure_name" type="StringName" /> - <argument index="2" name="arguments" type="Array" /> - <description> - </description> - </method> - <method name="initialize"> - <return type="bool" /> - <description> - </description> - </method> - <method name="terminate"> - <return type="bool" /> - <description> - </description> - </method> - </methods> - <members> - <member name="library" type="GDNativeLibrary" setter="set_library" getter="get_library"> - </member> - </members> -</class> diff --git a/modules/gdnative/doc_classes/GDNativeLibrary.xml b/modules/gdnative/doc_classes/GDNativeLibrary.xml deleted file mode 100644 index 66811467fc..0000000000 --- a/modules/gdnative/doc_classes/GDNativeLibrary.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="GDNativeLibrary" inherits="Resource" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> - <brief_description> - An external library containing functions or script classes to use in Godot. - </brief_description> - <description> - A GDNative library can implement [NativeScript]s, global functions to call with the [GDNative] class, or low-level engine extensions through interfaces such as XRInterfaceGDNative. The library must be compiled for each platform and architecture that the project will run on. - </description> - <tutorials> - <link title="GDNative C example">$DOCS_URL/tutorials/scripting/gdnative/gdnative_c_example.html</link> - <link title="GDNative C++ example">$DOCS_URL/tutorials/scripting/gdnative/gdnative_cpp_example.html</link> - </tutorials> - <methods> - <method name="get_current_dependencies" qualifiers="const"> - <return type="PackedStringArray" /> - <description> - Returns paths to all dependency libraries for the current platform and architecture. - </description> - </method> - <method name="get_current_library_path" qualifiers="const"> - <return type="String" /> - <description> - Returns the path to the dynamic library file for the current platform and architecture. - </description> - </method> - </methods> - <members> - <member name="config_file" type="ConfigFile" setter="set_config_file" getter="get_config_file"> - This resource in INI-style [ConfigFile] format, as in [code].gdnlib[/code] files. - </member> - <member name="load_once" type="bool" setter="set_load_once" getter="should_load_once" default="true"> - If [code]true[/code], Godot loads only one copy of the library and each script that references the library will share static data like static or global variables. - If [code]false[/code], Godot loads a separate copy of the library into memory for each script that references it. - </member> - <member name="reloadable" type="bool" setter="set_reloadable" getter="is_reloadable" default="true"> - If [code]true[/code], the editor will temporarily unload the library whenever the user switches away from the editor window, allowing the user to recompile the library without restarting Godot. - [b]Note:[/b] If the library defines tool scripts that run inside the editor, [code]reloadable[/code] must be [code]false[/code]. Otherwise, the editor will attempt to unload the tool scripts while they're in use and crash. - </member> - <member name="singleton" type="bool" setter="set_singleton" getter="is_singleton" default="false"> - If [code]true[/code], Godot loads the library at startup rather than the first time a script uses the library, calling [code]{prefix}gdnative_singleton[/code] after initializing the library (where [code]{prefix}[/code] is the value of [member symbol_prefix]). The library remains loaded as long as Godot is running. - [b]Note:[/b] A singleton library cannot be [member reloadable]. - </member> - <member name="symbol_prefix" type="String" setter="set_symbol_prefix" getter="get_symbol_prefix" default=""godot_""> - The prefix this library's entry point functions begin with. For example, a GDNativeLibrary would declare its [code]gdnative_init[/code] function as [code]godot_gdnative_init[/code] by default. - On platforms that require statically linking libraries (currently only iOS), each library must have a different [code]symbol_prefix[/code]. - </member> - </members> -</class> diff --git a/modules/gdnative/doc_classes/NativeScript.xml b/modules/gdnative/doc_classes/NativeScript.xml deleted file mode 100644 index b752b66f7e..0000000000 --- a/modules/gdnative/doc_classes/NativeScript.xml +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="NativeScript" inherits="Script" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> - <brief_description> - </brief_description> - <description> - </description> - <tutorials> - </tutorials> - <methods> - <method name="get_class_documentation" qualifiers="const"> - <return type="String" /> - <description> - Returns the documentation string that was previously set with [code]godot_nativescript_set_class_documentation[/code]. - </description> - </method> - <method name="get_method_documentation" qualifiers="const"> - <return type="String" /> - <argument index="0" name="method" type="StringName" /> - <description> - Returns the documentation string that was previously set with [code]godot_nativescript_set_method_documentation[/code]. - </description> - </method> - <method name="get_property_documentation" qualifiers="const"> - <return type="String" /> - <argument index="0" name="path" type="StringName" /> - <description> - Returns the documentation string that was previously set with [code]godot_nativescript_set_property_documentation[/code]. - </description> - </method> - <method name="get_signal_documentation" qualifiers="const"> - <return type="String" /> - <argument index="0" name="signal_name" type="StringName" /> - <description> - Returns the documentation string that was previously set with [code]godot_nativescript_set_signal_documentation[/code]. - </description> - </method> - <method name="new" qualifiers="vararg"> - <return type="Variant" /> - <description> - Constructs a new object of the base type with a script of this type already attached. - [b]Note:[/b] Any arguments passed to this function will be ignored and not passed to the native constructor function. This will change with in a future API extension. - </description> - </method> - </methods> - <members> - <member name="class_name" type="String" setter="set_class_name" getter="get_class_name" default=""""> - </member> - <member name="library" type="GDNativeLibrary" setter="set_library" getter="get_library"> - </member> - <member name="script_class_icon_path" type="String" setter="set_script_class_icon_path" getter="get_script_class_icon_path" default=""""> - </member> - <member name="script_class_name" type="String" setter="set_script_class_name" getter="get_script_class_name" default=""""> - </member> - </members> -</class> diff --git a/modules/gdnative/doc_classes/PluginScript.xml b/modules/gdnative/doc_classes/PluginScript.xml deleted file mode 100644 index 1fe6d95d3b..0000000000 --- a/modules/gdnative/doc_classes/PluginScript.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="PluginScript" inherits="Script" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> - <brief_description> - </brief_description> - <description> - </description> - <tutorials> - </tutorials> - <methods> - <method name="new" qualifiers="vararg"> - <return type="Variant" /> - <description> - Returns a new instance of the script. - </description> - </method> - </methods> -</class> diff --git a/modules/gdnative/doc_classes/VideoStreamGDNative.xml b/modules/gdnative/doc_classes/VideoStreamGDNative.xml deleted file mode 100644 index 2b27556fab..0000000000 --- a/modules/gdnative/doc_classes/VideoStreamGDNative.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="VideoStreamGDNative" inherits="VideoStream" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> - <brief_description> - [VideoStream] resource for for video formats implemented via GDNative. - </brief_description> - <description> - [VideoStream] resource for for video formats implemented via GDNative. - It can be used via [url=https://github.com/KidRigger/godot-videodecoder]godot-videodecoder[/url] which uses the [url=https://ffmpeg.org]FFmpeg[/url] library. - </description> - <tutorials> - </tutorials> - <methods> - <method name="get_file"> - <return type="String" /> - <description> - Returns the video file handled by this [VideoStreamGDNative]. - </description> - </method> - <method name="set_file"> - <return type="void" /> - <argument index="0" name="file" type="String" /> - <description> - Sets the video file that this [VideoStreamGDNative] resource handles. The supported extensions depend on the GDNative plugins used to expose video formats. - </description> - </method> - </methods> -</class> diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp deleted file mode 100644 index 3950ce1ade..0000000000 --- a/modules/gdnative/gdnative.cpp +++ /dev/null @@ -1,583 +0,0 @@ -/*************************************************************************/ -/* gdnative.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative.h" - -#include "core/config/project_settings.h" -#include "core/core_constants.h" -#include "core/io/dir_access.h" -#include "core/io/file_access.h" -#include "core/io/file_access_encrypted.h" -#include "core/os/os.h" - -#include "scene/main/scene_tree.h" - -static const String init_symbol = "gdnative_init"; -static const String terminate_symbol = "gdnative_terminate"; -static const String default_symbol_prefix = "godot_"; -static const bool default_singleton = false; -static const bool default_load_once = true; -static const bool default_reloadable = true; - -// Defined in gdnative_api_struct.gen.cpp -extern const godot_gdnative_core_api_struct api_struct; - -Map<String, Vector<Ref<GDNative>>> GDNativeLibrary::loaded_libraries; - -GDNativeLibrary::GDNativeLibrary() { - config_file.instantiate(); - - symbol_prefix = default_symbol_prefix; - load_once = default_load_once; - singleton = default_singleton; - reloadable = default_reloadable; -} - -GDNativeLibrary::~GDNativeLibrary() { -} - -bool GDNativeLibrary::_set(const StringName &p_name, const Variant &p_property) { - String name = p_name; - - if (name.begins_with("entry/")) { - String key = name.substr(6, name.length() - 6); - - config_file->set_value("entry", key, p_property); - - set_config_file(config_file); - - return true; - } - - if (name.begins_with("dependency/")) { - String key = name.substr(11, name.length() - 11); - - config_file->set_value("dependencies", key, p_property); - - set_config_file(config_file); - - return true; - } - - return false; -} - -bool GDNativeLibrary::_get(const StringName &p_name, Variant &r_property) const { - String name = p_name; - - if (name.begins_with("entry/")) { - String key = name.substr(6, name.length() - 6); - - r_property = config_file->get_value("entry", key); - - return true; - } - - if (name.begins_with("dependency/")) { - String key = name.substr(11, name.length() - 11); - - r_property = config_file->get_value("dependencies", key); - - return true; - } - - return false; -} - -void GDNativeLibrary::reset_state() { - config_file.instantiate(); - current_library_path = ""; - current_dependencies.clear(); - symbol_prefix = default_symbol_prefix; - load_once = default_load_once; - singleton = default_singleton; - reloadable = default_reloadable; -} - -void GDNativeLibrary::_get_property_list(List<PropertyInfo> *p_list) const { - // set entries - List<String> entry_key_list; - - if (config_file->has_section("entry")) { - config_file->get_section_keys("entry", &entry_key_list); - } - - for (const String &key : entry_key_list) { - PropertyInfo prop; - - prop.type = Variant::STRING; - prop.name = "entry/" + key; - - p_list->push_back(prop); - } - - // set dependencies - List<String> dependency_key_list; - - if (config_file->has_section("dependencies")) { - config_file->get_section_keys("dependencies", &dependency_key_list); - } - - for (const String &key : dependency_key_list) { - PropertyInfo prop; - - prop.type = Variant::STRING; - prop.name = "dependency/" + key; - - p_list->push_back(prop); - } -} - -void GDNativeLibrary::set_config_file(Ref<ConfigFile> p_config_file) { - ERR_FAIL_COND(p_config_file.is_null()); - - set_singleton(p_config_file->get_value("general", "singleton", default_singleton)); - set_load_once(p_config_file->get_value("general", "load_once", default_load_once)); - set_symbol_prefix(p_config_file->get_value("general", "symbol_prefix", default_symbol_prefix)); - set_reloadable(p_config_file->get_value("general", "reloadable", default_reloadable)); - - String entry_lib_path; - { - List<String> entry_keys; - - if (p_config_file->has_section("entry")) { - p_config_file->get_section_keys("entry", &entry_keys); - } - - for (const String &key : entry_keys) { - Vector<String> tags = key.split("."); - - bool skip = false; - for (int i = 0; i < tags.size(); i++) { - bool has_feature = OS::get_singleton()->has_feature(tags[i]); - - if (!has_feature) { - skip = true; - break; - } - } - - if (skip) { - continue; - } - - entry_lib_path = p_config_file->get_value("entry", key); - break; - } - } - - Vector<String> dependency_paths; - { - List<String> dependency_keys; - - if (p_config_file->has_section("dependencies")) { - p_config_file->get_section_keys("dependencies", &dependency_keys); - } - - for (const String &key : dependency_keys) { - Vector<String> tags = key.split("."); - - bool skip = false; - for (int i = 0; i < tags.size(); i++) { - bool has_feature = OS::get_singleton()->has_feature(tags[i]); - - if (!has_feature) { - skip = true; - break; - } - } - - if (skip) { - continue; - } - - dependency_paths = p_config_file->get_value("dependencies", key); - break; - } - } - - current_library_path = entry_lib_path; - current_dependencies = dependency_paths; -} - -void GDNativeLibrary::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_config_file"), &GDNativeLibrary::get_config_file); - ClassDB::bind_method(D_METHOD("set_config_file", "config_file"), &GDNativeLibrary::set_config_file); - - ClassDB::bind_method(D_METHOD("get_current_library_path"), &GDNativeLibrary::get_current_library_path); - ClassDB::bind_method(D_METHOD("get_current_dependencies"), &GDNativeLibrary::get_current_dependencies); - - ClassDB::bind_method(D_METHOD("should_load_once"), &GDNativeLibrary::should_load_once); - ClassDB::bind_method(D_METHOD("is_singleton"), &GDNativeLibrary::is_singleton); - ClassDB::bind_method(D_METHOD("get_symbol_prefix"), &GDNativeLibrary::get_symbol_prefix); - ClassDB::bind_method(D_METHOD("is_reloadable"), &GDNativeLibrary::is_reloadable); - - ClassDB::bind_method(D_METHOD("set_load_once", "load_once"), &GDNativeLibrary::set_load_once); - ClassDB::bind_method(D_METHOD("set_singleton", "singleton"), &GDNativeLibrary::set_singleton); - ClassDB::bind_method(D_METHOD("set_symbol_prefix", "symbol_prefix"), &GDNativeLibrary::set_symbol_prefix); - ClassDB::bind_method(D_METHOD("set_reloadable", "reloadable"), &GDNativeLibrary::set_reloadable); - - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "config_file", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile", PROPERTY_USAGE_NONE), "set_config_file", "get_config_file"); - - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "load_once"), "set_load_once", "should_load_once"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "singleton"), "set_singleton", "is_singleton"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "symbol_prefix"), "set_symbol_prefix", "get_symbol_prefix"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "reloadable"), "set_reloadable", "is_reloadable"); -} - -GDNative::GDNative() { - native_handle = nullptr; - initialized = false; -} - -GDNative::~GDNative() { -} - -void GDNative::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_library", "library"), &GDNative::set_library); - ClassDB::bind_method(D_METHOD("get_library"), &GDNative::get_library); - - ClassDB::bind_method(D_METHOD("initialize"), &GDNative::initialize); - ClassDB::bind_method(D_METHOD("terminate"), &GDNative::terminate); - - ClassDB::bind_method(D_METHOD("call_native", "calling_type", "procedure_name", "arguments"), &GDNative::call_native); - - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "GDNativeLibrary"), "set_library", "get_library"); -} - -void GDNative::set_library(Ref<GDNativeLibrary> p_library) { - ERR_FAIL_COND_MSG(library.is_valid(), "Tried to change library of GDNative when it is already set."); - library = p_library; -} - -Ref<GDNativeLibrary> GDNative::get_library() const { - return library; -} - -extern "C" void _gdnative_report_version_mismatch(const godot_object *p_library, const char *p_ext, godot_gdnative_api_version p_want, godot_gdnative_api_version p_have); -extern "C" void _gdnative_report_loading_error(const godot_object *p_library, const char *p_what); - -bool GDNative::initialize() { - if (library.is_null()) { - ERR_PRINT("No library set, can't initialize GDNative object"); - return false; - } - - String lib_path = library->get_current_library_path(); - if (lib_path.is_empty()) { - ERR_PRINT("No library set for this platform"); - return false; - } -#ifdef IPHONE_ENABLED - // On iOS we use static linking by default. - String path = ""; - - // On iOS dylibs is not allowed, but can be replaced with .framework or .xcframework. - // If they are used, we can run dlopen on them. - // They should be located under Frameworks directory, so we need to replace library path. - if (!lib_path.ends_with(".a")) { - path = ProjectSettings::get_singleton()->globalize_path(lib_path); - - if (!FileAccess::exists(path)) { - String lib_name = lib_path.get_basename().get_file(); - String framework_path_format = "Frameworks/$name.framework/$name"; - - Dictionary format_dict; - format_dict["name"] = lib_name; - String framework_path = framework_path_format.format(format_dict, "$_"); - - path = OS::get_singleton()->get_executable_path().get_base_dir().plus_file(framework_path); - } - } -#elif defined(ANDROID_ENABLED) - // On Android dynamic libraries are located separately from resource assets, - // we should pass library name to dlopen(). The library name is flattened - // during export. - String path = lib_path.get_file(); -#elif defined(UWP_ENABLED) - // On UWP we use a relative path from the app - String path = lib_path.replace("res://", ""); -#elif defined(OSX_ENABLED) - // On OSX the exported libraries are located under the Frameworks directory. - // So we need to replace the library path. - String path = ProjectSettings::get_singleton()->globalize_path(lib_path); - DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - - if (!da->file_exists(path) && !da->dir_exists(path)) { - path = OS::get_singleton()->get_executable_path().get_base_dir().plus_file("../Frameworks").plus_file(lib_path.get_file()); - } - - if (da->dir_exists(path)) { // Target library is a ".framework", add library base name to the path. - path = path.plus_file(path.get_file().get_basename()); - } - - memdelete(da); - -#else - String path = ProjectSettings::get_singleton()->globalize_path(lib_path); -#endif - - if (library->should_load_once()) { - if (GDNativeLibrary::loaded_libraries.has(lib_path)) { - // already loaded. Don't load again. - // copy some of the stuff instead - this->native_handle = GDNativeLibrary::loaded_libraries[lib_path][0]->native_handle; - initialized = true; - return true; - } - } - - Error err = OS::get_singleton()->open_dynamic_library(path, native_handle, true); - if (err != OK) { - return false; - } - - void *library_init; - - // we cheat here a little bit. you saw nothing - initialized = true; - - err = get_symbol(library->get_symbol_prefix() + init_symbol, library_init, false); - - initialized = false; - - if (err || !library_init) { - OS::get_singleton()->close_dynamic_library(native_handle); - native_handle = nullptr; - ERR_PRINT("Failed to obtain " + library->get_symbol_prefix() + "gdnative_init symbol"); - return false; - } - - godot_gdnative_init_fn library_init_fpointer; - library_init_fpointer = (godot_gdnative_init_fn)library_init; - - static uint64_t core_api_hash = 0; - static uint64_t editor_api_hash = 0; - static uint64_t no_api_hash = 0; - - if (!(core_api_hash || editor_api_hash || no_api_hash)) { - core_api_hash = ClassDB::get_api_hash(ClassDB::API_CORE); - editor_api_hash = ClassDB::get_api_hash(ClassDB::API_EDITOR); - no_api_hash = ClassDB::get_api_hash(ClassDB::API_NONE); - } - - godot_gdnative_init_options options; - - options.api_struct = &api_struct; - options.in_editor = Engine::get_singleton()->is_editor_hint(); - options.core_api_hash = core_api_hash; - options.editor_api_hash = editor_api_hash; - options.no_api_hash = no_api_hash; - options.report_version_mismatch = &_gdnative_report_version_mismatch; - options.report_loading_error = &_gdnative_report_loading_error; - options.gd_native_library = (godot_object *)(get_library().ptr()); - options.active_library_path = (godot_string *)&path; - - library_init_fpointer(&options); - - initialized = true; - - if (library->should_load_once() && !GDNativeLibrary::loaded_libraries.has(lib_path)) { - Vector<Ref<GDNative>> gdnatives; - gdnatives.resize(1); - gdnatives.write[0] = Ref<GDNative>(this); - GDNativeLibrary::loaded_libraries.insert(lib_path, gdnatives); - } - - return true; -} - -bool GDNative::terminate() { - if (!initialized) { - ERR_PRINT("No valid library handle, can't terminate GDNative object"); - return false; - } - - if (library->should_load_once()) { - Vector<Ref<GDNative>> *gdnatives = &GDNativeLibrary::loaded_libraries[library->get_current_library_path()]; - if (gdnatives->size() > 1) { - // there are other GDNative's still using this library, so we actually don't terminate - gdnatives->erase(Ref<GDNative>(this)); - initialized = false; - return true; - } else if (gdnatives->size() == 1) { - // we're the last one, terminate! - gdnatives->clear(); - // whew this looks scary, but all it does is remove the entry completely - GDNativeLibrary::loaded_libraries.erase(GDNativeLibrary::loaded_libraries.find(library->get_current_library_path())); - } - } - - void *library_terminate; - Error error = get_symbol(library->get_symbol_prefix() + terminate_symbol, library_terminate); - if (error || !library_terminate) { - OS::get_singleton()->close_dynamic_library(native_handle); - native_handle = nullptr; - initialized = false; - return true; - } - - godot_gdnative_terminate_fn library_terminate_pointer; - library_terminate_pointer = (godot_gdnative_terminate_fn)library_terminate; - - godot_gdnative_terminate_options options; - options.in_editor = Engine::get_singleton()->is_editor_hint(); - - library_terminate_pointer(&options); - - initialized = false; - - // GDNativeScriptLanguage::get_singleton()->initialized_libraries.erase(p_native_lib->path); - - OS::get_singleton()->close_dynamic_library(native_handle); - native_handle = nullptr; - - return true; -} - -bool GDNative::is_initialized() const { - return initialized; -} - -void GDNativeCallRegistry::register_native_call_type(StringName p_call_type, native_call_cb p_callback) { - native_calls.insert(p_call_type, p_callback); -} - -Vector<StringName> GDNativeCallRegistry::get_native_call_types() { - Vector<StringName> call_types; - call_types.resize(native_calls.size()); - - size_t idx = 0; - for (Map<StringName, native_call_cb>::Element *E = native_calls.front(); E; E = E->next(), idx++) { - call_types.write[idx] = E->key(); - } - - return call_types; -} - -Variant GDNative::call_native(StringName p_native_call_type, StringName p_procedure_name, Array p_arguments) { - 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(); - } - - void *procedure_handle; - - Error err = OS::get_singleton()->get_dynamic_library_symbol_handle( - native_handle, - p_procedure_name, - procedure_handle); - - if (err != OK || procedure_handle == nullptr) { - return Variant(); - } - - godot_variant result = E->get()(procedure_handle, (godot_array *)&p_arguments); - - Variant res = *(Variant *)&result; - godot_variant_destroy(&result); - return res; -} - -Error GDNative::get_symbol(StringName p_procedure_name, void *&r_handle, bool p_optional) const { - if (!initialized) { - ERR_PRINT("No valid library handle, can't get symbol from GDNative object"); - return ERR_CANT_OPEN; - } - - Error result = OS::get_singleton()->get_dynamic_library_symbol_handle( - native_handle, - p_procedure_name, - r_handle, - p_optional); - - return result; -} - -RES GDNativeLibraryResourceLoader::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) { - Ref<GDNativeLibrary> lib; - lib.instantiate(); - - Ref<ConfigFile> config = lib->get_config_file(); - - Error err = config->load(p_path); - - if (r_error) { - *r_error = err; - } - - lib->set_config_file(config); - - return lib; -} - -void GDNativeLibraryResourceLoader::get_recognized_extensions(List<String> *p_extensions) const { - p_extensions->push_back("gdnlib"); -} - -bool GDNativeLibraryResourceLoader::handles_type(const String &p_type) const { - return p_type == "GDNativeLibrary"; -} - -String GDNativeLibraryResourceLoader::get_resource_type(const String &p_path) const { - String el = p_path.get_extension().to_lower(); - if (el == "gdnlib") { - return "GDNativeLibrary"; - } - return ""; -} - -Error GDNativeLibraryResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t p_flags) { - Ref<GDNativeLibrary> lib = p_resource; - - if (lib.is_null()) { - return ERR_INVALID_DATA; - } - - Ref<ConfigFile> config = lib->get_config_file(); - - config->set_value("general", "singleton", lib->is_singleton()); - config->set_value("general", "load_once", lib->should_load_once()); - config->set_value("general", "symbol_prefix", lib->get_symbol_prefix()); - config->set_value("general", "reloadable", lib->is_reloadable()); - - return config->save(p_path); -} - -bool GDNativeLibraryResourceSaver::recognize(const RES &p_resource) const { - return Object::cast_to<GDNativeLibrary>(*p_resource) != nullptr; -} - -void GDNativeLibraryResourceSaver::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const { - if (Object::cast_to<GDNativeLibrary>(*p_resource) != nullptr) { - p_extensions->push_back("gdnlib"); - } -} diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h deleted file mode 100644 index 8facd43743..0000000000 --- a/modules/gdnative/gdnative.h +++ /dev/null @@ -1,184 +0,0 @@ -/*************************************************************************/ -/* gdnative.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 GDNATIVE_H -#define GDNATIVE_H - -#include "core/io/resource.h" -#include "core/io/resource_loader.h" -#include "core/io/resource_saver.h" -#include "core/os/thread_safe.h" - -#include "gdnative/gdnative.h" -#include "gdnative_api_struct.gen.h" - -#include "core/io/config_file.h" - -class GDNativeLibraryResourceLoader; -class GDNative; - -class GDNativeLibrary : public Resource { - GDCLASS(GDNativeLibrary, Resource); - - static Map<String, Vector<Ref<GDNative>>> loaded_libraries; - - friend class GDNativeLibraryResourceLoader; - friend class GDNative; - - Ref<ConfigFile> config_file; - - String current_library_path; - Vector<String> current_dependencies; - - bool singleton; - bool load_once; - String symbol_prefix; - bool reloadable; - -public: - virtual void reset_state() override; - - GDNativeLibrary(); - ~GDNativeLibrary(); - - virtual bool _set(const StringName &p_name, const Variant &p_property); - virtual bool _get(const StringName &p_name, Variant &r_property) const; - virtual void _get_property_list(List<PropertyInfo> *p_list) const; - - _FORCE_INLINE_ Ref<ConfigFile> get_config_file() { return config_file; } - - void set_config_file(Ref<ConfigFile> p_config_file); - - // things that change per-platform - // so there are no setters for this - _FORCE_INLINE_ String get_current_library_path() const { - return current_library_path; - } - _FORCE_INLINE_ Vector<String> get_current_dependencies() const { - return current_dependencies; - } - - // things that are a property of the library itself, not platform specific - _FORCE_INLINE_ bool should_load_once() const { - return load_once; - } - _FORCE_INLINE_ bool is_singleton() const { - return singleton; - } - _FORCE_INLINE_ String get_symbol_prefix() const { - return symbol_prefix; - } - - _FORCE_INLINE_ bool is_reloadable() const { - return reloadable; - } - - _FORCE_INLINE_ void set_load_once(bool p_load_once) { - config_file->set_value("general", "load_once", p_load_once); - load_once = p_load_once; - } - _FORCE_INLINE_ void set_singleton(bool p_singleton) { - config_file->set_value("general", "singleton", p_singleton); - singleton = p_singleton; - } - _FORCE_INLINE_ void set_symbol_prefix(String p_symbol_prefix) { - config_file->set_value("general", "symbol_prefix", p_symbol_prefix); - symbol_prefix = p_symbol_prefix; - } - - _FORCE_INLINE_ void set_reloadable(bool p_reloadable) { - config_file->set_value("general", "reloadable", p_reloadable); - reloadable = p_reloadable; - } - - static void _bind_methods(); -}; - -struct GDNativeCallRegistry { - static GDNativeCallRegistry *singleton; - - inline static GDNativeCallRegistry *get_singleton() { - return singleton; - } - - inline GDNativeCallRegistry() : - native_calls() {} - - Map<StringName, native_call_cb> native_calls; - - void register_native_call_type(StringName p_call_type, native_call_cb p_callback); - - Vector<StringName> get_native_call_types(); -}; - -class GDNative : public RefCounted { - GDCLASS(GDNative, RefCounted); - - Ref<GDNativeLibrary> library; - - void *native_handle; - - bool initialized; - -public: - GDNative(); - ~GDNative(); - - static void _bind_methods(); - - void set_library(Ref<GDNativeLibrary> p_library); - Ref<GDNativeLibrary> get_library() const; - - bool is_initialized() const; - - bool initialize(); - bool terminate(); - - Variant call_native(StringName p_native_call_type, StringName p_procedure_name, Array p_arguments = Array()); - - Error get_symbol(StringName p_procedure_name, void *&r_handle, bool p_optional = true) const; -}; - -class GDNativeLibraryResourceLoader : public ResourceFormatLoader { -public: - virtual RES load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE); - 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; -}; - -class GDNativeLibraryResourceSaver : public ResourceFormatSaver { -public: - virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags); - virtual bool recognize(const RES &p_resource) const; - virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const; -}; - -#endif // GDNATIVE_H diff --git a/modules/gdnative/gdnative/aabb.cpp b/modules/gdnative/gdnative/aabb.cpp deleted file mode 100644 index b8909433cc..0000000000 --- a/modules/gdnative/gdnative/aabb.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/*************************************************************************/ -/* aabb.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/aabb.h" - -#include "core/math/aabb.h" -#include "core/os/memory.h" - -static_assert(sizeof(godot_aabb) == sizeof(AABB), "AABB size mismatch"); - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_aabb_new(godot_aabb *p_self) { - memnew_placement(p_self, AABB); -} - -void GDAPI godot_aabb_new_copy(godot_aabb *r_dest, const godot_aabb *p_src) { - memnew_placement(r_dest, AABB(*(AABB *)p_src)); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/array.cpp b/modules/gdnative/gdnative/array.cpp deleted file mode 100644 index 31063e43c1..0000000000 --- a/modules/gdnative/gdnative/array.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************/ -/* array.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/array.h" - -#include "core/os/memory.h" -#include "core/variant/array.h" - -static_assert(sizeof(godot_array) == sizeof(Array), "Array size mismatch"); - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_array_new(godot_array *p_self) { - memnew_placement(p_self, Array); -} - -void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src) { - memnew_placement(r_dest, Array(*(Array *)p_src)); -} - -void GDAPI godot_array_destroy(godot_array *p_self) { - ((Array *)p_self)->~Array(); -} - -godot_variant GDAPI *godot_array_operator_index(godot_array *p_self, godot_int p_index) { - Array *self = (Array *)p_self; - return (godot_variant *)&self->operator[](p_index); -} - -const godot_variant GDAPI *godot_array_operator_index_const(const godot_array *p_self, godot_int p_index) { - const Array *self = (const Array *)p_self; - return (const godot_variant *)&self->operator[](p_index); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/basis.cpp b/modules/gdnative/gdnative/basis.cpp deleted file mode 100644 index af7f9a2399..0000000000 --- a/modules/gdnative/gdnative/basis.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/*************************************************************************/ -/* basis.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/basis.h" - -#include "core/math/basis.h" - -static_assert(sizeof(godot_basis) == sizeof(Basis), "Basis size mismatch"); - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_basis_new(godot_basis *p_self) { - memnew_placement(p_self, Basis); -} - -void GDAPI godot_basis_new_copy(godot_basis *r_dest, const godot_basis *p_src) { - memnew_placement(r_dest, Basis(*(Basis *)p_src)); -} - -godot_vector3 GDAPI *godot_basis_operator_index(godot_basis *p_self, godot_int p_index) { - Basis *self = (Basis *)p_self; - return (godot_vector3 *)&self->operator[](p_index); -} - -const godot_vector3 GDAPI *godot_basis_operator_index_const(const godot_basis *p_self, godot_int p_index) { - const Basis *self = (const Basis *)p_self; - return (const godot_vector3 *)&self->operator[](p_index); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/callable.cpp b/modules/gdnative/gdnative/callable.cpp deleted file mode 100644 index 7ae1038a13..0000000000 --- a/modules/gdnative/gdnative/callable.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************/ -/* callable.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/callable.h" - -#include "core/variant/callable.h" -#include "core/variant/variant.h" - -static_assert(sizeof(godot_callable) == sizeof(Callable), "Callable size mismatch"); - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_callable_new(godot_callable *p_self) { - memnew_placement(p_self, Callable); -} - -void GDAPI godot_callable_new_copy(godot_callable *r_dest, const godot_callable *p_src) { - memnew_placement(r_dest, Callable(*(Callable *)p_src)); -} - -void GDAPI godot_callable_destroy(godot_callable *p_self) { - Callable *self = (Callable *)p_self; - self->~Callable(); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/color.cpp b/modules/gdnative/gdnative/color.cpp deleted file mode 100644 index 8f13610b2c..0000000000 --- a/modules/gdnative/gdnative/color.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/*************************************************************************/ -/* color.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/color.h" - -#include "core/math/color.h" - -static_assert(sizeof(godot_color) == sizeof(Color), "Color size mismatch"); - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_color_new(godot_color *p_self) { - memnew_placement(p_self, Color); -} - -void GDAPI godot_color_new_copy(godot_color *r_dest, const godot_color *p_src) { - memnew_placement(r_dest, Color(*(Color *)p_src)); -} - -float GDAPI *godot_color_operator_index(godot_color *p_self, godot_int p_index) { - Color *self = (Color *)p_self; - return (float *)&self->operator[](p_index); -} - -const float GDAPI *godot_color_operator_index_const(const godot_color *p_self, godot_int p_index) { - const Color *self = (const Color *)p_self; - return (const float *)&self->operator[](p_index); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/dictionary.cpp b/modules/gdnative/gdnative/dictionary.cpp deleted file mode 100644 index dea01dad43..0000000000 --- a/modules/gdnative/gdnative/dictionary.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************/ -/* dictionary.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/dictionary.h" - -#include "core/variant/dictionary.h" -#include "core/variant/variant.h" - -static_assert(sizeof(godot_dictionary) == sizeof(Dictionary), "Dictionary size mismatch"); - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_dictionary_new(godot_dictionary *p_self) { - memnew_placement(p_self, Dictionary); -} - -void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *p_src) { - memnew_placement(r_dest, Dictionary(*(Dictionary *)p_src)); -} - -void GDAPI godot_dictionary_destroy(godot_dictionary *p_self) { - Dictionary *self = (Dictionary *)p_self; - self->~Dictionary(); -} - -godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_self, const godot_variant *p_key) { - Dictionary *self = (Dictionary *)p_self; - return (godot_variant *)&self->operator[](*((const Variant *)p_key)); -} - -const godot_variant GDAPI *godot_dictionary_operator_index_const(const godot_dictionary *p_self, const godot_variant *p_key) { - const Dictionary *self = (const Dictionary *)p_self; - return (const godot_variant *)&self->operator[](*((const Variant *)p_key)); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp deleted file mode 100644 index 8ba41b3224..0000000000 --- a/modules/gdnative/gdnative/gdnative.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/*************************************************************************/ -/* gdnative.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/gdnative.h" - -#include "core/config/engine.h" -#include "core/core_constants.h" -#include "core/error/error_macros.h" -#include "core/object/class_db.h" -#include "core/os/os.h" -#include "core/variant/variant.h" - -#include "modules/gdnative/gdnative.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_object_destroy(godot_object *p_o) { - memdelete((Object *)p_o); -} - -// Singleton API - -godot_object GDAPI *godot_global_get_singleton(char *p_name) { - return (godot_object *)Engine::get_singleton()->get_singleton_object(String(p_name)); -} // result shouldn't be freed - -// MethodBind API - -godot_method_bind GDAPI *godot_method_bind_get_method(const char *p_classname, const char *p_methodname) { - MethodBind *mb = ClassDB::get_method(StringName(p_classname), StringName(p_methodname)); - // MethodBind *mb = ClassDB::get_method("Node", "get_name"); - return (godot_method_bind *)mb; -} - -void GDAPI godot_method_bind_ptrcall(godot_method_bind *p_method_bind, godot_object *p_instance, const void **p_args, void *p_ret) { - MethodBind *mb = (MethodBind *)p_method_bind; - Object *o = (Object *)p_instance; - mb->ptrcall(o, p_args, p_ret); -} - -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) { - MethodBind *mb = (MethodBind *)p_method_bind; - Object *o = (Object *)p_instance; - const Variant **args = (const Variant **)p_args; - - godot_variant ret; - godot_variant_new_nil(&ret); - - Variant *ret_val = (Variant *)&ret; - - Callable::CallError r_error; - *ret_val = mb->call(o, args, p_arg_count, r_error); - - if (p_call_error) { - p_call_error->error = (godot_variant_call_error_error)r_error.error; - p_call_error->argument = r_error.argument; - p_call_error->expected = (godot_variant_type)r_error.expected; - } - - return ret; -} - -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) { - return (godot_class_constructor)class_info->creation_func; - } - return nullptr; -} - -godot_dictionary GDAPI godot_get_global_constants() { - godot_dictionary constants; - memnew_placement(&constants, Dictionary); - Dictionary *p_constants = (Dictionary *)&constants; - const int constants_count = CoreConstants::get_global_constant_count(); - for (int i = 0; i < constants_count; ++i) { - const char *name = CoreConstants::get_global_constant_name(i); - int value = CoreConstants::get_global_constant_value(i); - (*p_constants)[name] = value; - } - return constants; -} - -// System functions -void GDAPI godot_register_native_call_type(const char *p_call_type, native_call_cb p_callback) { - GDNativeCallRegistry::get_singleton()->register_native_call_type(StringName(p_call_type), p_callback); -} - -void GDAPI *godot_alloc(int p_bytes) { - return memalloc(p_bytes); -} - -void GDAPI *godot_realloc(void *p_ptr, int p_bytes) { - return memrealloc(p_ptr, p_bytes); -} - -void GDAPI godot_free(void *p_ptr) { - memfree(p_ptr); -} - -// Helper print functions. -void GDAPI godot_print_error(const char *p_description, const char *p_function, const char *p_file, int p_line) { - _err_print_error(p_function, p_file, p_line, p_description, false, ERR_HANDLER_ERROR); -} -void GDAPI godot_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line) { - _err_print_error(p_function, p_file, p_line, p_description, false, ERR_HANDLER_WARNING); -} -void GDAPI godot_print_script_error(const char *p_description, const char *p_function, const char *p_file, int p_line) { - _err_print_error(p_function, p_file, p_line, p_description, false, ERR_HANDLER_SCRIPT); -} - -void _gdnative_report_version_mismatch(const godot_object *p_library, const char *p_ext, godot_gdnative_api_version p_want, godot_gdnative_api_version p_have) { - String message = "Error loading GDNative file "; - GDNativeLibrary *library = (GDNativeLibrary *)p_library; - - message += library->get_current_library_path() + ": Extension \"" + p_ext + "\" can't be loaded.\n"; - - Dictionary versions; - versions["have_major"] = p_have.major; - versions["have_minor"] = p_have.minor; - versions["want_major"] = p_want.major; - versions["want_minor"] = p_want.minor; - - message += String("Got version {have_major}.{have_minor} but needs {want_major}.{want_minor}!").format(versions); - - _err_print_error("gdnative_init", library->get_current_library_path().utf8().ptr(), 0, message.utf8().ptr()); -} - -void _gdnative_report_loading_error(const godot_object *p_library, const char *p_what) { - String message = "Error loading GDNative file "; - GDNativeLibrary *library = (GDNativeLibrary *)p_library; - - message += library->get_current_library_path() + ": " + p_what; - - _err_print_error("gdnative_init", library->get_current_library_path().utf8().ptr(), 0, message.utf8().ptr()); -} - -godot_object GDAPI *godot_instance_from_id(uint64_t p_instance_id) { - return (godot_object *)ObjectDB::get_instance(ObjectID(p_instance_id)); -} - -void *godot_get_class_tag(const godot_string_name *p_class) { - StringName class_name = *(StringName *)p_class; - ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(class_name); - return class_info ? class_info->class_ptr : nullptr; -} - -godot_object *godot_object_cast_to(const godot_object *p_object, void *p_class_tag) { - if (!p_object) { - return nullptr; - } - Object *o = (Object *)p_object; - - return o->is_class_ptr(p_class_tag) ? (godot_object *)o : nullptr; -} - -uint64_t GDAPI godot_object_get_instance_id(const godot_object *p_object) { - const Object *o = (const Object *)p_object; - return (uint64_t)o->get_instance_id(); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/node_path.cpp b/modules/gdnative/gdnative/node_path.cpp deleted file mode 100644 index 3db705f550..0000000000 --- a/modules/gdnative/gdnative/node_path.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/*************************************************************************/ -/* node_path.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/node_path.h" - -#include "core/string/node_path.h" - -static_assert(sizeof(godot_node_path) == sizeof(NodePath), "NodePath size mismatch"); - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_node_path_new(godot_node_path *p_self) { - memnew_placement(p_self, NodePath); -} - -void GDAPI godot_node_path_new_copy(godot_node_path *r_dest, const godot_node_path *p_src) { - memnew_placement(r_dest, NodePath(*(NodePath *)p_src)); -} - -void GDAPI godot_node_path_destroy(godot_node_path *p_self) { - NodePath *self = (NodePath *)p_self; - self->~NodePath(); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/packed_arrays.cpp b/modules/gdnative/gdnative/packed_arrays.cpp deleted file mode 100644 index 0c49694e0b..0000000000 --- a/modules/gdnative/gdnative/packed_arrays.cpp +++ /dev/null @@ -1,320 +0,0 @@ -/*************************************************************************/ -/* packed_arrays.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/packed_arrays.h" - -#include "core/variant/variant.h" - -#include "core/math/vector2i.h" -#include "core/math/vector3i.h" - -static_assert(sizeof(godot_packed_byte_array) == sizeof(PackedByteArray), "PackedByteArray size mismatch"); -static_assert(sizeof(godot_packed_int32_array) == sizeof(PackedInt32Array), "PackedInt32Array size mismatch"); -static_assert(sizeof(godot_packed_int64_array) == sizeof(PackedInt64Array), "PackedInt64Array size mismatch"); -static_assert(sizeof(godot_packed_float32_array) == sizeof(PackedFloat32Array), "PackedFloat32Array size mismatch"); -static_assert(sizeof(godot_packed_float64_array) == sizeof(PackedFloat64Array), "PackedFloat64Array size mismatch"); -static_assert(sizeof(godot_packed_string_array) == sizeof(PackedStringArray), "PackedStringArray size mismatch"); -static_assert(sizeof(godot_packed_vector2_array) == sizeof(PackedVector2Array), "PackedVector2Array size mismatch"); -static_assert(sizeof(godot_packed_vector2i_array) == sizeof(Vector<Vector2i>), "Vector<Vector2i> size mismatch"); -static_assert(sizeof(godot_packed_vector3_array) == sizeof(PackedVector3Array), "PackedVector3Array size mismatch"); -static_assert(sizeof(godot_packed_vector3i_array) == sizeof(Vector<Vector3i>), "Vector<Vector3i> size mismatch"); -static_assert(sizeof(godot_packed_color_array) == sizeof(PackedColorArray), "PackedColorArray size mismatch"); - -#ifdef __cplusplus -extern "C" { -#endif - -// byte - -void GDAPI godot_packed_byte_array_new(godot_packed_byte_array *p_self) { - memnew_placement(p_self, PackedByteArray); -} - -void GDAPI godot_packed_byte_array_new_copy(godot_packed_byte_array *r_dest, const godot_packed_byte_array *p_src) { - memnew_placement(r_dest, PackedByteArray(*(PackedByteArray *)p_src)); -} - -void GDAPI godot_packed_byte_array_destroy(godot_packed_byte_array *p_self) { - ((PackedByteArray *)p_self)->~PackedByteArray(); -} - -uint8_t GDAPI *godot_packed_byte_array_operator_index(godot_packed_byte_array *p_self, godot_int p_index) { - PackedByteArray *self = (PackedByteArray *)p_self; - return (uint8_t *)&self->operator[](p_index); -} - -const uint8_t GDAPI *godot_packed_byte_array_operator_index_const(const godot_packed_byte_array *p_self, godot_int p_index) { - const PackedByteArray *self = (const PackedByteArray *)p_self; - return (const uint8_t *)&self->operator[](p_index); -} - -// int32 - -void GDAPI godot_packed_int32_array_new(godot_packed_int32_array *p_self) { - memnew_placement(p_self, PackedInt32Array); -} - -void GDAPI godot_packed_int32_array_new_copy(godot_packed_int32_array *r_dest, const godot_packed_int32_array *p_src) { - memnew_placement(r_dest, PackedInt32Array(*(PackedInt32Array *)p_src)); -} - -void GDAPI godot_packed_int32_array_destroy(godot_packed_int32_array *p_self) { - ((PackedInt32Array *)p_self)->~PackedInt32Array(); -} - -int32_t GDAPI *godot_packed_int32_array_operator_index(godot_packed_int32_array *p_self, godot_int p_index) { - PackedInt32Array *self = (PackedInt32Array *)p_self; - return (int32_t *)&self->operator[](p_index); -} - -const int32_t GDAPI *godot_packed_int32_array_operator_index_const(const godot_packed_int32_array *p_self, godot_int p_index) { - const PackedInt32Array *self = (const PackedInt32Array *)p_self; - return (const int32_t *)&self->operator[](p_index); -} - -// int64 - -void GDAPI godot_packed_int64_array_new(godot_packed_int64_array *p_self) { - memnew_placement(p_self, PackedInt64Array); -} - -void GDAPI godot_packed_int64_array_new_copy(godot_packed_int64_array *r_dest, const godot_packed_int64_array *p_src) { - memnew_placement(r_dest, PackedInt64Array(*(PackedInt64Array *)p_src)); -} - -void GDAPI godot_packed_int64_array_destroy(godot_packed_int64_array *p_self) { - ((PackedInt64Array *)p_self)->~PackedInt64Array(); -} - -int64_t GDAPI *godot_packed_int64_array_operator_index(godot_packed_int64_array *p_self, godot_int p_index) { - PackedInt64Array *self = (PackedInt64Array *)p_self; - return (int64_t *)&self->operator[](p_index); -} - -const int64_t GDAPI *godot_packed_int64_array_operator_index_const(const godot_packed_int64_array *p_self, godot_int p_index) { - const PackedInt64Array *self = (const PackedInt64Array *)p_self; - return (const int64_t *)&self->operator[](p_index); -} - -// float32 - -void GDAPI godot_packed_float32_array_new(godot_packed_float32_array *p_self) { - memnew_placement(p_self, PackedFloat32Array); -} - -void GDAPI godot_packed_float32_array_new_copy(godot_packed_float32_array *r_dest, const godot_packed_float32_array *p_src) { - memnew_placement(r_dest, PackedFloat32Array(*(PackedFloat32Array *)p_src)); -} - -void GDAPI godot_packed_float32_array_destroy(godot_packed_float32_array *p_self) { - ((PackedFloat32Array *)p_self)->~PackedFloat32Array(); -} - -float GDAPI *godot_packed_float32_array_operator_index(godot_packed_float32_array *p_self, godot_int p_index) { - PackedFloat32Array *self = (PackedFloat32Array *)p_self; - return (float *)&self->operator[](p_index); -} - -const float GDAPI *godot_packed_float32_array_operator_index_const(const godot_packed_float32_array *p_self, godot_int p_index) { - const PackedFloat32Array *self = (const PackedFloat32Array *)p_self; - return (const float *)&self->operator[](p_index); -} - -// float64 - -void GDAPI godot_packed_float64_array_new(godot_packed_float64_array *p_self) { - memnew_placement(p_self, PackedFloat64Array); -} - -void GDAPI godot_packed_float64_array_new_copy(godot_packed_float64_array *r_dest, const godot_packed_float64_array *p_src) { - memnew_placement(r_dest, PackedFloat64Array(*(PackedFloat64Array *)p_src)); -} - -void GDAPI godot_packed_float64_array_destroy(godot_packed_float64_array *p_self) { - ((PackedFloat64Array *)p_self)->~PackedFloat64Array(); -} - -double GDAPI *godot_packed_float64_array_operator_index(godot_packed_float64_array *p_self, godot_int p_index) { - PackedFloat64Array *self = (PackedFloat64Array *)p_self; - return (double *)&self->operator[](p_index); -} - -const double GDAPI *godot_packed_float64_array_operator_index_const(const godot_packed_float64_array *p_self, godot_int p_index) { - const PackedFloat64Array *self = (const PackedFloat64Array *)p_self; - return (const double *)&self->operator[](p_index); -} - -// string - -void GDAPI godot_packed_string_array_new(godot_packed_string_array *p_self) { - memnew_placement(p_self, PackedStringArray); -} - -void GDAPI godot_packed_string_array_new_copy(godot_packed_string_array *r_dest, const godot_packed_string_array *p_src) { - memnew_placement(r_dest, PackedStringArray(*(PackedStringArray *)p_src)); -} - -void GDAPI godot_packed_string_array_destroy(godot_packed_string_array *p_self) { - ((PackedStringArray *)p_self)->~PackedStringArray(); -} - -godot_string GDAPI *godot_packed_string_array_operator_index(godot_packed_string_array *p_self, godot_int p_index) { - PackedStringArray *self = (PackedStringArray *)p_self; - return (godot_string *)&self->operator[](p_index); -} - -const godot_string GDAPI *godot_packed_string_array_operator_index_const(const godot_packed_string_array *p_self, godot_int p_index) { - const PackedStringArray *self = (const PackedStringArray *)p_self; - return (const godot_string *)&self->operator[](p_index); -} - -// vector2 - -void GDAPI godot_packed_vector2_array_new(godot_packed_vector2_array *p_self) { - memnew_placement(p_self, PackedVector2Array); -} - -void GDAPI godot_packed_vector2_array_new_copy(godot_packed_vector2_array *r_dest, const godot_packed_vector2_array *p_src) { - memnew_placement(r_dest, PackedVector2Array(*(PackedVector2Array *)p_src)); -} - -void GDAPI godot_packed_vector2_array_destroy(godot_packed_vector2_array *p_self) { - ((PackedVector2Array *)p_self)->~PackedVector2Array(); -} - -godot_vector2 GDAPI *godot_packed_vector2_array_operator_index(godot_packed_vector2_array *p_self, godot_int p_index) { - PackedVector2Array *self = (PackedVector2Array *)p_self; - return (godot_vector2 *)&self->operator[](p_index); -} - -const godot_vector2 GDAPI *godot_packed_vector2_array_operator_index_const(const godot_packed_vector2_array *p_self, godot_int p_index) { - const PackedVector2Array *self = (const PackedVector2Array *)p_self; - return (const godot_vector2 *)&self->operator[](p_index); -} - -// vector2i - -void GDAPI godot_packed_vector2i_array_new(godot_packed_vector2i_array *p_self) { - memnew_placement(p_self, Vector<Vector2i>); -} - -void GDAPI godot_packed_vector2i_array_new_copy(godot_packed_vector2i_array *r_dest, const godot_packed_vector2i_array *p_src) { - memnew_placement(r_dest, Vector<Vector2i>(*(Vector<Vector2i> *)p_src)); -} - -void GDAPI godot_packed_vector2i_array_destroy(godot_packed_vector2i_array *p_self) { - ((Vector<Vector2i> *)p_self)->~Vector(); -} - -godot_vector2i GDAPI *godot_packed_vector2i_array_operator_index(godot_packed_vector2i_array *p_self, godot_int p_index) { - Vector<Vector2i> *self = (Vector<Vector2i> *)p_self; - return (godot_vector2i *)&self->operator[](p_index); -} - -const godot_vector2i GDAPI *godot_packed_vector2i_array_operator_index_const(const godot_packed_vector2i_array *p_self, godot_int p_index) { - const Vector<Vector2i> *self = (const Vector<Vector2i> *)p_self; - return (const godot_vector2i *)&self->operator[](p_index); -} - -// vector3 - -void GDAPI godot_packed_vector3_array_new(godot_packed_vector3_array *p_self) { - memnew_placement(p_self, PackedVector3Array); -} - -void GDAPI godot_packed_vector3_array_new_copy(godot_packed_vector3_array *r_dest, const godot_packed_vector3_array *p_src) { - memnew_placement(r_dest, PackedVector3Array(*(PackedVector3Array *)p_src)); -} - -void GDAPI godot_packed_vector3_array_destroy(godot_packed_vector3_array *p_self) { - ((PackedVector3Array *)p_self)->~PackedVector3Array(); -} - -godot_vector3 GDAPI *godot_packed_vector3_array_operator_index(godot_packed_vector3_array *p_self, godot_int p_index) { - PackedVector3Array *self = (PackedVector3Array *)p_self; - return (godot_vector3 *)&self->operator[](p_index); -} - -const godot_vector3 GDAPI *godot_packed_vector3_array_operator_index_const(const godot_packed_vector3_array *p_self, godot_int p_index) { - const PackedVector3Array *self = (const PackedVector3Array *)p_self; - return (const godot_vector3 *)&self->operator[](p_index); -} - -// vector3i - -void GDAPI godot_packed_vector3i_array_new(godot_packed_vector3i_array *p_self) { - memnew_placement(p_self, Vector<Vector3i>); -} - -void GDAPI godot_packed_vector3i_array_new_copy(godot_packed_vector3i_array *r_dest, const godot_packed_vector3i_array *p_src) { - memnew_placement(r_dest, Vector<Vector3i>(*(Vector<Vector3i> *)p_src)); -} - -void GDAPI godot_packed_vector3i_array_destroy(godot_packed_vector3i_array *p_self) { - ((Vector<Vector3i> *)p_self)->~Vector(); -} - -godot_vector3i GDAPI *godot_packed_vector3i_array_operator_index(godot_packed_vector3i_array *p_self, godot_int p_index) { - Vector<Vector3i> *self = (Vector<Vector3i> *)p_self; - return (godot_vector3i *)&self->operator[](p_index); -} - -const godot_vector3i GDAPI *godot_packed_vector3i_array_operator_index_const(const godot_packed_vector3i_array *p_self, godot_int p_index) { - const Vector<Vector3i> *self = (const Vector<Vector3i> *)p_self; - return (const godot_vector3i *)&self->operator[](p_index); -} - -// color - -void GDAPI godot_packed_color_array_new(godot_packed_color_array *p_self) { - memnew_placement(p_self, PackedColorArray); -} - -void GDAPI godot_packed_color_array_new_copy(godot_packed_color_array *r_dest, const godot_packed_color_array *p_src) { - memnew_placement(r_dest, PackedColorArray(*(PackedColorArray *)p_src)); -} - -void GDAPI godot_packed_color_array_destroy(godot_packed_color_array *p_self) { - ((PackedColorArray *)p_self)->~PackedColorArray(); -} - -godot_color GDAPI *godot_packed_color_array_operator_index(godot_packed_color_array *p_self, godot_int p_index) { - PackedColorArray *self = (PackedColorArray *)p_self; - return (godot_color *)&self->operator[](p_index); -} - -const godot_color GDAPI *godot_packed_color_array_operator_index_const(const godot_packed_color_array *p_self, godot_int p_index) { - const PackedColorArray *self = (const PackedColorArray *)p_self; - return (const godot_color *)&self->operator[](p_index); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/plane.cpp b/modules/gdnative/gdnative/plane.cpp deleted file mode 100644 index 41fa0da5db..0000000000 --- a/modules/gdnative/gdnative/plane.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/*************************************************************************/ -/* plane.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/plane.h" - -#include "core/math/plane.h" -#include "core/os/memory.h" - -static_assert(sizeof(godot_plane) == sizeof(Plane), "Plane size mismatch"); - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_plane_new(godot_plane *p_self) { - memnew_placement(p_self, Plane); -} - -void GDAPI godot_plane_new_copy(godot_plane *r_dest, const godot_plane *p_src) { - memnew_placement(r_dest, Plane(*(Plane *)p_src)); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/quaternion.cpp b/modules/gdnative/gdnative/quaternion.cpp deleted file mode 100644 index b91e47e77e..0000000000 --- a/modules/gdnative/gdnative/quaternion.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/*************************************************************************/ -/* quaternion.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/quaternion.h" - -#include "core/math/quaternion.h" - -static_assert(sizeof(godot_quaternion) == sizeof(Quaternion), "Quaternion size mismatch"); - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_quaternion_new(godot_quaternion *p_self) { - memnew_placement(p_self, Quaternion); -} - -void GDAPI godot_quaternion_new_copy(godot_quaternion *r_dest, const godot_quaternion *p_src) { - memnew_placement(r_dest, Quaternion(*(Quaternion *)p_src)); -} - -godot_real_t GDAPI *godot_quaternion_operator_index(godot_quaternion *p_self, godot_int p_index) { - Quaternion *self = (Quaternion *)p_self; - return (godot_real_t *)&self->operator[](p_index); -} - -const godot_real_t GDAPI *godot_quaternion_operator_index_const(const godot_quaternion *p_self, godot_int p_index) { - const Quaternion *self = (const Quaternion *)p_self; - return (const godot_real_t *)&self->operator[](p_index); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/rect2.cpp b/modules/gdnative/gdnative/rect2.cpp deleted file mode 100644 index 7e0ce76c26..0000000000 --- a/modules/gdnative/gdnative/rect2.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************/ -/* rect2.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/rect2.h" - -#include "core/math/rect2.h" -#include "core/math/rect2i.h" -#include "core/os/memory.h" - -static_assert(sizeof(godot_rect2) == sizeof(Rect2), "Rect2 size mismatch"); -static_assert(sizeof(godot_rect2i) == sizeof(Rect2i), "Rect2i size mismatch"); - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_rect2_new(godot_rect2 *p_self) { - memnew_placement(p_self, Rect2); -} - -void GDAPI godot_rect2_new_copy(godot_rect2 *r_dest, const godot_rect2 *p_src) { - memnew_placement(r_dest, Rect2(*(Rect2 *)p_src)); -} - -void GDAPI godot_rect2i_new(godot_rect2i *p_self) { - memnew_placement(p_self, Rect2i); -} - -void GDAPI godot_rect2i_new_copy(godot_rect2i *r_dest, const godot_rect2i *p_src) { - memnew_placement(r_dest, Rect2i(*(Rect2i *)p_src)); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/rid.cpp b/modules/gdnative/gdnative/rid.cpp deleted file mode 100644 index b40fa7c2c6..0000000000 --- a/modules/gdnative/gdnative/rid.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/*************************************************************************/ -/* rid.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/rid.h" - -#include "core/os/memory.h" -#include "core/templates/rid.h" - -static_assert(sizeof(godot_rid) == sizeof(RID), "RID size mismatch"); - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_rid_new(godot_rid *p_self) { - memnew_placement(p_self, RID); -} - -void GDAPI godot_rid_new_copy(godot_rid *r_dest, const godot_rid *p_src) { - memnew_placement(r_dest, RID(*(RID *)p_src)); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/signal.cpp b/modules/gdnative/gdnative/signal.cpp deleted file mode 100644 index 8293aed439..0000000000 --- a/modules/gdnative/gdnative/signal.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************/ -/* signal.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/signal.h" - -#include "core/variant/callable.h" -#include "core/variant/variant.h" - -static_assert(sizeof(godot_signal) == sizeof(Signal), "Signal size mismatch"); - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_signal_new(godot_signal *p_self) { - memnew_placement(p_self, Signal); -} - -void GDAPI godot_signal_new_copy(godot_signal *r_dest, const godot_signal *p_src) { - memnew_placement(r_dest, Signal(*(Signal *)p_src)); -} - -void GDAPI godot_signal_destroy(godot_signal *p_self) { - Signal *self = (Signal *)p_self; - self->~Signal(); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/string.cpp b/modules/gdnative/gdnative/string.cpp deleted file mode 100644 index 7a5d8c6703..0000000000 --- a/modules/gdnative/gdnative/string.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/*************************************************************************/ -/* string.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/string.h" - -#include "core/string/ustring.h" - -static_assert(sizeof(godot_string) == sizeof(String), "String size mismatch"); -static_assert(sizeof(godot_char_type) == sizeof(char32_t), "char32_t size mismatch"); - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_string_new(godot_string *r_dest) { - String *dest = (String *)r_dest; - memnew_placement(dest, String); -} - -void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src) { - memnew_placement(r_dest, String(*(String *)p_src)); -} - -void GDAPI godot_string_new_with_latin1_chars(godot_string *r_dest, const char *p_contents) { - String *dest = (String *)r_dest; - memnew_placement(dest, String); - *dest = String(p_contents); -} - -void GDAPI godot_string_new_with_utf8_chars(godot_string *r_dest, const char *p_contents) { - String *dest = (String *)r_dest; - memnew_placement(dest, String); - dest->parse_utf8(p_contents); -} - -void GDAPI godot_string_new_with_utf16_chars(godot_string *r_dest, const char16_t *p_contents) { - String *dest = (String *)r_dest; - memnew_placement(dest, String); - dest->parse_utf16(p_contents); -} - -void GDAPI godot_string_new_with_utf32_chars(godot_string *r_dest, const char32_t *p_contents) { - String *dest = (String *)r_dest; - memnew_placement(dest, String); - *dest = String((const char32_t *)p_contents); -} - -void GDAPI godot_string_new_with_wide_chars(godot_string *r_dest, const wchar_t *p_contents) { - String *dest = (String *)r_dest; - if (sizeof(wchar_t) == 2) { - // wchar_t is 16 bit, parse. - memnew_placement(dest, String); - dest->parse_utf16((const char16_t *)p_contents); - } else { - // wchar_t is 32 bit, copy. - memnew_placement(dest, String); - *dest = String((const char32_t *)p_contents); - } -} - -void GDAPI godot_string_new_with_latin1_chars_and_len(godot_string *r_dest, const char *p_contents, const int p_size) { - String *dest = (String *)r_dest; - memnew_placement(dest, String); - *dest = String(p_contents, p_size); -} - -void GDAPI godot_string_new_with_utf8_chars_and_len(godot_string *r_dest, const char *p_contents, const int p_size) { - String *dest = (String *)r_dest; - memnew_placement(dest, String); - dest->parse_utf8(p_contents, p_size); -} - -void GDAPI godot_string_new_with_utf16_chars_and_len(godot_string *r_dest, const char16_t *p_contents, const int p_size) { - String *dest = (String *)r_dest; - memnew_placement(dest, String); - dest->parse_utf16(p_contents, p_size); -} - -void GDAPI godot_string_new_with_utf32_chars_and_len(godot_string *r_dest, const char32_t *p_contents, const int p_size) { - String *dest = (String *)r_dest; - memnew_placement(dest, String); - *dest = String((const char32_t *)p_contents, p_size); -} - -void GDAPI godot_string_new_with_wide_chars_and_len(godot_string *r_dest, const wchar_t *p_contents, const int p_size) { - String *dest = (String *)r_dest; - if (sizeof(wchar_t) == 2) { - // wchar_t is 16 bit, parse. - memnew_placement(dest, String); - dest->parse_utf16((const char16_t *)p_contents, p_size); - } else { - // wchar_t is 32 bit, copy. - memnew_placement(dest, String); - *dest = String((const char32_t *)p_contents, p_size); - } -} - -const char GDAPI *godot_string_to_latin1_chars(const godot_string *p_self) { - String *self = (String *)p_self; - return self->ascii(true).get_data(); -} - -const char GDAPI *godot_string_to_utf8_chars(const godot_string *p_self) { - String *self = (String *)p_self; - return self->utf8().get_data(); -} - -const char16_t GDAPI *godot_string_to_utf16_chars(const godot_string *p_self) { - String *self = (String *)p_self; - return self->utf16().get_data(); -} - -const char32_t GDAPI *godot_string_to_utf32_chars(const godot_string *p_self) { - String *self = (String *)p_self; - return self->get_data(); -} - -const wchar_t GDAPI *godot_string_to_wide_chars(const godot_string *p_self) { - String *self = (String *)p_self; - if (sizeof(wchar_t) == 2) { - return (const wchar_t *)self->utf16().get_data(); - } else { - return (const wchar_t *)self->get_data(); - } -} - -char32_t GDAPI *godot_string_operator_index(godot_string *p_self, godot_int p_index) { - String *self = (String *)p_self; - return self->ptrw(); -} - -const char32_t GDAPI *godot_string_operator_index_const(const godot_string *p_self, godot_int p_index) { - const String *self = (const String *)p_self; - return self->ptr(); -} - -void GDAPI godot_string_destroy(godot_string *p_self) { - String *self = (String *)p_self; - self->~String(); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/string_name.cpp b/modules/gdnative/gdnative/string_name.cpp deleted file mode 100644 index 0bdacd2e5d..0000000000 --- a/modules/gdnative/gdnative/string_name.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************/ -/* string_name.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/string_name.h" - -#include "core/string/string_name.h" - -static_assert(sizeof(godot_string_name) == sizeof(StringName), "StringName size mismatch"); - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_string_name_new(godot_string_name *r_dest) { - StringName *dest = (StringName *)r_dest; - memnew_placement(dest, StringName); -} - -void GDAPI godot_string_name_new_copy(godot_string_name *r_dest, const godot_string_name *p_src) { - memnew_placement(r_dest, StringName(*(StringName *)p_src)); -} - -void GDAPI godot_string_name_new_with_latin1_chars(godot_string_name *r_dest, const char *p_contents) { - StringName *dest = (StringName *)r_dest; - memnew_placement(dest, StringName(p_contents)); -} - -void GDAPI godot_string_name_destroy(godot_string_name *p_self) { - StringName *self = (StringName *)p_self; - self->~StringName(); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/transform2d.cpp b/modules/gdnative/gdnative/transform2d.cpp deleted file mode 100644 index 7dc07024e5..0000000000 --- a/modules/gdnative/gdnative/transform2d.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************/ -/* transform2d.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/transform2d.h" - -#include "core/math/transform_2d.h" -#include "core/os/memory.h" - -static_assert(sizeof(godot_transform2d) == sizeof(Transform2D), "Transform2D size mismatch"); - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_transform2d_new(godot_transform2d *p_self) { - memnew_placement(p_self, Transform2D); -} - -void GDAPI godot_transform2d_new_copy(godot_transform2d *r_dest, const godot_transform2d *p_src) { - memnew_placement(r_dest, Transform2D(*(Transform2D *)p_src)); -} - -godot_vector2 GDAPI *godot_transform2d_operator_index(godot_transform2d *p_self, godot_int p_index) { - Transform2D *self = (Transform2D *)p_self; - return (godot_vector2 *)&self->operator[](p_index); -} - -const godot_vector2 GDAPI *godot_transform2d_operator_index_const(const godot_transform2d *p_self, godot_int p_index) { - const Transform2D *self = (const Transform2D *)p_self; - return (const godot_vector2 *)&self->operator[](p_index); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/transform_3d.cpp b/modules/gdnative/gdnative/transform_3d.cpp deleted file mode 100644 index b47e8e69de..0000000000 --- a/modules/gdnative/gdnative/transform_3d.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************/ -/* transform_3d.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/transform_3d.h" - -#include "core/math/transform_3d.h" - -static_assert(sizeof(godot_transform3d) == sizeof(Transform3D), "Transform3D size mismatch"); - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_transform3d_new(godot_transform3d *p_self) { - memnew_placement(p_self, Transform3D); -} - -void GDAPI godot_transform3d_new_copy(godot_transform3d *r_dest, const godot_transform3d *p_src) { - memnew_placement(r_dest, Transform3D(*(Transform3D *)p_src)); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/variant.cpp b/modules/gdnative/gdnative/variant.cpp deleted file mode 100644 index 42fa77a174..0000000000 --- a/modules/gdnative/gdnative/variant.cpp +++ /dev/null @@ -1,1273 +0,0 @@ -/*************************************************************************/ -/* variant.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/variant.h" - -#include "core/object/ref_counted.h" -#include "core/variant/variant.h" - -#ifdef __cplusplus -extern "C" { -#endif - -static_assert(sizeof(godot_variant) == sizeof(Variant), "Variant size mismatch"); - -// Workaround GCC ICE on armv7hl which was affected GCC 6.0 up to 8.0 (GH-16100). -// It was fixed upstream in 8.1, and a fix was backported to 7.4. -// This can be removed once no supported distro ships with versions older than 7.4. -#if defined(__arm__) && defined(__GNUC__) && !defined(__clang__) && \ - (__GNUC__ == 6 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4) || (__GNUC__ == 8 && __GNUC_MINOR__ < 1)) -#pragma GCC push_options -#pragma GCC optimize("-O0") -#endif - -#if defined(__arm__) && defined(__GNUC__) && !defined(__clang__) && \ - (__GNUC__ == 6 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4) || (__GNUC__ == 8 && __GNUC_MINOR__ < 1)) -#pragma GCC pop_options -#endif - -// Memory - -void GDAPI godot_variant_new_copy(godot_variant *p_dest, const godot_variant *p_src) { - Variant *dest = (Variant *)p_dest; - const Variant *src = (const Variant *)p_src; - memnew_placement(dest, Variant(*src)); -} - -void GDAPI godot_variant_new_nil(godot_variant *r_dest) { - Variant *dest = (Variant *)r_dest; - memnew_placement(dest, Variant); -} - -void GDAPI godot_variant_new_bool(godot_variant *r_dest, const godot_bool p_b) { - Variant *dest = (Variant *)r_dest; - memnew_placement(dest, Variant(p_b)); -} - -void GDAPI godot_variant_new_int(godot_variant *r_dest, const godot_int p_i) { - Variant *dest = (Variant *)r_dest; - memnew_placement(dest, Variant(p_i)); -} - -void GDAPI godot_variant_new_float(godot_variant *r_dest, const godot_float p_r) { - Variant *dest = (Variant *)r_dest; - memnew_placement(dest, Variant(p_r)); -} - -void GDAPI godot_variant_new_string(godot_variant *r_dest, const godot_string *p_s) { - Variant *dest = (Variant *)r_dest; - const String *s = (const String *)p_s; - memnew_placement(dest, Variant(*s)); -} - -void GDAPI godot_variant_new_string_name(godot_variant *r_dest, const godot_string_name *p_s) { - Variant *dest = (Variant *)r_dest; - const StringName *s = (const StringName *)p_s; - memnew_placement(dest, Variant(*s)); -} - -void GDAPI godot_variant_new_vector2(godot_variant *r_dest, const godot_vector2 *p_v2) { - Variant *dest = (Variant *)r_dest; - const Vector2 *v2 = (const Vector2 *)p_v2; - memnew_placement(dest, Variant(*v2)); -} - -void GDAPI godot_variant_new_vector2i(godot_variant *r_dest, const godot_vector2i *p_v2) { - Variant *dest = (Variant *)r_dest; - const Vector2i *v2 = (const Vector2i *)p_v2; - memnew_placement(dest, Variant(*v2)); -} - -void GDAPI godot_variant_new_rect2(godot_variant *r_dest, const godot_rect2 *p_rect2) { - Variant *dest = (Variant *)r_dest; - const Rect2 *rect2 = (const Rect2 *)p_rect2; - memnew_placement(dest, Variant(*rect2)); -} - -void GDAPI godot_variant_new_rect2i(godot_variant *r_dest, const godot_rect2i *p_rect2) { - Variant *dest = (Variant *)r_dest; - const Rect2i *rect2 = (const Rect2i *)p_rect2; - memnew_placement(dest, Variant(*rect2)); -} - -void GDAPI godot_variant_new_vector3(godot_variant *r_dest, const godot_vector3 *p_v3) { - Variant *dest = (Variant *)r_dest; - const Vector3 *v3 = (const Vector3 *)p_v3; - memnew_placement(dest, Variant(*v3)); -} - -void GDAPI godot_variant_new_vector3i(godot_variant *r_dest, const godot_vector3i *p_v3) { - Variant *dest = (Variant *)r_dest; - const Vector3i *v3 = (const Vector3i *)p_v3; - memnew_placement(dest, Variant(*v3)); -} - -void GDAPI godot_variant_new_transform2d(godot_variant *r_dest, const godot_transform2d *p_t2d) { - Variant *dest = (Variant *)r_dest; - const Transform2D *t2d = (const Transform2D *)p_t2d; - memnew_placement(dest, Variant(*t2d)); -} - -void GDAPI godot_variant_new_plane(godot_variant *r_dest, const godot_plane *p_plane) { - Variant *dest = (Variant *)r_dest; - const Plane *plane = (const Plane *)p_plane; - memnew_placement(dest, Variant(*plane)); -} - -void GDAPI godot_variant_new_quaternion(godot_variant *r_dest, const godot_quaternion *p_quaternion) { - Variant *dest = (Variant *)r_dest; - const Quaternion *quaternion = (const Quaternion *)p_quaternion; - memnew_placement(dest, Variant(*quaternion)); -} - -void GDAPI godot_variant_new_aabb(godot_variant *r_dest, const godot_aabb *p_aabb) { - Variant *dest = (Variant *)r_dest; - const AABB *aabb = (const AABB *)p_aabb; - memnew_placement(dest, Variant(*aabb)); -} - -void GDAPI godot_variant_new_basis(godot_variant *r_dest, const godot_basis *p_basis) { - Variant *dest = (Variant *)r_dest; - const Basis *basis = (const Basis *)p_basis; - memnew_placement(dest, Variant(*basis)); -} - -void GDAPI godot_variant_new_transform3d(godot_variant *r_dest, const godot_transform3d *p_trans) { - Variant *dest = (Variant *)r_dest; - const Transform3D *trans = (const Transform3D *)p_trans; - memnew_placement(dest, Variant(*trans)); -} - -void GDAPI godot_variant_new_color(godot_variant *r_dest, const godot_color *p_color) { - Variant *dest = (Variant *)r_dest; - const Color *color = (const Color *)p_color; - memnew_placement(dest, Variant(*color)); -} - -void GDAPI godot_variant_new_node_path(godot_variant *r_dest, const godot_node_path *p_np) { - Variant *dest = (Variant *)r_dest; - const NodePath *np = (const NodePath *)p_np; - memnew_placement(dest, Variant(*np)); -} - -void GDAPI godot_variant_new_rid(godot_variant *r_dest, const godot_rid *p_rid) { - Variant *dest = (Variant *)r_dest; - const RID *rid = (const RID *)p_rid; - memnew_placement(dest, Variant(*rid)); -} - -void GDAPI godot_variant_new_callable(godot_variant *r_dest, const godot_callable *p_cb) { - Variant *dest = (Variant *)r_dest; - const Callable *cb = (const Callable *)p_cb; - memnew_placement(dest, Variant(*cb)); -} - -void GDAPI godot_variant_new_signal(godot_variant *r_dest, const godot_signal *p_signal) { - Variant *dest = (Variant *)r_dest; - const Signal *signal = (const Signal *)p_signal; - memnew_placement(dest, Variant(*signal)); -} - -void GDAPI godot_variant_new_object(godot_variant *r_dest, const godot_object *p_obj) { - Variant *dest = (Variant *)r_dest; - const Object *obj = (const Object *)p_obj; - const RefCounted *ref_counted = Object::cast_to<RefCounted>(obj); - REF ref; - if (ref_counted) { - ref = REF(ref_counted); - } - if (!ref.is_null()) { - memnew_placement(dest, Variant(ref)); - } else { -#if defined(DEBUG_METHODS_ENABLED) - if (ref_counted) { - ERR_PRINT("RefCounted object has 0 refcount in godot_variant_new_object - you lost it somewhere."); - } -#endif - memnew_placement(dest, Variant(obj)); - } -} - -void GDAPI godot_variant_new_dictionary(godot_variant *r_dest, const godot_dictionary *p_dict) { - Variant *dest = (Variant *)r_dest; - const Dictionary *dict = (const Dictionary *)p_dict; - memnew_placement(dest, Variant(*dict)); -} - -void GDAPI godot_variant_new_array(godot_variant *r_dest, const godot_array *p_arr) { - Variant *dest = (Variant *)r_dest; - const Array *arr = (const Array *)p_arr; - memnew_placement(dest, Variant(*arr)); -} - -void GDAPI godot_variant_new_packed_byte_array(godot_variant *r_dest, const godot_packed_byte_array *p_pba) { - Variant *dest = (Variant *)r_dest; - const PackedByteArray *pba = (const PackedByteArray *)p_pba; - memnew_placement(dest, Variant(*pba)); -} - -void GDAPI godot_variant_new_packed_int32_array(godot_variant *r_dest, const godot_packed_int32_array *p_pia) { - Variant *dest = (Variant *)r_dest; - const PackedInt32Array *pia = (const PackedInt32Array *)p_pia; - memnew_placement(dest, Variant(*pia)); -} - -void GDAPI godot_variant_new_packed_int64_array(godot_variant *r_dest, const godot_packed_int64_array *p_pia) { - Variant *dest = (Variant *)r_dest; - const PackedInt64Array *pia = (const PackedInt64Array *)p_pia; - memnew_placement(dest, Variant(*pia)); -} - -void GDAPI godot_variant_new_packed_float32_array(godot_variant *r_dest, const godot_packed_float32_array *p_pra) { - Variant *dest = (Variant *)r_dest; - const PackedFloat32Array *pra = (const PackedFloat32Array *)p_pra; - memnew_placement(dest, Variant(*pra)); -} - -void GDAPI godot_variant_new_packed_float64_array(godot_variant *r_dest, const godot_packed_float64_array *p_pra) { - Variant *dest = (Variant *)r_dest; - const PackedFloat64Array *pra = (const PackedFloat64Array *)p_pra; - memnew_placement(dest, Variant(*pra)); -} - -void GDAPI godot_variant_new_packed_string_array(godot_variant *r_dest, const godot_packed_string_array *p_psa) { - Variant *dest = (Variant *)r_dest; - const PackedStringArray *psa = (const PackedStringArray *)p_psa; - memnew_placement(dest, Variant(*psa)); -} - -void GDAPI godot_variant_new_packed_vector2_array(godot_variant *r_dest, const godot_packed_vector2_array *p_pv2a) { - Variant *dest = (Variant *)r_dest; - const PackedVector2Array *pv2a = (const PackedVector2Array *)p_pv2a; - memnew_placement(dest, Variant(*pv2a)); -} - -void GDAPI godot_variant_new_packed_vector3_array(godot_variant *r_dest, const godot_packed_vector3_array *p_pv3a) { - Variant *dest = (Variant *)r_dest; - const PackedVector3Array *pv3a = (const PackedVector3Array *)p_pv3a; - memnew_placement(dest, Variant(*pv3a)); -} - -void GDAPI godot_variant_new_packed_color_array(godot_variant *r_dest, const godot_packed_color_array *p_pca) { - Variant *dest = (Variant *)r_dest; - const PackedColorArray *pca = (const PackedColorArray *)p_pca; - memnew_placement(dest, Variant(*pca)); -} - -godot_bool GDAPI godot_variant_as_bool(const godot_variant *p_self) { - const Variant *self = (const Variant *)p_self; - return self->operator bool(); -} - -godot_int GDAPI godot_variant_as_int(const godot_variant *p_self) { - const Variant *self = (const Variant *)p_self; - return self->operator int64_t(); -} - -godot_float GDAPI godot_variant_as_float(const godot_variant *p_self) { - const Variant *self = (const Variant *)p_self; - return self->operator double(); -} - -godot_string GDAPI godot_variant_as_string(const godot_variant *p_self) { - godot_string raw_dest; - const Variant *self = (const Variant *)p_self; - String *dest = (String *)&raw_dest; - memnew_placement(dest, String(self->operator String())); // operator = is overloaded by String - return raw_dest; -} - -godot_string_name GDAPI godot_variant_as_string_name(const godot_variant *p_self) { - godot_string_name raw_dest; - const Variant *self = (const Variant *)p_self; - StringName *dest = (StringName *)&raw_dest; - memnew_placement(dest, StringName(self->operator StringName())); // operator = is overloaded by StringName - return raw_dest; -} - -godot_vector2 GDAPI godot_variant_as_vector2(const godot_variant *p_self) { - godot_vector2 raw_dest; - const Variant *self = (const Variant *)p_self; - Vector2 *dest = (Vector2 *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_vector2i GDAPI godot_variant_as_vector2i(const godot_variant *p_self) { - godot_vector2i raw_dest; - const Variant *self = (const Variant *)p_self; - Vector2i *dest = (Vector2i *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_rect2 GDAPI godot_variant_as_rect2(const godot_variant *p_self) { - godot_rect2 raw_dest; - const Variant *self = (const Variant *)p_self; - Rect2 *dest = (Rect2 *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_rect2i GDAPI godot_variant_as_rect2i(const godot_variant *p_self) { - godot_rect2i raw_dest; - const Variant *self = (const Variant *)p_self; - Rect2i *dest = (Rect2i *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_vector3 GDAPI godot_variant_as_vector3(const godot_variant *p_self) { - godot_vector3 raw_dest; - const Variant *self = (const Variant *)p_self; - Vector3 *dest = (Vector3 *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_vector3i GDAPI godot_variant_as_vector3i(const godot_variant *p_self) { - godot_vector3i raw_dest; - const Variant *self = (const Variant *)p_self; - Vector3i *dest = (Vector3i *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_transform2d GDAPI godot_variant_as_transform2d(const godot_variant *p_self) { - godot_transform2d raw_dest; - const Variant *self = (const Variant *)p_self; - Transform2D *dest = (Transform2D *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_plane GDAPI godot_variant_as_plane(const godot_variant *p_self) { - godot_plane raw_dest; - const Variant *self = (const Variant *)p_self; - Plane *dest = (Plane *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_quaternion GDAPI godot_variant_as_quaternion(const godot_variant *p_self) { - godot_quaternion raw_dest; - const Variant *self = (const Variant *)p_self; - Quaternion *dest = (Quaternion *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_aabb GDAPI godot_variant_as_aabb(const godot_variant *p_self) { - godot_aabb raw_dest; - const Variant *self = (const Variant *)p_self; - AABB *dest = (AABB *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_basis GDAPI godot_variant_as_basis(const godot_variant *p_self) { - godot_basis raw_dest; - const Variant *self = (const Variant *)p_self; - Basis *dest = (Basis *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_transform3d GDAPI godot_variant_as_transform3d(const godot_variant *p_self) { - godot_transform3d raw_dest; - const Variant *self = (const Variant *)p_self; - Transform3D *dest = (Transform3D *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_color GDAPI godot_variant_as_color(const godot_variant *p_self) { - godot_color raw_dest; - const Variant *self = (const Variant *)p_self; - Color *dest = (Color *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_node_path GDAPI godot_variant_as_node_path(const godot_variant *p_self) { - godot_node_path raw_dest; - const Variant *self = (const Variant *)p_self; - NodePath *dest = (NodePath *)&raw_dest; - memnew_placement(dest, NodePath(self->operator NodePath())); // operator = is overloaded by NodePath - return raw_dest; -} - -godot_rid GDAPI godot_variant_as_rid(const godot_variant *p_self) { - godot_rid raw_dest; - const Variant *self = (const Variant *)p_self; - RID *dest = (RID *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_callable GDAPI godot_variant_as_callable(const godot_variant *p_self) { - godot_callable raw_dest; - const Variant *self = (const Variant *)p_self; - Callable *dest = (Callable *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_signal GDAPI godot_variant_as_signal(const godot_variant *p_self) { - godot_signal raw_dest; - const Variant *self = (const Variant *)p_self; - Signal *dest = (Signal *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_object GDAPI *godot_variant_as_object(const godot_variant *p_self) { - const Variant *self = (const Variant *)p_self; - Object *dest; - dest = *self; - return (godot_object *)dest; -} - -godot_dictionary GDAPI godot_variant_as_dictionary(const godot_variant *p_self) { - godot_dictionary raw_dest; - const Variant *self = (const Variant *)p_self; - Dictionary *dest = (Dictionary *)&raw_dest; - memnew_placement(dest, Dictionary(self->operator Dictionary())); // operator = is overloaded by Dictionary - return raw_dest; -} - -godot_array GDAPI godot_variant_as_array(const godot_variant *p_self) { - godot_array raw_dest; - const Variant *self = (const Variant *)p_self; - Array *dest = (Array *)&raw_dest; - memnew_placement(dest, Array(self->operator Array())); // operator = is overloaded by Array - return raw_dest; -} - -godot_packed_byte_array GDAPI godot_variant_as_packed_byte_array(const godot_variant *p_self) { - godot_packed_byte_array raw_dest; - const Variant *self = (const Variant *)p_self; - PackedByteArray *dest = (PackedByteArray *)&raw_dest; - memnew_placement(dest, PackedByteArray(self->operator PackedByteArray())); // operator = is overloaded by PackedByteArray - *dest = *self; - return raw_dest; -} - -godot_packed_int32_array GDAPI godot_variant_as_packed_int32_array(const godot_variant *p_self) { - godot_packed_int32_array raw_dest; - const Variant *self = (const Variant *)p_self; - PackedInt32Array *dest = (PackedInt32Array *)&raw_dest; - memnew_placement(dest, PackedInt32Array(self->operator PackedInt32Array())); // operator = is overloaded by PackedInt32Array - *dest = *self; - return raw_dest; -} - -godot_packed_int64_array GDAPI godot_variant_as_packed_int64_array(const godot_variant *p_self) { - godot_packed_int64_array raw_dest; - const Variant *self = (const Variant *)p_self; - PackedInt64Array *dest = (PackedInt64Array *)&raw_dest; - memnew_placement(dest, PackedInt64Array(self->operator PackedInt64Array())); // operator = is overloaded by PackedInt64Array - *dest = *self; - return raw_dest; -} - -godot_packed_float32_array GDAPI godot_variant_as_packed_float32_array(const godot_variant *p_self) { - godot_packed_float32_array raw_dest; - const Variant *self = (const Variant *)p_self; - PackedFloat32Array *dest = (PackedFloat32Array *)&raw_dest; - memnew_placement(dest, PackedFloat32Array(self->operator PackedFloat32Array())); // operator = is overloaded by PackedFloat32Array - *dest = *self; - return raw_dest; -} - -godot_packed_float64_array GDAPI godot_variant_as_packed_float64_array(const godot_variant *p_self) { - godot_packed_float64_array raw_dest; - const Variant *self = (const Variant *)p_self; - PackedFloat64Array *dest = (PackedFloat64Array *)&raw_dest; - memnew_placement(dest, PackedFloat64Array(self->operator PackedFloat64Array())); // operator = is overloaded by PackedFloat64Array - *dest = *self; - return raw_dest; -} - -godot_packed_string_array GDAPI godot_variant_as_packed_string_array(const godot_variant *p_self) { - godot_packed_string_array raw_dest; - const Variant *self = (const Variant *)p_self; - PackedStringArray *dest = (PackedStringArray *)&raw_dest; - memnew_placement(dest, PackedStringArray(self->operator PackedStringArray())); // operator = is overloaded by PackedStringArray - *dest = *self; - return raw_dest; -} - -godot_packed_vector2_array GDAPI godot_variant_as_packed_vector2_array(const godot_variant *p_self) { - godot_packed_vector2_array raw_dest; - const Variant *self = (const Variant *)p_self; - PackedVector2Array *dest = (PackedVector2Array *)&raw_dest; - memnew_placement(dest, PackedVector2Array(self->operator PackedVector2Array())); // operator = is overloaded by PackedVector2Array - *dest = *self; - return raw_dest; -} - -godot_packed_vector3_array GDAPI godot_variant_as_packed_vector3_array(const godot_variant *p_self) { - godot_packed_vector3_array raw_dest; - const Variant *self = (const Variant *)p_self; - PackedVector3Array *dest = (PackedVector3Array *)&raw_dest; - memnew_placement(dest, PackedVector3Array(self->operator PackedVector3Array())); // operator = is overloaded by PackedVector3Array - *dest = *self; - return raw_dest; -} - -godot_packed_color_array GDAPI godot_variant_as_packed_color_array(const godot_variant *p_self) { - godot_packed_color_array raw_dest; - const Variant *self = (const Variant *)p_self; - PackedColorArray *dest = (PackedColorArray *)&raw_dest; - memnew_placement(dest, PackedColorArray(self->operator PackedColorArray())); // operator = is overloaded by PackedColorArray - *dest = *self; - return raw_dest; -} - -void GDAPI godot_variant_destroy(godot_variant *p_self) { - Variant *self = (Variant *)p_self; - self->~Variant(); -} - -// Dynamic interaction. - -void GDAPI godot_variant_call(godot_variant *p_self, const godot_string_name *p_method, const godot_variant **p_args, const godot_int p_argcount, godot_variant *r_return, godot_variant_call_error *r_error) { - Variant *self = (Variant *)p_self; - const StringName *method = (const StringName *)p_method; - const Variant **args = (const Variant **)p_args; - Variant ret; - Callable::CallError error; - self->call(*method, args, p_argcount, ret, error); - memnew_placement(r_return, Variant(ret)); - - if (r_error) { - r_error->error = (godot_variant_call_error_error)error.error; - r_error->argument = error.argument; - r_error->expected = (godot_variant_type)error.expected; - } -} - -void GDAPI godot_variant_call_with_cstring(godot_variant *p_self, const char *p_method, const godot_variant **p_args, const godot_int p_argcount, godot_variant *r_return, godot_variant_call_error *r_error) { - Variant *self = (Variant *)p_self; - const StringName method(p_method); - const Variant **args = (const Variant **)p_args; - Variant ret; - Callable::CallError error; - self->call(method, args, p_argcount, ret, error); - memnew_placement(r_return, Variant(ret)); - - if (r_error) { - r_error->error = (godot_variant_call_error_error)error.error; - r_error->argument = error.argument; - r_error->expected = (godot_variant_type)error.expected; - } -} - -void GDAPI godot_variant_call_static(godot_variant_type p_type, const godot_string_name *p_method, const godot_variant **p_args, const godot_int p_argcount, godot_variant *r_return, godot_variant_call_error *r_error) { - Variant::Type type = (Variant::Type)p_type; - const StringName *method = (const StringName *)p_method; - const Variant **args = (const Variant **)p_args; - Variant ret; - Callable::CallError error; - Variant::call_static(type, *method, args, p_argcount, ret, error); - memnew_placement(r_return, Variant(ret)); - - if (r_error) { - r_error->error = (godot_variant_call_error_error)error.error; - r_error->argument = error.argument; - r_error->expected = (godot_variant_type)error.expected; - } -} - -void GDAPI godot_variant_call_static_with_cstring(godot_variant_type p_type, const char *p_method, const godot_variant **p_args, const godot_int p_argcount, godot_variant *r_return, godot_variant_call_error *r_error) { - Variant::Type type = (Variant::Type)p_type; - const StringName method(p_method); - const Variant **args = (const Variant **)p_args; - Variant ret; - Callable::CallError error; - Variant::call_static(type, method, args, p_argcount, ret, error); - memnew_placement(r_return, Variant(ret)); - - if (r_error) { - r_error->error = (godot_variant_call_error_error)error.error; - r_error->argument = error.argument; - r_error->expected = (godot_variant_type)error.expected; - } -} - -void GDAPI godot_variant_evaluate(godot_variant_operator p_op, const godot_variant *p_a, const godot_variant *p_b, godot_variant *r_return, bool *r_valid) { - Variant::Operator op = (Variant::Operator)p_op; - const Variant *a = (const Variant *)p_a; - const Variant *b = (const Variant *)p_b; - Variant *ret = (Variant *)r_return; - Variant::evaluate(op, *a, *b, *ret, *r_valid); -} - -void GDAPI godot_variant_set(godot_variant *p_self, const godot_variant *p_key, const godot_variant *p_value, bool *r_valid) { - Variant *self = (Variant *)p_self; - const Variant *key = (const Variant *)p_key; - const Variant *value = (const Variant *)p_value; - - self->set(*key, *value, r_valid); -} - -void GDAPI godot_variant_set_named(godot_variant *p_self, const godot_string_name *p_key, const godot_variant *p_value, bool *r_valid) { - Variant *self = (Variant *)p_self; - const StringName *key = (const StringName *)p_key; - const Variant *value = (const Variant *)p_value; - - self->set_named(*key, *value, *r_valid); -} - -void GDAPI godot_variant_set_named_with_cstring(godot_variant *p_self, const char *p_key, const godot_variant *p_value, bool *r_valid) { - Variant *self = (Variant *)p_self; - const StringName key(p_key); - const Variant *value = (const Variant *)p_value; - - self->set_named(key, *value, *r_valid); -} - -void GDAPI godot_variant_set_keyed(godot_variant *p_self, const godot_variant *p_key, const godot_variant *p_value, bool *r_valid) { - Variant *self = (Variant *)p_self; - const Variant *key = (const Variant *)p_key; - const Variant *value = (const Variant *)p_value; - - self->set_keyed(*key, *value, *r_valid); -} - -void GDAPI godot_variant_set_indexed(godot_variant *p_self, godot_int p_index, const godot_variant *p_value, bool *r_valid, bool *r_oob) { - Variant *self = (Variant *)p_self; - const Variant *value = (const Variant *)p_value; - - self->set_indexed(p_index, value, *r_valid, *r_oob); -} - -godot_variant GDAPI godot_variant_get(const godot_variant *p_self, const godot_variant *p_key, bool *r_valid) { - const Variant *self = (const Variant *)p_self; - const Variant *key = (const Variant *)p_key; - Variant ret; - - ret = self->get(*key, r_valid); - godot_variant result; - memnew_placement(&result, Variant(ret)); - return result; -} - -godot_variant GDAPI godot_variant_get_named(const godot_variant *p_self, const godot_string_name *p_key, bool *r_valid) { - const Variant *self = (const Variant *)p_self; - const StringName *key = (const StringName *)p_key; - Variant ret; - - ret = self->get_named(*key, *r_valid); - godot_variant result; - memnew_placement(&result, Variant(ret)); - return result; -} - -godot_variant GDAPI godot_variant_get_named_with_cstring(const godot_variant *p_self, const char *p_key, bool *r_valid) { - const Variant *self = (const Variant *)p_self; - const StringName *key = (const StringName *)p_key; - Variant ret; - - ret = self->get_named(*key, *r_valid); - godot_variant result; - memnew_placement(&result, Variant(ret)); - return result; -} - -godot_variant GDAPI godot_variant_get_keyed(const godot_variant *p_self, const godot_variant *p_key, bool *r_valid) { - const Variant *self = (const Variant *)p_self; - const Variant *key = (const Variant *)p_key; - Variant ret; - - ret = self->get_keyed(*key, *r_valid); - godot_variant result; - memnew_placement(&result, Variant(ret)); - return result; -} - -godot_variant GDAPI godot_variant_get_indexed(const godot_variant *p_self, godot_int p_index, bool *r_valid, bool *r_oob) { - const Variant *self = (const Variant *)p_self; - Variant ret; - - ret = self->get_indexed(p_index, *r_valid, *r_oob); - godot_variant result; - memnew_placement(&result, Variant(ret)); - return result; -} - -/// Iteration. -bool GDAPI godot_variant_iter_init(const godot_variant *p_self, godot_variant *r_iter, bool *r_valid) { - const Variant *self = (const Variant *)p_self; - Variant *iter = (Variant *)r_iter; - - return self->iter_init(*iter, *r_valid); -} - -bool GDAPI godot_variant_iter_next(const godot_variant *p_self, godot_variant *r_iter, bool *r_valid) { - const Variant *self = (const Variant *)p_self; - Variant *iter = (Variant *)r_iter; - - return self->iter_next(*iter, *r_valid); -} - -godot_variant GDAPI godot_variant_iter_get(const godot_variant *p_self, godot_variant *r_iter, bool *r_valid) { - const Variant *self = (const Variant *)p_self; - Variant *iter = (Variant *)r_iter; - - Variant result = self->iter_next(*iter, *r_valid); - godot_variant ret; - memnew_placement(&ret, Variant(result)); - return ret; -} - -/// Variant functions. -godot_bool GDAPI godot_variant_hash_compare(const godot_variant *p_self, const godot_variant *p_other) { - const Variant *self = (const Variant *)p_self; - const Variant *other = (const Variant *)p_other; - return self->hash_compare(*other); -} - -godot_bool GDAPI godot_variant_booleanize(const godot_variant *p_self) { - const Variant *self = (const Variant *)p_self; - return self->booleanize(); -} - -void GDAPI godot_variant_blend(const godot_variant *p_a, const godot_variant *p_b, float p_c, godot_variant *r_dst) { - const Variant *a = (const Variant *)p_a; - const Variant *b = (const Variant *)p_b; - Variant *dst = (Variant *)r_dst; - Variant::blend(*a, *b, p_c, *dst); -} - -void GDAPI godot_variant_interpolate(const godot_variant *p_a, const godot_variant *p_b, float p_c, godot_variant *r_dst) { - const Variant *a = (const Variant *)p_a; - const Variant *b = (const Variant *)p_b; - Variant *dst = (Variant *)r_dst; - Variant::interpolate(*a, *b, p_c, *dst); -} - -godot_variant GDAPI godot_variant_duplicate(const godot_variant *p_self, godot_bool p_deep) { - const Variant *self = (const Variant *)p_self; - Variant result = self->duplicate(p_deep); - godot_variant ret; - memnew_placement(&ret, Variant(result)); - return ret; -} - -godot_string GDAPI godot_variant_stringify(const godot_variant *p_self) { - const Variant *self = (const Variant *)p_self; - String result = *self; - godot_string ret; - memnew_placement(&ret, String(result)); - return ret; -} - -// Discovery API - -/// Operators -godot_validated_operator_evaluator GDAPI godot_variant_get_validated_operator_evaluator(godot_variant_operator p_operator, godot_variant_type p_type_a, godot_variant_type p_type_b) { - return (godot_validated_operator_evaluator)Variant::get_validated_operator_evaluator((Variant::Operator)p_operator, (Variant::Type)p_type_a, (Variant::Type)p_type_b); -} - -godot_ptr_operator_evaluator GDAPI godot_variant_get_ptr_operator_evaluator(godot_variant_operator p_operator, godot_variant_type p_type_a, godot_variant_type p_type_b) { - return (godot_ptr_operator_evaluator)Variant::get_ptr_operator_evaluator((Variant::Operator)p_operator, (Variant::Type)p_type_a, (Variant::Type)p_type_b); -} - -godot_variant_type GDAPI godot_variant_get_operator_return_type(godot_variant_operator p_operator, godot_variant_type p_type_a, godot_variant_type p_type_b) { - return (godot_variant_type)Variant::get_operator_return_type((Variant::Operator)p_operator, (Variant::Type)p_type_a, (Variant::Type)p_type_b); -} - -godot_string GDAPI godot_variant_get_operator_name(godot_variant_operator p_operator) { - String op_name = Variant::get_operator_name((Variant::Operator)p_operator); - godot_string ret; - memnew_placement(&ret, String(op_name)); - return ret; -} - -/// Built-in Methods - -bool GDAPI godot_variant_has_builtin_method(godot_variant_type p_type, const godot_string_name *p_method) { - return Variant::has_builtin_method((Variant::Type)p_type, *((const StringName *)p_method)); -} - -bool GDAPI godot_variant_has_builtin_method_with_cstring(godot_variant_type p_type, const char *p_method) { - return Variant::has_builtin_method((Variant::Type)p_type, StringName(p_method)); -} - -godot_validated_builtin_method GDAPI godot_variant_get_validated_builtin_method(godot_variant_type p_type, const godot_string_name *p_method) { - return (godot_validated_builtin_method)Variant::get_validated_builtin_method((Variant::Type)p_type, *((const StringName *)p_method)); -} - -godot_validated_builtin_method GDAPI godot_variant_get_validated_builtin_method_with_cstring(godot_variant_type p_type, const char *p_method) { - return (godot_validated_builtin_method)Variant::get_validated_builtin_method((Variant::Type)p_type, StringName(p_method)); -} - -godot_ptr_builtin_method GDAPI godot_variant_get_ptr_builtin_method(godot_variant_type p_type, const godot_string_name *p_method) { - return (godot_ptr_builtin_method)Variant::get_ptr_builtin_method((Variant::Type)p_type, *((const StringName *)p_method)); -} - -godot_ptr_builtin_method GDAPI godot_variant_get_ptr_builtin_method_with_cstring(godot_variant_type p_type, const char *p_method) { - return (godot_ptr_builtin_method)Variant::get_ptr_builtin_method((Variant::Type)p_type, StringName(p_method)); -} - -int GDAPI godot_variant_get_builtin_method_argument_count(godot_variant_type p_type, const godot_string_name *p_method) { - return Variant::get_builtin_method_argument_count((Variant::Type)p_type, *((const StringName *)p_method)); -} - -int GDAPI godot_variant_get_builtin_method_argument_count_with_cstring(godot_variant_type p_type, const char *p_method) { - return Variant::get_builtin_method_argument_count((Variant::Type)p_type, StringName(p_method)); -} - -godot_variant_type GDAPI godot_variant_get_builtin_method_argument_type(godot_variant_type p_type, const godot_string_name *p_method, int p_argument) { - return (godot_variant_type)Variant::get_builtin_method_argument_type((Variant::Type)p_type, *((const StringName *)p_method), p_argument); -} - -godot_variant_type GDAPI godot_variant_get_builtin_method_argument_type_with_cstring(godot_variant_type p_type, const char *p_method, int p_argument) { - return (godot_variant_type)Variant::get_builtin_method_argument_type((Variant::Type)p_type, StringName(p_method), p_argument); -} - -godot_string GDAPI godot_variant_get_builtin_method_argument_name(godot_variant_type p_type, const godot_string_name *p_method, int p_argument) { - String name = Variant::get_builtin_method_argument_name((Variant::Type)p_type, *((const StringName *)p_method), p_argument); - return *(godot_string *)&name; -} - -godot_string GDAPI godot_variant_get_builtin_method_argument_name_with_cstring(godot_variant_type p_type, const char *p_method, int p_argument) { - String name = Variant::get_builtin_method_argument_name((Variant::Type)p_type, StringName(p_method), p_argument); - return *(godot_string *)&name; -} - -bool GDAPI godot_variant_has_builtin_method_return_value(godot_variant_type p_type, const godot_string_name *p_method) { - return Variant::has_builtin_method_return_value((Variant::Type)p_type, *((const StringName *)p_method)); -} - -bool GDAPI godot_variant_has_builtin_method_return_value_with_cstring(godot_variant_type p_type, const char *p_method) { - return Variant::has_builtin_method_return_value((Variant::Type)p_type, StringName(p_method)); -} - -godot_variant_type GDAPI godot_variant_get_builtin_method_return_type(godot_variant_type p_type, const godot_string_name *p_method) { - return (godot_variant_type)Variant::get_builtin_method_return_type((Variant::Type)p_type, *((const StringName *)p_method)); -} - -godot_variant_type GDAPI godot_variant_get_builtin_method_return_type_with_cstring(godot_variant_type p_type, const char *p_method) { - return (godot_variant_type)Variant::get_builtin_method_return_type((Variant::Type)p_type, StringName(p_method)); -} - -bool GDAPI godot_variant_is_builtin_method_const(godot_variant_type p_type, const godot_string_name *p_method) { - return Variant::is_builtin_method_const((Variant::Type)p_type, *((const StringName *)p_method)); -} - -bool GDAPI godot_variant_is_builtin_method_const_with_cstring(godot_variant_type p_type, const char *p_method) { - return Variant::is_builtin_method_const((Variant::Type)p_type, StringName(p_method)); -} - -bool GDAPI godot_variant_is_builtin_method_static(godot_variant_type p_type, const godot_string_name *p_method) { - return Variant::is_builtin_method_static((Variant::Type)p_type, *((const StringName *)p_method)); -} - -bool GDAPI godot_variant_is_builtin_method_static_with_cstring(godot_variant_type p_type, const char *p_method) { - return Variant::is_builtin_method_static((Variant::Type)p_type, StringName(p_method)); -} - -bool GDAPI godot_variant_is_builtin_method_vararg(godot_variant_type p_type, const godot_string_name *p_method) { - return Variant::is_builtin_method_vararg((Variant::Type)p_type, *((const StringName *)p_method)); -} - -bool GDAPI godot_variant_is_builtin_method_vararg_with_cstring(godot_variant_type p_type, const char *p_method) { - return Variant::is_builtin_method_vararg((Variant::Type)p_type, StringName(p_method)); -} - -int GDAPI godot_variant_get_builtin_method_count(godot_variant_type p_type) { - return Variant::get_builtin_method_count((Variant::Type)p_type); -} - -void GDAPI godot_variant_get_builtin_method_list(godot_variant_type p_type, godot_string_name *r_list) { - List<StringName> list; - Variant::get_builtin_method_list((Variant::Type)p_type, &list); - int i = 0; - for (const StringName &E : list) { - memnew_placement(&r_list[i], StringName(E)); - } -} - -/// Constructors - -int GDAPI godot_variant_get_constructor_count(godot_variant_type p_type) { - return Variant::get_constructor_count((Variant::Type)p_type); -} - -godot_validated_constructor GDAPI godot_variant_get_validated_constructor(godot_variant_type p_type, int p_constructor) { - return (godot_validated_constructor)Variant::get_validated_constructor((Variant::Type)p_type, p_constructor); -} - -godot_ptr_constructor GDAPI godot_variant_get_ptr_constructor(godot_variant_type p_type, int p_constructor) { - return (godot_ptr_constructor)Variant::get_ptr_constructor((Variant::Type)p_type, p_constructor); -} - -int GDAPI godot_variant_get_constructor_argument_count(godot_variant_type p_type, int p_constructor) { - return Variant::get_constructor_argument_count((Variant::Type)p_type, p_constructor); -} - -godot_variant_type GDAPI godot_variant_get_constructor_argument_type(godot_variant_type p_type, int p_constructor, int p_argument) { - return (godot_variant_type)Variant::get_constructor_argument_type((Variant::Type)p_type, p_constructor, p_argument); -} - -godot_string GDAPI godot_variant_get_constructor_argument_name(godot_variant_type p_type, int p_constructor, int p_argument) { - String name = Variant::get_constructor_argument_name((Variant::Type)p_type, p_constructor, p_argument); - godot_string ret; - memnew_placement(&ret, String(name)); - return ret; -} - -void GDAPI godot_variant_construct(godot_variant_type p_type, godot_variant *p_base, const godot_variant **p_args, int p_argcount, godot_variant_call_error *r_error) { - Variant::construct((Variant::Type)p_type, *((Variant *)p_base), (const Variant **)p_args, p_argcount, *((Callable::CallError *)r_error)); -} - -/// Properties. -godot_variant_type GDAPI godot_variant_get_member_type(godot_variant_type p_type, const godot_string_name *p_member) { - return (godot_variant_type)Variant::get_member_type((Variant::Type)p_type, *((const StringName *)p_member)); -} - -godot_variant_type GDAPI godot_variant_get_member_type_with_cstring(godot_variant_type p_type, const char *p_member) { - return (godot_variant_type)Variant::get_member_type((Variant::Type)p_type, StringName(p_member)); -} - -int GDAPI godot_variant_get_member_count(godot_variant_type p_type) { - return Variant::get_member_count((Variant::Type)p_type); -} - -void GDAPI godot_variant_get_member_list(godot_variant_type p_type, godot_string_name *r_list) { - List<StringName> members; - Variant::get_member_list((Variant::Type)p_type, &members); - int i = 0; - for (const StringName &E : members) { - memnew_placement(&r_list[i++], StringName(E)); - } -} - -godot_validated_setter GDAPI godot_variant_get_validated_setter(godot_variant_type p_type, const godot_string_name *p_member) { - return (godot_validated_setter)Variant::get_member_validated_setter((Variant::Type)p_type, *((const StringName *)p_member)); -} - -godot_validated_setter GDAPI godot_variant_get_validated_setter_with_cstring(godot_variant_type p_type, const char *p_member) { - return (godot_validated_setter)Variant::get_member_validated_setter((Variant::Type)p_type, StringName(p_member)); -} - -godot_validated_getter GDAPI godot_variant_get_validated_getter(godot_variant_type p_type, const godot_string_name *p_member) { - return (godot_validated_getter)Variant::get_member_validated_getter((Variant::Type)p_type, *((const StringName *)p_member)); -} - -godot_validated_getter GDAPI godot_variant_get_validated_getter_with_cstring(godot_variant_type p_type, const char *p_member) { - return (godot_validated_getter)Variant::get_member_validated_getter((Variant::Type)p_type, StringName(p_member)); -} - -godot_ptr_setter GDAPI godot_variant_get_ptr_setter(godot_variant_type p_type, const godot_string_name *p_member) { - return (godot_ptr_setter)Variant::get_member_ptr_setter((Variant::Type)p_type, *((const StringName *)p_member)); -} - -godot_ptr_setter GDAPI godot_variant_get_ptr_setter_with_cstring(godot_variant_type p_type, const char *p_member) { - return (godot_ptr_setter)Variant::get_member_ptr_setter((Variant::Type)p_type, StringName(p_member)); -} - -godot_ptr_getter GDAPI godot_variant_get_ptr_getter(godot_variant_type p_type, const godot_string_name *p_member) { - return (godot_ptr_getter)Variant::get_member_ptr_getter((Variant::Type)p_type, *((const StringName *)p_member)); -} - -godot_ptr_getter GDAPI godot_variant_get_ptr_getter_with_cstring(godot_variant_type p_type, const char *p_member) { - return (godot_ptr_getter)Variant::get_member_ptr_getter((Variant::Type)p_type, StringName(p_member)); -} - -/// Indexing. -bool GDAPI godot_variant_has_indexing(godot_variant_type p_type) { - return Variant::has_indexing((Variant::Type)p_type); -} - -godot_variant_type GDAPI godot_variant_get_indexed_element_type(godot_variant_type p_type) { - return (godot_variant_type)Variant::get_indexed_element_type((Variant::Type)p_type); -} - -godot_validated_indexed_setter GDAPI godot_variant_get_validated_indexed_setter(godot_variant_type p_type) { - return (godot_validated_indexed_setter)Variant::get_member_validated_indexed_setter((Variant::Type)p_type); -} - -godot_validated_indexed_getter GDAPI godot_variant_get_validated_indexed_getter(godot_variant_type p_type) { - return (godot_validated_indexed_getter)Variant::get_member_validated_indexed_getter((Variant::Type)p_type); -} - -godot_ptr_indexed_setter GDAPI godot_variant_get_ptr_indexed_setter(godot_variant_type p_type) { - return (godot_ptr_indexed_setter)Variant::get_member_ptr_indexed_setter((Variant::Type)p_type); -} - -godot_ptr_indexed_getter GDAPI godot_variant_get_ptr_indexed_getter(godot_variant_type p_type) { - return (godot_ptr_indexed_getter)Variant::get_member_ptr_indexed_getter((Variant::Type)p_type); -} - -uint64_t GDAPI godot_variant_get_indexed_size(const godot_variant *p_self) { - const Variant *self = (const Variant *)p_self; - return self->get_indexed_size(); -} - -/// Keying. -bool GDAPI godot_variant_is_keyed(godot_variant_type p_type) { - return Variant::is_keyed((Variant::Type)p_type); -} - -godot_validated_keyed_setter GDAPI godot_variant_get_validated_keyed_setter(godot_variant_type p_type) { - return (godot_validated_keyed_setter)Variant::get_member_validated_keyed_setter((Variant::Type)p_type); -} - -godot_validated_keyed_getter GDAPI godot_variant_get_validated_keyed_getter(godot_variant_type p_type) { - return (godot_validated_keyed_getter)Variant::get_member_validated_keyed_getter((Variant::Type)p_type); -} - -godot_validated_keyed_checker GDAPI godot_variant_get_validated_keyed_checker(godot_variant_type p_type) { - return (godot_validated_keyed_checker)Variant::get_member_validated_keyed_checker((Variant::Type)p_type); -} - -godot_ptr_keyed_setter GDAPI godot_variant_get_ptr_keyed_setter(godot_variant_type p_type) { - return (godot_ptr_keyed_setter)Variant::get_member_ptr_keyed_setter((Variant::Type)p_type); -} - -godot_ptr_keyed_getter GDAPI godot_variant_get_ptr_keyed_getter(godot_variant_type p_type) { - return (godot_ptr_keyed_getter)Variant::get_member_ptr_keyed_getter((Variant::Type)p_type); -} - -godot_ptr_keyed_checker GDAPI godot_variant_get_ptr_keyed_checker(godot_variant_type p_type) { - return (godot_ptr_keyed_checker)Variant::get_member_ptr_keyed_checker((Variant::Type)p_type); -} - -/// Constants. -int GDAPI godot_variant_get_constants_count(godot_variant_type p_type) { - return Variant::get_constants_count_for_type((Variant::Type)p_type); -} - -void GDAPI godot_variant_get_constants_list(godot_variant_type p_type, godot_string_name *r_list) { - List<StringName> constants; - int i = 0; - Variant::get_constants_for_type((Variant::Type)p_type, &constants); - for (const StringName &E : constants) { - memnew_placement(&r_list[i++], StringName(E)); - } -} - -bool GDAPI godot_variant_has_constant(godot_variant_type p_type, const godot_string_name *p_constant) { - return Variant::has_constant((Variant::Type)p_type, *((const StringName *)p_constant)); -} - -bool GDAPI godot_variant_has_constant_with_cstring(godot_variant_type p_type, const char *p_constant) { - return Variant::has_constant((Variant::Type)p_type, StringName(p_constant)); -} - -godot_variant GDAPI godot_variant_get_constant_value(godot_variant_type p_type, const godot_string_name *p_constant) { - Variant constant = Variant::get_constant_value((Variant::Type)p_type, *((const StringName *)p_constant)); - godot_variant ret; - memnew_placement(&ret, Variant(constant)); - return ret; -} - -godot_variant GDAPI godot_variant_get_constant_value_with_cstring(godot_variant_type p_type, const char *p_constant) { - Variant constant = Variant::get_constant_value((Variant::Type)p_type, StringName(p_constant)); - godot_variant ret; - memnew_placement(&ret, Variant(constant)); - return ret; -} - -/// Utilities. -bool GDAPI godot_variant_has_utility_function(const godot_string_name *p_function) { - return Variant::has_utility_function(*((const StringName *)p_function)); -} - -bool GDAPI godot_variant_has_utility_function_with_cstring(const char *p_function) { - return Variant::has_utility_function(StringName(p_function)); -} - -void GDAPI godot_variant_call_utility_function(const godot_string_name *p_function, godot_variant *r_ret, const godot_variant **p_args, int p_argument_count, godot_variant_call_error *r_error) { - const StringName *function = (const StringName *)p_function; - Variant *ret = (Variant *)r_ret; - const Variant **args = (const Variant **)p_args; - Callable::CallError error; - - Variant::call_utility_function(*function, ret, args, p_argument_count, error); - - if (r_error) { - r_error->error = (godot_variant_call_error_error)error.error; - r_error->argument = error.argument; - r_error->expected = (godot_variant_type)error.expected; - } -} - -void GDAPI godot_variant_call_utility_function_with_cstring(const char *p_function, godot_variant *r_ret, const godot_variant **p_args, int p_argument_count, godot_variant_call_error *r_error) { - Variant *ret = (Variant *)r_ret; - const Variant **args = (const Variant **)p_args; - Callable::CallError error; - - Variant::call_utility_function(StringName(p_function), ret, args, p_argument_count, error); - - if (r_error) { - r_error->error = (godot_variant_call_error_error)error.error; - r_error->argument = error.argument; - r_error->expected = (godot_variant_type)error.expected; - } -} - -godot_ptr_utility_function GDAPI godot_variant_get_ptr_utility_function(const godot_string_name *p_function) { - return (godot_ptr_utility_function)Variant::get_ptr_utility_function(*((const StringName *)p_function)); -} - -godot_ptr_utility_function GDAPI godot_variant_get_ptr_utility_function_with_cstring(const char *p_function) { - return (godot_ptr_utility_function)Variant::get_ptr_utility_function(StringName(p_function)); -} - -godot_validated_utility_function GDAPI godot_variant_get_validated_utility_function(const godot_string_name *p_function) { - return (godot_validated_utility_function)Variant::get_validated_utility_function(*((const StringName *)p_function)); -} - -godot_validated_utility_function GDAPI godot_variant_get_validated_utility_function_with_cstring(const char *p_function) { - return (godot_validated_utility_function)Variant::get_validated_utility_function(StringName(p_function)); -} - -godot_variant_utility_function_type GDAPI godot_variant_get_utility_function_type(const godot_string_name *p_function) { - return (godot_variant_utility_function_type)Variant::get_utility_function_type(*((const StringName *)p_function)); -} - -godot_variant_utility_function_type GDAPI godot_variant_get_utility_function_type_with_cstring(const char *p_function) { - return (godot_variant_utility_function_type)Variant::get_utility_function_type(StringName(p_function)); -} - -int GDAPI godot_variant_get_utility_function_argument_count(const godot_string_name *p_function) { - return Variant::get_utility_function_argument_count(*((const StringName *)p_function)); -} - -int GDAPI godot_variant_get_utility_function_argument_count_with_cstring(const char *p_function) { - return Variant::get_utility_function_argument_count(StringName(p_function)); -} - -godot_variant_type GDAPI godot_variant_get_utility_function_argument_type(const godot_string_name *p_function, int p_argument) { - return (godot_variant_type)Variant::get_utility_function_argument_type(*((const StringName *)p_function), p_argument); -} - -godot_variant_type GDAPI godot_variant_get_utility_function_argument_type_with_cstring(const char *p_function, int p_argument) { - return (godot_variant_type)Variant::get_utility_function_argument_type(StringName(p_function), p_argument); -} - -godot_string GDAPI godot_variant_get_utility_function_argument_name(const godot_string_name *p_function, int p_argument) { - String argument_name = Variant::get_utility_function_argument_name(*((const StringName *)p_function), p_argument); - godot_string ret; - memnew_placement(&ret, String(argument_name)); - return ret; -} - -godot_string GDAPI godot_variant_get_utility_function_argument_name_with_cstring(const char *p_function, int p_argument) { - String argument_name = Variant::get_utility_function_argument_name(StringName(p_function), p_argument); - godot_string ret; - memnew_placement(&ret, String(argument_name)); - return ret; -} - -bool GDAPI godot_variant_has_utility_function_return_value(const godot_string_name *p_function) { - return Variant::has_utility_function_return_value(*((const StringName *)p_function)); -} - -bool GDAPI godot_variant_has_utility_function_return_value_with_cstring(const char *p_function) { - return Variant::has_utility_function_return_value(StringName(p_function)); -} - -godot_variant_type GDAPI godot_variant_get_utility_function_return_type(const godot_string_name *p_function) { - return (godot_variant_type)Variant::get_utility_function_return_type(*((const StringName *)p_function)); -} - -godot_variant_type GDAPI godot_variant_get_utility_function_return_type_with_cstring(const char *p_function) { - return (godot_variant_type)Variant::get_utility_function_return_type(StringName(p_function)); -} - -bool GDAPI godot_variant_is_utility_function_vararg(const godot_string_name *p_function) { - return Variant::is_utility_function_vararg(*((const StringName *)p_function)); -} - -bool GDAPI godot_variant_is_utility_function_vararg_with_cstring(const char *p_function) { - return Variant::is_utility_function_vararg(StringName(p_function)); -} - -int GDAPI godot_variant_get_utility_function_count() { - return Variant::get_utility_function_count(); -} - -void GDAPI godot_variant_get_utility_function_list(godot_string_name *r_functions) { - List<StringName> functions; - godot_string_name *func = r_functions; - Variant::get_utility_function_list(&functions); - - for (const StringName &E : functions) { - memnew_placement(func++, StringName(E)); - } -} - -// Introspection. - -godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_self) { - const Variant *self = (const Variant *)p_self; - return (godot_variant_type)self->get_type(); -} - -bool GDAPI godot_variant_has_method(const godot_variant *p_self, const godot_string_name *p_method) { - const Variant *self = (const Variant *)p_self; - const StringName *method = (const StringName *)p_method; - return self->has_method(*method); -} - -bool GDAPI godot_variant_has_member(godot_variant_type p_type, const godot_string_name *p_member) { - return Variant::has_member((Variant::Type)p_type, *((const StringName *)p_member)); -} - -bool GDAPI godot_variant_has_key(const godot_variant *p_self, const godot_variant *p_key, bool *r_valid) { - const Variant *self = (const Variant *)p_self; - const Variant *key = (const Variant *)p_key; - return self->has_key(*key, *r_valid); -} - -godot_string GDAPI godot_variant_get_type_name(godot_variant_type p_type) { - String name = Variant::get_type_name((Variant::Type)p_type); - godot_string ret; - memnew_placement(&ret, String(name)); - return ret; -} - -bool GDAPI godot_variant_can_convert(godot_variant_type p_from, godot_variant_type p_to) { - return Variant::can_convert((Variant::Type)p_from, (Variant::Type)p_to); -} - -bool GDAPI godot_variant_can_convert_strict(godot_variant_type p_from, godot_variant_type p_to) { - return Variant::can_convert_strict((Variant::Type)p_from, (Variant::Type)p_to); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/vector2.cpp b/modules/gdnative/gdnative/vector2.cpp deleted file mode 100644 index a8d4281d25..0000000000 --- a/modules/gdnative/gdnative/vector2.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/*************************************************************************/ -/* vector2.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/vector2.h" - -#include "core/math/vector2.h" -#include "core/math/vector2i.h" -#include "core/os/memory.h" - -static_assert(sizeof(godot_vector2) == sizeof(Vector2), "Vector2 size mismatch"); -static_assert(sizeof(godot_vector2i) == sizeof(Vector2i), "Vector2i size mismatch"); - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_vector2_new(godot_vector2 *p_self) { - memnew_placement(p_self, Vector2); -} - -void GDAPI godot_vector2_new_copy(godot_vector2 *r_dest, const godot_vector2 *p_src) { - memnew_placement(r_dest, Vector2(*(Vector2 *)p_src)); -} - -void GDAPI godot_vector2i_new(godot_vector2i *p_self) { - memnew_placement(p_self, Vector2i); -} - -void GDAPI godot_vector2i_new_copy(godot_vector2i *r_dest, const godot_vector2i *p_src) { - memnew_placement(r_dest, Vector2i(*(Vector2i *)p_src)); -} - -godot_real_t GDAPI *godot_vector2_operator_index(godot_vector2 *p_self, godot_int p_index) { - Vector2 *self = (Vector2 *)p_self; - return (godot_real_t *)&self->operator[](p_index); -} - -const godot_real_t GDAPI *godot_vector2_operator_index_const(const godot_vector2 *p_self, godot_int p_index) { - const Vector2 *self = (const Vector2 *)p_self; - return (const godot_real_t *)&self->operator[](p_index); -} - -int32_t GDAPI *godot_vector2i_operator_index(godot_vector2i *p_self, godot_int p_index) { - Vector2i *self = (Vector2i *)p_self; - return (int32_t *)&self->operator[](p_index); -} - -const int32_t GDAPI *godot_vector2i_operator_index_const(const godot_vector2i *p_self, godot_int p_index) { - const Vector2i *self = (const Vector2i *)p_self; - return (const int32_t *)&self->operator[](p_index); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/vector3.cpp b/modules/gdnative/gdnative/vector3.cpp deleted file mode 100644 index 37c88c3cca..0000000000 --- a/modules/gdnative/gdnative/vector3.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/*************************************************************************/ -/* vector3.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "gdnative/vector3.h" - -#include "core/math/vector3.h" -#include "core/math/vector3i.h" -#include "core/os/memory.h" - -static_assert(sizeof(godot_vector3) == sizeof(Vector3), "Vector3 size mismatch"); -static_assert(sizeof(godot_vector3i) == sizeof(Vector3i), "Vector3i size mismatch"); - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_vector3_new(godot_vector3 *p_self) { - memnew_placement(p_self, Vector3); -} - -void GDAPI godot_vector3_new_copy(godot_vector3 *r_dest, const godot_vector3 *p_src) { - memnew_placement(r_dest, Vector3(*(Vector3 *)p_src)); -} - -void GDAPI godot_vector3i_new(godot_vector3i *p_self) { - memnew_placement(p_self, Vector3i); -} - -void GDAPI godot_vector3i_new_copy(godot_vector3i *r_dest, const godot_vector3i *p_src) { - memnew_placement(r_dest, Vector3i(*(Vector3i *)p_src)); -} - -godot_real_t GDAPI *godot_vector3_operator_index(godot_vector3 *p_self, godot_int p_index) { - Vector3 *self = (Vector3 *)p_self; - return (godot_real_t *)&self->operator[](p_index); -} - -const godot_real_t GDAPI *godot_vector3_operator_index_const(const godot_vector3 *p_self, godot_int p_index) { - const Vector3 *self = (const Vector3 *)p_self; - return (const godot_real_t *)&self->operator[](p_index); -} - -int32_t GDAPI *godot_vector3i_operator_index(godot_vector3i *p_self, godot_int p_index) { - Vector3i *self = (Vector3i *)p_self; - return (int32_t *)&self->operator[](p_index); -} - -const int32_t GDAPI *godot_vector3i_operator_index_const(const godot_vector3i *p_self, godot_int p_index) { - const Vector3i *self = (const Vector3i *)p_self; - return (const int32_t *)&self->operator[](p_index); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json deleted file mode 100644 index cf1c7dc01f..0000000000 --- a/modules/gdnative/gdnative_api.json +++ /dev/null @@ -1,5108 +0,0 @@ -{ - "core": { - "type": "CORE", - "version": { - "major": 4, - "minor": 0 - }, - "next": null, - "api": [ - { - "name": "godot_object_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_object *", - "p_o" - ] - ] - }, - { - "name": "godot_global_get_singleton", - "return_type": "godot_object *", - "arguments": [ - [ - "char *", - "p_name" - ] - ] - }, - { - "name": "godot_method_bind_get_method", - "return_type": "godot_method_bind *", - "arguments": [ - [ - "const char *", - "p_classname" - ], - [ - "const char *", - "p_methodname" - ] - ] - }, - { - "name": "godot_method_bind_ptrcall", - "return_type": "void", - "arguments": [ - [ - "godot_method_bind *", - "p_method_bind" - ], - [ - "godot_object *", - "p_instance" - ], - [ - "const void **", - "p_args" - ], - [ - "void *", - "p_ret" - ] - ] - }, - { - "name": "godot_method_bind_call", - "return_type": "godot_variant", - "arguments": [ - [ - "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" - ] - ] - }, - { - "name": "godot_get_class_constructor", - "return_type": "godot_class_constructor", - "arguments": [ - [ - "const char *", - "p_classname" - ] - ] - }, - { - "name": "godot_get_global_constants", - "return_type": "godot_dictionary", - "arguments": [] - }, - { - "name": "godot_register_native_call_type", - "return_type": "void", - "arguments": [ - [ - "const char *", - "call_type" - ], - [ - "native_call_cb", - "p_callback" - ] - ] - }, - { - "name": "godot_alloc", - "return_type": "void *", - "arguments": [ - [ - "int", - "p_bytes" - ] - ] - }, - { - "name": "godot_realloc", - "return_type": "void *", - "arguments": [ - [ - "void *", - "p_ptr" - ], - [ - "int", - "p_bytes" - ] - ] - }, - { - "name": "godot_free", - "return_type": "void", - "arguments": [ - [ - "void *", - "p_ptr" - ] - ] - }, - { - "name": "godot_print_error", - "return_type": "void", - "arguments": [ - [ - "const char *", - "p_description" - ], - [ - "const char *", - "p_function" - ], - [ - "const char *", - "p_file" - ], - [ - "int", - "p_line" - ] - ] - }, - { - "name": "godot_print_warning", - "return_type": "void", - "arguments": [ - [ - "const char *", - "p_description" - ], - [ - "const char *", - "p_function" - ], - [ - "const char *", - "p_file" - ], - [ - "int", - "p_line" - ] - ] - }, - { - "name": "godot_print_script_error", - "return_type": "void", - "arguments": [ - [ - "const char *", - "p_description" - ], - [ - "const char *", - "p_function" - ], - [ - "const char *", - "p_file" - ], - [ - "int", - "p_line" - ] - ] - }, - { - "name": "godot_get_class_tag", - "return_type": "void *", - "arguments": [ - [ - "const godot_string_name *", - "p_class" - ] - ] - }, - { - "name": "godot_object_cast_to", - "return_type": "godot_object *", - "arguments": [ - [ - "const godot_object *", - "p_object" - ], - [ - "void *", - "p_class_tag" - ] - ] - }, - { - "name": "godot_instance_from_id", - "return_type": "godot_object *", - "arguments": [ - [ - "uint64_t", - "p_instance_id" - ] - ] - }, - { - "name": "godot_object_get_instance_id", - "return_type": "uint64_t", - "arguments": [ - [ - "const godot_object *", - "p_object" - ] - ] - }, - { - "name": "godot_variant_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_variant *", - "p_src" - ] - ] - }, - { - "name": "godot_variant_new_nil", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ] - ] - }, - { - "name": "godot_variant_new_bool", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_bool", - "p_b" - ] - ] - }, - { - "name": "godot_variant_new_int", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const int64_t", - "p_i" - ] - ] - }, - { - "name": "godot_variant_new_float", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const double", - "p_f" - ] - ] - }, - { - "name": "godot_variant_new_string", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_string *", - "p_s" - ] - ] - }, - { - "name": "godot_variant_new_string_name", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_string_name *", - "p_s" - ] - ] - }, - { - "name": "godot_variant_new_vector2", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_vector2 *", - "p_v2" - ] - ] - }, - { - "name": "godot_variant_new_vector2i", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_vector2i *", - "p_v2" - ] - ] - }, - { - "name": "godot_variant_new_rect2", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_rect2 *", - "p_rect2" - ] - ] - }, - { - "name": "godot_variant_new_rect2i", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_rect2i *", - "p_rect2" - ] - ] - }, - { - "name": "godot_variant_new_vector3", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_vector3 *", - "p_v3" - ] - ] - }, - { - "name": "godot_variant_new_vector3i", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_vector3i *", - "p_v3" - ] - ] - }, - { - "name": "godot_variant_new_transform2d", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_transform2d *", - "p_t2d" - ] - ] - }, - { - "name": "godot_variant_new_plane", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_plane *", - "p_plane" - ] - ] - }, - { - "name": "godot_variant_new_quaternion", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_quaternion *", - "p_quaternion" - ] - ] - }, - { - "name": "godot_variant_new_aabb", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_aabb *", - "p_aabb" - ] - ] - }, - { - "name": "godot_variant_new_basis", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_basis *", - "p_basis" - ] - ] - }, - { - "name": "godot_variant_new_transform3d", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_transform3d *", - "p_trans" - ] - ] - }, - { - "name": "godot_variant_new_color", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_color *", - "p_color" - ] - ] - }, - { - "name": "godot_variant_new_node_path", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_node_path *", - "p_np" - ] - ] - }, - { - "name": "godot_variant_new_rid", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_rid *", - "p_rid" - ] - ] - }, - { - "name": "godot_variant_new_object", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_object *", - "p_obj" - ] - ] - }, - { - "name": "godot_variant_new_callable", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_callable *", - "p_cb" - ] - ] - }, - { - "name": "godot_variant_new_signal", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_signal *", - "p_signal" - ] - ] - }, - { - "name": "godot_variant_new_dictionary", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_dictionary *", - "p_dict" - ] - ] - }, - { - "name": "godot_variant_new_array", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_array *", - "p_arr" - ] - ] - }, - { - "name": "godot_variant_new_packed_byte_array", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_packed_byte_array *", - "p_pba" - ] - ] - }, - { - "name": "godot_variant_new_packed_int32_array", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_packed_int32_array *", - "p_pia" - ] - ] - }, - { - "name": "godot_variant_new_packed_int64_array", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_packed_int64_array *", - "p_pia" - ] - ] - }, - { - "name": "godot_variant_new_packed_float32_array", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_packed_float32_array *", - "p_pra" - ] - ] - }, - { - "name": "godot_variant_new_packed_float64_array", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_packed_float64_array *", - "p_pra" - ] - ] - }, - { - "name": "godot_variant_new_packed_string_array", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_packed_string_array *", - "p_psa" - ] - ] - }, - { - "name": "godot_variant_new_packed_vector2_array", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_packed_vector2_array *", - "p_pv2a" - ] - ] - }, - { - "name": "godot_variant_new_packed_vector3_array", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_packed_vector3_array *", - "p_pv3a" - ] - ] - }, - { - "name": "godot_variant_new_packed_color_array", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "r_dest" - ], - [ - "const godot_packed_color_array *", - "p_pca" - ] - ] - }, - { - "name": "godot_variant_as_bool", - "return_type": "godot_bool", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_int", - "return_type": "int64_t", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_float", - "return_type": "double", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_string", - "return_type": "godot_string", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_string_name", - "return_type": "godot_string_name", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_vector2", - "return_type": "godot_vector2", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_vector2i", - "return_type": "godot_vector2i", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_rect2", - "return_type": "godot_rect2", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_rect2i", - "return_type": "godot_rect2i", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_vector3", - "return_type": "godot_vector3", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_vector3i", - "return_type": "godot_vector3i", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_transform2d", - "return_type": "godot_transform2d", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_plane", - "return_type": "godot_plane", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_quaternion", - "return_type": "godot_quaternion", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_aabb", - "return_type": "godot_aabb", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_basis", - "return_type": "godot_basis", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_transform3d", - "return_type": "godot_transform3d", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_color", - "return_type": "godot_color", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_node_path", - "return_type": "godot_node_path", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_rid", - "return_type": "godot_rid", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_object", - "return_type": "godot_object *", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_callable", - "return_type": "godot_callable", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_signal", - "return_type": "godot_signal", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_dictionary", - "return_type": "godot_dictionary", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_array", - "return_type": "godot_array", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_packed_byte_array", - "return_type": "godot_packed_byte_array", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_packed_int32_array", - "return_type": "godot_packed_int32_array", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_packed_int64_array", - "return_type": "godot_packed_int64_array", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_packed_float32_array", - "return_type": "godot_packed_float32_array", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_packed_float64_array", - "return_type": "godot_packed_float64_array", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_packed_string_array", - "return_type": "godot_packed_string_array", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_packed_vector2_array", - "return_type": "godot_packed_vector2_array", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_packed_vector3_array", - "return_type": "godot_packed_vector3_array", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_as_packed_color_array", - "return_type": "godot_packed_color_array", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_call", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "p_self" - ], - [ - "const godot_string_name *", - "p_method" - ], - [ - "const godot_variant **", - "p_args" - ], - [ - "const godot_int", - "p_argument_count" - ], - [ - "godot_variant *", - "r_return" - ], - [ - "godot_variant_call_error *", - "r_error" - ] - ] - }, - { - "name": "godot_variant_call_with_cstring", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "p_self" - ], - [ - "const char *", - "p_method" - ], - [ - "const godot_variant **", - "p_args" - ], - [ - "const godot_int", - "p_argument_count" - ], - [ - "godot_variant *", - "r_return" - ], - [ - "godot_variant_call_error *", - "r_error" - ] - ] - }, - { - "name": "godot_variant_evaluate", - "return_type": "void", - "arguments": [ - [ - "godot_variant_operator", - "p_op" - ], - [ - "const godot_variant *", - "p_a" - ], - [ - "const godot_variant *", - "p_b" - ], - [ - "godot_variant *", - "r_return" - ], - [ - "bool *", - "r_valid" - ] - ] - }, - { - "name": "godot_variant_set", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "p_self" - ], - [ - "const godot_variant *", - "p_key" - ], - [ - "const godot_variant *", - "p_value" - ], - [ - "bool *", - "r_valid" - ] - ] - }, - { - "name": "godot_variant_set_named", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "p_self" - ], - [ - "const godot_string_name *", - "p_key" - ], - [ - "const godot_variant *", - "p_value" - ], - [ - "bool *", - "r_valid" - ] - ] - }, - { - "name": "godot_variant_set_named_with_cstring", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "p_self" - ], - [ - "const char *", - "p_key" - ], - [ - "const godot_variant *", - "p_value" - ], - [ - "bool *", - "r_valid" - ] - ] - }, - { - "name": "godot_variant_set_keyed", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "p_self" - ], - [ - "const godot_variant *", - "p_key" - ], - [ - "const godot_variant *", - "p_value" - ], - [ - "bool *", - "r_valid" - ] - ] - }, - { - "name": "godot_variant_set_indexed", - "return_type": "void", - "arguments": [ - [ - "godot_variant *", - "p_self" - ], - [ - "godot_int", - "p_index" - ], - [ - "const godot_variant *", - "p_value" - ], - [ - "bool *", - "r_valid" - ], - [ - "bool *", - "r_oob" - ] - ] - }, - { - "name": "godot_variant_get", - "return_type": "godot_variant", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ], - [ - "const godot_variant *", - "p_key" - ], - [ - "bool *", - "r_valid" - ] - ] - }, - { - "name": "godot_variant_get_named", - "return_type": "godot_variant", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ], - [ - "const godot_string_name *", - "p_key" - ], - [ - "bool *", - "r_valid" - ] - ] - }, - { - "name": "godot_variant_get_named_with_cstring", - "return_type": "godot_variant", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ], - [ - "const char *", - "p_key" - ], - [ - "bool *", - "r_valid" - ] - ] - }, - { - "name": "godot_variant_get_keyed", - "return_type": "godot_variant", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ], - [ - "const godot_variant *", - "p_key" - ], - [ - "bool *", - "r_valid" - ] - ] - }, - { - "name": "godot_variant_get_indexed", - "return_type": "godot_variant", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ], - [ - "godot_int", - "p_index" - ], - [ - "bool *", - "r_valid" - ], - [ - "bool *", - "r_oob" - ] - ] - }, - { - "name": "godot_variant_iter_init", - "return_type": "bool", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ], - [ - "godot_variant *", - "r_iter" - ], - [ - "bool *", - "r_valid" - ] - ] - }, - { - "name": "godot_variant_iter_next", - "return_type": "bool", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ], - [ - "godot_variant *", - "r_iter" - ], - [ - "bool *", - "r_valid" - ] - ] - }, - { - "name": "godot_variant_iter_get", - "return_type": "godot_variant", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ], - [ - "godot_variant *", - "r_iter" - ], - [ - "bool *", - "r_valid" - ] - ] - }, - { - "name": "godot_variant_hash_compare", - "return_type": "godot_bool", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ], - [ - "const godot_variant *", - "p_other" - ] - ] - }, - { - "name": "godot_variant_booleanize", - "return_type": "godot_bool", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_blend", - "return_type": "void", - "arguments": [ - [ - "const godot_variant *", - "p_a" - ], - [ - "const godot_variant *", - "p_b" - ], - [ - "float", - "p_c" - ], - [ - "godot_variant *", - "r_dst" - ] - ] - }, - { - "name": "godot_variant_interpolate", - "return_type": "void", - "arguments": [ - [ - "const godot_variant *", - "p_a" - ], - [ - "const godot_variant *", - "p_b" - ], - [ - "float", - "p_c" - ], - [ - "godot_variant *", - "r_dst" - ] - ] - }, - { - "name": "godot_variant_duplicate", - "return_type": "godot_variant", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ], - [ - "godot_bool", - "p_deep" - ] - ] - }, - { - "name": "godot_variant_stringify", - "return_type": "godot_string", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_get_validated_operator_evaluator", - "return_type": "godot_validated_operator_evaluator", - "arguments": [ - [ - "godot_variant_operator", - "p_operator" - ], - [ - "godot_variant_type", - "p_type_a" - ], - [ - "godot_variant_type", - "p_type_b" - ] - ] - }, - { - "name": "godot_variant_get_ptr_operator_evaluator", - "return_type": "godot_ptr_operator_evaluator", - "arguments": [ - [ - "godot_variant_operator", - "p_operator" - ], - [ - "godot_variant_type", - "p_type_a" - ], - [ - "godot_variant_type", - "p_type_b" - ] - ] - }, - { - "name": "godot_variant_get_operator_return_type", - "return_type": "godot_variant_type", - "arguments": [ - [ - "godot_variant_operator", - "p_operator" - ], - [ - "godot_variant_type", - "p_type_a" - ], - [ - "godot_variant_type", - "p_type_b" - ] - ] - }, - { - "name": "godot_variant_get_operator_name", - "return_type": "godot_string", - "arguments": [ - [ - "godot_variant_operator", - "p_operator" - ] - ] - }, - { - "name": "godot_variant_has_builtin_method", - "return_type": "bool", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const godot_string_name *", - "p_method" - ] - ] - }, - { - "name": "godot_variant_has_builtin_method_with_cstring", - "return_type": "bool", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const char *", - "p_method" - ] - ] - }, - { - "name": "godot_variant_get_validated_builtin_method", - "return_type": "godot_validated_builtin_method", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const godot_string_name *", - "p_method" - ] - ] - }, - { - "name": "godot_variant_get_validated_builtin_method_with_cstring", - "return_type": "godot_validated_builtin_method", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const char *", - "p_method" - ] - ] - }, - { - "name": "godot_variant_get_ptr_builtin_method", - "return_type": "godot_ptr_builtin_method", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const godot_string_name *", - "p_method" - ] - ] - }, - { - "name": "godot_variant_get_ptr_builtin_method_with_cstring", - "return_type": "godot_ptr_builtin_method", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const char *", - "p_method" - ] - ] - }, - { - "name": "godot_variant_get_builtin_method_argument_count", - "return_type": "int", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const godot_string_name *", - "p_method" - ] - ] - }, - { - "name": "godot_variant_get_builtin_method_argument_count_with_cstring", - "return_type": "int", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const char *", - "p_method" - ] - ] - }, - { - "name": "godot_variant_get_builtin_method_argument_type", - "return_type": "godot_variant_type", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const godot_string_name *", - "p_method" - ], - [ - "int", - "p_argument" - ] - ] - }, - { - "name": "godot_variant_get_builtin_method_argument_type_with_cstring", - "return_type": "godot_variant_type", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const char *", - "p_method" - ], - [ - "int", - "p_argument" - ] - ] - }, - { - "name": "godot_variant_get_builtin_method_argument_name", - "return_type": "godot_string", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const godot_string_name *", - "p_method" - ], - [ - "int", - "p_argument" - ] - ] - }, - { - "name": "godot_variant_get_builtin_method_argument_name_with_cstring", - "return_type": "godot_string", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const char *", - "p_method" - ], - [ - "int", - "p_argument" - ] - ] - }, - { - "name": "godot_variant_has_builtin_method_return_value", - "return_type": "bool", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const godot_string_name *", - "p_method" - ] - ] - }, - { - "name": "godot_variant_has_builtin_method_return_value_with_cstring", - "return_type": "bool", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const char *", - "p_method" - ] - ] - }, - { - "name": "godot_variant_get_builtin_method_return_type", - "return_type": "godot_variant_type", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const godot_string_name *", - "p_method" - ] - ] - }, - { - "name": "godot_variant_get_builtin_method_return_type_with_cstring", - "return_type": "godot_variant_type", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const char *", - "p_method" - ] - ] - }, - { - "name": "godot_variant_is_builtin_method_const", - "return_type": "bool", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const godot_string_name *", - "p_method" - ] - ] - }, - { - "name": "godot_variant_is_builtin_method_const_with_cstring", - "return_type": "bool", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const char *", - "p_method" - ] - ] - }, - { - "name": "godot_variant_is_builtin_method_static", - "return_type": "bool", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const godot_string_name *", - "p_method" - ] - ] - }, - { - "name": "godot_variant_is_builtin_method_static_with_cstring", - "return_type": "bool", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const char *", - "p_method" - ] - ] - }, - { - "name": "godot_variant_is_builtin_method_vararg", - "return_type": "bool", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const godot_string_name *", - "p_method" - ] - ] - }, - { - "name": "godot_variant_is_builtin_method_vararg_with_cstring", - "return_type": "bool", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const char *", - "p_method" - ] - ] - }, - { - "name": "godot_variant_get_builtin_method_count", - "return_type": "int", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ] - ] - }, - { - "name": "godot_variant_get_builtin_method_list", - "return_type": "void", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "godot_string_name *", - "r_list" - ] - ] - }, - { - "name": "godot_variant_get_constructor_count", - "return_type": "int", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ] - ] - }, - { - "name": "godot_variant_get_validated_constructor", - "return_type": "godot_validated_constructor", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "int", - "p_constructor" - ] - ] - }, - { - "name": "godot_variant_get_ptr_constructor", - "return_type": "godot_ptr_constructor", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "int", - "p_constructor" - ] - ] - }, - { - "name": "godot_variant_get_constructor_argument_count", - "return_type": "int", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "int", - "p_constructor" - ] - ] - }, - { - "name": "godot_variant_get_constructor_argument_type", - "return_type": "godot_variant_type", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "int", - "p_constructor" - ], - [ - "int", - "p_argument" - ] - ] - }, - { - "name": "godot_variant_get_constructor_argument_name", - "return_type": "godot_string", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "int", - "p_constructor" - ], - [ - "int", - "p_argument" - ] - ] - }, - { - "name": "godot_variant_construct", - "return_type": "void", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "godot_variant *", - "p_base" - ], - [ - "const godot_variant **", - "p_args" - ], - [ - "int", - "p_argument_count" - ], - [ - "godot_variant_call_error *", - "r_error" - ] - ] - }, - { - "name": "godot_variant_get_member_type", - "return_type": "godot_variant_type", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const godot_string_name *", - "p_member" - ] - ] - }, - { - "name": "godot_variant_get_member_type_with_cstring", - "return_type": "godot_variant_type", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const char *", - "p_member" - ] - ] - }, - { - "name": "godot_variant_get_member_count", - "return_type": "int", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ] - ] - }, - { - "name": "godot_variant_get_member_list", - "return_type": "void", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "godot_string_name *", - "r_list" - ] - ] - }, - { - "name": "godot_variant_get_validated_setter", - "return_type": "godot_validated_setter", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const godot_string_name *", - "p_member" - ] - ] - }, - { - "name": "godot_variant_get_validated_setter_with_cstring", - "return_type": "godot_validated_setter", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const char *", - "p_member" - ] - ] - }, - { - "name": "godot_variant_get_validated_getter", - "return_type": "godot_validated_getter", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const godot_string_name *", - "p_member" - ] - ] - }, - { - "name": "godot_variant_get_validated_getter_with_cstring", - "return_type": "godot_validated_getter", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const char *", - "p_member" - ] - ] - }, - { - "name": "godot_variant_get_ptr_setter", - "return_type": "godot_ptr_setter", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const godot_string_name *", - "p_member" - ] - ] - }, - { - "name": "godot_variant_get_ptr_setter_with_cstring", - "return_type": "godot_ptr_setter", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const char *", - "p_member" - ] - ] - }, - { - "name": "godot_variant_get_ptr_getter", - "return_type": "godot_ptr_getter", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const godot_string_name *", - "p_member" - ] - ] - }, - { - "name": "godot_variant_get_ptr_getter_with_cstring", - "return_type": "godot_ptr_getter", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const char *", - "p_member" - ] - ] - }, - { - "name": "godot_variant_has_indexing", - "return_type": "bool", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ] - ] - }, - { - "name": "godot_variant_get_indexed_element_type", - "return_type": "godot_variant_type", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ] - ] - }, - { - "name": "godot_variant_get_validated_indexed_setter", - "return_type": "godot_validated_indexed_setter", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ] - ] - }, - { - "name": "godot_variant_get_validated_indexed_getter", - "return_type": "godot_validated_indexed_getter", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ] - ] - }, - { - "name": "godot_variant_get_ptr_indexed_setter", - "return_type": "godot_ptr_indexed_setter", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ] - ] - }, - { - "name": "godot_variant_get_ptr_indexed_getter", - "return_type": "godot_ptr_indexed_getter", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ] - ] - }, - { - "name": "godot_variant_get_indexed_size", - "return_type": "uint64_t", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_is_keyed", - "return_type": "bool", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ] - ] - }, - { - "name": "godot_variant_get_validated_keyed_setter", - "return_type": "godot_validated_keyed_setter", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ] - ] - }, - { - "name": "godot_variant_get_validated_keyed_getter", - "return_type": "godot_validated_keyed_getter", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ] - ] - }, - { - "name": "godot_variant_get_validated_keyed_checker", - "return_type": "godot_validated_keyed_checker", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ] - ] - }, - { - "name": "godot_variant_get_ptr_keyed_setter", - "return_type": "godot_ptr_keyed_setter", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ] - ] - }, - { - "name": "godot_variant_get_ptr_keyed_getter", - "return_type": "godot_ptr_keyed_getter", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ] - ] - }, - { - "name": "godot_variant_get_ptr_keyed_checker", - "return_type": "godot_ptr_keyed_checker", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ] - ] - }, - { - "name": "godot_variant_get_constants_count", - "return_type": "int", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ] - ] - }, - { - "name": "godot_variant_get_constants_list", - "return_type": "void", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "godot_string_name *", - "r_list" - ] - ] - }, - { - "name": "godot_variant_has_constant", - "return_type": "bool", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const godot_string_name *", - "p_constant" - ] - ] - }, - { - "name": "godot_variant_has_constant_with_cstring", - "return_type": "bool", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const char *", - "p_constant" - ] - ] - }, - { - "name": "godot_variant_get_constant_value", - "return_type": "godot_variant", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const godot_string_name *", - "p_constant" - ] - ] - }, - { - "name": "godot_variant_get_constant_value_with_cstring", - "return_type": "godot_variant", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const char *", - "p_constant" - ] - ] - }, - { - "name": "godot_variant_has_utility_function", - "return_type": "bool", - "arguments": [ - [ - "const godot_string_name *", - "p_function" - ] - ] - }, - { - "name": "godot_variant_has_utility_function_with_cstring", - "return_type": "bool", - "arguments": [ - [ - "const char *", - "p_function" - ] - ] - }, - { - "name": "godot_variant_call_utility_function", - "return_type": "void", - "arguments": [ - [ - "const godot_string_name *", - "p_function" - ], - [ - "godot_variant *", - "r_ret" - ], - [ - "const godot_variant **", - "p_args" - ], - [ - "int", - "p_argument_count" - ], - [ - "godot_variant_call_error *", - "r_error" - ] - ] - }, - { - "name": "godot_variant_call_utility_function_with_cstring", - "return_type": "void", - "arguments": [ - [ - "const char *", - "p_function" - ], - [ - "godot_variant *", - "r_ret" - ], - [ - "const godot_variant **", - "p_args" - ], - [ - "int", - "p_argument_count" - ], - [ - "godot_variant_call_error *", - "r_error" - ] - ] - }, - { - "name": "godot_variant_get_ptr_utility_function", - "return_type": "godot_ptr_utility_function", - "arguments": [ - [ - "const godot_string_name *", - "p_function" - ] - ] - }, - { - "name": "godot_variant_get_ptr_utility_function_with_cstring", - "return_type": "godot_ptr_utility_function", - "arguments": [ - [ - "const char *", - "p_function" - ] - ] - }, - { - "name": "godot_variant_get_validated_utility_function", - "return_type": "godot_validated_utility_function", - "arguments": [ - [ - "const godot_string_name *", - "p_function" - ] - ] - }, - { - "name": "godot_variant_get_validated_utility_function_with_cstring", - "return_type": "godot_validated_utility_function", - "arguments": [ - [ - "const char *", - "p_function" - ] - ] - }, - { - "name": "godot_variant_get_utility_function_type", - "return_type": "godot_variant_utility_function_type", - "arguments": [ - [ - "const godot_string_name *", - "p_function" - ] - ] - }, - { - "name": "godot_variant_get_utility_function_type_with_cstring", - "return_type": "godot_variant_utility_function_type", - "arguments": [ - [ - "const char *", - "p_function" - ] - ] - }, - { - "name": "godot_variant_get_utility_function_argument_count", - "return_type": "int", - "arguments": [ - [ - "const godot_string_name *", - "p_function" - ] - ] - }, - { - "name": "godot_variant_get_utility_function_argument_count_with_cstring", - "return_type": "int", - "arguments": [ - [ - "const char *", - "p_function" - ] - ] - }, - { - "name": "godot_variant_get_utility_function_argument_type", - "return_type": "godot_variant_type", - "arguments": [ - [ - "const godot_string_name *", - "p_function" - ], - [ - "int", - "p_argument" - ] - ] - }, - { - "name": "godot_variant_get_utility_function_argument_type_with_cstring", - "return_type": "godot_variant_type", - "arguments": [ - [ - "const char *", - "p_function" - ], - [ - "int", - "p_argument" - ] - ] - }, - { - "name": "godot_variant_get_utility_function_argument_name", - "return_type": "godot_string", - "arguments": [ - [ - "const godot_string_name *", - "p_function" - ], - [ - "int", - "p_argument" - ] - ] - }, - { - "name": "godot_variant_get_utility_function_argument_name_with_cstring", - "return_type": "godot_string", - "arguments": [ - [ - "const char *", - "p_function" - ], - [ - "int", - "p_argument" - ] - ] - }, - { - "name": "godot_variant_has_utility_function_return_value", - "return_type": "bool", - "arguments": [ - [ - "const godot_string_name *", - "p_function" - ] - ] - }, - { - "name": "godot_variant_has_utility_function_return_value_with_cstring", - "return_type": "bool", - "arguments": [ - [ - "const char *", - "p_function" - ] - ] - }, - { - "name": "godot_variant_get_utility_function_return_type", - "return_type": "godot_variant_type", - "arguments": [ - [ - "const godot_string_name *", - "p_function" - ] - ] - }, - { - "name": "godot_variant_get_utility_function_return_type_with_cstring", - "return_type": "godot_variant_type", - "arguments": [ - [ - "const char *", - "p_function" - ] - ] - }, - { - "name": "godot_variant_is_utility_function_vararg", - "return_type": "bool", - "arguments": [ - [ - "const godot_string_name *", - "p_function" - ] - ] - }, - { - "name": "godot_variant_is_utility_function_vararg_with_cstring", - "return_type": "bool", - "arguments": [ - [ - "const char *", - "p_function" - ] - ] - }, - { - "name": "godot_variant_get_utility_function_count", - "return_type": "int", - "arguments": [] - }, - { - "name": "godot_variant_get_utility_function_list", - "return_type": "void", - "arguments": [ - [ - "godot_string_name *", - "r_functions" - ] - ] - }, - { - "name": "godot_variant_get_type", - "return_type": "godot_variant_type", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ] - ] - }, - { - "name": "godot_variant_has_method", - "return_type": "bool", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ], - [ - "const godot_string_name *", - "p_method" - ] - ] - }, - { - "name": "godot_variant_has_member", - "return_type": "bool", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ], - [ - "const godot_string_name *", - "p_member" - ] - ] - }, - { - "name": "godot_variant_has_key", - "return_type": "bool", - "arguments": [ - [ - "const godot_variant *", - "p_self" - ], - [ - "const godot_variant *", - "p_key" - ], - [ - "bool *", - "r_valid" - ] - ] - }, - { - "name": "godot_variant_get_type_name", - "return_type": "godot_string", - "arguments": [ - [ - "godot_variant_type", - "p_type" - ] - ] - }, - { - "name": "godot_variant_can_convert", - "return_type": "bool", - "arguments": [ - [ - "godot_variant_type", - "p_from" - ], - [ - "godot_variant_type", - "p_to" - ] - ] - }, - { - "name": "godot_variant_can_convert_strict", - "return_type": "bool", - "arguments": [ - [ - "godot_variant_type", - "p_from" - ], - [ - "godot_variant_type", - "p_to" - ] - ] - }, - { - "name": "godot_aabb_new", - "return_type": "void", - "arguments": [ - [ - "godot_aabb *", - "p_self" - ] - ] - }, - { - "name": "godot_aabb_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_aabb *", - "r_dest" - ], - [ - "const godot_aabb *", - "p_src" - ] - ] - }, - { - "name": "godot_array_new", - "return_type": "void", - "arguments": [ - [ - "godot_array *", - "p_self" - ] - ] - }, - { - "name": "godot_array_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_array *", - "r_dest" - ], - [ - "const godot_array *", - "p_src" - ] - ] - }, - { - "name": "godot_array_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_array *", - "p_self" - ] - ] - }, - { - "name": "godot_array_operator_index", - "return_type": "godot_variant *", - "arguments": [ - [ - "godot_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_array_operator_index_const", - "return_type": "const godot_variant *", - "arguments": [ - [ - "const godot_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_basis_new", - "return_type": "void", - "arguments": [ - [ - "godot_basis *", - "p_self" - ] - ] - }, - { - "name": "godot_basis_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_basis *", - "r_dest" - ], - [ - "const godot_basis *", - "p_src" - ] - ] - }, - { - "name": "godot_basis_operator_index", - "return_type": "godot_vector3 *", - "arguments": [ - [ - "godot_basis *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_basis_operator_index_const", - "return_type": "const godot_vector3 *", - "arguments": [ - [ - "const godot_basis *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_callable_new", - "return_type": "void", - "arguments": [ - [ - "godot_callable *", - "p_self" - ] - ] - }, - { - "name": "godot_callable_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_callable *", - "r_dest" - ], - [ - "const godot_callable *", - "p_src" - ] - ] - }, - { - "name": "godot_callable_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_callable *", - "p_self" - ] - ] - }, - { - "name": "godot_color_new", - "return_type": "void", - "arguments": [ - [ - "godot_color *", - "p_self" - ] - ] - }, - { - "name": "godot_color_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_color *", - "r_dest" - ], - [ - "const godot_color *", - "p_src" - ] - ] - }, - { - "name": "godot_color_operator_index", - "return_type": "float *", - "arguments": [ - [ - "godot_color *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_color_operator_index_const", - "return_type": "const float *", - "arguments": [ - [ - "const godot_color *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_dictionary_new", - "return_type": "void", - "arguments": [ - [ - "godot_dictionary *", - "p_self" - ] - ] - }, - { - "name": "godot_dictionary_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_dictionary *", - "r_dest" - ], - [ - "const godot_dictionary *", - "p_src" - ] - ] - }, - { - "name": "godot_dictionary_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_dictionary *", - "p_self" - ] - ] - }, - { - "name": "godot_dictionary_operator_index", - "return_type": "godot_variant *", - "arguments": [ - [ - "godot_dictionary *", - "p_self" - ], - [ - "const godot_variant *", - "p_key" - ] - ] - }, - { - "name": "godot_dictionary_operator_index_const", - "return_type": "const godot_variant *", - "arguments": [ - [ - "const godot_dictionary *", - "p_self" - ], - [ - "const godot_variant *", - "p_key" - ] - ] - }, - { - "name": "godot_node_path_new", - "return_type": "void", - "arguments": [ - [ - "godot_node_path *", - "p_self" - ] - ] - }, - { - "name": "godot_node_path_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_node_path *", - "r_dest" - ], - [ - "const godot_node_path *", - "p_src" - ] - ] - }, - { - "name": "godot_node_path_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_node_path *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_byte_array_new", - "return_type": "void", - "arguments": [ - [ - "godot_packed_byte_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_byte_array_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_byte_array *", - "r_dest" - ], - [ - "const godot_packed_byte_array *", - "p_src" - ] - ] - }, - { - "name": "godot_packed_byte_array_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_byte_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_byte_array_operator_index", - "return_type": "uint8_t *", - "arguments": [ - [ - "godot_packed_byte_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_byte_array_operator_index_const", - "return_type": "const uint8_t *", - "arguments": [ - [ - "const godot_packed_byte_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_int32_array_new", - "return_type": "void", - "arguments": [ - [ - "godot_packed_int32_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_int32_array_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_int32_array *", - "r_dest" - ], - [ - "const godot_packed_int32_array *", - "p_src" - ] - ] - }, - { - "name": "godot_packed_int32_array_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_int32_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_int32_array_operator_index", - "return_type": "int32_t *", - "arguments": [ - [ - "godot_packed_int32_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_int32_array_operator_index_const", - "return_type": "const int32_t *", - "arguments": [ - [ - "const godot_packed_int32_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_int64_array_new", - "return_type": "void", - "arguments": [ - [ - "godot_packed_int64_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_int64_array_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_int64_array *", - "r_dest" - ], - [ - "const godot_packed_int64_array *", - "p_src" - ] - ] - }, - { - "name": "godot_packed_int64_array_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_int64_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_int64_array_operator_index", - "return_type": "int64_t *", - "arguments": [ - [ - "godot_packed_int64_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_int64_array_operator_index_const", - "return_type": "const int64_t *", - "arguments": [ - [ - "const godot_packed_int64_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_float32_array_new", - "return_type": "void", - "arguments": [ - [ - "godot_packed_float32_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_float32_array_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_float32_array *", - "r_dest" - ], - [ - "const godot_packed_float32_array *", - "p_src" - ] - ] - }, - { - "name": "godot_packed_float32_array_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_float32_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_float32_array_operator_index", - "return_type": "float *", - "arguments": [ - [ - "godot_packed_float32_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_float32_array_operator_index_const", - "return_type": "const float *", - "arguments": [ - [ - "const godot_packed_float32_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_float64_array_new", - "return_type": "void", - "arguments": [ - [ - "godot_packed_float64_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_float64_array_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_float64_array *", - "r_dest" - ], - [ - "const godot_packed_float64_array *", - "p_src" - ] - ] - }, - { - "name": "godot_packed_float64_array_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_float64_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_float64_array_operator_index", - "return_type": "double *", - "arguments": [ - [ - "godot_packed_float64_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_float64_array_operator_index_const", - "return_type": "const double *", - "arguments": [ - [ - "const godot_packed_float64_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_string_array_new", - "return_type": "void", - "arguments": [ - [ - "godot_packed_string_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_string_array_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_string_array *", - "r_dest" - ], - [ - "const godot_packed_string_array *", - "p_src" - ] - ] - }, - { - "name": "godot_packed_string_array_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_string_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_string_array_operator_index", - "return_type": "godot_string *", - "arguments": [ - [ - "godot_packed_string_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_string_array_operator_index_const", - "return_type": "const godot_string *", - "arguments": [ - [ - "const godot_packed_string_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_vector2_array_new", - "return_type": "void", - "arguments": [ - [ - "godot_packed_vector2_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_vector2_array_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_vector2_array *", - "r_dest" - ], - [ - "const godot_packed_vector2_array *", - "p_src" - ] - ] - }, - { - "name": "godot_packed_vector2_array_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_vector2_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_vector2_array_operator_index", - "return_type": "godot_vector2 *", - "arguments": [ - [ - "godot_packed_vector2_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_vector2_array_operator_index_const", - "return_type": "const godot_vector2 *", - "arguments": [ - [ - "const godot_packed_vector2_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_vector2i_array_new", - "return_type": "void", - "arguments": [ - [ - "godot_packed_vector2i_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_vector2i_array_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_vector2i_array *", - "r_dest" - ], - [ - "const godot_packed_vector2i_array *", - "p_src" - ] - ] - }, - { - "name": "godot_packed_vector2i_array_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_vector2i_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_vector2i_array_operator_index", - "return_type": "godot_vector2i *", - "arguments": [ - [ - "godot_packed_vector2i_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_vector2i_array_operator_index_const", - "return_type": "const godot_vector2i *", - "arguments": [ - [ - "const godot_packed_vector2i_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_vector3_array_new", - "return_type": "void", - "arguments": [ - [ - "godot_packed_vector3_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_vector3_array_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_vector3_array *", - "r_dest" - ], - [ - "const godot_packed_vector3_array *", - "p_src" - ] - ] - }, - { - "name": "godot_packed_vector3_array_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_vector3_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_vector3_array_operator_index", - "return_type": "godot_vector3 *", - "arguments": [ - [ - "godot_packed_vector3_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_vector3_array_operator_index_const", - "return_type": "const godot_vector3 *", - "arguments": [ - [ - "const godot_packed_vector3_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_vector3i_array_new", - "return_type": "void", - "arguments": [ - [ - "godot_packed_vector3i_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_vector3i_array_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_vector3i_array *", - "r_dest" - ], - [ - "const godot_packed_vector3i_array *", - "p_src" - ] - ] - }, - { - "name": "godot_packed_vector3i_array_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_vector3i_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_vector3i_array_operator_index", - "return_type": "godot_vector3i *", - "arguments": [ - [ - "godot_packed_vector3i_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_vector3i_array_operator_index_const", - "return_type": "const godot_vector3i *", - "arguments": [ - [ - "const godot_packed_vector3i_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_color_array_new", - "return_type": "void", - "arguments": [ - [ - "godot_packed_color_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_color_array_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_color_array *", - "r_dest" - ], - [ - "const godot_packed_color_array *", - "p_src" - ] - ] - }, - { - "name": "godot_packed_color_array_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_color_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_color_array_operator_index", - "return_type": "godot_color *", - "arguments": [ - [ - "godot_packed_color_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_color_array_operator_index_const", - "return_type": "const godot_color *", - "arguments": [ - [ - "const godot_packed_color_array *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_plane_new", - "return_type": "void", - "arguments": [ - [ - "godot_plane *", - "p_self" - ] - ] - }, - { - "name": "godot_plane_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_plane *", - "r_dest" - ], - [ - "const godot_plane *", - "p_src" - ] - ] - }, - { - "name": "godot_quaternion_new", - "return_type": "void", - "arguments": [ - [ - "godot_quaternion *", - "p_self" - ] - ] - }, - { - "name": "godot_quaternion_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_quaternion *", - "r_dest" - ], - [ - "const godot_quaternion *", - "p_src" - ] - ] - }, - { - "name": "godot_quaternion_operator_index", - "return_type": "godot_real_t *", - "arguments": [ - [ - "godot_quaternion *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_quaternion_operator_index_const", - "return_type": "const godot_real_t *", - "arguments": [ - [ - "const godot_quaternion *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_rect2_new", - "return_type": "void", - "arguments": [ - [ - "godot_rect2 *", - "p_self" - ] - ] - }, - { - "name": "godot_rect2_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_rect2 *", - "r_dest" - ], - [ - "const godot_rect2 *", - "p_src" - ] - ] - }, - { - "name": "godot_rect2i_new", - "return_type": "void", - "arguments": [ - [ - "godot_rect2i *", - "p_self" - ] - ] - }, - { - "name": "godot_rect2i_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_rect2i *", - "r_dest" - ], - [ - "const godot_rect2i *", - "p_src" - ] - ] - }, - { - "name": "godot_rid_new", - "return_type": "void", - "arguments": [ - [ - "godot_rid *", - "p_self" - ] - ] - }, - { - "name": "godot_rid_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_rid *", - "r_dest" - ], - [ - "const godot_rid *", - "p_src" - ] - ] - }, - { - "name": "godot_signal_new", - "return_type": "void", - "arguments": [ - [ - "godot_signal *", - "p_self" - ] - ] - }, - { - "name": "godot_signal_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_signal *", - "r_dest" - ], - [ - "const godot_signal *", - "p_src" - ] - ] - }, - { - "name": "godot_signal_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_signal *", - "p_self" - ] - ] - }, - { - "name": "godot_string_new", - "return_type": "void", - "arguments": [ - [ - "godot_string *", - "r_dest" - ] - ] - }, - { - "name": "godot_string_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_string *", - "r_dest" - ], - [ - "const godot_string *", - "p_src" - ] - ] - }, - { - "name": "godot_string_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_string *", - "p_self" - ] - ] - }, - { - "name": "godot_string_new_with_latin1_chars", - "return_type": "void", - "arguments": [ - [ - "godot_string *", - "r_dest" - ], - [ - "const char *", - "p_contents" - ] - ] - }, - { - "name": "godot_string_new_with_utf8_chars", - "return_type": "void", - "arguments": [ - [ - "godot_string *", - "r_dest" - ], - [ - "const char *", - "p_contents" - ] - ] - }, - { - "name": "godot_string_new_with_utf16_chars", - "return_type": "void", - "arguments": [ - [ - "godot_string *", - "r_dest" - ], - [ - "const char16_t *", - "p_contents" - ] - ] - }, - { - "name": "godot_string_new_with_utf32_chars", - "return_type": "void", - "arguments": [ - [ - "godot_string *", - "r_dest" - ], - [ - "const char32_t *", - "p_contents" - ] - ] - }, - { - "name": "godot_string_new_with_wide_chars", - "return_type": "void", - "arguments": [ - [ - "godot_string *", - "r_dest" - ], - [ - "const wchar_t *", - "p_contents" - ] - ] - }, - { - "name": "godot_string_new_with_latin1_chars_and_len", - "return_type": "void", - "arguments": [ - [ - "godot_string *", - "r_dest" - ], - [ - "const char *", - "p_contents" - ], - [ - "const int", - "p_size" - ] - ] - }, - { - "name": "godot_string_new_with_utf8_chars_and_len", - "return_type": "void", - "arguments": [ - [ - "godot_string *", - "r_dest" - ], - [ - "const char *", - "p_contents" - ], - [ - "const int", - "p_size" - ] - ] - }, - { - "name": "godot_string_new_with_utf16_chars_and_len", - "return_type": "void", - "arguments": [ - [ - "godot_string *", - "r_dest" - ], - [ - "const char16_t *", - "p_contents" - ], - [ - "const int", - "p_size" - ] - ] - }, - { - "name": "godot_string_new_with_utf32_chars_and_len", - "return_type": "void", - "arguments": [ - [ - "godot_string *", - "r_dest" - ], - [ - "const char32_t *", - "p_contents" - ], - [ - "const int", - "p_size" - ] - ] - }, - { - "name": "godot_string_new_with_wide_chars_and_len", - "return_type": "void", - "arguments": [ - [ - "godot_string *", - "r_dest" - ], - [ - "const wchar_t *", - "p_contents" - ], - [ - "const int", - "p_size" - ] - ] - }, - { - "name": "godot_string_to_latin1_chars", - "return_type": "const char *", - "arguments": [ - [ - "const godot_string *", - "p_self" - ] - ] - }, - { - "name": "godot_string_to_utf8_chars", - "return_type": "const char *", - "arguments": [ - [ - "const godot_string *", - "p_self" - ] - ] - }, - { - "name": "godot_string_to_utf16_chars", - "return_type": "const char16_t *", - "arguments": [ - [ - "const godot_string *", - "p_self" - ] - ] - }, - { - "name": "godot_string_to_utf32_chars", - "return_type": "const char32_t *", - "arguments": [ - [ - "const godot_string *", - "p_self" - ] - ] - }, - { - "name": "godot_string_to_wide_chars", - "return_type": "const wchar_t *", - "arguments": [ - [ - "const godot_string *", - "p_self" - ] - ] - }, - { - "name": "godot_string_operator_index", - "return_type": "char32_t *", - "arguments": [ - [ - "godot_string *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_string_operator_index_const", - "return_type": "const char32_t *", - "arguments": [ - [ - "const godot_string *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_string_name_new", - "return_type": "void", - "arguments": [ - [ - "godot_string_name *", - "r_dest" - ] - ] - }, - { - "name": "godot_string_name_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_string_name *", - "r_dest" - ], - [ - "const godot_string_name *", - "p_src" - ] - ] - }, - { - "name": "godot_string_name_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_string_name *", - "p_self" - ] - ] - }, - { - "name": "godot_string_name_new_with_latin1_chars", - "return_type": "void", - "arguments": [ - [ - "godot_string_name *", - "r_dest" - ], - [ - "const char *", - "p_contents" - ] - ] - }, - { - "name": "godot_transform3d_new", - "return_type": "void", - "arguments": [ - [ - "godot_transform3d *", - "r_dest" - ] - ] - }, - { - "name": "godot_transform3d_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_transform3d *", - "r_dest" - ], - [ - "const godot_transform3d *", - "p_src" - ] - ] - }, - { - "name": "godot_transform2d_new", - "return_type": "void", - "arguments": [ - [ - "godot_transform2d *", - "r_dest" - ] - ] - }, - { - "name": "godot_transform2d_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_transform2d *", - "r_dest" - ], - [ - "const godot_transform2d *", - "p_src" - ] - ] - }, - { - "name": "godot_transform2d_operator_index", - "return_type": "godot_vector2 *", - "arguments": [ - [ - "godot_transform2d *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_transform2d_operator_index_const", - "return_type": "const godot_vector2 *", - "arguments": [ - [ - "const godot_transform2d *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_vector2_new", - "return_type": "void", - "arguments": [ - [ - "godot_vector2 *", - "r_dest" - ] - ] - }, - { - "name": "godot_vector2_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_vector2 *", - "r_dest" - ], - [ - "const godot_vector2 *", - "p_src" - ] - ] - }, - { - "name": "godot_vector2_operator_index", - "return_type": "godot_real_t *", - "arguments": [ - [ - "godot_vector2 *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_vector2_operator_index_const", - "return_type": "const godot_real_t *", - "arguments": [ - [ - "const godot_vector2 *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_vector2i_new", - "return_type": "void", - "arguments": [ - [ - "godot_vector2i *", - "r_dest" - ] - ] - }, - { - "name": "godot_vector2i_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_vector2i *", - "r_dest" - ], - [ - "const godot_vector2i *", - "p_src" - ] - ] - }, - { - "name": "godot_vector2i_operator_index", - "return_type": "int32_t *", - "arguments": [ - [ - "godot_vector2i *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_vector2i_operator_index_const", - "return_type": "const int32_t *", - "arguments": [ - [ - "const godot_vector2i *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_vector3_new", - "return_type": "void", - "arguments": [ - [ - "godot_vector3 *", - "r_dest" - ] - ] - }, - { - "name": "godot_vector3_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_vector3 *", - "r_dest" - ], - [ - "const godot_vector3 *", - "p_src" - ] - ] - }, - { - "name": "godot_vector3_operator_index", - "return_type": "godot_real_t *", - "arguments": [ - [ - "godot_vector3 *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_vector3_operator_index_const", - "return_type": "const godot_real_t *", - "arguments": [ - [ - "const godot_vector3 *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_vector3i_new", - "return_type": "void", - "arguments": [ - [ - "godot_vector3i *", - "r_dest" - ] - ] - }, - { - "name": "godot_vector3i_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_vector3i *", - "r_dest" - ], - [ - "const godot_vector3i *", - "p_src" - ] - ] - }, - { - "name": "godot_vector3i_operator_index", - "return_type": "int32_t *", - "arguments": [ - [ - "godot_vector3i *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_vector3i_operator_index_const", - "return_type": "const int32_t *", - "arguments": [ - [ - "const godot_vector3i *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - } - ] - }, - "extensions": [ - { - "name": "nativescript", - "type": "NATIVESCRIPT", - "version": { - "major": 4, - "minor": 0 - }, - "next": null, - "api": [ - { - "name": "godot_nativescript_register_class", - "return_type": "void", - "arguments": [ - [ - "void *", - "p_gdnative_handle" - ], - [ - "const char *", - "p_name" - ], - [ - "const char *", - "p_base" - ], - [ - "godot_nativescript_instance_create_func", - "p_create_func" - ], - [ - "godot_nativescript_instance_destroy_func", - "p_destroy_func" - ] - ] - }, - { - "name": "godot_nativescript_register_tool_class", - "return_type": "void", - "arguments": [ - [ - "void *", - "p_gdnative_handle" - ], - [ - "const char *", - "p_name" - ], - [ - "const char *", - "p_base" - ], - [ - "godot_nativescript_instance_create_func", - "p_create_func" - ], - [ - "godot_nativescript_instance_destroy_func", - "p_destroy_func" - ] - ] - }, - { - "name": "godot_nativescript_register_method", - "return_type": "void", - "arguments": [ - [ - "void *", - "p_gdnative_handle" - ], - [ - "const char *", - "p_name" - ], - [ - "const char *", - "p_function_name" - ], - [ - "godot_nativescript_method_attributes", - "p_attr" - ], - [ - "godot_nativescript_instance_method", - "p_method" - ] - ] - }, - { - "name": "godot_nativescript_set_method_argument_information", - "return_type": "void", - "arguments": [ - [ - "void *", - "p_gdnative_handle" - ], - [ - "const char *", - "p_name" - ], - [ - "const char *", - "p_function_name" - ], - [ - "int", - "p_num_args" - ], - [ - "const godot_nativescript_method_argument *", - "p_args" - ] - ] - }, - { - "name": "godot_nativescript_register_property", - "return_type": "void", - "arguments": [ - [ - "void *", - "p_gdnative_handle" - ], - [ - "const char *", - "p_name" - ], - [ - "const char *", - "p_path" - ], - [ - "godot_nativescript_property_attributes *", - "p_attr" - ], - [ - "godot_nativescript_property_set_func", - "p_set_func" - ], - [ - "godot_nativescript_property_get_func", - "p_get_func" - ] - ] - }, - { - "name": "godot_nativescript_register_signal", - "return_type": "void", - "arguments": [ - [ - "void *", - "p_gdnative_handle" - ], - [ - "const char *", - "p_name" - ], - [ - "const godot_nativescript_signal *", - "p_signal" - ] - ] - }, - { - "name": "godot_nativescript_get_userdata", - "return_type": "void *", - "arguments": [ - [ - "godot_object *", - "p_instance" - ] - ] - }, - { - "name": "godot_nativescript_set_class_documentation", - "return_type": "void", - "arguments": [ - [ - "void *", - "p_gdnative_handle" - ], - [ - "const char *", - "p_name" - ], - [ - "godot_string", - "p_documentation" - ] - ] - }, - { - "name": "godot_nativescript_set_method_documentation", - "return_type": "void", - "arguments": [ - [ - "void *", - "p_gdnative_handle" - ], - [ - "const char *", - "p_name" - ], - [ - "const char *", - "p_function_name" - ], - [ - "godot_string", - "p_documentation" - ] - ] - }, - { - "name": "godot_nativescript_set_property_documentation", - "return_type": "void", - "arguments": [ - [ - "void *", - "p_gdnative_handle" - ], - [ - "const char *", - "p_name" - ], - [ - "const char *", - "p_path" - ], - [ - "godot_string", - "p_documentation" - ] - ] - }, - { - "name": "godot_nativescript_set_signal_documentation", - "return_type": "void", - "arguments": [ - [ - "void *", - "p_gdnative_handle" - ], - [ - "const char *", - "p_name" - ], - [ - "const char *", - "p_signal_name" - ], - [ - "godot_string", - "p_documentation" - ] - ] - }, - { - "name": "godot_nativescript_set_global_type_tag", - "return_type": "void", - "arguments": [ - [ - "int", - "p_idx" - ], - [ - "const char *", - "p_name" - ], - [ - "const void *", - "p_type_tag" - ] - ] - }, - { - "name": "godot_nativescript_get_global_type_tag", - "return_type": "const void *", - "arguments": [ - [ - "int", - "p_idx" - ], - [ - "const char *", - "p_name" - ] - ] - }, - { - "name": "godot_nativescript_set_type_tag", - "return_type": "void", - "arguments": [ - [ - "void *", - "p_gdnative_handle" - ], - [ - "const char *", - "p_name" - ], - [ - "const void *", - "p_type_tag" - ] - ] - }, - { - "name": "godot_nativescript_get_type_tag", - "return_type": "const void *", - "arguments": [ - [ - "const godot_object *", - "p_object" - ] - ] - }, - { - "name": "godot_nativescript_register_instance_binding_data_functions", - "return_type": "int", - "arguments": [ - [ - "godot_nativescript_instance_binding_functions", - "p_binding_functions" - ] - ] - }, - { - "name": "godot_nativescript_unregister_instance_binding_data_functions", - "return_type": "void", - "arguments": [ - [ - "int", - "p_idx" - ] - ] - }, - { - "name": "godot_nativescript_get_instance_binding_data", - "return_type": "void *", - "arguments": [ - [ - "int", - "p_idx" - ], - [ - "godot_object *", - "p_object" - ] - ] - }, - { - "name": "godot_nativescript_profiling_add_data", - "return_type": "void", - "arguments": [ - [ - "const char *", - "p_signature" - ], - [ - "uint64_t", - "p_line" - ] - ] - } - ] - }, - { - "name": "pluginscript", - "type": "PLUGINSCRIPT", - "version": { - "major": 1, - "minor": 0 - }, - "next": null, - "api": [ - { - "name": "godot_pluginscript_register_language", - "return_type": "void", - "arguments": [ - [ - "const godot_pluginscript_language_desc *", - "language_desc" - ] - ] - } - ] - }, - { - "name": "android", - "type": "ANDROID", - "version": { - "major": 1, - "minor": 1 - }, - "next": null, - "api": [ - { - "name": "godot_android_get_env", - "return_type": "JNIEnv*", - "arguments": [] - }, - { - "name": "godot_android_get_activity", - "return_type": "jobject", - "arguments": [] - }, - { - "name": "godot_android_get_surface", - "return_type": "jobject", - "arguments": [] - }, - { - "name": "godot_android_is_activity_resumed", - "return_type": "bool", - "arguments": [] - } - ] - }, - { - "name": "videodecoder", - "type": "VIDEODECODER", - "version": { - "major": 0, - "minor": 1 - }, - "next": null, - "api": [ - { - "name": "godot_videodecoder_file_read", - "return_type": "godot_int", - "arguments": [ - [ - "void *", - "file_ptr" - ], - [ - "uint8_t *", - "buf" - ], - [ - "int", - "buf_size" - ] - ] - }, - { - "name": "godot_videodecoder_file_seek", - "return_type": "int64_t", - "arguments": [ - [ - "void *", - "file_ptr" - ], - [ - "int64_t", - "pos" - ], - [ - "int", - "whence" - ] - ] - }, - { - "name": "godot_videodecoder_register_decoder", - "return_type": "void", - "arguments": [ - [ - "const godot_videodecoder_interface_gdnative *", - "p_interface" - ] - ] - } - ] - } - ] -} diff --git a/modules/gdnative/gdnative_builders.py b/modules/gdnative/gdnative_builders.py deleted file mode 100644 index 6c96e23426..0000000000 --- a/modules/gdnative/gdnative_builders.py +++ /dev/null @@ -1,263 +0,0 @@ -"""Functions used to generate source files during build time - -All such functions are invoked in a subprocess on Windows to prevent build flakiness. - -""" -import json -from platform_methods import subprocess_main - - -def _spaced(e): - return e if e[-1] == "*" else e + " " - - -def _build_gdnative_api_struct_header(api): - out = [ - "/* THIS FILE IS GENERATED DO NOT EDIT */", - "#ifndef GODOT_GDNATIVE_API_STRUCT_H", - "#define GODOT_GDNATIVE_API_STRUCT_H", - "", - "#include <gdnative/gdnative.h>", - "#include <android/godot_android.h>", - "#include <nativescript/godot_nativescript.h>", - "#include <pluginscript/godot_pluginscript.h>", - "#include <videodecoder/godot_videodecoder.h>", - "", - "#ifdef __cplusplus", - 'extern "C" {', - "#endif", - "", - "enum GDNATIVE_API_TYPES {", - "\tGDNATIVE_" + api["core"]["type"] + ",", - ] - - for ext in api["extensions"]: - out += ["\tGDNATIVE_EXT_" + ext["type"] + ","] - - out += ["};", ""] - - def generate_extension_struct(name, ext, include_version=True): - ret_val = [] - if ext["next"]: - ret_val += generate_extension_struct(name, ext["next"]) - - ret_val += [ - "typedef struct godot_gdnative_ext_" - + name - + ("" if not include_version else ("_{0}_{1}".format(ext["version"]["major"], ext["version"]["minor"]))) - + "_api_struct {", - "\tunsigned int type;", - "\tgodot_gdnative_api_version version;", - "\tconst godot_gdnative_api_struct *next;", - ] - - for funcdef in ext["api"]: - args = ", ".join(["%s%s" % (_spaced(t), n) for t, n in funcdef["arguments"]]) - ret_val.append("\t%s(*%s)(%s);" % (_spaced(funcdef["return_type"]), funcdef["name"], args)) - - ret_val += [ - "} godot_gdnative_ext_" - + name - + ("" if not include_version else ("_{0}_{1}".format(ext["version"]["major"], ext["version"]["minor"]))) - + "_api_struct;", - "", - ] - - return ret_val - - def generate_core_extension_struct(core): - ret_val = [] - if core["next"]: - ret_val += generate_core_extension_struct(core["next"]) - - ret_val += [ - "typedef struct godot_gdnative_core_" - + "{0}_{1}".format(core["version"]["major"], core["version"]["minor"]) - + "_api_struct {", - "\tunsigned int type;", - "\tgodot_gdnative_api_version version;", - "\tconst godot_gdnative_api_struct *next;", - ] - - for funcdef in core["api"]: - args = ", ".join(["%s%s" % (_spaced(t), n) for t, n in funcdef["arguments"]]) - ret_val.append("\t%s(*%s)(%s);" % (_spaced(funcdef["return_type"]), funcdef["name"], args)) - - ret_val += [ - "} godot_gdnative_core_" - + "{0}_{1}".format(core["version"]["major"], core["version"]["minor"]) - + "_api_struct;", - "", - ] - - return ret_val - - for ext in api["extensions"]: - name = ext["name"] - out += generate_extension_struct(name, ext, False) - - if api["core"]["next"]: - out += generate_core_extension_struct(api["core"]["next"]) - - out += [ - "typedef struct godot_gdnative_core_api_struct {", - "\tunsigned int type;", - "\tgodot_gdnative_api_version version;", - "\tconst godot_gdnative_api_struct *next;", - "\tunsigned int num_extensions;", - "\tconst godot_gdnative_api_struct **extensions;", - ] - - for funcdef in api["core"]["api"]: - args = ", ".join(["%s%s" % (_spaced(t), n) for t, n in funcdef["arguments"]]) - out.append("\t%s(*%s)(%s);" % (_spaced(funcdef["return_type"]), funcdef["name"], args)) - - out += [ - "} godot_gdnative_core_api_struct;", - "", - "#ifdef __cplusplus", - "}", - "#endif", - "", - "#endif // GODOT_GDNATIVE_API_STRUCT_H", - "", - ] - return "\n".join(out) - - -def _build_gdnative_api_struct_source(api): - out = ["/* THIS FILE IS GENERATED DO NOT EDIT */", "", "#include <gdnative_api_struct.gen.h>", ""] - - def get_extension_struct_name(name, ext, include_version=True): - return ( - "godot_gdnative_ext_" - + name - + ("" if not include_version else ("_{0}_{1}".format(ext["version"]["major"], ext["version"]["minor"]))) - + "_api_struct" - ) - - def get_extension_struct_instance_name(name, ext, include_version=True): - return ( - "api_extension_" - + name - + ("" if not include_version else ("_{0}_{1}".format(ext["version"]["major"], ext["version"]["minor"]))) - + "_struct" - ) - - def get_extension_struct_definition(name, ext, include_version=True): - - ret_val = [] - - if ext["next"]: - ret_val += get_extension_struct_definition(name, ext["next"]) - - ret_val += [ - "extern const " - + get_extension_struct_name(name, ext, include_version) - + " " - + get_extension_struct_instance_name(name, ext, include_version) - + " = {", - "\tGDNATIVE_EXT_" + ext["type"] + ",", - "\t{" + str(ext["version"]["major"]) + ", " + str(ext["version"]["minor"]) + "},", - "\t" - + ( - "nullptr" - if not ext["next"] - else ("(const godot_gdnative_api_struct *)&" + get_extension_struct_instance_name(name, ext["next"])) - ) - + ",", - ] - - for funcdef in ext["api"]: - ret_val.append("\t%s," % funcdef["name"]) - - ret_val += ["};\n"] - - return ret_val - - def get_core_struct_definition(core): - ret_val = [] - - if core["next"]: - ret_val += get_core_struct_definition(core["next"]) - - ret_val += [ - "extern const godot_gdnative_core_" - + "{0}_{1}_api_struct api_{0}_{1}".format(core["version"]["major"], core["version"]["minor"]) - + " = {", - "\tGDNATIVE_" + core["type"] + ",", - "\t{" + str(core["version"]["major"]) + ", " + str(core["version"]["minor"]) + "},", - "\t" - + ( - "nullptr" - if not core["next"] - else ( - "(const godot_gdnative_api_struct *)& api_{0}_{1}".format( - core["next"]["version"]["major"], core["next"]["version"]["minor"] - ) - ) - ) - + ",", - ] - - for funcdef in core["api"]: - ret_val.append("\t%s," % funcdef["name"]) - - ret_val += ["};\n"] - - return ret_val - - for ext in api["extensions"]: - name = ext["name"] - out += get_extension_struct_definition(name, ext, False) - - out += ["", "const godot_gdnative_api_struct *gdnative_extensions_pointers[] = {"] - - for ext in api["extensions"]: - name = ext["name"] - out += ["\t(godot_gdnative_api_struct *)&api_extension_" + name + "_struct,"] - - out += ["};\n"] - - if api["core"]["next"]: - out += get_core_struct_definition(api["core"]["next"]) - - out += [ - "extern const godot_gdnative_core_api_struct api_struct = {", - "\tGDNATIVE_" + api["core"]["type"] + ",", - "\t{" + str(api["core"]["version"]["major"]) + ", " + str(api["core"]["version"]["minor"]) + "},", - "\t" - + ( - "nullptr, " - if not api["core"]["next"] - else ( - "(const godot_gdnative_api_struct *)& api_{0}_{1},".format( - api["core"]["next"]["version"]["major"], api["core"]["next"]["version"]["minor"] - ) - ) - ), - "\t" + str(len(api["extensions"])) + ",", - "\tgdnative_extensions_pointers,", - ] - - for funcdef in api["core"]["api"]: - out.append("\t%s," % funcdef["name"]) - out.append("};\n") - - return "\n".join(out) - - -def build_gdnative_api_struct(target, source, env): - - with open(source[0], "r") as fd: - api = json.load(fd) - - header, source = target - with open(header, "w") as fd: - fd.write(_build_gdnative_api_struct_header(api)) - with open(source, "w") as fd: - fd.write(_build_gdnative_api_struct_source(api)) - - -if __name__ == "__main__": - subprocess_main(globals()) diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp deleted file mode 100644 index 66c8ab7b37..0000000000 --- a/modules/gdnative/gdnative_library_editor_plugin.cpp +++ /dev/null @@ -1,420 +0,0 @@ -/*************************************************************************/ -/* gdnative_library_editor_plugin.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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. */ -/*************************************************************************/ - -#ifdef TOOLS_ENABLED - -#include "gdnative_library_editor_plugin.h" - -#include "editor/editor_file_dialog.h" -#include "editor/editor_node.h" -#include "editor/editor_scale.h" -#include "gdnative.h" - -void GDNativeLibraryEditor::edit(Ref<GDNativeLibrary> p_library) { - library = p_library; - Ref<ConfigFile> config = p_library->get_config_file(); - - for (KeyValue<String, NativePlatformConfig> &E : platforms) { - for (List<String>::Element *it = E.value.entries.front(); it; it = it->next()) { - String target = E.key + "." + it->get(); - TargetConfig ecfg; - ecfg.library = config->get_value("entry", target, ""); - ecfg.dependencies = config->get_value("dependencies", target, Array()); - entry_configs[target] = ecfg; - } - } - - _update_tree(); -} - -void GDNativeLibraryEditor::_bind_methods() { -} - -void GDNativeLibraryEditor::_update_tree() { - tree->clear(); - TreeItem *root = tree->create_item(); - - PopupMenu *filter_list = filter->get_popup(); - String text = ""; - for (int i = 0; i < filter_list->get_item_count(); i++) { - if (!filter_list->is_item_checked(i)) { - continue; - } - Map<String, NativePlatformConfig>::Element *E = platforms.find(filter_list->get_item_metadata(i)); - if (!text.is_empty()) { - text += ", "; - } - text += E->get().name; - - TreeItem *platform = tree->create_item(root); - platform->set_text(0, E->get().name); - platform->set_metadata(0, E->get().library_extension); - - platform->set_custom_bg_color(0, get_theme_color(SNAME("prop_category"), SNAME("Editor"))); - platform->set_custom_bg_color(1, get_theme_color(SNAME("prop_category"), SNAME("Editor"))); - platform->set_custom_bg_color(2, get_theme_color(SNAME("prop_category"), SNAME("Editor"))); - platform->set_selectable(0, false); - platform->set_expand_right(0, true); - - for (List<String>::Element *it = E->value().entries.front(); it; it = it->next()) { - String target = E->key() + "." + it->get(); - TreeItem *bit = tree->create_item(platform); - - bit->set_text(0, it->get()); - bit->set_metadata(0, target); - bit->set_selectable(0, false); - bit->set_custom_bg_color(0, get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); - - bit->add_button(1, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), BUTTON_SELECT_LIBRARY, false, TTR("Select the dynamic library for this entry")); - String file = entry_configs[target].library; - if (!file.is_empty()) { - bit->add_button(1, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), BUTTON_CLEAR_LIBRARY, false, TTR("Clear")); - } - bit->set_text(1, file); - - bit->add_button(2, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), BUTTON_SELECT_DEPENDENCES, false, TTR("Select dependencies of the library for this entry")); - Array files = entry_configs[target].dependencies; - if (files.size()) { - bit->add_button(2, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), BUTTON_CLEAR_DEPENDENCES, false, TTR("Clear")); - } - bit->set_text(2, Variant(files)); - - bit->add_button(3, get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")), BUTTON_MOVE_UP, false, TTR("Move Up")); - bit->add_button(3, get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons")), BUTTON_MOVE_DOWN, false, TTR("Move Down")); - bit->add_button(3, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_ERASE_ENTRY, false, TTR("Remove current entry")); - } - - TreeItem *new_arch = tree->create_item(platform); - new_arch->set_text(0, TTR("Double click to create a new entry")); - new_arch->set_text_alignment(0, HORIZONTAL_ALIGNMENT_CENTER); - new_arch->set_custom_color(0, get_theme_color(SNAME("accent_color"), SNAME("Editor"))); - new_arch->set_expand_right(0, true); - new_arch->set_metadata(1, E->key()); - - platform->set_collapsed(collapsed_items.find(E->get().name) != nullptr); - } - filter->set_text(text); -} - -void GDNativeLibraryEditor::_on_item_button(Object *item, int column, int id) { - String target = Object::cast_to<TreeItem>(item)->get_metadata(0); - String platform = target.substr(0, target.find(".")); - String entry = target.substr(platform.length() + 1, target.length()); - String section = (id == BUTTON_SELECT_DEPENDENCES || id == BUTTON_CLEAR_DEPENDENCES) ? "dependencies" : "entry"; - - if (id == BUTTON_SELECT_LIBRARY || id == BUTTON_SELECT_DEPENDENCES) { - TreeItem *treeItem = Object::cast_to<TreeItem>(item)->get_parent(); - EditorFileDialog::FileMode mode = EditorFileDialog::FILE_MODE_OPEN_FILE; - if (id == BUTTON_SELECT_DEPENDENCES) { - mode = EditorFileDialog::FILE_MODE_OPEN_FILES; - } else if (treeItem->get_text(0) == "iOS" || treeItem->get_text(0) == "macOS") { - mode = EditorFileDialog::FILE_MODE_OPEN_ANY; - } - - file_dialog->set_meta("target", target); - file_dialog->set_meta("section", section); - file_dialog->clear_filters(); - - String filter_string = treeItem->get_metadata(0); - Vector<String> filters = filter_string.split(",", false, 0); - for (int i = 0; i < filters.size(); i++) { - file_dialog->add_filter(filters[i]); - } - - file_dialog->set_file_mode(mode); - file_dialog->popup_file_dialog(); - - } else if (id == BUTTON_CLEAR_LIBRARY) { - _set_target_value(section, target, ""); - } else if (id == BUTTON_CLEAR_DEPENDENCES) { - _set_target_value(section, target, Array()); - } else if (id == BUTTON_ERASE_ENTRY) { - _erase_entry(platform, entry); - } else if (id == BUTTON_MOVE_UP || id == BUTTON_MOVE_DOWN) { - _move_entry(platform, entry, id); - } -} - -void GDNativeLibraryEditor::_on_library_selected(const String &file) { - _set_target_value(file_dialog->get_meta("section"), file_dialog->get_meta("target"), file); -} - -void GDNativeLibraryEditor::_on_dependencies_selected(const PackedStringArray &files) { - _set_target_value(file_dialog->get_meta("section"), file_dialog->get_meta("target"), files); -} - -void GDNativeLibraryEditor::_on_filter_selected(int index) { - PopupMenu *filter_list = filter->get_popup(); - filter_list->set_item_checked(index, !filter_list->is_item_checked(index)); - _update_tree(); -} - -void GDNativeLibraryEditor::_on_item_collapsed(Object *p_item) { - TreeItem *item = Object::cast_to<TreeItem>(p_item); - String name = item->get_text(0); - - if (item->is_collapsed()) { - collapsed_items.insert(name); - } else if (Set<String>::Element *e = collapsed_items.find(name)) { - collapsed_items.erase(e); - } -} - -void GDNativeLibraryEditor::_on_item_activated() { - TreeItem *item = tree->get_selected(); - if (item && tree->get_selected_column() == 0 && item->get_metadata(0).get_type() == Variant::NIL) { - new_architecture_dialog->set_meta("platform", item->get_metadata(1)); - new_architecture_dialog->popup_centered(); - } -} - -void GDNativeLibraryEditor::_on_create_new_entry() { - String platform = new_architecture_dialog->get_meta("platform"); - String entry = new_architecture_input->get_text().strip_edges(); - if (!entry.is_empty()) { - platforms[platform].entries.push_back(entry); - _update_tree(); - } -} - -void GDNativeLibraryEditor::_set_target_value(const String §ion, const String &target, Variant file) { - if (section == "entry") { - entry_configs[target].library = file; - } else if (section == "dependencies") { - entry_configs[target].dependencies = file; - } - _translate_to_config_file(); - _update_tree(); -} - -void GDNativeLibraryEditor::_erase_entry(const String &platform, const String &entry) { - if (platforms.has(platform)) { - if (List<String>::Element *E = platforms[platform].entries.find(entry)) { - String target = platform + "." + entry; - - platforms[platform].entries.erase(E); - _set_target_value("entry", target, ""); - _set_target_value("dependencies", target, Array()); - _translate_to_config_file(); - _update_tree(); - } - } -} - -void GDNativeLibraryEditor::_move_entry(const String &platform, const String &entry, int dir) { - if (List<String>::Element *E = platforms[platform].entries.find(entry)) { - if (E->prev() && dir == BUTTON_MOVE_UP) { - platforms[platform].entries.insert_before(E->prev(), E->get()); - platforms[platform].entries.erase(E); - } else if (E->next() && dir == BUTTON_MOVE_DOWN) { - platforms[platform].entries.insert_after(E->next(), E->get()); - platforms[platform].entries.erase(E); - } - _translate_to_config_file(); - _update_tree(); - } -} - -void GDNativeLibraryEditor::_translate_to_config_file() { - if (!library.is_null()) { - Ref<ConfigFile> config = library->get_config_file(); - config->erase_section("entry"); - config->erase_section("dependencies"); - - for (KeyValue<String, NativePlatformConfig> &E : platforms) { - for (List<String>::Element *it = E.value.entries.front(); it; it = it->next()) { - String target = E.key + "." + it->get(); - if (entry_configs[target].library.is_empty() && entry_configs[target].dependencies.is_empty()) { - continue; - } - - config->set_value("entry", target, entry_configs[target].library); - config->set_value("dependencies", target, entry_configs[target].dependencies); - } - } - - library->notify_property_list_changed(); - } -} - -GDNativeLibraryEditor::GDNativeLibraryEditor() { - { // Define platforms - NativePlatformConfig platform_windows; - platform_windows.name = "Windows"; - platform_windows.entries.push_back("64"); - platform_windows.entries.push_back("32"); - platform_windows.library_extension = "*.dll"; - platforms["Windows"] = platform_windows; - - NativePlatformConfig platform_linux; - platform_linux.name = "Linux/X11"; - platform_linux.entries.push_back("64"); - platform_linux.entries.push_back("32"); - platform_linux.library_extension = "*.so"; - platforms["X11"] = platform_linux; - - NativePlatformConfig platform_osx; - platform_osx.name = "macOS"; - platform_osx.entries.push_back("64"); - platform_osx.library_extension = "*.framework; Framework, *.dylib; Dynamic Library"; - platforms["macOS"] = platform_osx; - - NativePlatformConfig platform_haiku; - platform_haiku.name = "Haiku"; - platform_haiku.entries.push_back("64"); - platform_haiku.entries.push_back("32"); - platform_haiku.library_extension = "*.so"; - platforms["Haiku"] = platform_haiku; - - NativePlatformConfig platform_uwp; - platform_uwp.name = "UWP"; - platform_uwp.entries.push_back("arm"); - platform_uwp.entries.push_back("32"); - platform_uwp.entries.push_back("64"); - platform_uwp.library_extension = "*.dll"; - platforms["UWP"] = platform_uwp; - - NativePlatformConfig platform_android; - platform_android.name = "Android"; - platform_android.entries.push_back("armeabi-v7a"); - platform_android.entries.push_back("arm64-v8a"); - platform_android.entries.push_back("x86"); - platform_android.entries.push_back("x86_64"); - platform_android.library_extension = "*.so"; - platforms["Android"] = platform_android; - - NativePlatformConfig platform_html5; - platform_html5.name = "HTML5"; - platform_html5.entries.push_back("wasm32"); - platform_html5.library_extension = "*.wasm"; - platforms["HTML5"] = platform_html5; - - NativePlatformConfig platform_ios; - platform_ios.name = "iOS"; - platform_ios.entries.push_back("arm64"); - platform_ios.entries.push_back("x86_64"); - // iOS can use both Static and Dynamic libraries. - // Frameworks is actually a folder with files. - platform_ios.library_extension = "*.framework; Framework, *.xcframework; Binary Framework, *.a; Static Library, *.dylib; Dynamic Library"; - platforms["iOS"] = platform_ios; - } - - VBoxContainer *container = memnew(VBoxContainer); - add_child(container); - container->set_anchors_and_offsets_preset(PRESET_WIDE); - - HBoxContainer *hbox = memnew(HBoxContainer); - container->add_child(hbox); - Label *label = memnew(Label); - label->set_text(TTR("Platform:")); - hbox->add_child(label); - filter = memnew(MenuButton); - filter->set_h_size_flags(SIZE_EXPAND_FILL); - filter->set_text_alignment(HORIZONTAL_ALIGNMENT_LEFT); - hbox->add_child(filter); - PopupMenu *filter_list = filter->get_popup(); - filter_list->set_hide_on_checkable_item_selection(false); - - int idx = 0; - for (const KeyValue<String, NativePlatformConfig> &E : platforms) { - filter_list->add_check_item(E.value.name, idx); - filter_list->set_item_metadata(idx, E.key); - filter_list->set_item_checked(idx, true); - idx += 1; - } - filter_list->connect("index_pressed", callable_mp(this, &GDNativeLibraryEditor::_on_filter_selected)); - - tree = memnew(Tree); - container->add_child(tree); - tree->set_v_size_flags(SIZE_EXPAND_FILL); - tree->set_hide_root(true); - tree->set_column_titles_visible(true); - tree->set_columns(4); - tree->set_column_expand(0, false); - tree->set_column_custom_minimum_width(0, int(200 * EDSCALE)); - tree->set_column_title(0, TTR("Platform")); - tree->set_column_title(1, TTR("Dynamic Library")); - tree->set_column_title(2, TTR("Dependencies")); - tree->set_column_expand(3, false); - tree->set_column_custom_minimum_width(3, int(110 * EDSCALE)); - tree->connect("button_pressed", callable_mp(this, &GDNativeLibraryEditor::_on_item_button)); - tree->connect("item_collapsed", callable_mp(this, &GDNativeLibraryEditor::_on_item_collapsed)); - tree->connect("item_activated", callable_mp(this, &GDNativeLibraryEditor::_on_item_activated)); - - file_dialog = memnew(EditorFileDialog); - file_dialog->set_access(EditorFileDialog::ACCESS_RESOURCES); - //file_dialog->set_resizable(true); - add_child(file_dialog); - file_dialog->connect("file_selected", callable_mp(this, &GDNativeLibraryEditor::_on_library_selected)); - file_dialog->connect("dir_selected", callable_mp(this, &GDNativeLibraryEditor::_on_library_selected)); - file_dialog->connect("files_selected", callable_mp(this, &GDNativeLibraryEditor::_on_dependencies_selected)); - - new_architecture_dialog = memnew(ConfirmationDialog); - add_child(new_architecture_dialog); - new_architecture_dialog->set_title(TTR("Add an architecture entry")); - new_architecture_input = memnew(LineEdit); - new_architecture_dialog->add_child(new_architecture_input); - // new_architecture_dialog->set_custom_minimum_size(Vector2(300, 80) * EDSCALE); - new_architecture_input->set_anchors_and_offsets_preset(PRESET_HCENTER_WIDE, PRESET_MODE_MINSIZE, 5 * EDSCALE); - new_architecture_dialog->get_ok_button()->connect("pressed", callable_mp(this, &GDNativeLibraryEditor::_on_create_new_entry)); -} - -void GDNativeLibraryEditorPlugin::edit(Object *p_node) { - Ref<GDNativeLibrary> new_library = Object::cast_to<GDNativeLibrary>(p_node); - if (new_library.is_valid()) { - library_editor->edit(new_library); - } -} - -bool GDNativeLibraryEditorPlugin::handles(Object *p_node) const { - return p_node->is_class("GDNativeLibrary"); -} - -void GDNativeLibraryEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { - button->show(); - EditorNode::get_singleton()->make_bottom_panel_item_visible(library_editor); - - } else { - if (library_editor->is_visible_in_tree()) { - EditorNode::get_singleton()->hide_bottom_panel(); - } - button->hide(); - } -} - -GDNativeLibraryEditorPlugin::GDNativeLibraryEditorPlugin() { - library_editor = memnew(GDNativeLibraryEditor); - library_editor->set_custom_minimum_size(Size2(0, 250 * EDSCALE)); - button = EditorNode::get_singleton()->add_bottom_panel_item(TTR("GDNativeLibrary"), library_editor); - button->hide(); -} - -#endif diff --git a/modules/gdnative/gdnative_library_editor_plugin.h b/modules/gdnative/gdnative_library_editor_plugin.h deleted file mode 100644 index 797695366c..0000000000 --- a/modules/gdnative/gdnative_library_editor_plugin.h +++ /dev/null @@ -1,119 +0,0 @@ -/*************************************************************************/ -/* gdnative_library_editor_plugin.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 GDNATIVE_LIBRARY_EDITOR_PLUGIN_H -#define GDNATIVE_LIBRARY_EDITOR_PLUGIN_H - -#ifdef TOOLS_ENABLED - -#include "editor/editor_plugin.h" -#include "gdnative.h" -#include "scene/gui/control.h" -#include "scene/gui/menu_button.h" -#include "scene/gui/tree.h" - -class EditorFileDialog; - -class GDNativeLibraryEditor : public Control { - GDCLASS(GDNativeLibraryEditor, Control); - - struct NativePlatformConfig { - String name; - String library_extension; - List<String> entries; - }; - - struct TargetConfig { - String library; - Array dependencies; - }; - - enum ItemButton { - BUTTON_SELECT_LIBRARY, - BUTTON_CLEAR_LIBRARY, - BUTTON_SELECT_DEPENDENCES, - BUTTON_CLEAR_DEPENDENCES, - BUTTON_ERASE_ENTRY, - BUTTON_MOVE_UP, - BUTTON_MOVE_DOWN, - }; - - Tree *tree; - MenuButton *filter; - EditorFileDialog *file_dialog; - ConfirmationDialog *new_architecture_dialog; - LineEdit *new_architecture_input; - Set<String> collapsed_items; - - String showing_platform; - Ref<GDNativeLibrary> library; - Map<String, NativePlatformConfig> platforms; - Map<String, TargetConfig> entry_configs; - -protected: - static void _bind_methods(); - void _update_tree(); - void _on_item_button(Object *item, int column, int id); - void _on_library_selected(const String &file); - void _on_dependencies_selected(const PackedStringArray &files); - void _on_filter_selected(int id); - void _on_item_collapsed(Object *p_item); - void _on_item_activated(); - void _on_create_new_entry(); - void _set_target_value(const String §ion, const String &target, Variant file); - void _erase_entry(const String &platform, const String &entry); - void _move_entry(const String &platform, const String &entry, int dir); - void _translate_to_config_file(); - -public: - void edit(Ref<GDNativeLibrary> p_library); - - GDNativeLibraryEditor(); -}; - -class GDNativeLibraryEditorPlugin : public EditorPlugin { - GDCLASS(GDNativeLibraryEditorPlugin, EditorPlugin); - - GDNativeLibraryEditor *library_editor = nullptr; - Button *button = nullptr; - -public: - virtual String get_name() const override { return "GDNativeLibrary"; } - bool has_main_screen() const override { return false; } - virtual void edit(Object *p_node) override; - virtual bool handles(Object *p_node) const override; - virtual void make_visible(bool p_visible) override; - - GDNativeLibraryEditorPlugin(); -}; - -#endif // TOOLS_ENABLED - -#endif // GDNATIVE_LIBRARY_EDITOR_PLUGIN_H diff --git a/modules/gdnative/gdnative_library_singleton_editor.cpp b/modules/gdnative/gdnative_library_singleton_editor.cpp deleted file mode 100644 index ce1f41bdf1..0000000000 --- a/modules/gdnative/gdnative_library_singleton_editor.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/*************************************************************************/ -/* gdnative_library_singleton_editor.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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. */ -/*************************************************************************/ - -#ifdef TOOLS_ENABLED -#include "gdnative_library_singleton_editor.h" -#include "gdnative.h" - -#include "core/config/project_settings.h" -#include "editor/editor_node.h" - -Set<String> GDNativeLibrarySingletonEditor::_find_singletons_recursive(EditorFileSystemDirectory *p_dir) { - Set<String> file_paths; - - // check children - - for (int i = 0; i < p_dir->get_file_count(); i++) { - String file_name = p_dir->get_file(i); - String file_type = p_dir->get_file_type(i); - - if (file_type != "GDNativeLibrary") { - continue; - } - - Ref<GDNativeLibrary> lib = ResourceLoader::load(p_dir->get_file_path(i)); - if (lib.is_valid() && lib->is_singleton()) { - file_paths.insert(p_dir->get_file_path(i)); - } - } - - // check subdirectories - for (int i = 0; i < p_dir->get_subdir_count(); i++) { - Set<String> paths = _find_singletons_recursive(p_dir->get_subdir(i)); - - for (Set<String>::Element *E = paths.front(); E; E = E->next()) { - file_paths.insert(E->get()); - } - } - - return file_paths; -} - -void GDNativeLibrarySingletonEditor::_discover_singletons() { - EditorFileSystemDirectory *dir = EditorFileSystem::get_singleton()->get_filesystem(); - - Set<String> file_paths = _find_singletons_recursive(dir); - - bool changed = false; - Array current_files; - if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons")) { - current_files = ProjectSettings::get_singleton()->get("gdnative/singletons"); - } - Array files; - for (Set<String>::Element *E = file_paths.front(); E; E = E->next()) { - if (!current_files.has(E->get())) { - changed = true; - } - files.append(E->get()); - } - - // Check for removed files - if (!changed) { - // Removed singleton - for (int j = 0; j < current_files.size(); j++) { - if (!files.has(current_files[j])) { - changed = true; - break; - } - } - } - - if (changed) { - ProjectSettings::get_singleton()->set("gdnative/singletons", files); - _update_libraries(); // So singleton options (i.e. disabled) updates too - ProjectSettings::get_singleton()->save(); - } -} - -void GDNativeLibrarySingletonEditor::_update_libraries() { - updating = true; - libraries->clear(); - libraries->create_item(); // root item - - Array singletons; - if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons")) { - singletons = ProjectSettings::get_singleton()->get("gdnative/singletons"); - } - Array singletons_disabled; - if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons_disabled")) { - singletons_disabled = ProjectSettings::get_singleton()->get("gdnative/singletons_disabled"); - } - - Array updated_disabled; - for (int i = 0; i < singletons.size(); i++) { - bool enabled = true; - String path = singletons[i]; - if (singletons_disabled.has(path)) { - enabled = false; - updated_disabled.push_back(path); - } - TreeItem *ti = libraries->create_item(libraries->get_root()); - ti->set_text(0, path.get_file()); - ti->set_tooltip(0, path); - ti->set_metadata(0, path); - ti->set_cell_mode(1, TreeItem::CELL_MODE_RANGE); - ti->set_text(1, "Disabled,Enabled"); - ti->set_range(1, enabled ? 1 : 0); - ti->set_custom_color(1, enabled ? Color(0, 1, 0) : Color(1, 0, 0)); - ti->set_editable(1, true); - } - - // The singletons list changed, we must update the settings - if (updated_disabled.size() != singletons_disabled.size()) { - ProjectSettings::get_singleton()->set("gdnative/singletons_disabled", updated_disabled); - } - - updating = false; -} - -void GDNativeLibrarySingletonEditor::_item_edited() { - if (updating) { - return; - } - - TreeItem *item = libraries->get_edited(); - if (!item) { - return; - } - - bool enabled = item->get_range(1); - String path = item->get_metadata(0); - - Array disabled_paths; - Array undo_paths; - if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons_disabled")) { - disabled_paths = ProjectSettings::get_singleton()->get("gdnative/singletons_disabled"); - // Duplicate so redo works (not a reference) - disabled_paths = disabled_paths.duplicate(); - // For undo, so we can reset the property. - undo_paths = disabled_paths.duplicate(); - } - - if (enabled) { - disabled_paths.erase(path); - } else { - if (disabled_paths.find(path) == -1) { - disabled_paths.push_back(path); - } - } - - undo_redo->create_action(enabled ? TTR("Enabled GDNative Singleton") : TTR("Disabled GDNative Singleton")); - undo_redo->add_do_property(ProjectSettings::get_singleton(), "gdnative/singletons_disabled", disabled_paths); - undo_redo->add_do_method(this, "_update_libraries"); - undo_redo->add_undo_property(ProjectSettings::get_singleton(), "gdnative/singletons_disabled", undo_paths); - undo_redo->add_undo_method(this, "_update_libraries"); - undo_redo->commit_action(); -} - -void GDNativeLibrarySingletonEditor::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_VISIBILITY_CHANGED: { - if (is_visible_in_tree()) { - _update_libraries(); - } - } break; - } -} - -void GDNativeLibrarySingletonEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("_update_libraries"), &GDNativeLibrarySingletonEditor::_update_libraries); -} - -GDNativeLibrarySingletonEditor::GDNativeLibrarySingletonEditor() { - undo_redo = EditorNode::get_singleton()->get_undo_redo(); - libraries = memnew(Tree); - libraries->set_columns(2); - libraries->set_column_titles_visible(true); - libraries->set_column_title(0, TTR("Library")); - libraries->set_column_title(1, TTR("Status")); - libraries->set_hide_root(true); - add_margin_child(TTR("Libraries: "), libraries, true); - updating = false; - libraries->connect("item_edited", callable_mp(this, &GDNativeLibrarySingletonEditor::_item_edited)); - EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &GDNativeLibrarySingletonEditor::_discover_singletons)); -} - -#endif // TOOLS_ENABLED diff --git a/modules/gdnative/gdnative_library_singleton_editor.h b/modules/gdnative/gdnative_library_singleton_editor.h deleted file mode 100644 index 16155723bc..0000000000 --- a/modules/gdnative/gdnative_library_singleton_editor.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************/ -/* gdnative_library_singleton_editor.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 GD_NATIVE_LIBRARY_EDITOR_H -#define GD_NATIVE_LIBRARY_EDITOR_H - -#ifdef TOOLS_ENABLED -#include "editor/editor_file_system.h" -#include "editor/project_settings_editor.h" - -class GDNativeLibrarySingletonEditor : public VBoxContainer { - GDCLASS(GDNativeLibrarySingletonEditor, VBoxContainer); - -private: - Tree *libraries; - UndoRedo *undo_redo; - - bool updating; - - static Set<String> _find_singletons_recursive(EditorFileSystemDirectory *p_dir); - -protected: - void _notification(int p_what); - static void _bind_methods(); - - void _discover_singletons(); - void _item_edited(); - void _update_libraries(); - -public: - GDNativeLibrarySingletonEditor(); -}; - -#endif -#endif // GD_NATIVE_LIBRARY_EDITOR_H diff --git a/modules/gdnative/icons/GDNativeLibrary.svg b/modules/gdnative/icons/GDNativeLibrary.svg deleted file mode 100644 index 0ddfd4e6f2..0000000000 --- a/modules/gdnative/icons/GDNativeLibrary.svg +++ /dev/null @@ -1 +0,0 @@ -<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m7 1-.56445 2.2578a5 5 0 0 0 -.68945.2793l-1.9883-1.1934-1.4141 1.4141 1.1953 1.9941a5 5 0 0 0 -.28516.68555l-2.2539.5625v2l2.2578.56445a5 5 0 0 0 .2793.6875l-1.1934 1.9902 1.4141 1.4141 1.9941-1.1953a5 5 0 0 0 .68555.28516l.5625 2.2539v-5.2695a2 2 0 0 1 -1-1.7305 2 2 0 0 1 1-1.7285v-.27148h1 4.5762a5 5 0 0 0 -.11328-.25195l1.1934-1.9902-1.4141-1.4141-1.9941 1.1953a5 5 0 0 0 -.68555-.28516l-.5625-2.2539h-2zm2 7v1 5 1h5c.55228 0 1-.4477 1-1v-5c0-.5523-.44772-1-1-1v4l-1-1-1 1v-4z" fill="#e0e0e0"/></svg> diff --git a/modules/gdnative/icons/NativeScript.svg b/modules/gdnative/icons/NativeScript.svg deleted file mode 100644 index 2224b36b29..0000000000 --- a/modules/gdnative/icons/NativeScript.svg +++ /dev/null @@ -1 +0,0 @@ -<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m7 1-.56445 2.2578a5 5 0 0 0 -.68945.2793l-1.9883-1.1934-1.4141 1.4141 1.1953 1.9941a5 5 0 0 0 -.28516.68555l-2.2539.5625h3v1 1h2v-.95117a2 2 0 0 1 0-.048828 2 2 0 0 1 2-2 2 2 0 0 1 2 2v1h5v-2l-2.2578-.56445a5 5 0 0 0 -.2793-.6875l1.1934-1.9902-1.4141-1.4141-1.9941 1.1953a5 5 0 0 0 -.68555-.28516l-.5625-2.2539h-2zm-6 7v4 4h2a3 3 0 0 0 3-3 3 3 0 0 0 -3-3v-2zm6 0v2h2v-2zm3 2v6h2v-4a1 1 0 0 1 1 1v3h2v-3a3 3 0 0 0 -3-3zm-7 2a1 1 0 0 1 1 1 1 1 0 0 1 -1 1zm4 0v4h2v-4z" fill="#e0e0e0"/></svg> diff --git a/modules/gdnative/include/android/godot_android.h b/modules/gdnative/include/android/godot_android.h deleted file mode 100644 index 859a85ae1e..0000000000 --- a/modules/gdnative/include/android/godot_android.h +++ /dev/null @@ -1,56 +0,0 @@ -/*************************************************************************/ -/* godot_android.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_ANDROID_GDN_H -#define GODOT_ANDROID_GDN_H - -#include <gdnative/gdnative.h> - -#ifdef __ANDROID__ -#include <jni.h> -#else -#define JNIEnv void -#define jobject void * -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -JNIEnv *GDAPI godot_android_get_env(); -jobject GDAPI godot_android_get_activity(); -jobject GDAPI godot_android_get_surface(); -bool GDAPI godot_android_is_activity_resumed(); - -#ifdef __cplusplus -} -#endif - -#endif /* !GODOT_ANDROID_GDN_H */ diff --git a/modules/gdnative/include/gdnative/aabb.h b/modules/gdnative/include/gdnative/aabb.h deleted file mode 100644 index 67818f61c8..0000000000 --- a/modules/gdnative/include/gdnative/aabb.h +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************/ -/* aabb.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_AABB_H -#define GODOT_AABB_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <gdnative/math_defs.h> - -#define GODOT_AABB_SIZE (sizeof(godot_real_t) * 6) - -#ifndef GODOT_CORE_API_GODOT_AABB_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_AABB_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_AABB_SIZE]; -} godot_aabb; -#endif - -#include <gdnative/gdnative.h> - -void GDAPI godot_aabb_new(godot_aabb *p_self); -void GDAPI godot_aabb_new_copy(godot_aabb *r_dest, const godot_aabb *p_src); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_AABB_H diff --git a/modules/gdnative/include/gdnative/array.h b/modules/gdnative/include/gdnative/array.h deleted file mode 100644 index cee641a7c5..0000000000 --- a/modules/gdnative/include/gdnative/array.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************/ -/* array.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_ARRAY_H -#define GODOT_ARRAY_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdint.h> - -#define GODOT_ARRAY_SIZE sizeof(void *) - -#ifndef GODOT_CORE_API_GODOT_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_ARRAY_SIZE]; -} godot_array; -#endif - -#include <gdnative/gdnative.h> -#include <gdnative/variant_struct.h> - -void GDAPI godot_array_new(godot_array *p_self); -void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src); -void GDAPI godot_array_destroy(godot_array *p_self); -godot_variant GDAPI *godot_array_operator_index(godot_array *p_self, godot_int p_index); -const godot_variant GDAPI *godot_array_operator_index_const(const godot_array *p_self, godot_int p_index); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_ARRAY_H diff --git a/modules/gdnative/include/gdnative/basis.h b/modules/gdnative/include/gdnative/basis.h deleted file mode 100644 index 50c9aa6408..0000000000 --- a/modules/gdnative/include/gdnative/basis.h +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************/ -/* basis.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_BASIS_H -#define GODOT_BASIS_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <gdnative/math_defs.h> - -#define GODOT_BASIS_SIZE (sizeof(godot_real_t) * 9) - -#ifndef GODOT_CORE_API_GODOT_BASIS_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_BASIS_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_BASIS_SIZE]; -} godot_basis; -#endif - -#include <gdnative/gdnative.h> - -void GDAPI godot_basis_new(godot_basis *p_self); -void GDAPI godot_basis_new_copy(godot_basis *r_dest, const godot_basis *p_src); -godot_vector3 GDAPI *godot_basis_operator_index(godot_basis *p_self, godot_int p_index); -const godot_vector3 GDAPI *godot_basis_operator_index_const(const godot_basis *p_self, godot_int p_index); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_BASIS_H diff --git a/modules/gdnative/include/gdnative/callable.h b/modules/gdnative/include/gdnative/callable.h deleted file mode 100644 index db068d2ac7..0000000000 --- a/modules/gdnative/include/gdnative/callable.h +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************/ -/* callable.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_CALLABLE_H -#define GODOT_CALLABLE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdint.h> - -// Alignment hardcoded in `core/variant/callable.h`. -#define GODOT_CALLABLE_SIZE (16) - -#ifndef GODOT_CORE_API_GODOT_CALLABLE_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_CALLABLE_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_CALLABLE_SIZE]; -} godot_callable; -#endif - -#include <gdnative/gdnative.h> - -void GDAPI godot_callable_new(godot_callable *p_self); -void GDAPI godot_callable_new_copy(godot_callable *r_dest, const godot_callable *p_src); -void GDAPI godot_callable_destroy(godot_callable *p_self); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/modules/gdnative/include/gdnative/color.h b/modules/gdnative/include/gdnative/color.h deleted file mode 100644 index 2d64a323f9..0000000000 --- a/modules/gdnative/include/gdnative/color.h +++ /dev/null @@ -1,61 +0,0 @@ -/*************************************************************************/ -/* color.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_COLOR_H -#define GODOT_COLOR_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <gdnative/math_defs.h> - -// Colors should always use 32-bit floats, so don't use real_t here. -#define GODOT_COLOR_SIZE (sizeof(float) * 4) - -#ifndef GODOT_CORE_API_GODOT_COLOR_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_COLOR_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_COLOR_SIZE]; -} godot_color; -#endif - -#include <gdnative/gdnative.h> - -void GDAPI godot_color_new(godot_color *p_self); -void GDAPI godot_color_new_copy(godot_color *r_dest, const godot_color *p_src); -float GDAPI *godot_color_operator_index(godot_color *p_self, godot_int p_index); -const float GDAPI *godot_color_operator_index_const(const godot_color *p_self, godot_int p_index); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_COLOR_H diff --git a/modules/gdnative/include/gdnative/dictionary.h b/modules/gdnative/include/gdnative/dictionary.h deleted file mode 100644 index 4219753f71..0000000000 --- a/modules/gdnative/include/gdnative/dictionary.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************/ -/* dictionary.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_DICTIONARY_H -#define GODOT_DICTIONARY_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdint.h> - -#define GODOT_DICTIONARY_SIZE sizeof(void *) - -#ifndef GODOT_CORE_API_GODOT_DICTIONARY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_DICTIONARY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_DICTIONARY_SIZE]; -} godot_dictionary; -#endif - -#include <gdnative/gdnative.h> -#include <gdnative/variant_struct.h> - -void GDAPI godot_dictionary_new(godot_dictionary *p_self); -void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *p_src); -void GDAPI godot_dictionary_destroy(godot_dictionary *p_self); -godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_self, const godot_variant *p_key); -const godot_variant GDAPI *godot_dictionary_operator_index_const(const godot_dictionary *p_self, const godot_variant *p_key); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_DICTIONARY_H diff --git a/modules/gdnative/include/gdnative/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h deleted file mode 100644 index b46a00c185..0000000000 --- a/modules/gdnative/include/gdnative/gdnative.h +++ /dev/null @@ -1,287 +0,0 @@ -/*************************************************************************/ -/* gdnative.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_GDNATIVE_H -#define GODOT_GDNATIVE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(_WIN32) || defined(__ANDROID__) -#define GDCALLINGCONV -#define GDAPI GDCALLINGCONV -#elif defined(__APPLE__) -#include "TargetConditionals.h" -#if TARGET_OS_IPHONE -#define GDCALLINGCONV __attribute__((visibility("default"))) -#define GDAPI GDCALLINGCONV -#elif TARGET_OS_MAC -#define GDCALLINGCONV __attribute__((sysv_abi)) -#define GDAPI GDCALLINGCONV -#endif -#else // !_WIN32 && !__APPLE__ -#define GDCALLINGCONV __attribute__((sysv_abi)) -#define GDAPI GDCALLINGCONV -#endif - -// This is for libraries *using* the header, NOT GODOT EXPOSING STUFF!! -#ifdef __GNUC__ -#define GDN_EXPORT __attribute__((visibility("default"))) -#elif defined(_WIN32) -#define GDN_EXPORT __declspec(dllexport) -#else -#define GDN_EXPORT -#endif - -#include <stdbool.h> -#include <stdint.h> - -////// Error - -typedef enum { - GODOT_OK, // (0) - GODOT_FAILED, ///< Generic fail error - GODOT_ERR_UNAVAILABLE, ///< What is requested is unsupported/unavailable - GODOT_ERR_UNCONFIGURED, ///< The object being used hasn't been properly set up yet - GODOT_ERR_UNAUTHORIZED, ///< Missing credentials for requested resource - GODOT_ERR_PARAMETER_RANGE_ERROR, ///< Parameter given out of range (5) - GODOT_ERR_OUT_OF_MEMORY, ///< Out of memory - GODOT_ERR_FILE_NOT_FOUND, - GODOT_ERR_FILE_BAD_DRIVE, - GODOT_ERR_FILE_BAD_PATH, - GODOT_ERR_FILE_NO_PERMISSION, // (10) - GODOT_ERR_FILE_ALREADY_IN_USE, - GODOT_ERR_FILE_CANT_OPEN, - GODOT_ERR_FILE_CANT_WRITE, - GODOT_ERR_FILE_CANT_READ, - GODOT_ERR_FILE_UNRECOGNIZED, // (15) - GODOT_ERR_FILE_CORRUPT, - GODOT_ERR_FILE_MISSING_DEPENDENCIES, - GODOT_ERR_FILE_EOF, - GODOT_ERR_CANT_OPEN, ///< Can't open a resource/socket/file - GODOT_ERR_CANT_CREATE, // (20) - GODOT_ERR_QUERY_FAILED, - GODOT_ERR_ALREADY_IN_USE, - GODOT_ERR_LOCKED, ///< resource is locked - GODOT_ERR_TIMEOUT, - GODOT_ERR_CANT_CONNECT, // (25) - GODOT_ERR_CANT_RESOLVE, - GODOT_ERR_CONNECTION_ERROR, - GODOT_ERR_CANT_ACQUIRE_RESOURCE, - GODOT_ERR_CANT_FORK, - GODOT_ERR_INVALID_DATA, ///< Data passed is invalid (30) - GODOT_ERR_INVALID_PARAMETER, ///< Parameter passed is invalid - GODOT_ERR_ALREADY_EXISTS, ///< When adding, item already exists - GODOT_ERR_DOES_NOT_EXIST, ///< When retrieving/erasing, it item does not exist - GODOT_ERR_DATABASE_CANT_READ, ///< database is full - GODOT_ERR_DATABASE_CANT_WRITE, ///< database is full (35) - GODOT_ERR_COMPILATION_FAILED, - GODOT_ERR_METHOD_NOT_FOUND, - GODOT_ERR_LINK_FAILED, - GODOT_ERR_SCRIPT_FAILED, - GODOT_ERR_CYCLIC_LINK, // (40) - GODOT_ERR_INVALID_DECLARATION, - GODOT_ERR_DUPLICATE_SYMBOL, - GODOT_ERR_PARSE_ERROR, - GODOT_ERR_BUSY, - GODOT_ERR_SKIP, // (45) - GODOT_ERR_HELP, ///< user requested help!! - GODOT_ERR_BUG, ///< a bug in the software certainly happened, due to a double check failing or unexpected behavior. - GODOT_ERR_PRINTER_ON_FIRE, /// the parallel port printer is engulfed in flames -} godot_error; - -/////// Object (forward declared) -typedef void godot_object; - -/////// String - -#include <gdnative/string.h> - -/////// String name - -#include <gdnative/string_name.h> - -////// Vector2 & Vector2i - -#include <gdnative/vector2.h> - -////// Rect2 & Rect2i - -#include <gdnative/rect2.h> - -////// Vector3 & Vector3i - -#include <gdnative/vector3.h> - -////// Transform2D - -#include <gdnative/transform2d.h> - -/////// Plane - -#include <gdnative/plane.h> - -/////// Quaternion - -#include <gdnative/quaternion.h> - -/////// AABB - -#include <gdnative/aabb.h> - -/////// Basis - -#include <gdnative/basis.h> - -/////// Transform3D - -#include <gdnative/transform_3d.h> - -/////// Color - -#include <gdnative/color.h> - -/////// NodePath - -#include <gdnative/node_path.h> - -/////// RID - -#include <gdnative/rid.h> - -/////// Callable & Signal - -#include <gdnative/callable.h> - -/////// Dictionary - -#include <gdnative/dictionary.h> - -/////// Array - -#include <gdnative/array.h> - -// single API file for Packed*Array -#include <gdnative/packed_arrays.h> - -void GDAPI godot_object_destroy(godot_object *p_o); - -////// Variant - -#include <gdnative/variant.h> - -////// Singleton API - -godot_object GDAPI *godot_global_get_singleton(char *p_name); // Result shouldn't be freed. - -////// MethodBind API - -typedef struct { - uint8_t _dont_touch_that[1]; // TODO -} godot_method_bind; - -godot_method_bind GDAPI *godot_method_bind_get_method(const char *p_classname, const char *p_methodname); -void GDAPI godot_method_bind_ptrcall(godot_method_bind *p_method_bind, godot_object *p_instance, const void **p_args, void *p_ret); -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_gdnative_api_version { - unsigned int major; - unsigned int minor; -} godot_gdnative_api_version; - -typedef struct godot_gdnative_api_struct godot_gdnative_api_struct; - -struct godot_gdnative_api_struct { - unsigned int type; - godot_gdnative_api_version version; - const godot_gdnative_api_struct *next; -}; - -#define GDNATIVE_VERSION_COMPATIBLE(want, have) (want.major == have.major && want.minor <= have.minor) - -typedef struct { - godot_bool in_editor; - uint64_t core_api_hash; - uint64_t editor_api_hash; - uint64_t no_api_hash; - void (*report_version_mismatch)(const godot_object *p_library, const char *p_what, godot_gdnative_api_version p_want, godot_gdnative_api_version p_have); - void (*report_loading_error)(const godot_object *p_library, const char *p_what); - godot_object *gd_native_library; // pointer to GDNativeLibrary that is being initialized - const struct godot_gdnative_core_api_struct *api_struct; - const godot_string *active_library_path; -} godot_gdnative_init_options; - -typedef struct { - godot_bool in_editor; -} godot_gdnative_terminate_options; - -// Calling convention? -typedef godot_object *(*godot_class_constructor)(); - -godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classname); - -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)(godot_array *); - -////// System Functions - -typedef godot_variant (*native_call_cb)(void *, godot_array *); -void GDAPI godot_register_native_call_type(const char *p_call_type, native_call_cb p_callback); - -//using these will help Godot track how much memory is in use in debug mode -void GDAPI *godot_alloc(int p_bytes); -void GDAPI *godot_realloc(void *p_ptr, int p_bytes); -void GDAPI godot_free(void *p_ptr); - -// Helper print functions. -void GDAPI godot_print_error(const char *p_description, const char *p_function, const char *p_file, int p_line); -void GDAPI godot_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line); -void GDAPI godot_print_script_error(const char *p_description, const char *p_function, const char *p_file, int p_line); - -//tags used for safe dynamic casting -void GDAPI *godot_get_class_tag(const godot_string_name *p_class); -godot_object GDAPI *godot_object_cast_to(const godot_object *p_object, void *p_class_tag); - -// equivalent of GDScript's instance_from_id -godot_object GDAPI *godot_instance_from_id(uint64_t p_instance_id); - -uint64_t GDAPI godot_object_get_instance_id(const godot_object *p_object); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_GDNATIVE_H diff --git a/modules/gdnative/include/gdnative/math_defs.h b/modules/gdnative/include/gdnative/math_defs.h deleted file mode 100644 index dee027527e..0000000000 --- a/modules/gdnative/include/gdnative/math_defs.h +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************/ -/* math_defs.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_GDNATIVE_MATH_DEFS_H -#define GODOT_GDNATIVE_MATH_DEFS_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdbool.h> -#include <stdint.h> - -////// bool - -typedef bool godot_bool; - -#define GODOT_TRUE 1 -#define GODOT_FALSE 0 - -/////// int - -typedef int64_t godot_int; - -/////// float - -typedef double godot_float; - -#ifdef REAL_T_IS_DOUBLE -typedef double godot_real_t; -#else -typedef float godot_real_t; -#endif - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_C_H diff --git a/modules/gdnative/include/gdnative/node_path.h b/modules/gdnative/include/gdnative/node_path.h deleted file mode 100644 index 46b693dcf6..0000000000 --- a/modules/gdnative/include/gdnative/node_path.h +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************/ -/* node_path.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_NODE_PATH_H -#define GODOT_NODE_PATH_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdint.h> - -#define GODOT_NODE_PATH_SIZE sizeof(void *) - -#ifndef GODOT_CORE_API_GODOT_NODE_PATH_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_NODE_PATH_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_NODE_PATH_SIZE]; -} godot_node_path; -#endif - -#include <gdnative/gdnative.h> - -void GDAPI godot_node_path_new(godot_node_path *p_self); -void GDAPI godot_node_path_new_copy(godot_node_path *r_dest, const godot_node_path *p_src); -void GDAPI godot_node_path_destroy(godot_node_path *p_self); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_NODE_PATH_H diff --git a/modules/gdnative/include/gdnative/packed_arrays.h b/modules/gdnative/include/gdnative/packed_arrays.h deleted file mode 100644 index f4935ee0dc..0000000000 --- a/modules/gdnative/include/gdnative/packed_arrays.h +++ /dev/null @@ -1,255 +0,0 @@ -/*************************************************************************/ -/* packed_arrays.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_PACKED_ARRAYS_H -#define GODOT_PACKED_ARRAYS_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdint.h> - -/////// PackedByteArray - -#define GODOT_PACKED_BYTE_ARRAY_SIZE (2 * sizeof(void *)) - -#ifndef GODOT_CORE_API_GODOT_PACKED_BYTE_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_PACKED_BYTE_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_PACKED_BYTE_ARRAY_SIZE]; -} godot_packed_byte_array; -#endif - -/////// PackedInt32Array - -#define GODOT_PACKED_INT32_ARRAY_SIZE (2 * sizeof(void *)) - -#ifndef GODOT_CORE_API_GODOT_PACKED_INT32_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_PACKED_INT32_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_PACKED_INT32_ARRAY_SIZE]; -} godot_packed_int32_array; -#endif - -/////// PackedInt64Array - -#define GODOT_PACKED_INT64_ARRAY_SIZE (2 * sizeof(void *)) - -#ifndef GODOT_CORE_API_GODOT_PACKED_INT64_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_PACKED_INT64_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_PACKED_INT64_ARRAY_SIZE]; -} godot_packed_int64_array; -#endif - -/////// PackedFloat32Array - -#define GODOT_PACKED_FLOAT32_ARRAY_SIZE (2 * sizeof(void *)) - -#ifndef GODOT_CORE_API_GODOT_PACKED_FLOAT32_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_PACKED_FLOAT32_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_PACKED_FLOAT32_ARRAY_SIZE]; -} godot_packed_float32_array; -#endif - -/////// PackedFloat64Array - -#define GODOT_PACKED_FLOAT64_ARRAY_SIZE (2 * sizeof(void *)) - -#ifndef GODOT_CORE_API_GODOT_PACKED_FLOAT64_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_PACKED_FLOAT64_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_PACKED_FLOAT64_ARRAY_SIZE]; -} godot_packed_float64_array; -#endif - -/////// PackedStringArray - -#define GODOT_PACKED_STRING_ARRAY_SIZE (2 * sizeof(void *)) - -#ifndef GODOT_CORE_API_GODOT_PACKED_STRING_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_PACKED_STRING_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_PACKED_STRING_ARRAY_SIZE]; -} godot_packed_string_array; -#endif - -/////// PackedVector2Array - -#define GODOT_PACKED_VECTOR2_ARRAY_SIZE (2 * sizeof(void *)) - -#ifndef GODOT_CORE_API_GODOT_PACKED_VECTOR2_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_PACKED_VECTOR2_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_PACKED_VECTOR2_ARRAY_SIZE]; -} godot_packed_vector2_array; -#endif - -/////// PackedVector2iArray - -#define GODOT_PACKED_VECTOR2I_ARRAY_SIZE (2 * sizeof(void *)) - -#ifndef GODOT_CORE_API_GODOT_PACKED_VECTOR2I_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_PACKED_VECTOR2I_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_PACKED_VECTOR2I_ARRAY_SIZE]; -} godot_packed_vector2i_array; -#endif - -/////// PackedVector3Array - -#define GODOT_PACKED_VECTOR3_ARRAY_SIZE (2 * sizeof(void *)) - -#ifndef GODOT_CORE_API_GODOT_PACKED_VECTOR3_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_PACKED_VECTOR3_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_PACKED_VECTOR3_ARRAY_SIZE]; -} godot_packed_vector3_array; -#endif - -/////// PackedVector3iArray - -#define GODOT_PACKED_VECTOR3I_ARRAY_SIZE (2 * sizeof(void *)) - -#ifndef GODOT_CORE_API_GODOT_PACKED_VECTOR3I_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_PACKED_VECTOR3I_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_PACKED_VECTOR3I_ARRAY_SIZE]; -} godot_packed_vector3i_array; -#endif - -/////// PackedColorArray - -#define GODOT_PACKED_COLOR_ARRAY_SIZE (2 * sizeof(void *)) - -#ifndef GODOT_CORE_API_GODOT_PACKED_COLOR_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_PACKED_COLOR_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_PACKED_COLOR_ARRAY_SIZE]; -} godot_packed_color_array; -#endif - -#include <gdnative/gdnative.h> - -// Byte. - -void GDAPI godot_packed_byte_array_new(godot_packed_byte_array *p_self); -void GDAPI godot_packed_byte_array_new_copy(godot_packed_byte_array *r_dest, const godot_packed_byte_array *p_src); -void GDAPI godot_packed_byte_array_destroy(godot_packed_byte_array *p_self); -uint8_t GDAPI *godot_packed_byte_array_operator_index(godot_packed_byte_array *p_self, godot_int p_index); -const uint8_t GDAPI *godot_packed_byte_array_operator_index_const(const godot_packed_byte_array *p_self, godot_int p_index); - -// Int32. - -void GDAPI godot_packed_int32_array_new(godot_packed_int32_array *p_self); -void GDAPI godot_packed_int32_array_new_copy(godot_packed_int32_array *r_dest, const godot_packed_int32_array *p_src); -void GDAPI godot_packed_int32_array_destroy(godot_packed_int32_array *p_self); -int32_t GDAPI *godot_packed_int32_array_operator_index(godot_packed_int32_array *p_self, godot_int p_index); -const int32_t GDAPI *godot_packed_int32_array_operator_index_const(const godot_packed_int32_array *p_self, godot_int p_index); - -// Int64. - -void GDAPI godot_packed_int64_array_new(godot_packed_int64_array *p_self); -void GDAPI godot_packed_int64_array_new_copy(godot_packed_int64_array *r_dest, const godot_packed_int64_array *p_src); -void GDAPI godot_packed_int64_array_destroy(godot_packed_int64_array *p_self); -int64_t GDAPI *godot_packed_int64_array_operator_index(godot_packed_int64_array *p_self, godot_int p_index); -const int64_t GDAPI *godot_packed_int64_array_operator_index_const(const godot_packed_int64_array *p_self, godot_int p_index); - -// Float32. - -void GDAPI godot_packed_float32_array_new(godot_packed_float32_array *p_self); -void GDAPI godot_packed_float32_array_new_copy(godot_packed_float32_array *r_dest, const godot_packed_float32_array *p_src); -void GDAPI godot_packed_float32_array_destroy(godot_packed_float32_array *p_self); -float GDAPI *godot_packed_float32_array_operator_index(godot_packed_float32_array *p_self, godot_int p_index); -const float GDAPI *godot_packed_float32_array_operator_index_const(const godot_packed_float32_array *p_self, godot_int p_index); - -// Float64. - -void GDAPI godot_packed_float64_array_new(godot_packed_float64_array *p_self); -void GDAPI godot_packed_float64_array_new_copy(godot_packed_float64_array *r_dest, const godot_packed_float64_array *p_src); -void GDAPI godot_packed_float64_array_destroy(godot_packed_float64_array *p_self); -double GDAPI *godot_packed_float64_array_operator_index(godot_packed_float64_array *p_self, godot_int p_index); -const double GDAPI *godot_packed_float64_array_operator_index_const(const godot_packed_float64_array *p_self, godot_int p_index); - -// String. - -void GDAPI godot_packed_string_array_new(godot_packed_string_array *p_self); -void GDAPI godot_packed_string_array_new_copy(godot_packed_string_array *r_dest, const godot_packed_string_array *p_src); -void GDAPI godot_packed_string_array_destroy(godot_packed_string_array *p_self); -godot_string GDAPI *godot_packed_string_array_operator_index(godot_packed_string_array *p_self, godot_int p_index); -const godot_string GDAPI *godot_packed_string_array_operator_index_const(const godot_packed_string_array *p_self, godot_int p_index); - -// Vector2. - -void GDAPI godot_packed_vector2_array_new(godot_packed_vector2_array *p_self); -void GDAPI godot_packed_vector2_array_new_copy(godot_packed_vector2_array *r_dest, const godot_packed_vector2_array *p_src); -void GDAPI godot_packed_vector2_array_destroy(godot_packed_vector2_array *p_self); -godot_vector2 GDAPI *godot_packed_vector2_array_operator_index(godot_packed_vector2_array *p_self, godot_int p_index); -const godot_vector2 GDAPI *godot_packed_vector2_array_operator_index_const(const godot_packed_vector2_array *p_self, godot_int p_index); - -// Vector2i. - -void GDAPI godot_packed_vector2i_array_new(godot_packed_vector2i_array *p_self); -void GDAPI godot_packed_vector2i_array_new_copy(godot_packed_vector2i_array *r_dest, const godot_packed_vector2i_array *p_src); -void GDAPI godot_packed_vector2i_array_destroy(godot_packed_vector2i_array *p_self); -godot_vector2i GDAPI *godot_packed_vector2i_array_operator_index(godot_packed_vector2i_array *p_self, godot_int p_index); -const godot_vector2i GDAPI *godot_packed_vector2i_array_operator_index_const(const godot_packed_vector2i_array *p_self, godot_int p_index); - -// Vector3. - -void GDAPI godot_packed_vector3_array_new(godot_packed_vector3_array *p_self); -void GDAPI godot_packed_vector3_array_new_copy(godot_packed_vector3_array *r_dest, const godot_packed_vector3_array *p_src); -void GDAPI godot_packed_vector3_array_destroy(godot_packed_vector3_array *p_self); -godot_vector3 GDAPI *godot_packed_vector3_array_operator_index(godot_packed_vector3_array *p_self, godot_int p_index); -const godot_vector3 GDAPI *godot_packed_vector3_array_operator_index_const(const godot_packed_vector3_array *p_self, godot_int p_index); - -// Vector3i. - -void GDAPI godot_packed_vector3i_array_new(godot_packed_vector3i_array *p_self); -void GDAPI godot_packed_vector3i_array_new_copy(godot_packed_vector3i_array *r_dest, const godot_packed_vector3i_array *p_src); -void GDAPI godot_packed_vector3i_array_destroy(godot_packed_vector3i_array *p_self); -godot_vector3i GDAPI *godot_packed_vector3i_array_operator_index(godot_packed_vector3i_array *p_self, godot_int p_index); -const godot_vector3i GDAPI *godot_packed_vector3i_array_operator_index_const(const godot_packed_vector3i_array *p_self, godot_int p_index); - -// Color. - -void GDAPI godot_packed_color_array_new(godot_packed_color_array *p_self); -void GDAPI godot_packed_color_array_new_copy(godot_packed_color_array *r_dest, const godot_packed_color_array *p_src); -void GDAPI godot_packed_color_array_destroy(godot_packed_color_array *p_self); -godot_color GDAPI *godot_packed_color_array_operator_index(godot_packed_color_array *p_self, godot_int p_index); -const godot_color GDAPI *godot_packed_color_array_operator_index_const(const godot_packed_color_array *p_self, godot_int p_index); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_PACKED_ARRAYS_H diff --git a/modules/gdnative/include/gdnative/plane.h b/modules/gdnative/include/gdnative/plane.h deleted file mode 100644 index e8f4f13b99..0000000000 --- a/modules/gdnative/include/gdnative/plane.h +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************/ -/* plane.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_PLANE_H -#define GODOT_PLANE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <gdnative/math_defs.h> - -#define GODOT_PLANE_SIZE (sizeof(godot_real_t) * 4) - -#ifndef GODOT_CORE_API_GODOT_PLANE_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_PLANE_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_PLANE_SIZE]; -} godot_plane; -#endif - -#include <gdnative/gdnative.h> - -void GDAPI godot_plane_new(godot_plane *p_self); -void GDAPI godot_plane_new_copy(godot_plane *r_dest, const godot_plane *p_src); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_PLANE_H diff --git a/modules/gdnative/include/gdnative/quaternion.h b/modules/gdnative/include/gdnative/quaternion.h deleted file mode 100644 index 80e99c3a7c..0000000000 --- a/modules/gdnative/include/gdnative/quaternion.h +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************/ -/* quaternion.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_QUATERNION_H -#define GODOT_QUATERNION_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <gdnative/math_defs.h> - -#define GODOT_QUATERNION_SIZE (sizeof(godot_real_t) * 4) - -#ifndef GODOT_CORE_API_GODOT_QUATERNION_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_QUATERNION_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_QUATERNION_SIZE]; -} godot_quaternion; -#endif - -#include <gdnative/gdnative.h> - -void GDAPI godot_quaternion_new(godot_quaternion *p_self); -void GDAPI godot_quaternion_new_copy(godot_quaternion *r_dest, const godot_quaternion *p_src); -godot_real_t GDAPI *godot_quaternion_operator_index(godot_quaternion *p_self, godot_int p_index); -const godot_real_t GDAPI *godot_quaternion_operator_index_const(const godot_quaternion *p_self, godot_int p_index); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_QUATERNION_H diff --git a/modules/gdnative/include/gdnative/rect2.h b/modules/gdnative/include/gdnative/rect2.h deleted file mode 100644 index a901537fc4..0000000000 --- a/modules/gdnative/include/gdnative/rect2.h +++ /dev/null @@ -1,69 +0,0 @@ -/*************************************************************************/ -/* rect2.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_RECT2_H -#define GODOT_RECT2_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <gdnative/math_defs.h> - -#define GODOT_RECT2_SIZE (sizeof(godot_real_t) * 4) - -#ifndef GODOT_CORE_API_GODOT_RECT2_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_RECT2_TYPE_DEFINED -typedef struct godot_rect2 { - uint8_t _dont_touch_that[GODOT_RECT2_SIZE]; -} godot_rect2; -#endif - -#define GODOT_RECT2I_SIZE (sizeof(int32_t) * 4) - -#ifndef GODOT_CORE_API_GODOT_RECT2I_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_RECT2I_TYPE_DEFINED -typedef struct godot_rect2i { - uint8_t _dont_touch_that[GODOT_RECT2I_SIZE]; -} godot_rect2i; -#endif - -#include <gdnative/gdnative.h> - -void GDAPI godot_rect2_new(godot_rect2 *p_self); -void GDAPI godot_rect2_new_copy(godot_rect2 *r_dest, const godot_rect2 *p_src); -void GDAPI godot_rect2i_new(godot_rect2i *p_self); -void GDAPI godot_rect2i_new_copy(godot_rect2i *r_dest, const godot_rect2i *p_src); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_RECT2_H diff --git a/modules/gdnative/include/gdnative/rid.h b/modules/gdnative/include/gdnative/rid.h deleted file mode 100644 index f3013f36f0..0000000000 --- a/modules/gdnative/include/gdnative/rid.h +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************/ -/* rid.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_RID_H -#define GODOT_RID_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdint.h> - -#define GODOT_RID_SIZE sizeof(uint64_t) - -#ifndef GODOT_CORE_API_GODOT_RID_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_RID_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_RID_SIZE]; -} godot_rid; -#endif - -#include <gdnative/gdnative.h> - -void GDAPI godot_rid_new(godot_rid *p_self); -void GDAPI godot_rid_new_copy(godot_rid *r_dest, const godot_rid *p_src); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_RID_H diff --git a/modules/gdnative/include/gdnative/signal.h b/modules/gdnative/include/gdnative/signal.h deleted file mode 100644 index 64aef1c918..0000000000 --- a/modules/gdnative/include/gdnative/signal.h +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************/ -/* signal.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_SIGNAL_H -#define GODOT_SIGNAL_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdint.h> - -// Alignment hardcoded in `core/variant/callable.h`. -#define GODOT_SIGNAL_SIZE (16) - -#ifndef GODOT_CORE_API_GODOT_SIGNAL_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_SIGNAL_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_SIGNAL_SIZE]; -} godot_signal; -#endif - -#include <gdnative/gdnative.h> - -void GDAPI godot_signal_new(godot_signal *p_self); -void GDAPI godot_signal_new_copy(godot_signal *r_dest, const godot_signal *p_src); -void GDAPI godot_signal_destroy(godot_signal *p_self); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/modules/gdnative/include/gdnative/string.h b/modules/gdnative/include/gdnative/string.h deleted file mode 100644 index 375e8f94c3..0000000000 --- a/modules/gdnative/include/gdnative/string.h +++ /dev/null @@ -1,89 +0,0 @@ -/*************************************************************************/ -/* string.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_STRING_H -#define GODOT_STRING_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stddef.h> -#include <stdint.h> - -#ifndef __cplusplus -typedef uint16_t char16_t; -typedef uint32_t char32_t; -#endif - -typedef char32_t godot_char_type; - -#define GODOT_STRING_SIZE sizeof(void *) - -#ifndef GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_STRING_SIZE]; -} godot_string; -#endif - -#include <gdnative/gdnative.h> -#include <gdnative/math_defs.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); -void GDAPI godot_string_destroy(godot_string *p_self); - -void GDAPI godot_string_new_with_latin1_chars(godot_string *r_dest, const char *p_contents); -void GDAPI godot_string_new_with_utf8_chars(godot_string *r_dest, const char *p_contents); -void GDAPI godot_string_new_with_utf16_chars(godot_string *r_dest, const char16_t *p_contents); -void GDAPI godot_string_new_with_utf32_chars(godot_string *r_dest, const char32_t *p_contents); -void GDAPI godot_string_new_with_wide_chars(godot_string *r_dest, const wchar_t *p_contents); - -void GDAPI godot_string_new_with_latin1_chars_and_len(godot_string *r_dest, const char *p_contents, const int p_size); -void GDAPI godot_string_new_with_utf8_chars_and_len(godot_string *r_dest, const char *p_contents, const int p_size); -void GDAPI godot_string_new_with_utf16_chars_and_len(godot_string *r_dest, const char16_t *p_contents, const int p_size); -void GDAPI godot_string_new_with_utf32_chars_and_len(godot_string *r_dest, const char32_t *p_contents, const int p_size); -void GDAPI godot_string_new_with_wide_chars_and_len(godot_string *r_dest, const wchar_t *p_contents, const int p_size); - -const char GDAPI *godot_string_to_latin1_chars(const godot_string *p_self); -const char GDAPI *godot_string_to_utf8_chars(const godot_string *p_self); -const char16_t GDAPI *godot_string_to_utf16_chars(const godot_string *p_self); -const char32_t GDAPI *godot_string_to_utf32_chars(const godot_string *p_self); -const wchar_t GDAPI *godot_string_to_wide_chars(const godot_string *p_self); - -char32_t GDAPI *godot_string_operator_index(godot_string *p_self, godot_int p_index); -const char32_t GDAPI *godot_string_operator_index_const(const godot_string *p_self, godot_int p_index); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_STRING_H diff --git a/modules/gdnative/include/gdnative/string_name.h b/modules/gdnative/include/gdnative/string_name.h deleted file mode 100644 index 6f4d9c64fe..0000000000 --- a/modules/gdnative/include/gdnative/string_name.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************/ -/* string_name.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_STRING_NAME_H -#define GODOT_STRING_NAME_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdint.h> -#include <wchar.h> - -#define GODOT_STRING_NAME_SIZE sizeof(void *) - -#ifndef GODOT_CORE_API_GODOT_STRING_NAME_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_STRING_NAME_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_STRING_NAME_SIZE]; -} godot_string_name; -#endif - -#include <gdnative/gdnative.h> - -void GDAPI godot_string_name_new(godot_string_name *r_dest); -void GDAPI godot_string_name_new_copy(godot_string_name *r_dest, const godot_string_name *p_src); -void GDAPI godot_string_name_destroy(godot_string_name *p_self); - -void GDAPI godot_string_name_new_with_latin1_chars(godot_string_name *r_dest, const char *p_contents); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_STRING_NAME_H diff --git a/modules/gdnative/include/gdnative/transform2d.h b/modules/gdnative/include/gdnative/transform2d.h deleted file mode 100644 index a083e61a2c..0000000000 --- a/modules/gdnative/include/gdnative/transform2d.h +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************/ -/* transform2d.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_TRANSFORM2D_H -#define GODOT_TRANSFORM2D_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <gdnative/math_defs.h> - -#define GODOT_TRANSFORM2D_SIZE (sizeof(godot_real_t) * 6) - -#ifndef GODOT_CORE_API_GODOT_TRANSFORM2D_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_TRANSFORM2D_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_TRANSFORM2D_SIZE]; -} godot_transform2d; -#endif - -#include <gdnative/gdnative.h> - -void GDAPI godot_transform2d_new(godot_transform2d *p_self); -void GDAPI godot_transform2d_new_copy(godot_transform2d *r_dest, const godot_transform2d *p_src); -godot_vector2 GDAPI *godot_transform2d_operator_index(godot_transform2d *p_self, godot_int p_index); -const godot_vector2 GDAPI *godot_transform2d_operator_index_const(const godot_transform2d *p_self, godot_int p_index); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_TRANSFORM2D_H diff --git a/modules/gdnative/include/gdnative/transform_3d.h b/modules/gdnative/include/gdnative/transform_3d.h deleted file mode 100644 index abd64a4d1d..0000000000 --- a/modules/gdnative/include/gdnative/transform_3d.h +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************/ -/* transform_3d.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_TRANSFORM3D_H -#define GODOT_TRANSFORM3D_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <gdnative/math_defs.h> - -#define GODOT_TRANSFORM3D_SIZE (sizeof(godot_real_t) * 12) - -#ifndef GODOT_CORE_API_GODOT_TRANSFORM3D_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_TRANSFORM3D_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_TRANSFORM3D_SIZE]; -} godot_transform3d; -#endif - -#include <gdnative/gdnative.h> - -void GDAPI godot_transform3d_new(godot_transform3d *p_self); -void GDAPI godot_transform3d_new_copy(godot_transform3d *r_dest, const godot_transform3d *p_src); -godot_vector3 GDAPI *godot_transform3d_operator_index(godot_transform3d *p_self, godot_int p_index); -const godot_vector3 GDAPI *godot_transform3d_operator_index_const(const godot_transform3d *p_self, godot_int p_index); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_TRANSFORM3D_H diff --git a/modules/gdnative/include/gdnative/variant.h b/modules/gdnative/include/gdnative/variant.h deleted file mode 100644 index b716fdaca1..0000000000 --- a/modules/gdnative/include/gdnative/variant.h +++ /dev/null @@ -1,425 +0,0 @@ -/*************************************************************************/ -/* variant.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_VARIANT_H -#define GODOT_VARIANT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <gdnative/math_defs.h> -#include <gdnative/variant_struct.h> - -typedef enum godot_variant_type { - GODOT_VARIANT_TYPE_NIL, - - // atomic types - GODOT_VARIANT_TYPE_BOOL, - GODOT_VARIANT_TYPE_INT, - GODOT_VARIANT_TYPE_FLOAT, - GODOT_VARIANT_TYPE_STRING, - - // math types - GODOT_VARIANT_TYPE_VECTOR2, - GODOT_VARIANT_TYPE_VECTOR2I, - GODOT_VARIANT_TYPE_RECT2, - GODOT_VARIANT_TYPE_RECT2I, - GODOT_VARIANT_TYPE_VECTOR3, - GODOT_VARIANT_TYPE_VECTOR3I, - GODOT_VARIANT_TYPE_TRANSFORM2D, - GODOT_VARIANT_TYPE_PLANE, - GODOT_VARIANT_TYPE_QUATERNION, - GODOT_VARIANT_TYPE_AABB, - GODOT_VARIANT_TYPE_BASIS, - GODOT_VARIANT_TYPE_TRANSFORM3D, - - // misc types - GODOT_VARIANT_TYPE_COLOR, - GODOT_VARIANT_TYPE_STRING_NAME, - GODOT_VARIANT_TYPE_NODE_PATH, - GODOT_VARIANT_TYPE_RID, - GODOT_VARIANT_TYPE_OBJECT, - GODOT_VARIANT_TYPE_CALLABLE, - GODOT_VARIANT_TYPE_SIGNAL, - GODOT_VARIANT_TYPE_DICTIONARY, - GODOT_VARIANT_TYPE_ARRAY, - - // arrays - GODOT_VARIANT_TYPE_PACKED_BYTE_ARRAY, - GODOT_VARIANT_TYPE_PACKED_INT32_ARRAY, - GODOT_VARIANT_TYPE_PACKED_INT64_ARRAY, - GODOT_VARIANT_TYPE_PACKED_FLOAT32_ARRAY, - GODOT_VARIANT_TYPE_PACKED_FLOAT64_ARRAY, - GODOT_VARIANT_TYPE_PACKED_STRING_ARRAY, - GODOT_VARIANT_TYPE_PACKED_VECTOR2_ARRAY, - GODOT_VARIANT_TYPE_PACKED_VECTOR3_ARRAY, - GODOT_VARIANT_TYPE_PACKED_COLOR_ARRAY, -} godot_variant_type; - -typedef enum godot_variant_call_error_error { - GODOT_CALL_ERROR_CALL_OK, - GODOT_CALL_ERROR_CALL_ERROR_INVALID_METHOD, - GODOT_CALL_ERROR_CALL_ERROR_INVALID_ARGUMENT, - GODOT_CALL_ERROR_CALL_ERROR_TOO_MANY_ARGUMENTS, - GODOT_CALL_ERROR_CALL_ERROR_TOO_FEW_ARGUMENTS, - GODOT_CALL_ERROR_CALL_ERROR_INSTANCE_IS_NULL, -} godot_variant_call_error_error; - -typedef struct godot_variant_call_error { - godot_variant_call_error_error error; - int argument; - godot_variant_type expected; -} godot_variant_call_error; - -typedef enum godot_variant_operator { - // comparison - GODOT_VARIANT_OP_EQUAL, - GODOT_VARIANT_OP_NOT_EQUAL, - GODOT_VARIANT_OP_LESS, - GODOT_VARIANT_OP_LESS_EQUAL, - GODOT_VARIANT_OP_GREATER, - GODOT_VARIANT_OP_GREATER_EQUAL, - - // mathematic - GODOT_VARIANT_OP_ADD, - GODOT_VARIANT_OP_SUBTRACT, - GODOT_VARIANT_OP_MULTIPLY, - GODOT_VARIANT_OP_DIVIDE, - GODOT_VARIANT_OP_NEGATE, - GODOT_VARIANT_OP_POSITIVE, - GODOT_VARIANT_OP_MODULE, - GODOT_VARIANT_OP_STRING_CONCAT, - - // bitwise - GODOT_VARIANT_OP_SHIFT_LEFT, - GODOT_VARIANT_OP_SHIFT_RIGHT, - GODOT_VARIANT_OP_BIT_AND, - GODOT_VARIANT_OP_BIT_OR, - GODOT_VARIANT_OP_BIT_XOR, - GODOT_VARIANT_OP_BIT_NEGATE, - - // logic - GODOT_VARIANT_OP_AND, - GODOT_VARIANT_OP_OR, - GODOT_VARIANT_OP_XOR, - GODOT_VARIANT_OP_NOT, - - // containment - GODOT_VARIANT_OP_IN, - - GODOT_VARIANT_OP_MAX, -} godot_variant_operator; - -typedef enum godot_variant_utility_function_type { - GODOT_UTILITY_FUNC_TYPE_MATH, - GODOT_UTILITY_FUNC_TYPE_RANDOM, - GODOT_UTILITY_FUNC_TYPE_GENERAL, -} godot_variant_utility_function_type; - -// Types for function pointers. -typedef void (*godot_validated_operator_evaluator)(const godot_variant *p_left, const godot_variant *p_right, godot_variant *r_result); -typedef void (*godot_ptr_operator_evaluator)(const void *p_left, const void *p_right, void *r_result); -typedef void (*godot_validated_builtin_method)(godot_variant *p_base, const godot_variant **p_args, int p_argument_count, godot_variant *r_return); -typedef void (*godot_ptr_builtin_method)(void *p_base, const void **p_args, void *r_return, int p_argument_count); -typedef void (*godot_validated_constructor)(godot_variant *p_base, const godot_variant **p_args); -typedef void (*godot_ptr_constructor)(void *p_base, const void **p_args); -typedef void (*godot_validated_setter)(godot_variant *p_base, const godot_variant *p_value); -typedef void (*godot_validated_getter)(const godot_variant *p_base, godot_variant *r_value); -typedef void (*godot_ptr_setter)(void *p_base, const void *p_value); -typedef void (*godot_ptr_getter)(const void *p_base, void *r_value); -typedef void (*godot_validated_indexed_setter)(godot_variant *p_base, godot_int p_index, const godot_variant *p_value, bool *r_oob); -typedef void (*godot_validated_indexed_getter)(const godot_variant *p_base, godot_int p_index, godot_variant *r_value, bool *r_oob); -typedef void (*godot_ptr_indexed_setter)(void *p_base, godot_int p_index, const void *p_value); -typedef void (*godot_ptr_indexed_getter)(const void *p_base, godot_int p_index, void *r_value); -typedef void (*godot_validated_keyed_setter)(godot_variant *p_base, const godot_variant *p_key, const godot_variant *p_value, bool *r_valid); -typedef void (*godot_validated_keyed_getter)(const godot_variant *p_base, const godot_variant *p_key, godot_variant *r_value, bool *r_valid); -typedef bool (*godot_validated_keyed_checker)(const godot_variant *p_base, const godot_variant *p_key, bool *r_valid); -typedef void (*godot_ptr_keyed_setter)(void *p_base, const void *p_key, const void *p_value); -typedef void (*godot_ptr_keyed_getter)(const void *p_base, const void *p_key, void *r_value); -typedef uint32_t (*godot_ptr_keyed_checker)(const godot_variant *p_base, const godot_variant *p_key); -typedef void (*godot_validated_utility_function)(godot_variant *r_return, const godot_variant **p_arguments, int p_argument_count); -typedef void (*godot_ptr_utility_function)(void *r_return, const void **p_arguments, int p_argument_count); - -#include <gdnative/aabb.h> -#include <gdnative/array.h> -#include <gdnative/basis.h> -#include <gdnative/callable.h> -#include <gdnative/color.h> -#include <gdnative/dictionary.h> -#include <gdnative/node_path.h> -#include <gdnative/packed_arrays.h> -#include <gdnative/plane.h> -#include <gdnative/quaternion.h> -#include <gdnative/rect2.h> -#include <gdnative/rid.h> -#include <gdnative/signal.h> -#include <gdnative/string.h> -#include <gdnative/string_name.h> -#include <gdnative/transform2d.h> -#include <gdnative/transform_3d.h> -#include <gdnative/variant.h> -#include <gdnative/vector2.h> -#include <gdnative/vector3.h> - -#include <gdnative/gdnative.h> - -// Memory. - -void GDAPI godot_variant_new_copy(godot_variant *r_dest, const godot_variant *p_src); - -void GDAPI godot_variant_new_nil(godot_variant *r_dest); -void GDAPI godot_variant_new_bool(godot_variant *r_dest, const godot_bool p_b); -void GDAPI godot_variant_new_int(godot_variant *r_dest, const godot_int p_i); -void GDAPI godot_variant_new_float(godot_variant *r_dest, const godot_float p_f); -void GDAPI godot_variant_new_string(godot_variant *r_dest, const godot_string *p_s); -void GDAPI godot_variant_new_vector2(godot_variant *r_dest, const godot_vector2 *p_v2); -void GDAPI godot_variant_new_vector2i(godot_variant *r_dest, const godot_vector2i *p_v2); -void GDAPI godot_variant_new_rect2(godot_variant *r_dest, const godot_rect2 *p_rect2); -void GDAPI godot_variant_new_rect2i(godot_variant *r_dest, const godot_rect2i *p_rect2); -void GDAPI godot_variant_new_vector3(godot_variant *r_dest, const godot_vector3 *p_v3); -void GDAPI godot_variant_new_vector3i(godot_variant *r_dest, const godot_vector3i *p_v3); -void GDAPI godot_variant_new_transform2d(godot_variant *r_dest, const godot_transform2d *p_t2d); -void GDAPI godot_variant_new_plane(godot_variant *r_dest, const godot_plane *p_plane); -void GDAPI godot_variant_new_quaternion(godot_variant *r_dest, const godot_quaternion *p_quaternion); -void GDAPI godot_variant_new_aabb(godot_variant *r_dest, const godot_aabb *p_aabb); -void GDAPI godot_variant_new_basis(godot_variant *r_dest, const godot_basis *p_basis); -void GDAPI godot_variant_new_transform3d(godot_variant *r_dest, const godot_transform3d *p_trans); -void GDAPI godot_variant_new_color(godot_variant *r_dest, const godot_color *p_color); -void GDAPI godot_variant_new_string_name(godot_variant *r_dest, const godot_string_name *p_s); -void GDAPI godot_variant_new_node_path(godot_variant *r_dest, const godot_node_path *p_np); -void GDAPI godot_variant_new_rid(godot_variant *r_dest, const godot_rid *p_rid); -void GDAPI godot_variant_new_object(godot_variant *r_dest, const godot_object *p_obj); -void GDAPI godot_variant_new_callable(godot_variant *r_dest, const godot_callable *p_callable); -void GDAPI godot_variant_new_signal(godot_variant *r_dest, const godot_signal *p_signal); -void GDAPI godot_variant_new_dictionary(godot_variant *r_dest, const godot_dictionary *p_dict); -void GDAPI godot_variant_new_array(godot_variant *r_dest, const godot_array *p_arr); -void GDAPI godot_variant_new_packed_byte_array(godot_variant *r_dest, const godot_packed_byte_array *p_pba); -void GDAPI godot_variant_new_packed_int32_array(godot_variant *r_dest, const godot_packed_int32_array *p_pia); -void GDAPI godot_variant_new_packed_int64_array(godot_variant *r_dest, const godot_packed_int64_array *p_pia); -void GDAPI godot_variant_new_packed_float32_array(godot_variant *r_dest, const godot_packed_float32_array *p_pra); -void GDAPI godot_variant_new_packed_float64_array(godot_variant *r_dest, const godot_packed_float64_array *p_pra); -void GDAPI godot_variant_new_packed_string_array(godot_variant *r_dest, const godot_packed_string_array *p_psa); -void GDAPI godot_variant_new_packed_vector2_array(godot_variant *r_dest, const godot_packed_vector2_array *p_pv2a); -void GDAPI godot_variant_new_packed_vector3_array(godot_variant *r_dest, const godot_packed_vector3_array *p_pv3a); -void GDAPI godot_variant_new_packed_color_array(godot_variant *r_dest, const godot_packed_color_array *p_pca); - -godot_bool GDAPI godot_variant_as_bool(const godot_variant *p_self); -godot_int GDAPI godot_variant_as_int(const godot_variant *p_self); -godot_float GDAPI godot_variant_as_float(const godot_variant *p_self); -godot_string GDAPI godot_variant_as_string(const godot_variant *p_self); -godot_vector2 GDAPI godot_variant_as_vector2(const godot_variant *p_self); -godot_vector2i GDAPI godot_variant_as_vector2i(const godot_variant *p_self); -godot_rect2 GDAPI godot_variant_as_rect2(const godot_variant *p_self); -godot_rect2i GDAPI godot_variant_as_rect2i(const godot_variant *p_self); -godot_vector3 GDAPI godot_variant_as_vector3(const godot_variant *p_self); -godot_vector3i GDAPI godot_variant_as_vector3i(const godot_variant *p_self); -godot_transform2d GDAPI godot_variant_as_transform2d(const godot_variant *p_self); -godot_plane GDAPI godot_variant_as_plane(const godot_variant *p_self); -godot_quaternion GDAPI godot_variant_as_quaternion(const godot_variant *p_self); -godot_aabb GDAPI godot_variant_as_aabb(const godot_variant *p_self); -godot_basis GDAPI godot_variant_as_basis(const godot_variant *p_self); -godot_transform3d GDAPI godot_variant_as_transform3d(const godot_variant *p_self); -godot_color GDAPI godot_variant_as_color(const godot_variant *p_self); -godot_string_name GDAPI godot_variant_as_string_name(const godot_variant *p_self); -godot_node_path GDAPI godot_variant_as_node_path(const godot_variant *p_self); -godot_rid GDAPI godot_variant_as_rid(const godot_variant *p_self); -godot_object GDAPI *godot_variant_as_object(const godot_variant *p_self); -godot_callable GDAPI godot_variant_as_callable(const godot_variant *p_self); -godot_signal GDAPI godot_variant_as_signal(const godot_variant *p_self); -godot_dictionary GDAPI godot_variant_as_dictionary(const godot_variant *p_self); -godot_array GDAPI godot_variant_as_array(const godot_variant *p_self); -godot_packed_byte_array GDAPI godot_variant_as_packed_byte_array(const godot_variant *p_self); -godot_packed_int32_array GDAPI godot_variant_as_packed_int32_array(const godot_variant *p_self); -godot_packed_int64_array GDAPI godot_variant_as_packed_int64_array(const godot_variant *p_self); -godot_packed_float32_array GDAPI godot_variant_as_packed_float32_array(const godot_variant *p_self); -godot_packed_float64_array GDAPI godot_variant_as_packed_float64_array(const godot_variant *p_self); -godot_packed_string_array GDAPI godot_variant_as_packed_string_array(const godot_variant *p_self); -godot_packed_vector2_array GDAPI godot_variant_as_packed_vector2_array(const godot_variant *p_self); -godot_packed_vector3_array GDAPI godot_variant_as_packed_vector3_array(const godot_variant *p_self); -godot_packed_color_array GDAPI godot_variant_as_packed_color_array(const godot_variant *p_self); - -void GDAPI godot_variant_destroy(godot_variant *p_self); - -// Dynamic interaction. - -void GDAPI godot_variant_call(godot_variant *p_self, const godot_string_name *p_method, const godot_variant **p_args, const godot_int p_argument_count, godot_variant *r_return, godot_variant_call_error *r_error); -void GDAPI godot_variant_call_with_cstring(godot_variant *p_self, const char *p_method, const godot_variant **p_args, const godot_int p_argument_count, godot_variant *r_return, godot_variant_call_error *r_error); -void GDAPI godot_variant_call_static(godot_variant_type p_type, const godot_string_name *p_method, const godot_variant **p_args, const godot_int p_argument_count, godot_variant *r_return, godot_variant_call_error *r_error); -void GDAPI godot_variant_call_static_with_cstring(godot_variant_type p_type, const char *p_method, const godot_variant **p_args, const godot_int p_argument_count, godot_variant *r_return, godot_variant_call_error *r_error); -void GDAPI godot_variant_evaluate(godot_variant_operator p_op, const godot_variant *p_a, const godot_variant *p_b, godot_variant *r_return, bool *r_valid); -void GDAPI godot_variant_set(godot_variant *p_self, const godot_variant *p_key, const godot_variant *p_value, bool *r_valid); -void GDAPI godot_variant_set_named(godot_variant *p_self, const godot_string_name *p_name, const godot_variant *p_value, bool *r_valid); -void GDAPI godot_variant_set_named_with_cstring(godot_variant *p_self, const char *p_name, const godot_variant *p_value, bool *r_valid); -void GDAPI godot_variant_set_keyed(godot_variant *p_self, const godot_variant *p_key, const godot_variant *p_value, bool *r_valid); -void GDAPI godot_variant_set_indexed(godot_variant *p_self, godot_int p_index, const godot_variant *p_value, bool *r_valid, bool *r_oob); -godot_variant GDAPI godot_variant_get(const godot_variant *p_self, const godot_variant *p_key, bool *r_valid); -godot_variant GDAPI godot_variant_get_named(const godot_variant *p_self, const godot_string_name *p_key, bool *r_valid); -godot_variant GDAPI godot_variant_get_named_with_cstring(const godot_variant *p_self, const char *p_key, bool *r_valid); -godot_variant GDAPI godot_variant_get_keyed(const godot_variant *p_self, const godot_variant *p_key, bool *r_valid); -godot_variant GDAPI godot_variant_get_indexed(const godot_variant *p_self, godot_int p_index, bool *r_valid, bool *r_oob); -/// Iteration. -bool GDAPI godot_variant_iter_init(const godot_variant *p_self, godot_variant *r_iter, bool *r_valid); -bool GDAPI godot_variant_iter_next(const godot_variant *p_self, godot_variant *r_iter, bool *r_valid); -godot_variant GDAPI godot_variant_iter_get(const godot_variant *p_self, godot_variant *r_iter, bool *r_valid); - -/// Variant functions. -godot_bool GDAPI godot_variant_hash_compare(const godot_variant *p_self, const godot_variant *p_other); -godot_bool GDAPI godot_variant_booleanize(const godot_variant *p_self); -void GDAPI godot_variant_blend(const godot_variant *p_a, const godot_variant *p_b, float p_c, godot_variant *r_dst); -void GDAPI godot_variant_interpolate(const godot_variant *p_a, const godot_variant *p_b, float p_c, godot_variant *r_dst); -godot_variant GDAPI godot_variant_duplicate(const godot_variant *p_self, godot_bool p_deep); -godot_string GDAPI godot_variant_stringify(const godot_variant *p_self); - -// Discovery API. - -/// Operators. -godot_validated_operator_evaluator GDAPI godot_variant_get_validated_operator_evaluator(godot_variant_operator p_operator, godot_variant_type p_type_a, godot_variant_type p_type_b); -godot_ptr_operator_evaluator GDAPI godot_variant_get_ptr_operator_evaluator(godot_variant_operator p_operator, godot_variant_type p_type_a, godot_variant_type p_type_b); -godot_variant_type GDAPI godot_variant_get_operator_return_type(godot_variant_operator p_operator, godot_variant_type p_type_a, godot_variant_type p_type_b); -godot_string GDAPI godot_variant_get_operator_name(godot_variant_operator p_operator); - -/// Built-in methods. -bool GDAPI godot_variant_has_builtin_method(godot_variant_type p_type, const godot_string_name *p_method); -bool GDAPI godot_variant_has_builtin_method_with_cstring(godot_variant_type p_type, const char *p_method); -godot_validated_builtin_method GDAPI godot_variant_get_validated_builtin_method(godot_variant_type p_type, const godot_string_name *p_method); -godot_validated_builtin_method GDAPI godot_variant_get_validated_builtin_method_with_cstring(godot_variant_type p_type, const char *p_method); -godot_ptr_builtin_method GDAPI godot_variant_get_ptr_builtin_method(godot_variant_type p_type, const godot_string_name *p_method); -godot_ptr_builtin_method GDAPI godot_variant_get_ptr_builtin_method_with_cstring(godot_variant_type p_type, const char *p_method); -int GDAPI godot_variant_get_builtin_method_argument_count(godot_variant_type p_type, const godot_string_name *p_method); -int GDAPI godot_variant_get_builtin_method_argument_count_with_cstring(godot_variant_type p_type, const char *p_method); -godot_variant_type GDAPI godot_variant_get_builtin_method_argument_type(godot_variant_type p_type, const godot_string_name *p_method, int p_argument); -godot_variant_type GDAPI godot_variant_get_builtin_method_argument_type_with_cstring(godot_variant_type p_type, const char *p_method, int p_argument); -godot_string GDAPI godot_variant_get_builtin_method_argument_name(godot_variant_type p_type, const godot_string_name *p_method, int p_argument); -godot_string GDAPI godot_variant_get_builtin_method_argument_name_with_cstring(godot_variant_type p_type, const char *p_method, int p_argument); -bool GDAPI godot_variant_has_builtin_method_return_value(godot_variant_type p_type, const godot_string_name *p_method); -bool GDAPI godot_variant_has_builtin_method_return_value_with_cstring(godot_variant_type p_type, const char *p_method); -godot_variant_type GDAPI godot_variant_get_builtin_method_return_type(godot_variant_type p_type, const godot_string_name *p_method); -godot_variant_type GDAPI godot_variant_get_builtin_method_return_type_with_cstring(godot_variant_type p_type, const char *p_method); -bool GDAPI godot_variant_is_builtin_method_const(godot_variant_type p_type, const godot_string_name *p_method); -bool GDAPI godot_variant_is_builtin_method_const_with_cstring(godot_variant_type p_type, const char *p_method); -bool GDAPI godot_variant_is_builtin_method_static(godot_variant_type p_type, const godot_string_name *p_method); -bool GDAPI godot_variant_is_builtin_method_static_with_cstring(godot_variant_type p_type, const char *p_method); -bool GDAPI godot_variant_is_builtin_method_vararg(godot_variant_type p_type, const godot_string_name *p_method); -bool GDAPI godot_variant_is_builtin_method_vararg_with_cstring(godot_variant_type p_type, const char *p_method); -int GDAPI godot_variant_get_builtin_method_count(godot_variant_type p_type); -void GDAPI godot_variant_get_builtin_method_list(godot_variant_type p_type, godot_string_name *r_list); - -/// Constructors. -int GDAPI godot_variant_get_constructor_count(godot_variant_type p_type); -godot_validated_constructor GDAPI godot_variant_get_validated_constructor(godot_variant_type p_type, int p_constructor); -godot_ptr_constructor GDAPI godot_variant_get_ptr_constructor(godot_variant_type p_type, int p_constructor); -int GDAPI godot_variant_get_constructor_argument_count(godot_variant_type p_type, int p_constructor); -godot_variant_type GDAPI godot_variant_get_constructor_argument_type(godot_variant_type p_type, int p_constructor, int p_argument); -godot_string GDAPI godot_variant_get_constructor_argument_name(godot_variant_type p_type, int p_constructor, int p_argument); -void GDAPI godot_variant_construct(godot_variant_type p_type, godot_variant *p_base, const godot_variant **p_args, int p_argument_count, godot_variant_call_error *r_error); - -/// Properties. -godot_variant_type GDAPI godot_variant_get_member_type(godot_variant_type p_type, const godot_string_name *p_member); -godot_variant_type GDAPI godot_variant_get_member_type_with_cstring(godot_variant_type p_type, const char *p_member); -int GDAPI godot_variant_get_member_count(godot_variant_type p_type); -void GDAPI godot_variant_get_member_list(godot_variant_type p_type, godot_string_name *r_list); -godot_validated_setter GDAPI godot_variant_get_validated_setter(godot_variant_type p_type, const godot_string_name *p_member); -godot_validated_setter GDAPI godot_variant_get_validated_setter_with_cstring(godot_variant_type p_type, const char *p_member); -godot_validated_getter GDAPI godot_variant_get_validated_getter(godot_variant_type p_type, const godot_string_name *p_member); -godot_validated_getter GDAPI godot_variant_get_validated_getter_with_cstring(godot_variant_type p_type, const char *p_member); -godot_ptr_setter GDAPI godot_variant_get_ptr_setter(godot_variant_type p_type, const godot_string_name *p_member); -godot_ptr_setter GDAPI godot_variant_get_ptr_setter_with_cstring(godot_variant_type p_type, const char *p_member); -godot_ptr_getter GDAPI godot_variant_get_ptr_getter(godot_variant_type p_type, const godot_string_name *p_member); -godot_ptr_getter GDAPI godot_variant_get_ptr_getter_with_cstring(godot_variant_type p_type, const char *p_member); - -/// Indexing. -bool GDAPI godot_variant_has_indexing(godot_variant_type p_type); -godot_variant_type GDAPI godot_variant_get_indexed_element_type(godot_variant_type p_type); -godot_validated_indexed_setter GDAPI godot_variant_get_validated_indexed_setter(godot_variant_type p_type); -godot_validated_indexed_getter GDAPI godot_variant_get_validated_indexed_getter(godot_variant_type p_type); -godot_ptr_indexed_setter GDAPI godot_variant_get_ptr_indexed_setter(godot_variant_type p_type); -godot_ptr_indexed_getter GDAPI godot_variant_get_ptr_indexed_getter(godot_variant_type p_type); -uint64_t GDAPI godot_variant_get_indexed_size(const godot_variant *p_self); - -/// Keying. -bool GDAPI godot_variant_is_keyed(godot_variant_type p_type); -godot_validated_keyed_setter GDAPI godot_variant_get_validated_keyed_setter(godot_variant_type p_type); -godot_validated_keyed_getter GDAPI godot_variant_get_validated_keyed_getter(godot_variant_type p_type); -godot_validated_keyed_checker GDAPI godot_variant_get_validated_keyed_checker(godot_variant_type p_type); -godot_ptr_keyed_setter GDAPI godot_variant_get_ptr_keyed_setter(godot_variant_type p_type); -godot_ptr_keyed_getter GDAPI godot_variant_get_ptr_keyed_getter(godot_variant_type p_type); -godot_ptr_keyed_checker GDAPI godot_variant_get_ptr_keyed_checker(godot_variant_type p_type); - -/// Constants. -int GDAPI godot_variant_get_constants_count(godot_variant_type p_type); -void GDAPI godot_variant_get_constants_list(godot_variant_type p_type, godot_string_name *r_list); -bool GDAPI godot_variant_has_constant(godot_variant_type p_type, const godot_string_name *p_constant); -bool GDAPI godot_variant_has_constant_with_cstring(godot_variant_type p_type, const char *p_constant); -godot_variant GDAPI godot_variant_get_constant_value(godot_variant_type p_type, const godot_string_name *p_constant); -godot_variant GDAPI godot_variant_get_constant_value_with_cstring(godot_variant_type p_type, const char *p_constant); - -/// Utilities. -bool GDAPI godot_variant_has_utility_function(const godot_string_name *p_function); -bool GDAPI godot_variant_has_utility_function_with_cstring(const char *p_function); -void GDAPI godot_variant_call_utility_function(const godot_string_name *p_function, godot_variant *r_ret, const godot_variant **p_args, int p_argument_count, godot_variant_call_error *r_error); -void GDAPI godot_variant_call_utility_function_with_cstring(const char *p_function, godot_variant *r_ret, const godot_variant **p_args, int p_argument_count, godot_variant_call_error *r_error); -godot_ptr_utility_function GDAPI godot_variant_get_ptr_utility_function(const godot_string_name *p_function); -godot_ptr_utility_function GDAPI godot_variant_get_ptr_utility_function_with_cstring(const char *p_function); -godot_validated_utility_function GDAPI godot_variant_get_validated_utility_function(const godot_string_name *p_function); -godot_validated_utility_function GDAPI godot_variant_get_validated_utility_function_with_cstring(const char *p_function); -godot_variant_utility_function_type GDAPI godot_variant_get_utility_function_type(const godot_string_name *p_function); -godot_variant_utility_function_type GDAPI godot_variant_get_utility_function_type_with_cstring(const char *p_function); -int GDAPI godot_variant_get_utility_function_argument_count(const godot_string_name *p_function); -int GDAPI godot_variant_get_utility_function_argument_count_with_cstring(const char *p_function); -godot_variant_type GDAPI godot_variant_get_utility_function_argument_type(const godot_string_name *p_function, int p_argument); -godot_variant_type GDAPI godot_variant_get_utility_function_argument_type_with_cstring(const char *p_function, int p_argument); -godot_string GDAPI godot_variant_get_utility_function_argument_name(const godot_string_name *p_function, int p_argument); -godot_string GDAPI godot_variant_get_utility_function_argument_name_with_cstring(const char *p_function, int p_argument); -bool GDAPI godot_variant_has_utility_function_return_value(const godot_string_name *p_function); -bool GDAPI godot_variant_has_utility_function_return_value_with_cstring(const char *p_function); -godot_variant_type GDAPI godot_variant_get_utility_function_return_type(const godot_string_name *p_function); -godot_variant_type GDAPI godot_variant_get_utility_function_return_type_with_cstring(const char *p_function); -bool GDAPI godot_variant_is_utility_function_vararg(const godot_string_name *p_function); -bool GDAPI godot_variant_is_utility_function_vararg_with_cstring(const char *p_function); -int GDAPI godot_variant_get_utility_function_count(); -void GDAPI godot_variant_get_utility_function_list(godot_string_name *r_functions); - -// Introspection. - -godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_self); -bool GDAPI godot_variant_has_method(const godot_variant *p_self, const godot_string_name *p_method); -bool GDAPI godot_variant_has_member(godot_variant_type p_type, const godot_string_name *p_member); -bool GDAPI godot_variant_has_key(const godot_variant *p_self, const godot_variant *p_key, bool *r_valid); - -godot_string GDAPI godot_variant_get_type_name(godot_variant_type p_type); -bool GDAPI godot_variant_can_convert(godot_variant_type p_from, godot_variant_type p_to); -bool GDAPI godot_variant_can_convert_strict(godot_variant_type p_from, godot_variant_type p_to); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/modules/gdnative/include/gdnative/variant_struct.h b/modules/gdnative/include/gdnative/variant_struct.h deleted file mode 100644 index cc75a8c498..0000000000 --- a/modules/gdnative/include/gdnative/variant_struct.h +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************/ -/* variant_struct.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_VARIANT_STRUCT_H -#define GODOT_VARIANT_STRUCT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <gdnative/math_defs.h> - -#define GODOT_VARIANT_SIZE (sizeof(godot_real_t) * 4 + sizeof(int64_t)) - -#ifndef GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_VARIANT_SIZE]; -} godot_variant; -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/modules/gdnative/include/gdnative/vector2.h b/modules/gdnative/include/gdnative/vector2.h deleted file mode 100644 index f5b55fd4ce..0000000000 --- a/modules/gdnative/include/gdnative/vector2.h +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************/ -/* vector2.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_VECTOR2_H -#define GODOT_VECTOR2_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <gdnative/math_defs.h> - -#define GODOT_VECTOR2_SIZE (sizeof(godot_real_t) * 2) - -#ifndef GODOT_CORE_API_GODOT_VECTOR2_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_VECTOR2_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_VECTOR2_SIZE]; -} godot_vector2; -#endif - -#define GODOT_VECTOR2I_SIZE (sizeof(int32_t) * 2) - -#ifndef GODOT_CORE_API_GODOT_VECTOR2I_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_VECTOR2I_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_VECTOR2I_SIZE]; -} godot_vector2i; -#endif - -#include <gdnative/gdnative.h> - -void GDAPI godot_vector2_new(godot_vector2 *p_self); -void GDAPI godot_vector2_new_copy(godot_vector2 *r_dest, const godot_vector2 *p_src); -void GDAPI godot_vector2i_new(godot_vector2i *p_self); -void GDAPI godot_vector2i_new_copy(godot_vector2i *r_dest, const godot_vector2i *p_src); -godot_real_t GDAPI *godot_vector2_operator_index(godot_vector2 *p_self, godot_int p_index); -const godot_real_t GDAPI *godot_vector2_operator_index_const(const godot_vector2 *p_self, godot_int p_index); -int32_t GDAPI *godot_vector2i_operator_index(godot_vector2i *p_self, godot_int p_index); -const int32_t GDAPI *godot_vector2i_operator_index_const(const godot_vector2i *p_self, godot_int p_index); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_VECTOR2_H diff --git a/modules/gdnative/include/gdnative/vector3.h b/modules/gdnative/include/gdnative/vector3.h deleted file mode 100644 index d52cd38a72..0000000000 --- a/modules/gdnative/include/gdnative/vector3.h +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************/ -/* vector3.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_VECTOR3_H -#define GODOT_VECTOR3_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <gdnative/math_defs.h> - -#define GODOT_VECTOR3_SIZE (sizeof(godot_real_t) * 3) - -#ifndef GODOT_CORE_API_GODOT_VECTOR3_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_VECTOR3_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_VECTOR3_SIZE]; -} godot_vector3; -#endif - -#define GODOT_VECTOR3I_SIZE (sizeof(int32_t) * 3) - -#ifndef GODOT_CORE_API_GODOT_VECTOR3I_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_VECTOR3I_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_VECTOR3I_SIZE]; -} godot_vector3i; -#endif - -#include <gdnative/gdnative.h> - -void GDAPI godot_vector3_new(godot_vector3 *p_self); -void GDAPI godot_vector3_new_copy(godot_vector3 *r_dest, const godot_vector3 *p_src); -void GDAPI godot_vector3i_new(godot_vector3i *p_self); -void GDAPI godot_vector3i_new_copy(godot_vector3i *r_dest, const godot_vector3i *p_src); -godot_real_t GDAPI *godot_vector3_operator_index(godot_vector3 *p_self, godot_int p_index); -const godot_real_t GDAPI *godot_vector3_operator_index_const(const godot_vector3 *p_self, godot_int p_index); -int32_t GDAPI *godot_vector3i_operator_index(godot_vector3i *p_self, godot_int p_index); -const int32_t GDAPI *godot_vector3i_operator_index_const(const godot_vector3i *p_self, godot_int p_index); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_VECTOR3_H diff --git a/modules/gdnative/include/nativescript/godot_nativescript.h b/modules/gdnative/include/nativescript/godot_nativescript.h deleted file mode 100644 index 879291c2e0..0000000000 --- a/modules/gdnative/include/nativescript/godot_nativescript.h +++ /dev/null @@ -1,233 +0,0 @@ -/*************************************************************************/ -/* godot_nativescript.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_NATIVESCRIPT_H -#define GODOT_NATIVESCRIPT_H - -#include <gdnative/gdnative.h> - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - GODOT_METHOD_RPC_MODE_DISABLED, - GODOT_METHOD_RPC_MODE_ANY_PEER, - GODOT_METHOD_RPC_MODE_AUTHORITY, -} godot_nativescript_method_rpc_mode; - -typedef enum { - 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 function (Math::ease) - GODOT_PROPERTY_HINT_LENGTH, ///< hint_text= "length" (as integer) - 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_2D_NAVIGATION, - GODOT_PROPERTY_HINT_LAYERS_3D_RENDER, - GODOT_PROPERTY_HINT_LAYERS_3D_PHYSICS, - GODOT_PROPERTY_HINT_LAYERS_3D_NAVIGATION, - GODOT_PROPERTY_HINT_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc," - GODOT_PROPERTY_HINT_DIR, ///< a directory 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 directory 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_PLACEHOLDER_TEXT, ///< used to set a placeholder text for string properties - 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_LOCALE_ID, - GODOT_PROPERTY_HINT_MAX, -} godot_nativescript_property_hint; - -typedef enum { - 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_SUBGROUP = 512, - 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_NO_EDITOR = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_NETWORK, -} godot_nativescript_property_usage_flags; - -typedef struct { - godot_nativescript_method_rpc_mode rset_type; - - godot_int type; - godot_nativescript_property_hint hint; - godot_string hint_string; - godot_nativescript_property_usage_flags usage; - godot_variant default_value; -} godot_nativescript_property_attributes; - -typedef struct { - // instance pointer, method_data - return user data - GDCALLINGCONV void *(*create_func)(godot_object *, void *); - void *method_data; - GDCALLINGCONV void (*free_func)(void *); -} godot_nativescript_instance_create_func; - -typedef struct { - // instance pointer, method data, user data - GDCALLINGCONV void (*destroy_func)(godot_object *, void *, void *); - void *method_data; - GDCALLINGCONV void (*free_func)(void *); -} godot_nativescript_instance_destroy_func; - -void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_nativescript_instance_create_func p_create_func, godot_nativescript_instance_destroy_func p_destroy_func); - -void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_nativescript_instance_create_func p_create_func, godot_nativescript_instance_destroy_func p_destroy_func); - -typedef struct { - godot_nativescript_method_rpc_mode rpc_type; -} godot_nativescript_method_attributes; - -typedef struct { - godot_string name; - - godot_variant_type type; - godot_nativescript_property_hint hint; - godot_string hint_string; -} godot_nativescript_method_argument; - -typedef struct { - // instance pointer, method data, user data, num args, args - return result as variant - GDCALLINGCONV godot_variant (*method)(godot_object *, void *, void *, int, godot_variant **); - void *method_data; - GDCALLINGCONV void (*free_func)(void *); -} godot_nativescript_instance_method; - -void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_nativescript_method_attributes p_attr, godot_nativescript_instance_method p_method); -void GDAPI godot_nativescript_set_method_argument_information(void *p_gdnative_handle, const char *p_name, const char *p_function_name, int p_num_args, const godot_nativescript_method_argument *p_args); - -typedef struct { - // 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_nativescript_property_set_func; - -typedef struct { - // 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_nativescript_property_get_func; - -void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_nativescript_property_attributes *p_attr, godot_nativescript_property_set_func p_set_func, godot_nativescript_property_get_func p_get_func); - -typedef struct { - godot_string name; - godot_int type; - godot_nativescript_property_hint hint; - godot_string hint_string; - godot_nativescript_property_usage_flags usage; - godot_variant default_value; -} godot_nativescript_signal_argument; - -typedef struct { - godot_string name; - int num_args; - godot_nativescript_signal_argument *args; - int num_default_args; - godot_variant *default_args; -} godot_nativescript_signal; - -void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const godot_nativescript_signal *p_signal); - -void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance); - -// documentation - -void GDAPI godot_nativescript_set_class_documentation(void *p_gdnative_handle, const char *p_name, godot_string p_documentation); -void GDAPI godot_nativescript_set_method_documentation(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_string p_documentation); -void GDAPI godot_nativescript_set_property_documentation(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_string p_documentation); -void GDAPI godot_nativescript_set_signal_documentation(void *p_gdnative_handle, const char *p_name, const char *p_signal_name, godot_string p_documentation); - -// type tag API - -void GDAPI godot_nativescript_set_global_type_tag(int p_idx, const char *p_name, const void *p_type_tag); -const void GDAPI *godot_nativescript_get_global_type_tag(int p_idx, const char *p_name); - -void GDAPI godot_nativescript_set_type_tag(void *p_gdnative_handle, const char *p_name, const void *p_type_tag); -const void GDAPI *godot_nativescript_get_type_tag(const godot_object *p_object); - -// instance binding API - -typedef struct { - GDCALLINGCONV void *(*alloc_instance_binding_data)(void *, const void *, godot_object *); - GDCALLINGCONV void (*free_instance_binding_data)(void *, void *); - GDCALLINGCONV void (*refcount_incremented_instance_binding)(void *, godot_object *); - GDCALLINGCONV bool (*refcount_decremented_instance_binding)(void *, godot_object *); - void *data; - GDCALLINGCONV void (*free_func)(void *); -} godot_nativescript_instance_binding_functions; - -int GDAPI godot_nativescript_register_instance_binding_data_functions(godot_nativescript_instance_binding_functions p_binding_functions); -void GDAPI godot_nativescript_unregister_instance_binding_data_functions(int p_idx); - -void GDAPI *godot_nativescript_get_instance_binding_data(int p_idx, godot_object *p_object); - -void GDAPI godot_nativescript_profiling_add_data(const char *p_signature, uint64_t p_time); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/modules/gdnative/include/pluginscript/godot_pluginscript.h b/modules/gdnative/include/pluginscript/godot_pluginscript.h deleted file mode 100644 index 0042d79966..0000000000 --- a/modules/gdnative/include/pluginscript/godot_pluginscript.h +++ /dev/null @@ -1,171 +0,0 @@ -/*************************************************************************/ -/* godot_pluginscript.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_PLUGINSCRIPT_H -#define GODOT_PLUGINSCRIPT_H - -#include <gdnative/gdnative.h> -#include <nativescript/godot_nativescript.h> - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void godot_pluginscript_instance_data; -typedef void godot_pluginscript_script_data; -typedef void godot_pluginscript_language_data; - -// --- Instance --- - -typedef struct { - godot_pluginscript_instance_data *(*init)(godot_pluginscript_script_data *p_data, godot_object *p_owner); - void (*finish)(godot_pluginscript_instance_data *p_data); - - godot_bool (*set_prop)(godot_pluginscript_instance_data *p_data, const godot_string_name *p_name, const godot_variant *p_value); - godot_bool (*get_prop)(godot_pluginscript_instance_data *p_data, const godot_string_name *p_name, godot_variant *r_ret); - - godot_variant (*call_method)(godot_pluginscript_instance_data *p_data, - const godot_string_name *p_method, const godot_variant **p_args, - int p_argcount, godot_variant_call_error *r_error); - - void (*notification)(godot_pluginscript_instance_data *p_data, int p_notification); - godot_string (*to_string)(godot_pluginscript_instance_data *p_data, godot_bool *r_valid); - - //this is used by script languages that keep a reference counter of their own - //you can make make Ref<> not die when it reaches zero, so deleting the reference - //depends entirely from the script. - // Note: You can set those function pointer to nullptr if not needed. - void (*refcount_incremented)(godot_pluginscript_instance_data *p_data); - bool (*refcount_decremented)(godot_pluginscript_instance_data *p_data); // return true if it can die -} godot_pluginscript_instance_desc; - -// --- Script --- - -typedef struct { - godot_pluginscript_script_data *data; - godot_string_name name; - godot_bool is_tool; - godot_string_name base; - godot_string icon_path; - - // Member lines format: {<string>: <int>} - godot_dictionary member_lines; - // Method info dictionary format - // { - // name: <string> - // args: [<dict:property>] - // default_args: [<variant>] - // return: <dict:property> - // flags: <int> - // rpc_mode: <int:godot_method_rpc_mode> - // } - godot_array methods; - // Same format than for methods - godot_array signals; - // Property info dictionary format - // { - // name: <string> - // type: <int:godot_variant_type> - // hint: <int:godot_property_hint> - // hint_string: <string> - // usage: <int:godot_property_usage_flags> - // default_value: <variant> - // rset_mode: <int:godot_method_rpc_mode> - // } - godot_array properties; -} godot_pluginscript_script_manifest; - -typedef struct { - godot_pluginscript_script_manifest (*init)(godot_pluginscript_language_data *p_data, const godot_string *p_path, const godot_string *p_source, godot_error *r_error); - void (*finish)(godot_pluginscript_script_data *p_data); - godot_pluginscript_instance_desc instance_desc; -} godot_pluginscript_script_desc; - -// --- Language --- - -typedef struct { - godot_string_name signature; - godot_int call_count; - godot_int total_time; // In microseconds - godot_int self_time; // In microseconds -} godot_pluginscript_profiling_data; - -typedef struct { - const char *name; - const char *type; - const char *extension; - const char **recognized_extensions; // nullptr terminated array - godot_pluginscript_language_data *(*init)(); - void (*finish)(godot_pluginscript_language_data *p_data); - const char **reserved_words; // nullptr terminated array - const char **comment_delimiters; // nullptr terminated array - const char **string_delimiters; // nullptr terminated array - godot_bool has_named_classes; - godot_bool supports_builtin_mode; - godot_bool can_inherit_from_file; - - godot_string (*get_template_source_code)(godot_pluginscript_language_data *p_data, const godot_string *p_class_name, const godot_string *p_base_class_name); - godot_bool (*validate)(godot_pluginscript_language_data *p_data, const godot_string *p_script, const godot_string *p_path, godot_packed_string_array *r_functions, godot_array *r_errors); // errors = Array of Dictionary with "line", "column", "message" keys - int (*find_function)(godot_pluginscript_language_data *p_data, const godot_string *p_function, const godot_string *p_code); // Can be nullptr - godot_string (*make_function)(godot_pluginscript_language_data *p_data, const godot_string *p_class, const godot_string *p_name, const godot_packed_string_array *p_args); - godot_error (*complete_code)(godot_pluginscript_language_data *p_data, const godot_string *p_code, const godot_string *p_path, godot_object *p_owner, godot_array *r_options, godot_bool *r_force, godot_string *r_call_hint); - void (*auto_indent_code)(godot_pluginscript_language_data *p_data, godot_string *p_code, int p_from_line, int p_to_line); - - void (*add_global_constant)(godot_pluginscript_language_data *p_data, const godot_string_name *p_variable, const godot_variant *p_value); - godot_string (*debug_get_error)(godot_pluginscript_language_data *p_data); - int (*debug_get_stack_level_count)(godot_pluginscript_language_data *p_data); - int (*debug_get_stack_level_line)(godot_pluginscript_language_data *p_data, int p_level); - godot_string (*debug_get_stack_level_function)(godot_pluginscript_language_data *p_data, int p_level); - godot_string (*debug_get_stack_level_source)(godot_pluginscript_language_data *p_data, int p_level); - void (*debug_get_stack_level_locals)(godot_pluginscript_language_data *p_data, int p_level, godot_packed_string_array *p_locals, godot_array *p_values, int p_max_subitems, int p_max_depth); - void (*debug_get_stack_level_members)(godot_pluginscript_language_data *p_data, int p_level, godot_packed_string_array *p_members, godot_array *p_values, int p_max_subitems, int p_max_depth); - void (*debug_get_globals)(godot_pluginscript_language_data *p_data, godot_packed_string_array *p_locals, godot_array *p_values, int p_max_subitems, int p_max_depth); - godot_string (*debug_parse_stack_level_expression)(godot_pluginscript_language_data *p_data, int p_level, const godot_string *p_expression, int p_max_subitems, int p_max_depth); - - // TODO: could this stuff be moved to the godot_pluginscript_language_desc ? - void (*get_public_functions)(godot_pluginscript_language_data *p_data, godot_array *r_functions); - void (*get_public_constants)(godot_pluginscript_language_data *p_data, godot_dictionary *r_constants); - - void (*profiling_start)(godot_pluginscript_language_data *p_data); - void (*profiling_stop)(godot_pluginscript_language_data *p_data); - int (*profiling_get_accumulated_data)(godot_pluginscript_language_data *p_data, godot_pluginscript_profiling_data *r_info, int p_info_max); - int (*profiling_get_frame_data)(godot_pluginscript_language_data *p_data, godot_pluginscript_profiling_data *r_info, int p_info_max); - void (*profiling_frame)(godot_pluginscript_language_data *p_data); - - godot_pluginscript_script_desc script_desc; -} godot_pluginscript_language_desc; - -void GDAPI godot_pluginscript_register_language(const godot_pluginscript_language_desc *language_desc); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_PLUGINSCRIPT_H diff --git a/modules/gdnative/include/videodecoder/godot_videodecoder.h b/modules/gdnative/include/videodecoder/godot_videodecoder.h deleted file mode 100644 index 16daba0a67..0000000000 --- a/modules/gdnative/include/videodecoder/godot_videodecoder.h +++ /dev/null @@ -1,75 +0,0 @@ -/*************************************************************************/ -/* godot_videodecoder.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef GODOT_NATIVEVIDEODECODER_H -#define GODOT_NATIVEVIDEODECODER_H - -#include <gdnative/gdnative.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define GODOTAV_API_MAJOR 0 -#define GODOTAV_API_MINOR 1 - -typedef struct -{ - godot_gdnative_api_version version; - void *next; - void *(*constructor)(godot_object *); - void (*destructor)(void *); - const char *(*get_plugin_name)(); - const char **(*get_supported_extensions)(int *count); - godot_bool (*open_file)(void *, void *); // data struct, and a FileAccess pointer - godot_float (*get_length)(const void *); - godot_float (*get_playback_position)(const void *); - void (*seek)(void *, godot_float); - void (*set_audio_track)(void *, godot_int); - void (*update)(void *, godot_float); - godot_packed_byte_array *(*get_videoframe)(void *); - godot_int (*get_audioframe)(void *, float *, int); - godot_int (*get_channels)(const void *); - godot_int (*get_mix_rate)(const void *); - godot_vector2 (*get_texture_size)(const void *); -} godot_videodecoder_interface_gdnative; - -typedef int (*GDNativeAudioMixCallback)(void *, const float *, int); - -// FileAccess wrappers for custom FFmpeg IO -godot_int GDAPI godot_videodecoder_file_read(void *file_ptr, uint8_t *buf, int buf_size); -int64_t GDAPI godot_videodecoder_file_seek(void *file_ptr, int64_t pos, int whence); -void GDAPI godot_videodecoder_register_decoder(const godot_videodecoder_interface_gdnative *p_interface); - -#ifdef __cplusplus -} -#endif - -#endif /* GODOT_NATIVEVIDEODECODER_H */ diff --git a/modules/gdnative/nativescript/SCsub b/modules/gdnative/nativescript/SCsub deleted file mode 100644 index 4212e87a87..0000000000 --- a/modules/gdnative/nativescript/SCsub +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python - -Import("env") -Import("env_gdnative") - -env_gdnative.add_source_files(env.modules_sources, "*.cpp") - -if "platform" in env and env["platform"] in ["linuxbsd", "iphone"]: - env.Append(LINKFLAGS=["-rdynamic"]) diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp deleted file mode 100644 index 0309d1d9c7..0000000000 --- a/modules/gdnative/nativescript/api_generator.cpp +++ /dev/null @@ -1,948 +0,0 @@ -/*************************************************************************/ -/* api_generator.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 "core/config/engine.h" -#include "core/core_constants.h" -#include "core/io/file_access.h" -#include "core/object/class_db.h" -#include "core/string/string_builder.h" -#include "core/templates/pair.h" -#include "core/variant/variant_parser.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 != nullptr; 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 = 0; - bool has_varargs = false; - bool is_editor = false; - bool is_noscript = false; - bool is_const = false; - bool is_static = false; // For builtin types. - bool is_reverse = false; - bool is_virtual = false; - bool is_from_script = false; -}; - -struct PropertyAPI { - String name; - String getter; - String setter; - String type; - int index = 0; -}; - -struct ConstantAPI { - String constant_name; - int constant_value = 0; - Variant builtin_constant_value; // For builtin types; - String builtin_constant_type; // For builtin types; -}; - -struct SignalAPI { - String name; - List<String> argument_types; - List<String> argument_names; - Map<int, Variant> default_arguments; -}; - -struct EnumAPI { - String name; - List<Pair<int, String>> values; -}; - -struct OperatorAPI { // For builtin types; - String name; - int oper = Variant::OP_MAX; - String other_type; - String return_type; -}; - -struct ClassAPI { - String class_name; - String super_class_name; - - ClassDB::APIType api_type = ClassDB::API_NONE; - - bool is_singleton = false; - String singleton_name; - bool is_instantiable = false; - // @Unclear - bool is_ref_counted = false; - bool has_indexing = false; // For builtin types. - String indexed_type; // For builtin types. - bool is_keyed = false; // For builtin types. - - List<MethodAPI> methods; - List<MethodAPI> constructors; // For builtin types. - List<PropertyAPI> properties; - List<ConstantAPI> constants; - List<SignalAPI> signals_; - List<EnumAPI> enums; - List<OperatorAPI> operators; // For builtin types. -}; - -static String get_type_name(const PropertyInfo &info) { - if (info.type == Variant::INT && (info.usage & PROPERTY_USAGE_CLASS_IS_ENUM)) { - return String("enum.") + String(info.class_name).replace(".", "::"); - } - if (info.class_name != StringName()) { - return info.class_name; - } - if (info.hint == PROPERTY_HINT_RESOURCE_TYPE) { - return info.class_name; - } - if (info.type == Variant::NIL && (info.usage & PROPERTY_USAGE_NIL_IS_VARIANT)) { - return "Variant"; - } - if (info.type == Variant::NIL) { - return "void"; - } - return Variant::get_type_name(info.type); -} - -/* - * Some comparison helper functions we need - */ - -struct MethodInfoComparator { - StringName::AlphCompare compare; - bool operator()(const MethodInfo &p_a, const MethodInfo &p_b) const { - return compare(p_a.name, p_b.name); - } -}; - -struct PropertyInfoComparator { - StringName::AlphCompare compare; - bool operator()(const PropertyInfo &p_a, const PropertyInfo &p_b) const { - return compare(p_a.name, p_b.name); - } -}; - -struct ConstantAPIComparator { - NoCaseComparator compare; - bool operator()(const ConstantAPI &p_a, const ConstantAPI &p_b) const { - return compare(p_a.constant_name, p_b.constant_name); - } -}; - -/* - * 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); - classes.sort_custom<StringName::AlphCompare>(); - - // Register global constants as a fake CoreConstants singleton class - { - ClassAPI global_constants_api; - global_constants_api.class_name = "CoreConstants"; - global_constants_api.api_type = ClassDB::API_CORE; - global_constants_api.is_singleton = true; - global_constants_api.singleton_name = "CoreConstants"; - global_constants_api.is_instantiable = false; - const int constants_count = CoreConstants::get_global_constant_count(); - - Map<StringName, EnumAPI> enum_api_map; - for (int i = 0; i < constants_count; ++i) { - StringName enum_name = CoreConstants::get_global_constant_enum(i); - String name = String(CoreConstants::get_global_constant_name(i)); - int value = CoreConstants::get_global_constant_value(i); - - if (enum_name == StringName()) { - ConstantAPI constant_api; - constant_api.constant_name = name; - constant_api.constant_value = value; - global_constants_api.constants.push_back(constant_api); - } else { - EnumAPI enum_api; - if (enum_api_map.has(enum_name)) { - enum_api = enum_api_map[enum_name]; - } else { - enum_api.name = String(enum_name); - } - enum_api.values.push_back(Pair(value, name)); - - enum_api_map[enum_name] = enum_api; - } - } - for (const KeyValue<StringName, EnumAPI> &E : enum_api_map) { - global_constants_api.enums.push_back(E.value); - } - global_constants_api.constants.sort_custom<ConstantAPIComparator>(); - api.push_back(global_constants_api); - } - - for (List<StringName>::Element *e = classes.front(); e != nullptr; e = e->next()) { - StringName class_name = e->get(); - - if (!ClassDB::is_class_exposed(class_name)) { - continue; - } - - 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); - { - class_api.is_singleton = Engine::get_singleton()->has_singleton(class_name); - if (class_api.is_singleton) { - class_api.singleton_name = class_name; - } - } - class_api.is_instantiable = !class_api.is_singleton && ClassDB::can_instantiate(class_name); - - { - List<StringName> inheriters; - ClassDB::get_inheriters_from_class("RefCounted", &inheriters); - bool is_ref_counted = !!inheriters.find(class_name) || class_name == "RefCounted"; - // @Unclear - class_api.is_ref_counted = !class_api.is_singleton && is_ref_counted; - } - - // constants - { - List<String> constant; - ClassDB::get_integer_constant_list(class_name, &constant, true); - constant.sort_custom<NoCaseComparator>(); - for (List<String>::Element *c = constant.front(); c != nullptr; 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); - signals_.sort_custom<MethodInfoComparator>(); - - 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.contains(":")) { - type = argument.name.get_slice(":", 1); - name = argument.name.get_slice(":", 0); - } else { - type = get_type_name(argument); - } - - 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); - properties.sort_custom<PropertyInfoComparator>(); - - for (List<PropertyInfo>::Element *p = properties.front(); p != nullptr; 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.contains(":")) { - property_api.type = p->get().name.get_slice(":", 1); - property_api.name = p->get().name.get_slice(":", 0); - } else { - MethodInfo minfo; - ClassDB::get_method_info(class_name, property_api.getter, &minfo, true, false); - property_api.type = get_type_name(minfo.return_val); - } - - property_api.index = ClassDB::get_property_index(class_name, p->get().name); - - if (!property_api.setter.is_empty() || !property_api.getter.is_empty()) { - class_api.properties.push_back(property_api); - } - } - } - - //methods - { - List<MethodInfo> methods; - ClassDB::get_method_list(class_name, &methods, true); - methods.sort_custom<MethodInfoComparator>(); - - for (List<MethodInfo>::Element *m = methods.front(); m != nullptr; 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 = method_info.name; - //method return type - if (method_api.method_name.contains(":")) { - method_api.return_type = method_api.method_name.get_slice(":", 1); - method_api.method_name = method_api.method_name.get_slice(":", 0); - } else { - method_api.return_type = get_type_name(m->get().return_val); - } - - method_api.argument_count = method_info.arguments.size(); - method_api.has_varargs = method_bind && method_bind->is_vararg(); - - // Method flags - method_api.is_virtual = false; - 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.contains(":")) { - 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.class_name; - } else if (arg_info.type == Variant::NIL) { - arg_type = "Variant"; - } else if (arg_info.type == Variant::OBJECT) { - arg_type = arg_info.class_name; - if (arg_type.is_empty()) { - arg_type = Variant::get_type_name(arg_info.type); - } - } else { - arg_type = get_type_name(arg_info); - } - - 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); - } - } - - // enums - { - List<EnumAPI> enums; - List<StringName> enum_names; - ClassDB::get_enum_list(class_name, &enum_names, true); - for (const StringName &E : enum_names) { - List<StringName> value_names; - EnumAPI enum_api; - enum_api.name = E; - ClassDB::get_enum_constants(class_name, E, &value_names, true); - for (List<StringName>::Element *val_e = value_names.front(); val_e; val_e = val_e->next()) { - int int_val = ClassDB::get_integer_constant(class_name, val_e->get(), nullptr); - enum_api.values.push_back(Pair<int, String>(int_val, val_e->get())); - } - enum_api.values.sort_custom<PairSort<int, String>>(); - class_api.enums.push_back(enum_api); - } - } - - api.push_back(class_api); - } - - return api; -} - -/* - * Reads the builtin Variant API to a list - */ -List<ClassAPI> generate_c_builtin_api_types() { - List<ClassAPI> api; - - // Special class for the utility methods. - { - ClassAPI utility_api; - utility_api.class_name = "Utilities"; - utility_api.is_instantiable = false; - - List<StringName> utility_functions; - Variant::get_utility_function_list(&utility_functions); - for (const StringName &E : utility_functions) { - const StringName &function_name = E; - - MethodAPI function_api; - function_api.method_name = function_name; - function_api.has_varargs = Variant::is_utility_function_vararg(function_name); - function_api.argument_count = function_api.has_varargs ? 0 : Variant::get_utility_function_argument_count(function_name); - function_api.is_const = Variant::get_utility_function_type(function_name) == Variant::UTILITY_FUNC_TYPE_MATH; - - for (int i = 0; i < function_api.argument_count; i++) { - function_api.argument_names.push_back(Variant::get_utility_function_argument_name(function_name, i)); - Variant::Type arg_type = Variant::get_utility_function_argument_type(function_name, i); - function_api.argument_types.push_back(arg_type == Variant::NIL ? "Variant" : Variant::get_type_name(arg_type)); - } - - if (Variant::has_utility_function_return_value(function_name)) { - Variant::Type ret_type = Variant::get_utility_function_return_type(function_name); - function_api.return_type = ret_type == Variant::NIL ? "Variant" : Variant::get_type_name(ret_type); - } else { - function_api.return_type = "void"; - } - - utility_api.methods.push_back(function_api); - } - - api.push_back(utility_api); - } - - for (int t = 0; t < Variant::VARIANT_MAX; t++) { - Variant::Type type = (Variant::Type)t; - - ClassAPI class_api; - class_api.class_name = Variant::get_type_name(type); - class_api.is_instantiable = true; - class_api.has_indexing = Variant::has_indexing(type); - class_api.indexed_type = Variant::get_type_name(Variant::get_indexed_element_type(type)); - class_api.is_keyed = Variant::is_keyed(type); - // Types that are passed by reference. - switch (type) { - case Variant::OBJECT: - case Variant::DICTIONARY: - case Variant::ARRAY: - case Variant::PACKED_BYTE_ARRAY: - case Variant::PACKED_INT32_ARRAY: - case Variant::PACKED_INT64_ARRAY: - case Variant::PACKED_FLOAT32_ARRAY: - case Variant::PACKED_FLOAT64_ARRAY: - case Variant::PACKED_STRING_ARRAY: - case Variant::PACKED_VECTOR2_ARRAY: - case Variant::PACKED_VECTOR3_ARRAY: - case Variant::PACKED_COLOR_ARRAY: - class_api.is_ref_counted = true; - break; - default: - class_api.is_ref_counted = false; - break; - } - - // Methods. - - List<StringName> methods; - Variant::get_builtin_method_list(type, &methods); - for (const StringName &E : methods) { - const StringName &method_name = E; - - MethodAPI method_api; - - method_api.method_name = method_name; - method_api.argument_count = Variant::get_builtin_method_argument_count(type, method_name); - method_api.has_varargs = Variant::is_builtin_method_vararg(type, method_name); - method_api.is_const = Variant::is_builtin_method_const(type, method_name); - method_api.is_static = Variant::is_builtin_method_static(type, method_name); - - for (int i = 0; i < method_api.argument_count; i++) { - method_api.argument_names.push_back(Variant::get_builtin_method_argument_name(type, method_name, i)); - Variant::Type arg_type = Variant::get_builtin_method_argument_type(type, method_name, i); - method_api.argument_types.push_back(arg_type == Variant::NIL ? "Variant" : Variant::get_type_name(arg_type)); - } - - Vector<Variant> default_arguments = Variant::get_builtin_method_default_arguments(type, method_name); - - int default_start = method_api.argument_names.size() - default_arguments.size(); - - for (int i = 0; i < default_arguments.size(); i++) { - method_api.default_arguments[default_start + i] = default_arguments[i]; - } - - if (Variant::has_builtin_method_return_value(type, method_name)) { - Variant::Type ret_type = Variant::get_builtin_method_return_type(type, method_name); - method_api.return_type = ret_type == Variant::NIL ? "Variant" : Variant::get_type_name(ret_type); - } else { - method_api.return_type = "void"; - } - - class_api.methods.push_back(method_api); - } - - // Constructors. - - for (int c = 0; c < Variant::get_constructor_count(type); c++) { - MethodAPI constructor_api; - - constructor_api.method_name = Variant::get_type_name(type); - constructor_api.argument_count = Variant::get_constructor_argument_count(type, c); - constructor_api.return_type = Variant::get_type_name(type); - - for (int i = 0; i < constructor_api.argument_count; i++) { - constructor_api.argument_names.push_back(Variant::get_constructor_argument_name(type, c, i)); - Variant::Type arg_type = Variant::get_constructor_argument_type(type, c, i); - constructor_api.argument_types.push_back(arg_type == Variant::NIL ? "Variant" : Variant::get_type_name(arg_type)); - } - - class_api.constructors.push_back(constructor_api); - } - - // Constants. - - List<StringName> constants; - Variant::get_constants_for_type(type, &constants); - for (const StringName &E : constants) { - const StringName &constant_name = E; - ConstantAPI constant_api; - - constant_api.constant_name = constant_name; - constant_api.builtin_constant_value = Variant::get_constant_value(type, constant_name); - constant_api.builtin_constant_type = Variant::get_type_name(constant_api.builtin_constant_value.get_type()); - - class_api.constants.push_back(constant_api); - } - - // Members. - - List<StringName> members; - Variant::get_member_list(type, &members); - for (const StringName &E : members) { - const StringName &member_name = E; - - PropertyAPI member_api; - member_api.name = member_name; - Variant::Type member_type = Variant::get_member_type(type, member_name); - member_api.type = member_type == Variant::NIL ? "Variant" : Variant::get_type_name(member_type); - - class_api.properties.push_back(member_api); - } - - // Operators. - - for (int op = 0; op < Variant::OP_MAX; op++) { - Variant::Operator oper = (Variant::Operator)op; - - for (int ot = 0; ot < Variant::VARIANT_MAX; ot++) { - Variant::Type other_type = (Variant::Type)ot; - - if (!Variant::get_validated_operator_evaluator(oper, type, other_type)) { - continue; - } - - OperatorAPI oper_api; - oper_api.name = Variant::get_operator_name(oper); - oper_api.oper = oper; - oper_api.other_type = Variant::get_type_name(other_type); - oper_api.return_type = Variant::get_type_name(Variant::get_operator_return_type(oper, type, other_type)); - - class_api.operators.push_back(oper_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; - VariantWriter writer; - - source.push_back("[\n"); - - for (const List<ClassAPI>::Element *c = p_api.front(); c != nullptr; 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("\t\t\"singleton_name\": \"" + api.singleton_name + "\",\n"); - source.push_back(String("\t\t\"instantiable\": ") + (api.is_instantiable ? "true" : "false") + ",\n"); - source.push_back(String("\t\t\"is_ref_counted\": ") + (api.is_ref_counted ? "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\t\"index\": ") + itos(e->get().index) + "\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(String("\t\t\t\t\t\t\"has_default_value\": ") + (e->get().default_arguments.has(i) ? "true" : "false") + ",\n"); - String default_value; - if (e->get().default_arguments.has(i)) { - writer.write_to_string(e->get().default_arguments[i], default_value); - default_value = default_value.replace("\n", "").json_escape(); - } - source.push_back("\t\t\t\t\t\t\"default_value\": \"" + default_value + "\"\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"); - String default_value; - if (e->get().default_arguments.has(i)) { - writer.write_to_string(e->get().default_arguments[i], default_value); - default_value = default_value.replace("\n", "").json_escape(); - } - source.push_back("\t\t\t\t\t\t\"default_value\": \"" + default_value + "\"\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\"enums\": [\n"); - for (List<EnumAPI>::Element *e = api.enums.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\"values\": {\n"); - for (List<Pair<int, String>>::Element *val_e = e->get().values.front(); val_e; val_e = val_e->next()) { - source.push_back("\t\t\t\t\t\"" + val_e->get().second + "\": " + itos(val_e->get().first)); - source.push_back(String((val_e->next() ? "," : "")) + "\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; -} - -static int indent_level = 0; - -static void append_indented(StringBuilder &p_source, const String &p_text) { - for (int i = 0; i < indent_level; i++) { - p_source.append("\t"); - } - p_source.append(p_text); - p_source.append("\n"); -} - -static void append_indented(StringBuilder &p_source, const char *p_text) { - for (int i = 0; i < indent_level; i++) { - p_source.append("\t"); - } - p_source.append(p_text); - p_source.append("\n"); -} - -static void write_builtin_method(StringBuilder &p_source, const MethodAPI &p_method) { - VariantWriter writer; - - append_indented(p_source, vformat(R"("name": "%s",)", p_method.method_name)); - append_indented(p_source, vformat(R"("return_type": "%s",)", p_method.return_type)); - append_indented(p_source, vformat(R"("is_const": %s,)", p_method.is_const ? "true" : "false")); - append_indented(p_source, vformat(R"("is_static": %s,)", p_method.is_static ? "true" : "false")); - append_indented(p_source, vformat(R"("has_varargs": %s,)", p_method.has_varargs ? "true" : "false")); - - append_indented(p_source, R"("arguments": [)"); - indent_level++; - for (int i = 0; i < p_method.argument_count; i++) { - append_indented(p_source, "{"); - indent_level++; - - append_indented(p_source, vformat(R"("name": "%s",)", p_method.argument_names[i])); - append_indented(p_source, vformat(R"("type": "%s",)", p_method.argument_types[i])); - append_indented(p_source, vformat(R"("has_default_value": %s,)", p_method.default_arguments.has(i) ? "true" : "false")); - String default_value; - if (p_method.default_arguments.has(i)) { - writer.write_to_string(p_method.default_arguments[i], default_value); - default_value = default_value.replace("\n", "").json_escape(); - } - append_indented(p_source, vformat(R"("default_value": "%s")", default_value)); - - indent_level--; - append_indented(p_source, i < p_method.argument_count - 1 ? "}," : "}"); - } - indent_level--; - append_indented(p_source, "]"); -} - -static List<String> generate_c_builtin_api_json(const List<ClassAPI> &p_api) { - StringBuilder source; - - source.append("[\n"); - - indent_level = 1; - - for (const List<ClassAPI>::Element *C = p_api.front(); C; C = C->next()) { - const ClassAPI &class_api = C->get(); - append_indented(source, "{"); - indent_level++; - - append_indented(source, vformat(R"("name": "%s",)", class_api.class_name)); - append_indented(source, vformat(R"("is_instantiable": %s,)", class_api.is_instantiable ? "true" : "false")); - append_indented(source, vformat(R"("is_ref_counted": %s,)", class_api.is_ref_counted ? "true" : "false")); - append_indented(source, vformat(R"("has_indexing": %s,)", class_api.has_indexing ? "true" : "false")); - append_indented(source, vformat(R"("indexed_type": "%s",)", class_api.has_indexing && class_api.indexed_type == "Nil" ? "Variant" : class_api.indexed_type)); - append_indented(source, vformat(R"("is_keyed": %s,)", class_api.is_keyed ? "true" : "false")); - - // Constructors. - append_indented(source, R"("constructors": [)"); - indent_level++; - for (const List<MethodAPI>::Element *E = class_api.constructors.front(); E; E = E->next()) { - const MethodAPI &constructor = E->get(); - append_indented(source, "{"); - indent_level++; - - write_builtin_method(source, constructor); - - indent_level--; - append_indented(source, E->next() ? "}," : "}"); - } - indent_level--; - append_indented(source, "],"); - - // Constants. - append_indented(source, R"("constants": [)"); - indent_level++; - for (const List<ConstantAPI>::Element *E = class_api.constants.front(); E; E = E->next()) { - const ConstantAPI &constant = E->get(); - append_indented(source, "{"); - indent_level++; - - append_indented(source, vformat(R"("name": "%s",)", constant.constant_name)); - append_indented(source, vformat(R"("type": "%s",)", constant.builtin_constant_type)); - append_indented(source, vformat(R"("value": "%s")", constant.builtin_constant_value.operator String())); - - indent_level--; - append_indented(source, E->next() ? "}," : "}"); - } - indent_level--; - append_indented(source, "],"); - - // Methods. - append_indented(source, R"("methods": [)"); - indent_level++; - for (const List<MethodAPI>::Element *E = class_api.methods.front(); E; E = E->next()) { - const MethodAPI &method = E->get(); - append_indented(source, "{"); - indent_level++; - - write_builtin_method(source, method); - - indent_level--; - append_indented(source, E->next() ? "}," : "}"); - } - indent_level--; - append_indented(source, "],"); - - // Members. - append_indented(source, R"("members": [)"); - indent_level++; - for (const List<PropertyAPI>::Element *E = class_api.properties.front(); E; E = E->next()) { - const PropertyAPI &member = E->get(); - append_indented(source, "{"); - indent_level++; - - append_indented(source, vformat(R"("name": "%s",)", member.name)); - append_indented(source, vformat(R"("type": "%s")", member.type)); - - indent_level--; - append_indented(source, E->next() ? "}," : "}"); - } - indent_level--; - append_indented(source, "],"); - - // Operators. - append_indented(source, R"("operators": [)"); - indent_level++; - for (const List<OperatorAPI>::Element *E = class_api.operators.front(); E; E = E->next()) { - const OperatorAPI &oper = E->get(); - append_indented(source, "{"); - indent_level++; - - append_indented(source, vformat(R"("name": "%s",)", oper.name)); - append_indented(source, vformat(R"("operator": %d,)", oper.oper)); - append_indented(source, vformat(R"("other_type": "%s",)", oper.other_type)); - append_indented(source, vformat(R"("return_type": "%s")", oper.return_type)); - - indent_level--; - append_indented(source, E->next() ? "}," : "}"); - } - indent_level--; - append_indented(source, "]"); - - indent_level--; - append_indented(source, C->next() ? "}," : "}"); - } - - indent_level--; - source.append("]\n"); - - List<String> result; - result.push_back(source.as_string()); - return result; -} - -#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 -} -/* - * Saves the builtin Godot API to a JSON file located at - * p_path - */ -Error generate_c_builtin_api(const String &p_path) { -#ifndef TOOLS_ENABLED - return ERR_BUG; -#else - - List<ClassAPI> api = generate_c_builtin_api_types(); - - List<String> json_source = generate_c_builtin_api_json(api); - - return save_file(p_path, json_source); -#endif -} diff --git a/modules/gdnative/nativescript/api_generator.h b/modules/gdnative/nativescript/api_generator.h deleted file mode 100644 index 58e141f07e..0000000000 --- a/modules/gdnative/nativescript/api_generator.h +++ /dev/null @@ -1,40 +0,0 @@ -/*************************************************************************/ -/* api_generator.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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/string/ustring.h" -#include "core/typedefs.h" - -Error generate_c_api(const String &p_path); -Error generate_c_builtin_api(const String &p_path); - -#endif // API_GENERATOR_H diff --git a/modules/gdnative/nativescript/godot_nativescript.cpp b/modules/gdnative/nativescript/godot_nativescript.cpp deleted file mode 100644 index 992eeba8f4..0000000000 --- a/modules/gdnative/nativescript/godot_nativescript.cpp +++ /dev/null @@ -1,344 +0,0 @@ -/*************************************************************************/ -/* godot_nativescript.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 "nativescript/godot_nativescript.h" - -#include "core/config/project_settings.h" -#include "core/core_constants.h" -#include "core/error/error_macros.h" -#include "core/object/class_db.h" -#include "core/variant/variant.h" -#include "gdnative/gdnative.h" -#include <stdint.h> - -#include "nativescript.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern "C" void _native_script_hook() { -} - -#define NSL NativeScriptLanguage::get_singleton() - -// Script API - -void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_nativescript_instance_create_func p_create_func, godot_nativescript_instance_destroy_func p_destroy_func) { - String *s = (String *)p_gdnative_handle; - - Map<StringName, NativeScriptDesc> *classes = &NSL->library_classes[*s]; - - NativeScriptDesc desc; - - desc.create_func = p_create_func; - desc.destroy_func = p_destroy_func; - desc.is_tool = false; - - desc.base = p_base; - - if (classes->has(p_base)) { - desc.base_data = &(*classes)[p_base]; - desc.base_native_type = desc.base_data->base_native_type; - - const NativeScriptDesc *b = desc.base_data; - while (b) { - desc.rpc_methods.append_array(b->rpc_methods); - b = b->base_data; - } - - } else { - desc.base_data = nullptr; - desc.base_native_type = p_base; - } - - classes->insert(p_name, desc); -} - -void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_nativescript_instance_create_func p_create_func, godot_nativescript_instance_destroy_func p_destroy_func) { - String *s = (String *)p_gdnative_handle; - - Map<StringName, NativeScriptDesc> *classes = &NSL->library_classes[*s]; - - NativeScriptDesc desc; - - desc.create_func = p_create_func; - desc.destroy_func = p_destroy_func; - desc.is_tool = true; - desc.base = p_base; - - if (classes->has(p_base)) { - desc.base_data = &(*classes)[p_base]; - desc.base_native_type = desc.base_data->base_native_type; - - const NativeScriptDesc *b = desc.base_data; - while (b) { - desc.rpc_methods.append_array(b->rpc_methods); - b = b->base_data; - } - - } else { - desc.base_data = nullptr; - desc.base_native_type = p_base; - } - - classes->insert(p_name, desc); -} - -void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_nativescript_method_attributes p_attr, godot_nativescript_instance_method p_method) { - String *s = (String *)p_gdnative_handle; - - Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); - ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class."); - - NativeScriptDesc::Method method; - method.method = p_method; - method.rpc_mode = p_attr.rpc_type; - method.rpc_method_id = UINT16_MAX; - method.info = MethodInfo(p_function_name); - - E->get().methods.insert(p_function_name, method); - - if (p_attr.rpc_type != GODOT_METHOD_RPC_MODE_DISABLED) { - Multiplayer::RPCConfig nd; - nd.name = String(p_name); - nd.rpc_mode = Multiplayer::RPCMode(p_attr.rpc_type); - E->get().rpc_methods.push_back(nd); - } -} - -void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_nativescript_property_attributes *p_attr, godot_nativescript_property_set_func p_set_func, godot_nativescript_property_get_func p_get_func) { - String *s = (String *)p_gdnative_handle; - - Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); - ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class."); - - NativeScriptDesc::Property property; - property.default_value = *(Variant *)&p_attr->default_value; - property.getter = p_get_func; - property.setter = p_set_func; - property.info = PropertyInfo((Variant::Type)p_attr->type, - p_path, - (PropertyHint)p_attr->hint, - *(String *)&p_attr->hint_string, - (PropertyUsageFlags)p_attr->usage); - - E->get().properties.insert(p_path, property); -} - -void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const godot_nativescript_signal *p_signal) { - String *s = (String *)p_gdnative_handle; - - Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); - ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class."); - - List<PropertyInfo> args; - Vector<Variant> default_args; - - for (int i = 0; i < p_signal->num_args; i++) { - PropertyInfo info; - - godot_nativescript_signal_argument arg = p_signal->args[i]; - - info.hint = (PropertyHint)arg.hint; - info.hint_string = *(String *)&arg.hint_string; - info.name = *(String *)&arg.name; - info.type = (Variant::Type)arg.type; - info.usage = (PropertyUsageFlags)arg.usage; - - args.push_back(info); - } - - for (int i = 0; i < p_signal->num_default_args; i++) { - Variant *v; - godot_nativescript_signal_argument attrib = p_signal->args[i]; - - v = (Variant *)&attrib.default_value; - - default_args.push_back(*v); - } - - MethodInfo method_info; - method_info.name = *(String *)&p_signal->name; - method_info.arguments = args; - method_info.default_arguments = default_args; - - NativeScriptDesc::Signal signal; - signal.signal = method_info; - - E->get().signals_.insert(*(String *)&p_signal->name, signal); -} - -void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance) { - Object *instance = (Object *)p_instance; - if (!instance) { - return nullptr; - } - if (instance->get_script_instance() && instance->get_script_instance()->get_language() == NativeScriptLanguage::get_singleton()) { - return ((NativeScriptInstance *)instance->get_script_instance())->userdata; - } - return nullptr; -} - -/* - * - * - * NativeScript 1.1 - * - * - */ - -void GDAPI godot_nativescript_set_method_argument_information(void *p_gdnative_handle, const char *p_name, const char *p_function_name, int p_num_args, const godot_nativescript_method_argument *p_args) { - String *s = (String *)p_gdnative_handle; - - Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); - ERR_FAIL_COND_MSG(!E, "Attempted to add argument information for a method on a non-existent class."); - - Map<StringName, NativeScriptDesc::Method>::Element *method = E->get().methods.find(p_function_name); - ERR_FAIL_COND_MSG(!method, "Attempted to add argument information to non-existent method."); - - MethodInfo *method_information = &method->get().info; - - List<PropertyInfo> args; - - for (int i = 0; i < p_num_args; i++) { - godot_nativescript_method_argument arg = p_args[i]; - String name = *(String *)&arg.name; - String hint_string = *(String *)&arg.hint_string; - - Variant::Type type = (Variant::Type)arg.type; - PropertyHint hint = (PropertyHint)arg.hint; - - args.push_back(PropertyInfo(type, p_name, hint, hint_string)); - } - - method_information->arguments = args; -} - -void GDAPI godot_nativescript_set_class_documentation(void *p_gdnative_handle, const char *p_name, godot_string p_documentation) { - String *s = (String *)p_gdnative_handle; - - Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); - ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a non-existent class."); - - E->get().documentation = *(String *)&p_documentation; -} - -void GDAPI godot_nativescript_set_method_documentation(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_string p_documentation) { - String *s = (String *)p_gdnative_handle; - - Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); - ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a method on a non-existent class."); - - Map<StringName, NativeScriptDesc::Method>::Element *method = E->get().methods.find(p_function_name); - ERR_FAIL_COND_MSG(!method, "Attempted to add documentation to non-existent method."); - - method->get().documentation = *(String *)&p_documentation; -} - -void GDAPI godot_nativescript_set_property_documentation(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_string p_documentation) { - String *s = (String *)p_gdnative_handle; - - Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); - ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a property on a non-existent class."); - - OrderedHashMap<StringName, NativeScriptDesc::Property>::Element property = E->get().properties.find(p_path); - ERR_FAIL_COND_MSG(!property, "Attempted to add documentation to non-existent property."); - - property.get().documentation = *(String *)&p_documentation; -} - -void GDAPI godot_nativescript_set_signal_documentation(void *p_gdnative_handle, const char *p_name, const char *p_signal_name, godot_string p_documentation) { - String *s = (String *)p_gdnative_handle; - - Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); - ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a signal on a non-existent class."); - - Map<StringName, NativeScriptDesc::Signal>::Element *signal = E->get().signals_.find(p_signal_name); - ERR_FAIL_COND_MSG(!signal, "Attempted to add documentation to non-existent signal."); - - signal->get().documentation = *(String *)&p_documentation; -} - -void GDAPI godot_nativescript_set_global_type_tag(int p_idx, const char *p_name, const void *p_type_tag) { - NativeScriptLanguage::get_singleton()->set_global_type_tag(p_idx, StringName(p_name), p_type_tag); -} - -const void GDAPI *godot_nativescript_get_global_type_tag(int p_idx, const char *p_name) { - return NativeScriptLanguage::get_singleton()->get_global_type_tag(p_idx, StringName(p_name)); -} - -void GDAPI godot_nativescript_set_type_tag(void *p_gdnative_handle, const char *p_name, const void *p_type_tag) { - String *s = (String *)p_gdnative_handle; - - Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); - ERR_FAIL_COND_MSG(!E, "Attempted to set type tag on a non-existent class."); - - E->get().type_tag = p_type_tag; -} - -const void GDAPI *godot_nativescript_get_type_tag(const godot_object *p_object) { - const Object *o = (Object *)p_object; - - if (!o->get_script_instance()) { - return nullptr; - } else { - NativeScript *script = Object::cast_to<NativeScript>(o->get_script_instance()->get_script().ptr()); - if (!script) { - return nullptr; - } - - if (script->get_script_desc()) { - return script->get_script_desc()->type_tag; - } - } - - return nullptr; -} - -int GDAPI godot_nativescript_register_instance_binding_data_functions(godot_nativescript_instance_binding_functions p_binding_functions) { - return NativeScriptLanguage::get_singleton()->register_binding_functions(p_binding_functions); -} - -void GDAPI godot_nativescript_unregister_instance_binding_data_functions(int p_idx) { - NativeScriptLanguage::get_singleton()->unregister_binding_functions(p_idx); -} - -void GDAPI *godot_nativescript_get_instance_binding_data(int p_idx, godot_object *p_object) { - return nullptr; -} - -void GDAPI godot_nativescript_profiling_add_data(const char *p_signature, uint64_t p_time) { - NativeScriptLanguage::get_singleton()->profiling_add_data(StringName(p_signature), p_time); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp deleted file mode 100644 index 95976a8827..0000000000 --- a/modules/gdnative/nativescript/nativescript.cpp +++ /dev/null @@ -1,1777 +0,0 @@ -/*************************************************************************/ -/* nativescript.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 "nativescript.h" - -#include <stdint.h> - -#include "gdnative/gdnative.h" - -#include "core/config/project_settings.h" -#include "core/core_constants.h" -#include "core/core_string_names.h" -#include "core/io/file_access.h" -#include "core/io/file_access_encrypted.h" -#include "core/os/os.h" - -#include "main/main.h" - -#include "scene/main/scene_tree.h" -#include "scene/resources/resource_format_text.h" - -#include <stdlib.h> - -#ifndef NO_THREADS -#include "core/os/thread.h" -#endif - -#if defined(TOOLS_ENABLED) && defined(DEBUG_METHODS_ENABLED) -#include "api_generator.h" -#endif - -#ifdef TOOLS_ENABLED -#include "editor/editor_node.h" -#endif - -void NativeScript::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_class_name", "class_name"), &NativeScript::set_class_name); - ClassDB::bind_method(D_METHOD("get_class_name"), &NativeScript::get_class_name); - - ClassDB::bind_method(D_METHOD("set_library", "library"), &NativeScript::set_library); - ClassDB::bind_method(D_METHOD("get_library"), &NativeScript::get_library); - - ClassDB::bind_method(D_METHOD("set_script_class_name", "class_name"), &NativeScript::set_script_class_name); - ClassDB::bind_method(D_METHOD("get_script_class_name"), &NativeScript::get_script_class_name); - ClassDB::bind_method(D_METHOD("set_script_class_icon_path", "icon_path"), &NativeScript::set_script_class_icon_path); - ClassDB::bind_method(D_METHOD("get_script_class_icon_path"), &NativeScript::get_script_class_icon_path); - - ClassDB::bind_method(D_METHOD("get_class_documentation"), &NativeScript::get_class_documentation); - ClassDB::bind_method(D_METHOD("get_method_documentation", "method"), &NativeScript::get_method_documentation); - ClassDB::bind_method(D_METHOD("get_signal_documentation", "signal_name"), &NativeScript::get_signal_documentation); - ClassDB::bind_method(D_METHOD("get_property_documentation", "path"), &NativeScript::get_property_documentation); - - ADD_PROPERTY(PropertyInfo(Variant::STRING, "class_name"), "set_class_name", "get_class_name"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "GDNativeLibrary"), "set_library", "get_library"); - ADD_GROUP("Script Class", "script_class_"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "script_class_name"), "set_script_class_name", "get_script_class_name"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "script_class_icon_path", PROPERTY_HINT_FILE), "set_script_class_icon_path", "get_script_class_icon_path"); - - ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "new", &NativeScript::_new, MethodInfo("new")); -} - -#define NSL NativeScriptLanguage::get_singleton() - -#ifdef TOOLS_ENABLED - -void NativeScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) { - NativeScriptDesc *script_data = get_script_desc(); - - ERR_FAIL_COND(!script_data); - - List<PropertyInfo> info; - get_script_property_list(&info); - Map<StringName, Variant> values; - for (const PropertyInfo &E : info) { - Variant value; - get_property_default_value(E.name, value); - values[E.name] = value; - } - - p_placeholder->update(info, values); -} - -void NativeScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) { - placeholders.erase(p_placeholder); -} - -#endif - -bool NativeScript::inherits_script(const Ref<Script> &p_script) const { - Ref<NativeScript> ns = p_script; - if (ns.is_null()) { - return false; - } - - const NativeScriptDesc *other_s = ns->get_script_desc(); - if (!other_s) { - return false; - } - - const NativeScriptDesc *s = get_script_desc(); - - while (s) { - if (s == other_s) { - return true; - } - s = s->base_data; - } - - return false; -} - -void NativeScript::set_class_name(String p_class_name) { - class_name = p_class_name; -} - -String NativeScript::get_class_name() const { - return class_name; -} - -void NativeScript::set_library(Ref<GDNativeLibrary> p_library) { - if (!library.is_null()) { - WARN_PRINT("Library in NativeScript already set. Do nothing."); - return; - } - if (p_library.is_null()) { - return; - } - library = p_library; - lib_path = library->get_current_library_path(); - -#ifndef NO_THREADS - if (Thread::get_caller_id() != Thread::get_main_id()) { - NSL->defer_init_library(p_library, this); - } else -#endif - { - NSL->init_library(p_library); - NSL->register_script(this); - } -} - -Ref<GDNativeLibrary> NativeScript::get_library() const { - return library; -} - -void NativeScript::set_script_class_name(String p_type) { - script_class_name = p_type; -} - -String NativeScript::get_script_class_name() const { - return script_class_name; -} - -void NativeScript::set_script_class_icon_path(String p_icon_path) { - script_class_icon_path = p_icon_path; -} - -String NativeScript::get_script_class_icon_path() const { - return script_class_icon_path; -} - -bool NativeScript::can_instantiate() const { - NativeScriptDesc *script_data = get_script_desc(); - -#ifdef TOOLS_ENABLED - // Only valid if this is either a tool script or a "regular" script. - // (so, an environment where scripting is disabled (and not the editor) would not - // create objects). - return script_data && (is_tool() || ScriptServer::is_scripting_enabled()); -#else - return script_data; -#endif -} - -Ref<Script> NativeScript::get_base_script() const { - NativeScriptDesc *script_data = get_script_desc(); - - if (!script_data) { - return Ref<Script>(); - } - - NativeScript *script = (NativeScript *)NSL->create_script(); - Ref<NativeScript> ns = Ref<NativeScript>(script); - ERR_FAIL_COND_V(!ns.is_valid(), Ref<Script>()); - - ns->set_class_name(script_data->base); - ns->set_library(get_library()); - return ns; -} - -StringName NativeScript::get_instance_base_type() const { - NativeScriptDesc *script_data = get_script_desc(); - - if (!script_data) { - return ""; - } - - return script_data->base_native_type; -} - -ScriptInstance *NativeScript::instance_create(Object *p_this) { - NativeScriptDesc *script_data = get_script_desc(); - - if (!script_data) { - return nullptr; - } - - NativeScriptInstance *nsi = memnew(NativeScriptInstance); - - nsi->owner = p_this; - nsi->script = Ref<NativeScript>(this); - -#ifndef TOOLS_ENABLED - if (!ScriptServer::is_scripting_enabled()) { - nsi->userdata = nullptr; - } else { - nsi->userdata = script_data->create_func.create_func((godot_object *)p_this, script_data->create_func.method_data); - } -#else - nsi->userdata = script_data->create_func.create_func((godot_object *)p_this, script_data->create_func.method_data); -#endif - - { - MutexLock lock(owners_lock); - - instance_owners.insert(p_this); - } - - return nsi; -} - -PlaceHolderScriptInstance *NativeScript::placeholder_instance_create(Object *p_this) { -#ifdef TOOLS_ENABLED - PlaceHolderScriptInstance *sins = memnew(PlaceHolderScriptInstance(NSL, Ref<Script>(this), p_this)); - placeholders.insert(sins); - - _update_placeholder(sins); - - return sins; -#else - return nullptr; -#endif -} - -bool NativeScript::instance_has(const Object *p_this) const { - return instance_owners.has((Object *)p_this); -} - -bool NativeScript::has_source_code() const { - return false; -} - -String NativeScript::get_source_code() const { - return ""; -} - -void NativeScript::set_source_code(const String &p_code) { -} - -Error NativeScript::reload(bool p_keep_state) { - return FAILED; -} - -bool NativeScript::has_method(const StringName &p_method) const { - NativeScriptDesc *script_data = get_script_desc(); - - while (script_data) { - if (script_data->methods.has(p_method)) { - return true; - } - - script_data = script_data->base_data; - } - return false; -} - -MethodInfo NativeScript::get_method_info(const StringName &p_method) const { - NativeScriptDesc *script_data = get_script_desc(); - - if (!script_data) { - return MethodInfo(); - } - - while (script_data) { - Map<StringName, NativeScriptDesc::Method>::Element *M = script_data->methods.find(p_method); - - if (M) { - return M->get().info; - } - - script_data = script_data->base_data; - } - return MethodInfo(); -} - -bool NativeScript::is_valid() const { - return true; -} - -bool NativeScript::is_tool() const { - NativeScriptDesc *script_data = get_script_desc(); - - if (script_data) { - return script_data->is_tool; - } - - return false; -} - -ScriptLanguage *NativeScript::get_language() const { - return NativeScriptLanguage::get_singleton(); -} - -bool NativeScript::has_script_signal(const StringName &p_signal) const { - NativeScriptDesc *script_data = get_script_desc(); - - while (script_data) { - if (script_data->signals_.has(p_signal)) { - return true; - } - script_data = script_data->base_data; - } - return false; -} - -void NativeScript::get_script_signal_list(List<MethodInfo> *r_signals) const { - NativeScriptDesc *script_data = get_script_desc(); - - if (!script_data) { - return; - } - - Set<MethodInfo> signals_; - - while (script_data) { - for (const KeyValue<StringName, NativeScriptDesc::Signal> &S : script_data->signals_) { - signals_.insert(S.value.signal); - } - - script_data = script_data->base_data; - } - - for (Set<MethodInfo>::Element *E = signals_.front(); E; E = E->next()) { - r_signals->push_back(E->get()); - } -} - -bool NativeScript::get_property_default_value(const StringName &p_property, Variant &r_value) const { - NativeScriptDesc *script_data = get_script_desc(); - - OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P; - while (!P && script_data) { - P = script_data->properties.find(p_property); - script_data = script_data->base_data; - } - if (!P) { - return false; - } - - r_value = P.get().default_value; - return true; -} - -void NativeScript::update_exports() { -} - -void NativeScript::get_script_method_list(List<MethodInfo> *p_list) const { - NativeScriptDesc *script_data = get_script_desc(); - - if (!script_data) { - return; - } - - Set<MethodInfo> methods; - - while (script_data) { - for (const KeyValue<StringName, NativeScriptDesc::Method> &E : script_data->methods) { - methods.insert(E.value.info); - } - - script_data = script_data->base_data; - } - - for (Set<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - p_list->push_back(E->get()); - } -} - -void NativeScript::get_script_property_list(List<PropertyInfo> *p_list) const { - NativeScriptDesc *script_data = get_script_desc(); - - Set<StringName> existing_properties; - List<PropertyInfo>::Element *original_back = p_list->back(); - while (script_data) { - List<PropertyInfo>::Element *insert_position = original_back; - - for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.front(); E; E = E.next()) { - if (!existing_properties.has(E.key())) { - insert_position = p_list->insert_after(insert_position, E.get().info); - existing_properties.insert(E.key()); - } - } - script_data = script_data->base_data; - } -} - -const Vector<Multiplayer::RPCConfig> NativeScript::get_rpc_methods() const { - NativeScriptDesc *script_data = get_script_desc(); - ERR_FAIL_COND_V(!script_data, Vector<Multiplayer::RPCConfig>()); - - return script_data->rpc_methods; -} - -String NativeScript::get_class_documentation() const { - NativeScriptDesc *script_data = get_script_desc(); - - ERR_FAIL_COND_V_MSG(!script_data, "", "Attempt to get class documentation on invalid NativeScript."); - - return script_data->documentation; -} - -String NativeScript::get_method_documentation(const StringName &p_method) const { - NativeScriptDesc *script_data = get_script_desc(); - - ERR_FAIL_COND_V_MSG(!script_data, "", "Attempt to get method documentation on invalid NativeScript."); - - while (script_data) { - Map<StringName, NativeScriptDesc::Method>::Element *method = script_data->methods.find(p_method); - - if (method) { - return method->get().documentation; - } - - script_data = script_data->base_data; - } - - ERR_FAIL_V_MSG("", "Attempt to get method documentation for non-existent method."); -} - -String NativeScript::get_signal_documentation(const StringName &p_signal_name) const { - NativeScriptDesc *script_data = get_script_desc(); - - ERR_FAIL_COND_V_MSG(!script_data, "", "Attempt to get signal documentation on invalid NativeScript."); - - while (script_data) { - Map<StringName, NativeScriptDesc::Signal>::Element *signal = script_data->signals_.find(p_signal_name); - - if (signal) { - return signal->get().documentation; - } - - script_data = script_data->base_data; - } - - ERR_FAIL_V_MSG("", "Attempt to get signal documentation for non-existent signal."); -} - -String NativeScript::get_property_documentation(const StringName &p_path) const { - NativeScriptDesc *script_data = get_script_desc(); - - ERR_FAIL_COND_V_MSG(!script_data, "", "Attempt to get property documentation on invalid NativeScript."); - - while (script_data) { - OrderedHashMap<StringName, NativeScriptDesc::Property>::Element property = script_data->properties.find(p_path); - - if (property) { - return property.get().documentation; - } - - script_data = script_data->base_data; - } - - ERR_FAIL_V_MSG("", "Attempt to get property documentation for non-existent signal."); -} - -Variant NativeScript::_new(const Variant **p_args, int p_argcount, Callable::CallError &r_error) { - if (lib_path.is_empty() || class_name.is_empty() || library.is_null()) { - r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; - return Variant(); - } - - NativeScriptDesc *script_data = get_script_desc(); - - if (!script_data) { - r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; - return Variant(); - } - - r_error.error = Callable::CallError::CALL_OK; - - REF ref; - Object *owner = nullptr; - - if (!(script_data->base_native_type == "")) { - owner = ClassDB::instantiate(script_data->base_native_type); - } else { - owner = memnew(RefCounted); - } - - if (!owner) { - r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; - return Variant(); - } - - RefCounted *r = Object::cast_to<RefCounted>(owner); - if (r) { - ref = REF(r); - } - - NativeScriptInstance *instance = (NativeScriptInstance *)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; - } -} - -NativeScript::NativeScript() { - library = Ref<GDNative>(); - lib_path = ""; - class_name = ""; -} - -NativeScript::~NativeScript() { - NSL->unregister_script(this); -} - -#define GET_SCRIPT_DESC() script->get_script_desc() - -void NativeScriptInstance::_ml_call_reversed(NativeScriptDesc *script_data, const StringName &p_method, const Variant **p_args, int p_argcount) { - if (script_data->base_data) { - _ml_call_reversed(script_data->base_data, p_method, p_args, p_argcount); - } - - Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method); - if (E) { - godot_variant res = E->get().method.method((godot_object *)owner, E->get().method.method_data, userdata, p_argcount, (godot_variant **)p_args); - godot_variant_destroy(&res); - } -} - -bool NativeScriptInstance::set(const StringName &p_name, const Variant &p_value) { - NativeScriptDesc *script_data = GET_SCRIPT_DESC(); - - while (script_data) { - OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = script_data->properties.find(p_name); - if (P) { - P.get().setter.set_func((godot_object *)owner, - P.get().setter.method_data, - userdata, - (godot_variant *)&p_value); - return true; - } - - Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find("_set"); - if (E) { - Variant name = p_name; - const Variant *args[2] = { &name, &p_value }; - - godot_variant result; - result = E->get().method.method((godot_object *)owner, - E->get().method.method_data, - userdata, - 2, - (godot_variant **)args); - bool handled = *(Variant *)&result; - godot_variant_destroy(&result); - if (handled) { - return true; - } - } - - script_data = script_data->base_data; - } - return false; -} - -bool NativeScriptInstance::get(const StringName &p_name, Variant &r_ret) const { - NativeScriptDesc *script_data = GET_SCRIPT_DESC(); - - while (script_data) { - OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = script_data->properties.find(p_name); - if (P) { - godot_variant value; - value = P.get().getter.get_func((godot_object *)owner, - P.get().getter.method_data, - userdata); - r_ret = *(Variant *)&value; - godot_variant_destroy(&value); - return true; - } - - Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find("_get"); - if (E) { - Variant name = p_name; - const Variant *args[1] = { &name }; - - godot_variant result; - result = E->get().method.method((godot_object *)owner, - E->get().method.method_data, - userdata, - 1, - (godot_variant **)args); - r_ret = *(Variant *)&result; - godot_variant_destroy(&result); - if (r_ret.get_type() != Variant::NIL) { - return true; - } - } - - script_data = script_data->base_data; - } - return false; -} - -void NativeScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const { - script->get_script_property_list(p_properties); - - NativeScriptDesc *script_data = GET_SCRIPT_DESC(); - - while (script_data) { - Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find("_get_property_list"); - if (E) { - godot_variant result; - result = E->get().method.method((godot_object *)owner, - E->get().method.method_data, - userdata, - 0, - nullptr); - Variant res = *(Variant *)&result; - godot_variant_destroy(&result); - - ERR_FAIL_COND_MSG(res.get_type() != Variant::ARRAY, "_get_property_list must return an array of dictionaries."); - - Array arr = res; - for (int i = 0; i < arr.size(); i++) { - Dictionary d = arr[i]; - - ERR_CONTINUE(!d.has("name")); - ERR_CONTINUE(!d.has("type")); - - PropertyInfo info; - - info.type = Variant::Type(d["type"].operator int64_t()); - ERR_CONTINUE(info.type < 0 || info.type >= Variant::VARIANT_MAX); - - info.name = d["name"]; - ERR_CONTINUE(info.name.is_empty()); - - if (d.has("hint")) { - info.hint = PropertyHint(d["hint"].operator int64_t()); - } - - if (d.has("hint_string")) { - info.hint_string = d["hint_string"]; - } - - if (d.has("usage")) { - info.usage = d["usage"]; - } - - p_properties->push_back(info); - } - } - - script_data = script_data->base_data; - } - return; -} - -Variant::Type NativeScriptInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const { - NativeScriptDesc *script_data = GET_SCRIPT_DESC(); - - while (script_data) { - OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = script_data->properties.find(p_name); - if (P) { - *r_is_valid = true; - return P.get().info.type; - } - - script_data = script_data->base_data; - } - return Variant::NIL; -} - -void NativeScriptInstance::get_method_list(List<MethodInfo> *p_list) const { - script->get_script_method_list(p_list); -} - -bool NativeScriptInstance::has_method(const StringName &p_method) const { - return script->has_method(p_method); -} - -Variant NativeScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { - NativeScriptDesc *script_data = GET_SCRIPT_DESC(); - - while (script_data) { - Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method); - if (E) { - godot_variant result; - -#ifdef DEBUG_ENABLED - current_method_call = p_method; -#endif - - result = E->get().method.method((godot_object *)owner, - E->get().method.method_data, - userdata, - p_argcount, - (godot_variant **)p_args); - -#ifdef DEBUG_ENABLED - current_method_call = ""; -#endif - - Variant res = *(Variant *)&result; - godot_variant_destroy(&result); - r_error.error = Callable::CallError::CALL_OK; - return res; - } - - script_data = script_data->base_data; - } - - r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; - return Variant(); -} - -void NativeScriptInstance::notification(int p_what) { -#ifdef DEBUG_ENABLED - switch (p_what) { - case MainLoop::NOTIFICATION_CRASH: { - if (current_method_call != StringName()) { - ERR_PRINT("NativeScriptInstance detected crash on method: " + current_method_call); - current_method_call = ""; - } - } break; - } -#endif - - Variant value = p_what; - const Variant *args[1] = { &value }; - Callable::CallError error; - call("_notification", args, 1, error); -} - -String NativeScriptInstance::to_string(bool *r_valid) { - if (has_method(CoreStringNames::get_singleton()->_to_string)) { - Callable::CallError ce; - Variant ret = call(CoreStringNames::get_singleton()->_to_string, nullptr, 0, ce); - if (ce.error == Callable::CallError::CALL_OK) { - if (ret.get_type() != Variant::STRING) { - if (r_valid) { - *r_valid = false; - } - ERR_FAIL_V_MSG(String(), "Wrong type for " + CoreStringNames::get_singleton()->_to_string + ", must be a String."); - } - if (r_valid) { - *r_valid = true; - } - return ret.operator String(); - } - } - if (r_valid) { - *r_valid = false; - } - return String(); -} - -void NativeScriptInstance::refcount_incremented() { - Callable::CallError err; - call("_refcount_incremented", nullptr, 0, err); - if (err.error != Callable::CallError::CALL_OK && err.error != Callable::CallError::CALL_ERROR_INVALID_METHOD) { - ERR_PRINT("Failed to invoke _refcount_incremented - should not happen"); - } -} - -bool NativeScriptInstance::refcount_decremented() { - Callable::CallError err; - Variant ret = call("_refcount_decremented", nullptr, 0, err); - if (err.error != Callable::CallError::CALL_OK && err.error != Callable::CallError::CALL_ERROR_INVALID_METHOD) { - ERR_PRINT("Failed to invoke _refcount_decremented - should not happen"); - return true; // assume we can destroy the object - } - if (err.error == Callable::CallError::CALL_ERROR_INVALID_METHOD) { - // the method does not exist, default is true - return true; - } - return ret; -} - -Ref<Script> NativeScriptInstance::get_script() const { - return script; -} - -const Vector<Multiplayer::RPCConfig> NativeScriptInstance::get_rpc_methods() const { - return script->get_rpc_methods(); -} - -ScriptLanguage *NativeScriptInstance::get_language() { - return NativeScriptLanguage::get_singleton(); -} - -NativeScriptInstance::~NativeScriptInstance() { - NativeScriptDesc *script_data = GET_SCRIPT_DESC(); - - if (!script_data) { - return; - } - - script_data->destroy_func.destroy_func((godot_object *)owner, script_data->destroy_func.method_data, userdata); - - if (owner) { - MutexLock lock(script->owners_lock); - - script->instance_owners.erase(owner); - } -} - -NativeScriptLanguage *NativeScriptLanguage::singleton; - -void NativeScriptLanguage::_unload_stuff(bool p_reload) { - Map<String, Ref<GDNative>> erase_and_unload; - - for (KeyValue<String, Map<StringName, NativeScriptDesc>> &L : library_classes) { - String lib_path = L.key; - Map<StringName, NativeScriptDesc> classes = L.value; - - if (p_reload) { - Map<String, Ref<GDNative>>::Element *E = library_gdnatives.find(lib_path); - Ref<GDNative> gdn; - - if (E) { - gdn = E->get(); - } - - bool should_reload = false; - - if (gdn.is_valid()) { - Ref<GDNativeLibrary> lib = gdn->get_library(); - if (lib.is_valid()) { - should_reload = lib->is_reloadable(); - } - } - - if (!should_reload) { - continue; - } - } - - Map<String, Ref<GDNative>>::Element *E = library_gdnatives.find(lib_path); - Ref<GDNative> gdn; - - if (E) { - gdn = E->get(); - } - - for (KeyValue<StringName, NativeScriptDesc> &C : classes) { - // free property stuff first - for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C.value.properties.front(); P; P = P.next()) { - if (P.get().getter.free_func) { - P.get().getter.free_func(P.get().getter.method_data); - } - - if (P.get().setter.free_func) { - P.get().setter.free_func(P.get().setter.method_data); - } - } - - // free method stuff - for (const KeyValue<StringName, NativeScriptDesc::Method> &M : C.value.methods) { - if (M.value.method.free_func) { - M.value.method.free_func(M.value.method.method_data); - } - } - - // free constructor/destructor - if (C.value.create_func.free_func) { - C.value.create_func.free_func(C.value.create_func.method_data); - } - - if (C.value.destroy_func.free_func) { - C.value.destroy_func.free_func(C.value.destroy_func.method_data); - } - } - - erase_and_unload.insert(lib_path, gdn); - } - - for (KeyValue<String, Ref<GDNative>> &E : erase_and_unload) { - String lib_path = E.key; - Ref<GDNative> gdn = E.value; - - library_classes.erase(lib_path); - - if (gdn.is_valid() && gdn->get_library().is_valid()) { - Ref<GDNativeLibrary> lib = gdn->get_library(); - void *terminate_fn; - Error err = gdn->get_symbol(lib->get_symbol_prefix() + _terminate_call_name, terminate_fn, true); - - if (err == OK) { - void (*terminate)(void *) = (void (*)(void *))terminate_fn; - - terminate((void *)&lib_path); - } - } - } -} - -NativeScriptLanguage::NativeScriptLanguage() { - NativeScriptLanguage::singleton = this; - - _init_call_type = "nativescript_init"; - _init_call_name = "nativescript_init"; - _terminate_call_name = "nativescript_terminate"; - _noarg_call_type = "nativescript_no_arg"; - _frame_call_name = "nativescript_frame"; -#ifndef NO_THREADS - _thread_enter_call_name = "nativescript_thread_enter"; - _thread_exit_call_name = "nativescript_thread_exit"; -#endif -} - -NativeScriptLanguage::~NativeScriptLanguage() { - for (KeyValue<String, Ref<GDNative>> &L : NSL->library_gdnatives) { - Ref<GDNative> lib = L.value; - // only shut down valid libs, duh! - if (lib.is_valid()) { - // If it's a singleton-library then the gdnative module - // manages the destruction at engine shutdown, not NativeScript. - if (!lib->get_library()->is_singleton()) { - lib->terminate(); - } - } - } - - NSL->library_classes.clear(); - NSL->library_gdnatives.clear(); - NSL->library_script_users.clear(); -} - -String NativeScriptLanguage::get_name() const { - return "NativeScript"; -} - -void _add_reload_node() { -#ifdef TOOLS_ENABLED - NativeReloadNode *rn = memnew(NativeReloadNode); - EditorNode::get_singleton()->add_child(rn); -#endif -} - -void NativeScriptLanguage::init() { -#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"); - - if (E && E->next()) { - if (generate_c_api(E->next()->get()) != OK) { - ERR_PRINT("Failed to generate C API\n"); - } - Main::cleanup(true); - exit(0); - } - - E = args.find("--gdnative-generate-json-builtin-api"); - - if (E && E->next()) { - if (generate_c_builtin_api(E->next()->get()) != OK) { - ERR_PRINT("Failed to generate C builtin API\n"); - } - Main::cleanup(true); - exit(0); - } -#endif - -#ifdef TOOLS_ENABLED - EditorNode::add_init_callback(&_add_reload_node); -#endif -} - -String NativeScriptLanguage::get_type() const { - return "NativeScript"; -} - -String NativeScriptLanguage::get_extension() const { - return "gdns"; -} - -Error NativeScriptLanguage::execute_file(const String &p_path) { - return OK; // Qué? -} - -void NativeScriptLanguage::finish() { - _unload_stuff(); -} - -void NativeScriptLanguage::get_reserved_words(List<String> *p_words) const { -} - -bool NativeScriptLanguage::is_control_flow_keyword(String p_keyword) const { - return false; -} - -void NativeScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const { -} - -void NativeScriptLanguage::get_string_delimiters(List<String> *p_delimiters) const { -} - -Ref<Script> NativeScriptLanguage::get_template(const String &p_class_name, const String &p_base_class_name) const { - NativeScript *s = memnew(NativeScript); - s->set_class_name(p_class_name); - return Ref<NativeScript>(s); -} - -bool NativeScriptLanguage::validate(const String &p_script, const String &p_path, List<String> *r_functions, List<ScriptLanguage::ScriptError> *r_errors, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const { - return true; -} - -Script *NativeScriptLanguage::create_script() const { - NativeScript *script = memnew(NativeScript); - return script; -} - -bool NativeScriptLanguage::has_named_classes() const { - return true; -} - -bool NativeScriptLanguage::supports_builtin_mode() const { - return true; -} - -int NativeScriptLanguage::find_function(const String &p_function, const String &p_code) const { - return -1; -} - -String NativeScriptLanguage::make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const { - return ""; -} - -void NativeScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_to_line) const { -} - -void NativeScriptLanguage::add_global_constant(const StringName &p_variable, const Variant &p_value) { -} - -// Debugging stuff here. Not used for now. -String NativeScriptLanguage::debug_get_error() const { - return ""; -} - -int NativeScriptLanguage::debug_get_stack_level_count() const { - return -1; -} - -int NativeScriptLanguage::debug_get_stack_level_line(int p_level) const { - return -1; -} - -String NativeScriptLanguage::debug_get_stack_level_function(int p_level) const { - return ""; -} - -String NativeScriptLanguage::debug_get_stack_level_source(int p_level) const { - return ""; -} - -void NativeScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) { -} - -void NativeScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) { -} - -void NativeScriptLanguage::debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) { -} - -String NativeScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) { - return ""; -} - -// Debugging stuff end. - -void NativeScriptLanguage::reload_all_scripts() { -} - -void NativeScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) { -} - -void NativeScriptLanguage::get_recognized_extensions(List<String> *p_extensions) const { - p_extensions->push_back("gdns"); -} - -void NativeScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const { -} - -void NativeScriptLanguage::get_public_constants(List<Pair<String, Variant>> *p_constants) const { -} - -void NativeScriptLanguage::profiling_start() { -#ifdef DEBUG_ENABLED - MutexLock lock(mutex); - - profile_data.clear(); -#endif -} - -void NativeScriptLanguage::profiling_stop() { -#ifdef DEBUG_ENABLED - MutexLock lock(mutex); -#endif -} - -int NativeScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) { -#ifdef DEBUG_ENABLED - MutexLock lock(mutex); - - int current = 0; - - for (const KeyValue<StringName, ProfileData> &d : profile_data) { - if (current >= p_info_max) { - break; - } - - p_info_arr[current].call_count = d.value.call_count; - p_info_arr[current].self_time = d.value.self_time; - p_info_arr[current].total_time = d.value.total_time; - p_info_arr[current].signature = d.value.signature; - current++; - } - - return current; -#else - return 0; -#endif -} - -int NativeScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) { -#ifdef DEBUG_ENABLED - MutexLock lock(mutex); - - int current = 0; - - for (const KeyValue<StringName, ProfileData> &d : profile_data) { - if (current >= p_info_max) { - break; - } - - if (d.value.last_frame_call_count) { - p_info_arr[current].call_count = d.value.last_frame_call_count; - p_info_arr[current].self_time = d.value.last_frame_self_time; - p_info_arr[current].total_time = d.value.last_frame_total_time; - p_info_arr[current].signature = d.value.signature; - current++; - } - } - - return current; -#else - return 0; -#endif -} - -void NativeScriptLanguage::profiling_add_data(StringName p_signature, uint64_t p_time) { -#ifdef DEBUG_ENABLED - MutexLock lock(mutex); - - Map<StringName, ProfileData>::Element *d = profile_data.find(p_signature); - if (d) { - d->get().call_count += 1; - d->get().total_time += p_time; - d->get().frame_call_count += 1; - d->get().frame_total_time += p_time; - } else { - ProfileData data; - - data.signature = p_signature; - data.call_count = 1; - data.self_time = 0; - data.total_time = p_time; - data.frame_call_count = 1; - data.frame_self_time = 0; - data.frame_total_time = p_time; - data.last_frame_call_count = 0; - data.last_frame_self_time = 0; - data.last_frame_total_time = 0; - - profile_data.insert(p_signature, data); - } -#endif -} - -int NativeScriptLanguage::register_binding_functions(godot_nativescript_instance_binding_functions p_binding_functions) { - // find index - - int idx = -1; - - for (int i = 0; i < binding_functions.size(); i++) { - if (!binding_functions[i].first) { - // free, we'll take it - idx = i; - break; - } - } - - if (idx == -1) { - idx = binding_functions.size(); - binding_functions.resize(idx + 1); - } - - // set the functions - binding_functions.write[idx].first = true; - binding_functions.write[idx].second = p_binding_functions; - - return idx; -} - -void NativeScriptLanguage::unregister_binding_functions(int p_idx) { - ERR_FAIL_INDEX(p_idx, binding_functions.size()); - - for (Set<Vector<void *> *>::Element *E = binding_instances.front(); E; E = E->next()) { - Vector<void *> &binding_data = *E->get(); - - if (p_idx < binding_data.size() && binding_data[p_idx] && binding_functions[p_idx].second.free_instance_binding_data) { - binding_functions[p_idx].second.free_instance_binding_data(binding_functions[p_idx].second.data, binding_data[p_idx]); - } - } - - binding_functions.write[p_idx].first = false; - - if (binding_functions[p_idx].second.free_func) { - binding_functions[p_idx].second.free_func(binding_functions[p_idx].second.data); - } -} - -void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_object) { - return nullptr; -#if 0 - ERR_FAIL_INDEX_V(p_idx, binding_functions.size(), nullptr); - - ERR_FAIL_COND_V_MSG(!binding_functions[p_idx].first, nullptr, "Tried to get binding data for a nativescript binding that does not exist."); - - Vector<void *> *binding_data = (Vector<void *> *)p_object->get_script_instance_binding(lang_idx); - - if (!binding_data) { - return nullptr; // should never happen. - } - - if (binding_data->size() <= p_idx) { - // okay, add new elements here. - int old_size = binding_data->size(); - - binding_data->resize(p_idx + 1); - - for (int i = old_size; i <= p_idx; i++) { - (*binding_data).write[i] = nullptr; - } - } - - if (!(*binding_data)[p_idx]) { - const void *global_type_tag = get_global_type_tag(p_idx, p_object->get_class_name()); - - // no binding data yet, soooooo alloc new one \o/ - (*binding_data).write[p_idx] = binding_functions[p_idx].second.alloc_instance_binding_data(binding_functions[p_idx].second.data, global_type_tag, (godot_object *)p_object); - } - - return (*binding_data)[p_idx]; -#endif -} - -void *NativeScriptLanguage::alloc_instance_binding_data(Object *p_object) { - return nullptr; -#if 0 - Vector<void *> *binding_data = new Vector<void *>; - - binding_data->resize(binding_functions.size()); - - for (int i = 0; i < binding_functions.size(); i++) { - (*binding_data).write[i] = nullptr; - } - - binding_instances.insert(binding_data); - - return (void *)binding_data; -#endif -} - -void NativeScriptLanguage::free_instance_binding_data(void *p_data) { -#if 0 - if (!p_data) { - return; - } - - Vector<void *> &binding_data = *(Vector<void *> *)p_data; - - for (int i = 0; i < binding_data.size(); i++) { - if (!binding_data[i]) { - continue; - } - - if (binding_functions[i].first && binding_functions[i].second.free_instance_binding_data) { - binding_functions[i].second.free_instance_binding_data(binding_functions[i].second.data, binding_data[i]); - } - } - - binding_instances.erase(&binding_data); - - delete &binding_data; -#endif -} - -void NativeScriptLanguage::refcount_incremented_instance_binding(Object *p_object) { -#if 0 - void *data = p_object->get_script_instance_binding(lang_idx); - - if (!data) { - return; - } - - Vector<void *> &binding_data = *(Vector<void *> *)data; - - for (int i = 0; i < binding_data.size(); i++) { - if (!binding_data[i]) { - continue; - } - - if (!binding_functions[i].first) { - continue; - } - - if (binding_functions[i].second.refcount_incremented_instance_binding) { - binding_functions[i].second.refcount_incremented_instance_binding(binding_data[i], p_object); - } - } -#endif -} - -bool NativeScriptLanguage::refcount_decremented_instance_binding(Object *p_object) { -#if 0 - void *data = p_object->get_script_instance_binding(lang_idx); - - if (!data) { - return true; - } - - Vector<void *> &binding_data = *(Vector<void *> *)data; - - bool can_die = true; - - for (int i = 0; i < binding_data.size(); i++) { - if (!binding_data[i]) { - continue; - } - - if (!binding_functions[i].first) { - continue; - } - - if (binding_functions[i].second.refcount_decremented_instance_binding) { - can_die = can_die && binding_functions[i].second.refcount_decremented_instance_binding(binding_data[i], p_object); - } - } - - return can_die; -#endif - return false; -} - -void NativeScriptLanguage::set_global_type_tag(int p_idx, StringName p_class_name, const void *p_type_tag) { - if (!global_type_tags.has(p_idx)) { - global_type_tags.insert(p_idx, HashMap<StringName, const void *>()); - } - - HashMap<StringName, const void *> &tags = global_type_tags[p_idx]; - - tags.set(p_class_name, p_type_tag); -} - -const void *NativeScriptLanguage::get_global_type_tag(int p_idx, StringName p_class_name) const { - if (!global_type_tags.has(p_idx)) { - return nullptr; - } - - const HashMap<StringName, const void *> &tags = global_type_tags[p_idx]; - - if (!tags.has(p_class_name)) { - return nullptr; - } - - const void *tag = tags.get(p_class_name); - - return tag; -} - -#ifndef NO_THREADS -void NativeScriptLanguage::defer_init_library(Ref<GDNativeLibrary> lib, NativeScript *script) { - MutexLock lock(mutex); - libs_to_init.insert(lib); - scripts_to_register.insert(script); - has_objects_to_register.set(); -} -#endif - -void NativeScriptLanguage::init_library(const Ref<GDNativeLibrary> &lib) { - MutexLock lock(mutex); - - // See if this library was "registered" already. - const String &lib_path = lib->get_current_library_path(); - ERR_FAIL_COND_MSG(lib_path.length() == 0, lib->get_name() + " does not have a library for the current platform."); - Map<String, Ref<GDNative>>::Element *E = library_gdnatives.find(lib_path); - - if (!E) { - Ref<GDNative> gdn; - gdn.instantiate(); - gdn->set_library(lib); - - // TODO check the return value? - gdn->initialize(); - - library_gdnatives.insert(lib_path, gdn); - - library_classes.insert(lib_path, Map<StringName, NativeScriptDesc>()); - - if (!library_script_users.has(lib_path)) { - library_script_users.insert(lib_path, Set<NativeScript *>()); - } - - void *proc_ptr; - - Error err = gdn->get_symbol(lib->get_symbol_prefix() + _init_call_name, proc_ptr); - - if (err != OK) { - ERR_PRINT(String("No " + _init_call_name + " in \"" + lib_path + "\" found").utf8().get_data()); - } else { - ((void (*)(godot_string *))proc_ptr)((godot_string *)&lib_path); - } - } else { - // already initialized. Nice. - } -} - -void NativeScriptLanguage::register_script(NativeScript *script) { - MutexLock lock(mutex); - - library_script_users[script->lib_path].insert(script); -} - -void NativeScriptLanguage::unregister_script(NativeScript *script) { - MutexLock lock(mutex); - - Map<String, Set<NativeScript *>>::Element *S = library_script_users.find(script->lib_path); - if (S) { - S->get().erase(script); - if (S->get().size() == 0) { - library_script_users.erase(S); - - Map<String, Ref<GDNative>>::Element *G = library_gdnatives.find(script->lib_path); - if (G && G->get()->get_library()->is_reloadable()) { - // ONLY if the library is marked as reloadable, and no more instances of its scripts exist do we unload the library - - // First remove meta data related to the library - Map<String, Map<StringName, NativeScriptDesc>>::Element *L = library_classes.find(script->lib_path); - if (L) { - Map<StringName, NativeScriptDesc> classes = L->get(); - - for (KeyValue<StringName, NativeScriptDesc> &C : classes) { - // free property stuff first - for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C.value.properties.front(); P; P = P.next()) { - if (P.get().getter.free_func) { - P.get().getter.free_func(P.get().getter.method_data); - } - - if (P.get().setter.free_func) { - P.get().setter.free_func(P.get().setter.method_data); - } - } - - // free method stuff - for (const KeyValue<StringName, NativeScriptDesc::Method> &M : C.value.methods) { - if (M.value.method.free_func) { - M.value.method.free_func(M.value.method.method_data); - } - } - - // free constructor/destructor - if (C.value.create_func.free_func) { - C.value.create_func.free_func(C.value.create_func.method_data); - } - - if (C.value.destroy_func.free_func) { - C.value.destroy_func.free_func(C.value.destroy_func.method_data); - } - } - - library_classes.erase(script->lib_path); - } - - // now unload the library - G->get()->terminate(); - library_gdnatives.erase(G); - } - } - } -#ifndef NO_THREADS - scripts_to_register.erase(script); -#endif -} - -void NativeScriptLanguage::call_libraries_cb(const StringName &name) { - // library_gdnatives is modified only from the main thread, so it's safe not to use mutex here - for (KeyValue<String, Ref<GDNative>> &L : library_gdnatives) { - if (L.value.is_null()) { - continue; - } - - if (L.value->is_initialized()) { - void *proc_ptr; - Error err = L.value->get_symbol(L.value->get_library()->get_symbol_prefix() + name, proc_ptr); - - if (!err) { - ((void (*)())proc_ptr)(); - } - } - } -} - -void NativeScriptLanguage::frame() { -#ifndef NO_THREADS - if (has_objects_to_register.is_set()) { - MutexLock lock(mutex); - for (Set<Ref<GDNativeLibrary>>::Element *L = libs_to_init.front(); L; L = L->next()) { - init_library(L->get()); - } - libs_to_init.clear(); - for (Set<NativeScript *>::Element *S = scripts_to_register.front(); S; S = S->next()) { - register_script(S->get()); - } - scripts_to_register.clear(); - has_objects_to_register.clear(); - } -#endif - -#ifdef DEBUG_ENABLED - { - MutexLock lock(mutex); - - for (KeyValue<StringName, ProfileData> &d : profile_data) { - d.value.last_frame_call_count = d.value.frame_call_count; - d.value.last_frame_self_time = d.value.frame_self_time; - d.value.last_frame_total_time = d.value.frame_total_time; - d.value.frame_call_count = 0; - d.value.frame_self_time = 0; - d.value.frame_total_time = 0; - } - } -#endif - - call_libraries_cb(_frame_call_name); -} - -#ifndef NO_THREADS - -void NativeScriptLanguage::thread_enter() { - call_libraries_cb(_thread_enter_call_name); -} - -void NativeScriptLanguage::thread_exit() { - call_libraries_cb(_thread_exit_call_name); -} - -#endif // NO_THREADS - -bool NativeScriptLanguage::handles_global_class_type(const String &p_type) const { - return p_type == "NativeScript"; -} - -String NativeScriptLanguage::get_global_class_name(const String &p_path, String *r_base_type, String *r_icon_path) const { - if (!p_path.is_empty()) { - Ref<NativeScript> script = ResourceLoader::load(p_path, "NativeScript"); - if (script.is_valid()) { - if (r_base_type) { - *r_base_type = script->get_instance_base_type(); - } - if (r_icon_path) { - *r_icon_path = script->get_script_class_icon_path(); - } - return script->get_script_class_name(); - } - if (r_base_type) { - *r_base_type = String(); - } - if (r_icon_path) { - *r_icon_path = String(); - } - } - return String(); -} - -void NativeReloadNode::_bind_methods() { - ClassDB::bind_method(D_METHOD("_notification"), &NativeReloadNode::_notification); -} - -void NativeReloadNode::_notification(int p_what) { -#ifdef TOOLS_ENABLED - switch (p_what) { - case NOTIFICATION_APPLICATION_FOCUS_OUT: { - if (unloaded) { - break; - } - MutexLock lock(NSL->mutex); - NSL->_unload_stuff(true); - - for (KeyValue<String, Ref<GDNative>> &L : NSL->library_gdnatives) { - Ref<GDNative> gdn = L.value; - - if (gdn.is_null()) { - continue; - } - - // Don't unload what should not be reloaded! - if (!gdn->get_library()->is_reloadable()) { - continue; - } - - // singleton libraries might have alive pointers living inside the - // editor. Also reloading a singleton library would mean that - // the singleton entry will not be called again, as this only - // happens at engine startup. - if (gdn->get_library()->is_singleton()) { - continue; - } - - gdn->terminate(); - } - - unloaded = true; - } break; - - case NOTIFICATION_APPLICATION_FOCUS_IN: { - if (!unloaded) { - break; - } - MutexLock lock(NSL->mutex); - - Set<StringName> libs_to_remove; - for (KeyValue<String, Ref<GDNative>> &L : NSL->library_gdnatives) { - Ref<GDNative> gdn = L.value; - - if (gdn.is_null()) { - continue; - } - - if (!gdn->get_library()->is_reloadable()) { - continue; - } - - // since singleton libraries are not unloaded there is no point - // in loading them again. - if (gdn->get_library()->is_singleton()) { - continue; - } - - if (!gdn->initialize()) { - libs_to_remove.insert(L.key); - continue; - } - - NSL->library_classes.insert(L.key, Map<StringName, NativeScriptDesc>()); - - // here the library registers all the classes and stuff. - - void *proc_ptr; - Error err = gdn->get_symbol(gdn->get_library()->get_symbol_prefix() + "nativescript_init", proc_ptr); - if (err != OK) { - ERR_PRINT(String("No godot_nativescript_init in \"" + L.key + "\" found").utf8().get_data()); - } else { - ((void (*)(void *))proc_ptr)((void *)&L.key); - } - - for (KeyValue<String, Set<NativeScript *>> &U : NSL->library_script_users) { - for (Set<NativeScript *>::Element *S = U.value.front(); S; S = S->next()) { - NativeScript *script = S->get(); - - if (script->placeholders.size() == 0) { - continue; - } - - for (Set<PlaceHolderScriptInstance *>::Element *P = script->placeholders.front(); P; P = P->next()) { - script->_update_placeholder(P->get()); - } - } - } - } - - unloaded = false; - - for (Set<StringName>::Element *R = libs_to_remove.front(); R; R = R->next()) { - NSL->library_gdnatives.erase(R->get()); - } - } break; - } -#endif -} - -RES ResourceFormatLoaderNativeScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_no_cache) { - return ResourceFormatLoaderText::singleton->load(p_path, p_original_path, r_error); -} - -void ResourceFormatLoaderNativeScript::get_recognized_extensions(List<String> *p_extensions) const { - p_extensions->push_back("gdns"); -} - -bool ResourceFormatLoaderNativeScript::handles_type(const String &p_type) const { - return (p_type == "Script" || p_type == "NativeScript"); -} - -String ResourceFormatLoaderNativeScript::get_resource_type(const String &p_path) const { - String el = p_path.get_extension().to_lower(); - if (el == "gdns") { - return "NativeScript"; - } - return ""; -} - -Error ResourceFormatSaverNativeScript::save(const String &p_path, const RES &p_resource, uint32_t p_flags) { - ResourceFormatSaverText rfst; - return rfst.save(p_path, p_resource, p_flags); -} - -bool ResourceFormatSaverNativeScript::recognize(const RES &p_resource) const { - return Object::cast_to<NativeScript>(*p_resource) != nullptr; -} - -void ResourceFormatSaverNativeScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const { - if (Object::cast_to<NativeScript>(*p_resource)) { - p_extensions->push_back("gdns"); - } -} diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h deleted file mode 100644 index 2d01de5832..0000000000 --- a/modules/gdnative/nativescript/nativescript.h +++ /dev/null @@ -1,393 +0,0 @@ -/*************************************************************************/ -/* nativescript.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 NATIVE_SCRIPT_H -#define NATIVE_SCRIPT_H - -#include "core/doc_data.h" -#include "core/io/resource.h" -#include "core/io/resource_loader.h" -#include "core/io/resource_saver.h" -#include "core/object/script_language.h" -#include "core/os/mutex.h" -#include "core/os/thread_safe.h" -#include "core/templates/oa_hash_map.h" -#include "core/templates/ordered_hash_map.h" -#include "core/templates/safe_refcount.h" -#include "core/templates/self_list.h" -#include "scene/main/node.h" - -#include "modules/gdnative/gdnative.h" - -#include <nativescript/godot_nativescript.h> - -struct NativeScriptDesc { - struct Method { - godot_nativescript_instance_method method; - MethodInfo info; - int rpc_mode = 0; - uint16_t rpc_method_id = 0; - String documentation; - }; - - struct Property { - godot_nativescript_property_set_func setter; - godot_nativescript_property_get_func getter; - PropertyInfo info; - Variant default_value; - String documentation; - }; - - struct Signal { - MethodInfo signal; - String documentation; - }; - - Map<StringName, Method> methods; - Vector<Multiplayer::RPCConfig> rpc_methods; - OrderedHashMap<StringName, Property> properties; - Map<StringName, Signal> signals_; // QtCreator doesn't like the name signals - StringName base; - StringName base_native_type; - NativeScriptDesc *base_data = nullptr; - godot_nativescript_instance_create_func create_func; - godot_nativescript_instance_destroy_func destroy_func; - - String documentation; - - const void *type_tag = nullptr; - - bool is_tool = false; - - inline NativeScriptDesc() { - memset(&create_func, 0, sizeof(godot_nativescript_instance_create_func)); - memset(&destroy_func, 0, sizeof(godot_nativescript_instance_destroy_func)); - } -}; - -class NativeScript : public Script { - GDCLASS(NativeScript, Script); - -#ifdef TOOLS_ENABLED - Set<PlaceHolderScriptInstance *> placeholders; - void _update_placeholder(PlaceHolderScriptInstance *p_placeholder); - virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder) override; -#endif - - friend class NativeScriptInstance; - friend class NativeScriptLanguage; - friend class NativeReloadNode; - friend class GDNativeLibrary; - - Ref<GDNativeLibrary> library; - - String lib_path; - - String class_name; - - String script_class_name; - String script_class_icon_path; - - Mutex owners_lock; - Set<Object *> instance_owners; - -protected: - static void _bind_methods(); - -public: - inline NativeScriptDesc *get_script_desc() const; - - bool inherits_script(const Ref<Script> &p_script) const override; - - void set_class_name(String p_class_name); - String get_class_name() const; - - void set_library(Ref<GDNativeLibrary> p_library); - Ref<GDNativeLibrary> get_library() const; - - void set_script_class_name(String p_type); - String get_script_class_name() const; - void set_script_class_icon_path(String p_icon_path); - String get_script_class_icon_path() const; - - virtual bool can_instantiate() const override; - - virtual Ref<Script> get_base_script() const override; //for script inheritance - - virtual StringName get_instance_base_type() const override; // this may not work in all scripts, will return empty if so - virtual ScriptInstance *instance_create(Object *p_this) override; - virtual PlaceHolderScriptInstance *placeholder_instance_create(Object *p_this) override; - virtual bool instance_has(const Object *p_this) const override; - - virtual bool has_source_code() const override; - virtual String get_source_code() const override; - virtual void set_source_code(const String &p_code) override; - virtual Error reload(bool p_keep_state = false) override; - -#ifdef TOOLS_ENABLED - virtual const Vector<DocData::ClassDoc> &get_documentation() const override { - static Vector<DocData::ClassDoc> docs; - return docs; - } -#endif // TOOLS_ENABLED - - virtual bool has_method(const StringName &p_method) const override; - virtual MethodInfo get_method_info(const StringName &p_method) const override; - - virtual bool is_tool() const override; - virtual bool is_valid() const override; - - virtual ScriptLanguage *get_language() const override; - - virtual bool has_script_signal(const StringName &p_signal) const override; - virtual void get_script_signal_list(List<MethodInfo> *r_signals) const override; - - virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const override; - - virtual void update_exports() override; //editor tool - virtual void get_script_method_list(List<MethodInfo> *p_list) const override; - virtual void get_script_property_list(List<PropertyInfo> *p_list) const override; - - virtual const Vector<Multiplayer::RPCConfig> get_rpc_methods() const override; - - String get_class_documentation() const; - String get_method_documentation(const StringName &p_method) const; - String get_signal_documentation(const StringName &p_signal_name) const; - String get_property_documentation(const StringName &p_path) const; - - Variant _new(const Variant **p_args, int p_argcount, Callable::CallError &r_error); - - NativeScript(); - ~NativeScript(); -}; - -class NativeScriptInstance : public ScriptInstance { - friend class NativeScript; - - Object *owner; - Ref<NativeScript> script; -#ifdef DEBUG_ENABLED - StringName current_method_call; -#endif - - void _ml_call_reversed(NativeScriptDesc *script_data, const StringName &p_method, const Variant **p_args, int p_argcount); - -public: - void *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) 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, Callable::CallError &r_error); - virtual void notification(int p_what); - String to_string(bool *r_valid); - virtual Ref<Script> get_script() const; - - virtual const Vector<Multiplayer::RPCConfig> get_rpc_methods() const; - - virtual ScriptLanguage *get_language(); - - virtual void refcount_incremented(); - virtual bool refcount_decremented(); - - ~NativeScriptInstance(); -}; - -class NativeReloadNode; - -class NativeScriptLanguage : public ScriptLanguage { - friend class NativeScript; - friend class NativeScriptInstance; - friend class NativeReloadNode; - -private: - static NativeScriptLanguage *singleton; - int lang_idx = 0; - - void _unload_stuff(bool p_reload = false); - - Mutex mutex; -#ifndef NO_THREADS - Set<Ref<GDNativeLibrary>> libs_to_init; - Set<NativeScript *> scripts_to_register; - SafeFlag has_objects_to_register; // so that we don't lock mutex every frame - it's rarely needed - void defer_init_library(Ref<GDNativeLibrary> lib, NativeScript *script); -#endif - - void init_library(const Ref<GDNativeLibrary> &lib); - void register_script(NativeScript *script); - void unregister_script(NativeScript *script); - - void call_libraries_cb(const StringName &name); - - Vector<Pair<bool, godot_nativescript_instance_binding_functions>> binding_functions; - Set<Vector<void *> *> binding_instances; - - Map<int, HashMap<StringName, const void *>> global_type_tags; - - struct ProfileData { - StringName signature; - uint64_t call_count = 0; - uint64_t self_time = 0; - uint64_t total_time = 0; - uint64_t frame_call_count = 0; - uint64_t frame_self_time = 0; - uint64_t frame_total_time = 0; - uint64_t last_frame_call_count = 0; - uint64_t last_frame_self_time = 0; - uint64_t last_frame_total_time = 0; - }; - - Map<StringName, ProfileData> profile_data; - -public: - // These two maps must only be touched on the main thread - Map<String, Map<StringName, NativeScriptDesc>> library_classes; - Map<String, Ref<GDNative>> library_gdnatives; - - Map<String, Set<NativeScript *>> library_script_users; - - StringName _init_call_type; - StringName _init_call_name; - StringName _terminate_call_name; - StringName _noarg_call_type; - StringName _frame_call_name; -#ifndef NO_THREADS - StringName _thread_enter_call_name; - StringName _thread_exit_call_name; -#endif - - NativeScriptLanguage(); - ~NativeScriptLanguage(); - - inline static NativeScriptLanguage *get_singleton() { - return singleton; - } - - _FORCE_INLINE_ void set_language_index(int p_idx) { lang_idx = p_idx; } - -#ifndef NO_THREADS - virtual void thread_enter(); - virtual void thread_exit(); -#endif - - virtual void frame(); - - virtual String get_name() const; - virtual void init(); - virtual String get_type() const; - virtual String get_extension() const; - virtual Error execute_file(const String &p_path); - virtual void finish(); - virtual void get_reserved_words(List<String> *p_words) const; - virtual bool is_control_flow_keyword(String p_keyword) 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, const String &p_path, List<String> *r_functions, List<ScriptLanguage::ScriptError> *r_errors = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const; - virtual Script *create_script() const; - virtual bool has_named_classes() const; - virtual bool supports_builtin_mode() 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 PackedStringArray &p_args) const; - 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); - 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, int p_max_depth); - virtual void debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth); - virtual void debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth); - virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth); - virtual void reload_all_scripts(); - virtual void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload); - 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; - 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); - - int register_binding_functions(godot_nativescript_instance_binding_functions p_binding_functions); - void unregister_binding_functions(int p_idx); - - void *get_instance_binding_data(int p_idx, Object *p_object); - - virtual void *alloc_instance_binding_data(Object *p_object); - virtual void free_instance_binding_data(void *p_data); - virtual void refcount_incremented_instance_binding(Object *p_object); - virtual bool refcount_decremented_instance_binding(Object *p_object); - - void set_global_type_tag(int p_idx, StringName p_class_name, const void *p_type_tag); - const void *get_global_type_tag(int p_idx, StringName p_class_name) const; - - virtual bool handles_global_class_type(const String &p_type) const; - virtual String get_global_class_name(const String &p_path, String *r_base_type, String *r_icon_path) const; - - void profiling_add_data(StringName p_signature, uint64_t p_time); -}; - -inline NativeScriptDesc *NativeScript::get_script_desc() const { - Map<StringName, NativeScriptDesc>::Element *E = NativeScriptLanguage::singleton->library_classes[lib_path].find(class_name); - return E ? &E->get() : nullptr; -} - -class NativeReloadNode : public Node { - GDCLASS(NativeReloadNode, Node); - bool unloaded = false; - -public: - static void _bind_methods(); - void _notification(int p_what); - - NativeReloadNode() {} -}; - -class ResourceFormatLoaderNativeScript : public ResourceFormatLoader { -public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE); - 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; -}; - -class ResourceFormatSaverNativeScript : 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; -}; - -#endif // GDNATIVE_H diff --git a/modules/gdnative/nativescript/register_types.cpp b/modules/gdnative/nativescript/register_types.cpp deleted file mode 100644 index ee63dca9a3..0000000000 --- a/modules/gdnative/nativescript/register_types.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/*************************************************************************/ -/* register_types.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 "register_types.h" - -#include "core/io/resource_loader.h" -#include "core/io/resource_saver.h" - -#include "nativescript.h" - -#include "core/os/os.h" - -NativeScriptLanguage *native_script_language; - -Ref<ResourceFormatLoaderNativeScript> resource_loader_gdns; -Ref<ResourceFormatSaverNativeScript> resource_saver_gdns; - -void register_nativescript_types() { - native_script_language = memnew(NativeScriptLanguage); - - GDREGISTER_CLASS(NativeScript); - - native_script_language->set_language_index(ScriptServer::get_language_count()); - ScriptServer::register_language(native_script_language); - - resource_saver_gdns.instantiate(); - ResourceSaver::add_resource_format_saver(resource_saver_gdns); - - resource_loader_gdns.instantiate(); - ResourceLoader::add_resource_format_loader(resource_loader_gdns); -} - -void unregister_nativescript_types() { - ResourceLoader::remove_resource_format_loader(resource_loader_gdns); - resource_loader_gdns.unref(); - - ResourceSaver::remove_resource_format_saver(resource_saver_gdns); - resource_saver_gdns.unref(); - - if (native_script_language) { - ScriptServer::unregister_language(native_script_language); - memdelete(native_script_language); - } -} diff --git a/modules/gdnative/nativescript/register_types.h b/modules/gdnative/nativescript/register_types.h deleted file mode 100644 index ce6085f62a..0000000000 --- a/modules/gdnative/nativescript/register_types.h +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************/ -/* register_types.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 NATIVESCRIPT_REGISTER_TYPES_H -#define NATIVESCRIPT_REGISTER_TYPES_H - -void register_nativescript_types(); -void unregister_nativescript_types(); - -#endif // NATIVESCRIPT_REGISTER_TYPES_H diff --git a/modules/gdnative/pluginscript/SCsub b/modules/gdnative/pluginscript/SCsub deleted file mode 100644 index 0b2db3b504..0000000000 --- a/modules/gdnative/pluginscript/SCsub +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env python - -Import("env") -Import("env_gdnative") - -env_gdnative.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/gdnative/pluginscript/pluginscript_instance.cpp b/modules/gdnative/pluginscript/pluginscript_instance.cpp deleted file mode 100644 index 9236aceb3e..0000000000 --- a/modules/gdnative/pluginscript/pluginscript_instance.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/*************************************************************************/ -/* pluginscript_instance.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 "pluginscript_instance.h" - -// Godot imports -#include "core/os/os.h" -#include "core/variant/variant.h" - -// PluginScript imports -#include "pluginscript_language.h" -#include "pluginscript_script.h" - -bool PluginScriptInstance::set(const StringName &p_name, const Variant &p_value) { - return _desc->set_prop(_data, (const godot_string_name *)&p_name, (const godot_variant *)&p_value); -} - -bool PluginScriptInstance::get(const StringName &p_name, Variant &r_ret) const { - return _desc->get_prop(_data, (const godot_string_name *)&p_name, (godot_variant *)&r_ret); -} - -Ref<Script> PluginScriptInstance::get_script() const { - return _script; -} - -ScriptLanguage *PluginScriptInstance::get_language() { - return _script->get_language(); -} - -Variant::Type PluginScriptInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const { - if (!_script->has_property(p_name)) { - if (r_is_valid) { - *r_is_valid = false; - } - return Variant::NIL; - } - if (r_is_valid) { - *r_is_valid = true; - } - return _script->get_property_info(p_name).type; -} - -void PluginScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const { - _script->get_script_property_list(p_properties); -} - -void PluginScriptInstance::get_method_list(List<MethodInfo> *p_list) const { - _script->get_script_method_list(p_list); -} - -bool PluginScriptInstance::has_method(const StringName &p_method) const { - return _script->has_method(p_method); -} - -Variant PluginScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { - // TODO: optimize when calling a Godot method from Godot to avoid param conversion ? - godot_variant ret = _desc->call_method( - _data, (godot_string_name *)&p_method, (const godot_variant **)p_args, - p_argcount, (godot_variant_call_error *)&r_error); - Variant var_ret = *(Variant *)&ret; - godot_variant_destroy(&ret); - return var_ret; -} - -void PluginScriptInstance::notification(int p_notification) { - _desc->notification(_data, p_notification); -} - -String PluginScriptInstance::to_string(bool *r_valid) { - godot_string ret = _desc->to_string(_data, r_valid); - String str_ret = *(String *)&ret; - godot_string_destroy(&ret); - return str_ret; -} - -const Vector<Multiplayer::RPCConfig> PluginScriptInstance::get_rpc_methods() const { - return _script->get_rpc_methods(); -} - -void PluginScriptInstance::refcount_incremented() { - if (_desc->refcount_decremented) { - _desc->refcount_incremented(_data); - } -} - -bool PluginScriptInstance::refcount_decremented() { - // Return true if it can die - if (_desc->refcount_decremented) { - return _desc->refcount_decremented(_data); - } - return true; -} - -PluginScriptInstance::PluginScriptInstance() { -} - -bool PluginScriptInstance::init(PluginScript *p_script, Object *p_owner) { - _owner = p_owner; - _owner_variant = Variant(p_owner); - _script = Ref<PluginScript>(p_script); - _desc = &p_script->_desc->instance_desc; - _data = _desc->init(p_script->_data, (godot_object *)p_owner); - ERR_FAIL_COND_V(_data == nullptr, false); - p_owner->set_script_instance(this); - return true; -} - -PluginScriptInstance::~PluginScriptInstance() { - _desc->finish(_data); - _script->_language->lock(); - _script->_instances.erase(_owner); - _script->_language->unlock(); -} diff --git a/modules/gdnative/pluginscript/pluginscript_instance.h b/modules/gdnative/pluginscript/pluginscript_instance.h deleted file mode 100644 index 09b051c008..0000000000 --- a/modules/gdnative/pluginscript/pluginscript_instance.h +++ /dev/null @@ -1,82 +0,0 @@ -/*************************************************************************/ -/* pluginscript_instance.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 PLUGINSCRIPT_INSTANCE_H -#define PLUGINSCRIPT_INSTANCE_H - -// Godot imports -#include "core/object/script_language.h" - -// PluginScript imports -#include <pluginscript/godot_pluginscript.h> - -class PluginScript; - -class PluginScriptInstance : public ScriptInstance { - friend class PluginScript; - -private: - Ref<PluginScript> _script; - Object *_owner = nullptr; - Variant _owner_variant; - godot_pluginscript_instance_data *_data = nullptr; - const godot_pluginscript_instance_desc *_desc = nullptr; - -public: - _FORCE_INLINE_ Object *get_owner() { return _owner; } - - 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 = nullptr) 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, Callable::CallError &r_error); - - virtual void notification(int p_notification); - virtual String to_string(bool *r_valid); - - virtual Ref<Script> get_script() const; - - virtual ScriptLanguage *get_language(); - - virtual const Vector<Multiplayer::RPCConfig> get_rpc_methods() const; - - virtual void refcount_incremented(); - virtual bool refcount_decremented(); - - PluginScriptInstance(); - bool init(PluginScript *p_script, Object *p_owner); - virtual ~PluginScriptInstance(); -}; - -#endif // PLUGINSCRIPT_INSTANCE_H diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp deleted file mode 100644 index 0e068dec3a..0000000000 --- a/modules/gdnative/pluginscript/pluginscript_language.cpp +++ /dev/null @@ -1,459 +0,0 @@ -/*************************************************************************/ -/* pluginscript_language.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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. */ -/*************************************************************************/ - -// Godot imports -#include "core/config/project_settings.h" -#include "core/io/file_access.h" -#include "core/os/os.h" -// PluginScript imports -#include "pluginscript_language.h" -#include "pluginscript_script.h" - -String PluginScriptLanguage::get_name() const { - return String(_desc.name); -} - -void PluginScriptLanguage::init() { - _data = _desc.init(); -} - -String PluginScriptLanguage::get_type() const { - // We should use _desc.type here, however the returned type is used to - // query ClassDB which would complain given the type is not registered - // from his point of view... - // To solve this we just use a more generic (but present in ClassDB) type. - return String("PluginScript"); -} - -String PluginScriptLanguage::get_extension() const { - return String(_desc.extension); -} - -Error PluginScriptLanguage::execute_file(const String &p_path) { - // TODO: pretty sure this method is totally deprecated and should be removed... - return OK; -} - -void PluginScriptLanguage::finish() { - _desc.finish(_data); -} - -/* EDITOR FUNCTIONS */ - -void PluginScriptLanguage::get_reserved_words(List<String> *p_words) const { - if (_desc.reserved_words) { - const char **w = _desc.reserved_words; - while (*w) { - p_words->push_back(*w); - w++; - } - } -} - -bool PluginScriptLanguage::is_control_flow_keyword(String p_keyword) const { - return false; -} - -void PluginScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const { - if (_desc.comment_delimiters) { - const char **w = _desc.comment_delimiters; - while (*w) { - p_delimiters->push_back(*w); - w++; - } - } -} - -void PluginScriptLanguage::get_string_delimiters(List<String> *p_delimiters) const { - if (_desc.string_delimiters) { - const char **w = _desc.string_delimiters; - while (*w) { - p_delimiters->push_back(*w); - w++; - } - } -} - -Ref<Script> PluginScriptLanguage::get_template(const String &p_class_name, const String &p_base_class_name) const { - Script *ns = create_script(); - Ref<Script> script = Ref<Script>(ns); - if (_desc.get_template_source_code) { - godot_string src = _desc.get_template_source_code(_data, (godot_string *)&p_class_name, (godot_string *)&p_base_class_name); - script->set_source_code(*(String *)&src); - godot_string_destroy(&src); - } - return script; -} - -bool PluginScriptLanguage::validate(const String &p_script, const String &p_path, List<String> *r_functions, List<ScriptLanguage::ScriptError> *r_errors, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const { - PackedStringArray functions; - Array errors; - if (_desc.validate) { - bool ret = _desc.validate( - _data, - (godot_string *)&p_script, - (godot_string *)&p_path, - (godot_packed_string_array *)&functions, - (godot_array *)&errors); - for (int i = 0; i < functions.size(); i++) { - r_functions->push_back(functions[i]); - } - if (r_errors) { - for (int i = 0; i < errors.size(); i++) { - Dictionary error = errors[i]; - ScriptLanguage::ScriptError e; - e.line = error["line"]; - e.column = error["column"]; - e.message = error["message"]; - r_errors->push_back(e); - } - } - return ret; - } - return true; -} - -Script *PluginScriptLanguage::create_script() const { - PluginScript *script = memnew(PluginScript()); - // I'm hurting kittens doing this I guess... - script->init(const_cast<PluginScriptLanguage *>(this)); - return script; -} - -bool PluginScriptLanguage::has_named_classes() const { - return _desc.has_named_classes; -} - -bool PluginScriptLanguage::supports_builtin_mode() const { - return _desc.supports_builtin_mode; -} - -bool PluginScriptLanguage::can_inherit_from_file() const { - return _desc.can_inherit_from_file; -} - -int PluginScriptLanguage::find_function(const String &p_function, const String &p_code) const { - if (_desc.find_function) { - return _desc.find_function(_data, (godot_string *)&p_function, (godot_string *)&p_code); - } - return -1; -} - -String PluginScriptLanguage::make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const { - if (_desc.make_function) { - godot_string tmp = _desc.make_function(_data, (godot_string *)&p_class, (godot_string *)&p_name, (godot_packed_string_array *)&p_args); - String ret = *(String *)&tmp; - godot_string_destroy(&tmp); - return ret; - } - return String(); -} - -Error PluginScriptLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_force, String &r_call_hint) { - if (_desc.complete_code) { - Array options; - godot_error tmp = _desc.complete_code( - _data, - (godot_string *)&p_code, - (godot_string *)&p_path, - (godot_object *)p_owner, - (godot_array *)&options, - &r_force, - (godot_string *)&r_call_hint); - for (int i = 0; i < options.size(); i++) { - ScriptCodeCompletionOption option(options[i], ScriptCodeCompletionOption::KIND_PLAIN_TEXT); - r_options->push_back(option); - } - return (Error)tmp; - } - return ERR_UNAVAILABLE; -} - -void PluginScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_to_line) const { - if (_desc.auto_indent_code) { - _desc.auto_indent_code(_data, (godot_string *)&p_code, p_from_line, p_to_line); - } - return; -} - -void PluginScriptLanguage::add_global_constant(const StringName &p_variable, const Variant &p_value) { - _desc.add_global_constant(_data, (godot_string_name *)&p_variable, (godot_variant *)&p_value); -} - -/* LOADER FUNCTIONS */ - -void PluginScriptLanguage::get_recognized_extensions(List<String> *p_extensions) const { - for (int i = 0; _desc.recognized_extensions[i]; ++i) { - p_extensions->push_back(String(_desc.recognized_extensions[i])); - } -} - -void PluginScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const { - // TODO: provide this statically in `godot_pluginscript_language_desc` ? - if (_desc.get_public_functions) { - Array functions; - _desc.get_public_functions(_data, (godot_array *)&functions); - for (int i = 0; i < functions.size(); i++) { - MethodInfo mi = MethodInfo::from_dict(functions[i]); - p_functions->push_back(mi); - } - } -} - -void PluginScriptLanguage::get_public_constants(List<Pair<String, Variant>> *p_constants) const { - // TODO: provide this statically in `godot_pluginscript_language_desc` ? - if (_desc.get_public_constants) { - Dictionary constants; - _desc.get_public_constants(_data, (godot_dictionary *)&constants); - for (const Variant *key = constants.next(); key; key = constants.next(key)) { - Variant value = constants[*key]; - p_constants->push_back(Pair<String, Variant>(*key, value)); - } - } -} - -void PluginScriptLanguage::profiling_start() { -#ifdef DEBUG_ENABLED - if (_desc.profiling_start) { - lock(); - _desc.profiling_start(_data); - unlock(); - } -#endif -} - -void PluginScriptLanguage::profiling_stop() { -#ifdef DEBUG_ENABLED - if (_desc.profiling_stop) { - lock(); - _desc.profiling_stop(_data); - unlock(); - } -#endif -} - -int PluginScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) { - int info_count = 0; -#ifdef DEBUG_ENABLED - if (_desc.profiling_get_accumulated_data) { - godot_pluginscript_profiling_data *info = (godot_pluginscript_profiling_data *)memalloc( - sizeof(godot_pluginscript_profiling_data) * p_info_max); - info_count = _desc.profiling_get_accumulated_data(_data, info, p_info_max); - for (int i = 0; i < info_count; ++i) { - p_info_arr[i].signature = *(StringName *)&info[i].signature; - p_info_arr[i].call_count = info[i].call_count; - p_info_arr[i].total_time = info[i].total_time; - p_info_arr[i].self_time = info[i].self_time; - godot_string_name_destroy(&info[i].signature); - } - } -#endif - return info_count; -} - -int PluginScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) { - int info_count = 0; -#ifdef DEBUG_ENABLED - if (_desc.profiling_get_frame_data) { - godot_pluginscript_profiling_data *info = (godot_pluginscript_profiling_data *)memalloc( - sizeof(godot_pluginscript_profiling_data) * p_info_max); - info_count = _desc.profiling_get_frame_data(_data, info, p_info_max); - for (int i = 0; i < info_count; ++i) { - p_info_arr[i].signature = *(StringName *)&info[i].signature; - p_info_arr[i].call_count = info[i].call_count; - p_info_arr[i].total_time = info[i].total_time; - p_info_arr[i].self_time = info[i].self_time; - godot_string_name_destroy(&info[i].signature); - } - } -#endif - return info_count; -} - -void PluginScriptLanguage::frame() { -#ifdef DEBUG_ENABLED - if (_desc.profiling_frame) { - _desc.profiling_frame(_data); - } -#endif -} - -/* DEBUGGER FUNCTIONS */ - -String PluginScriptLanguage::debug_get_error() const { - if (_desc.debug_get_error) { - godot_string tmp = _desc.debug_get_error(_data); - String ret = *(String *)&tmp; - godot_string_destroy(&tmp); - return ret; - } - return String("Nothing"); -} - -int PluginScriptLanguage::debug_get_stack_level_count() const { - if (_desc.debug_get_stack_level_count) { - return _desc.debug_get_stack_level_count(_data); - } - return 1; -} - -int PluginScriptLanguage::debug_get_stack_level_line(int p_level) const { - if (_desc.debug_get_stack_level_line) { - return _desc.debug_get_stack_level_line(_data, p_level); - } - return 1; -} - -String PluginScriptLanguage::debug_get_stack_level_function(int p_level) const { - if (_desc.debug_get_stack_level_function) { - godot_string tmp = _desc.debug_get_stack_level_function(_data, p_level); - String ret = *(String *)&tmp; - godot_string_destroy(&tmp); - return ret; - } - return String("Nothing"); -} - -String PluginScriptLanguage::debug_get_stack_level_source(int p_level) const { - if (_desc.debug_get_stack_level_source) { - godot_string tmp = _desc.debug_get_stack_level_source(_data, p_level); - String ret = *(String *)&tmp; - godot_string_destroy(&tmp); - return ret; - } - return String("Nothing"); -} - -void PluginScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) { - if (_desc.debug_get_stack_level_locals) { - PackedStringArray locals; - Array values; - _desc.debug_get_stack_level_locals(_data, p_level, (godot_packed_string_array *)&locals, (godot_array *)&values, p_max_subitems, p_max_depth); - for (int i = 0; i < locals.size(); i++) { - p_locals->push_back(locals[i]); - } - for (int i = 0; i < values.size(); i++) { - p_values->push_back(values[i]); - } - } -} - -void PluginScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) { - if (_desc.debug_get_stack_level_members) { - PackedStringArray members; - Array values; - _desc.debug_get_stack_level_members(_data, p_level, (godot_packed_string_array *)&members, (godot_array *)&values, p_max_subitems, p_max_depth); - for (int i = 0; i < members.size(); i++) { - p_members->push_back(members[i]); - } - for (int i = 0; i < values.size(); i++) { - p_values->push_back(values[i]); - } - } -} - -void PluginScriptLanguage::debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) { - if (_desc.debug_get_globals) { - PackedStringArray locals; - Array values; - _desc.debug_get_globals(_data, (godot_packed_string_array *)&locals, (godot_array *)&values, p_max_subitems, p_max_depth); - for (int i = 0; i < locals.size(); i++) { - p_locals->push_back(locals[i]); - } - for (int i = 0; i < values.size(); i++) { - p_values->push_back(values[i]); - } - } -} - -String PluginScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) { - if (_desc.debug_parse_stack_level_expression) { - godot_string tmp = _desc.debug_parse_stack_level_expression(_data, p_level, (godot_string *)&p_expression, p_max_subitems, p_max_depth); - String ret = *(String *)&tmp; - godot_string_destroy(&tmp); - return ret; - } - return String("Nothing"); -} - -void PluginScriptLanguage::reload_all_scripts() { - // TODO -} - -void PluginScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) { -#ifdef DEBUG_ENABLED - lock(); - // TODO - unlock(); -#endif -} - -bool PluginScriptLanguage::handles_global_class_type(const String &p_type) const { - return p_type == "PluginScript"; -} - -String PluginScriptLanguage::get_global_class_name(const String &p_path, String *r_base_type, String *r_icon_path) const { - if (!p_path.is_empty()) { - Ref<PluginScript> script = ResourceLoader::load(p_path, "PluginScript"); - if (script.is_valid()) { - if (r_base_type) { - *r_base_type = script->get_instance_base_type(); - } - if (r_icon_path) { - *r_icon_path = script->get_script_class_icon_path(); - } - return script->get_script_class_name(); - } - if (r_base_type) { - *r_base_type = String(); - } - if (r_icon_path) { - *r_icon_path = String(); - } - } - return String(); -} - -void PluginScriptLanguage::lock() { - _lock.lock(); -} - -void PluginScriptLanguage::unlock() { - _lock.unlock(); -} - -PluginScriptLanguage::PluginScriptLanguage(const godot_pluginscript_language_desc *desc) : - _desc(*desc) { - _resource_loader = Ref<ResourceFormatLoaderPluginScript>(memnew(ResourceFormatLoaderPluginScript(this))); - _resource_saver = Ref<ResourceFormatSaverPluginScript>(memnew(ResourceFormatSaverPluginScript(this))); -} - -PluginScriptLanguage::~PluginScriptLanguage() { -} diff --git a/modules/gdnative/pluginscript/pluginscript_language.h b/modules/gdnative/pluginscript/pluginscript_language.h deleted file mode 100644 index 6039f807a8..0000000000 --- a/modules/gdnative/pluginscript/pluginscript_language.h +++ /dev/null @@ -1,138 +0,0 @@ -/*************************************************************************/ -/* pluginscript_language.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 PLUGINSCRIPT_LANGUAGE_H -#define PLUGINSCRIPT_LANGUAGE_H - -// Godot imports -#include "core/io/resource_loader.h" -#include "core/io/resource_saver.h" -#include "core/object/script_language.h" -#include "core/templates/map.h" -#include "core/templates/self_list.h" -// PluginScript imports -#include "pluginscript_loader.h" -#include <pluginscript/godot_pluginscript.h> - -class PluginScript; -class PluginScriptInstance; - -class PluginScriptLanguage : public ScriptLanguage { - friend class PluginScript; - friend class PluginScriptInstance; - - Ref<ResourceFormatLoaderPluginScript> _resource_loader; - Ref<ResourceFormatSaverPluginScript> _resource_saver; - const godot_pluginscript_language_desc _desc; - godot_pluginscript_language_data *_data; - - Mutex _lock; - SelfList<PluginScript>::List _script_list; - -public: - virtual String get_name() const; - - _FORCE_INLINE_ Ref<ResourceFormatLoaderPluginScript> get_resource_loader() { return _resource_loader; } - _FORCE_INLINE_ Ref<ResourceFormatSaverPluginScript> get_resource_saver() { return _resource_saver; } - - /* 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 bool is_control_flow_keyword(String p_keyword) 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, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::ScriptError> *r_errors = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const; - virtual Script *create_script() const; - virtual bool has_named_classes() const; - virtual bool supports_builtin_mode() const; - virtual bool can_inherit_from_file() 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 PackedStringArray &p_args) const; - virtual Error complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_force, String &r_call_hint); - 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 - // void thread_enter() {} - // 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; - - 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(); - - /* GLOBAL CLASSES */ - - virtual bool handles_global_class_type(const String &p_type) const; - virtual String get_global_class_name(const String &p_path, String *r_base_type = nullptr, String *r_icon_path = nullptr) const; - - void lock(); - void unlock(); - - PluginScriptLanguage(const godot_pluginscript_language_desc *desc); - virtual ~PluginScriptLanguage(); -}; - -#endif // PLUGINSCRIPT_LANGUAGE_H diff --git a/modules/gdnative/pluginscript/pluginscript_loader.cpp b/modules/gdnative/pluginscript/pluginscript_loader.cpp deleted file mode 100644 index a151d551dc..0000000000 --- a/modules/gdnative/pluginscript/pluginscript_loader.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/*************************************************************************/ -/* pluginscript_loader.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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. */ -/*************************************************************************/ - -// Godot imports -#include "core/io/file_access.h" -// Pythonscript imports -#include "pluginscript_language.h" -#include "pluginscript_loader.h" -#include "pluginscript_script.h" - -ResourceFormatLoaderPluginScript::ResourceFormatLoaderPluginScript(PluginScriptLanguage *language) { - _language = language; -} - -RES ResourceFormatLoaderPluginScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) { - if (r_error) { - *r_error = ERR_FILE_CANT_OPEN; - } - - PluginScript *script = memnew(PluginScript); - script->init(_language); - - Ref<PluginScript> scriptres(script); - - Error err = script->load_source_code(p_path); - ERR_FAIL_COND_V(err != OK, RES()); - - script->set_path(p_original_path); - - script->reload(); - - if (r_error) { - *r_error = OK; - } - - return scriptres; -} - -void ResourceFormatLoaderPluginScript::get_recognized_extensions(List<String> *p_extensions) const { - p_extensions->push_back(_language->get_extension()); -} - -bool ResourceFormatLoaderPluginScript::handles_type(const String &p_type) const { - return p_type == "Script" || p_type == _language->get_type(); -} - -String ResourceFormatLoaderPluginScript::get_resource_type(const String &p_path) const { - String el = p_path.get_extension().to_lower(); - if (el == _language->get_extension()) { - return _language->get_type(); - } - return ""; -} - -ResourceFormatSaverPluginScript::ResourceFormatSaverPluginScript(PluginScriptLanguage *language) { - _language = language; -} - -Error ResourceFormatSaverPluginScript::save(const String &p_path, const RES &p_resource, uint32_t p_flags) { - Ref<PluginScript> sqscr = p_resource; - ERR_FAIL_COND_V(sqscr.is_null(), ERR_INVALID_PARAMETER); - - String source = sqscr->get_source_code(); - - Error err; - FileAccess *file = FileAccess::open(p_path, FileAccess::WRITE, &err); - ERR_FAIL_COND_V(err, err); - - file->store_string(source); - if (file->get_error() != OK && file->get_error() != ERR_FILE_EOF) { - memdelete(file); - return ERR_CANT_CREATE; - } - file->close(); - memdelete(file); - return OK; -} - -void ResourceFormatSaverPluginScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const { - if (Object::cast_to<PluginScript>(*p_resource)) { - p_extensions->push_back(_language->get_extension()); - } -} - -bool ResourceFormatSaverPluginScript::recognize(const RES &p_resource) const { - return Object::cast_to<PluginScript>(*p_resource) != nullptr; -} diff --git a/modules/gdnative/pluginscript/pluginscript_loader.h b/modules/gdnative/pluginscript/pluginscript_loader.h deleted file mode 100644 index bcce742aea..0000000000 --- a/modules/gdnative/pluginscript/pluginscript_loader.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************/ -/* pluginscript_loader.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 PYTHONSCRIPT_PY_LOADER_H -#define PYTHONSCRIPT_PY_LOADER_H - -// Godot imports -#include "core/io/resource_loader.h" -#include "core/io/resource_saver.h" -#include "core/object/script_language.h" - -class PluginScriptLanguage; - -class ResourceFormatLoaderPluginScript : public ResourceFormatLoader { - PluginScriptLanguage *_language; - -public: - ResourceFormatLoaderPluginScript(PluginScriptLanguage *language); - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE); - 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; -}; - -class ResourceFormatSaverPluginScript : public ResourceFormatSaver { - PluginScriptLanguage *_language; - -public: - ResourceFormatSaverPluginScript(PluginScriptLanguage *language); - virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0); - virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const; - virtual bool recognize(const RES &p_resource) const; -}; - -#endif // PYTHONSCRIPT_PY_LOADER_H diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp deleted file mode 100644 index ec3c9eb4ff..0000000000 --- a/modules/gdnative/pluginscript/pluginscript_script.cpp +++ /dev/null @@ -1,510 +0,0 @@ -/*************************************************************************/ -/* pluginscript_script.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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. */ -/*************************************************************************/ - -// Godot imports -#include "core/io/file_access.h" -// PluginScript imports -#include "pluginscript_instance.h" -#include "pluginscript_script.h" - -#include <stdint.h> - -#ifdef DEBUG_ENABLED -#define __ASSERT_SCRIPT_REASON "Cannot retrieve PluginScript class for this script, is your code correct?" -#define ASSERT_SCRIPT_VALID() \ - { \ - ERR_FAIL_COND_MSG(!can_instantiate(), __ASSERT_SCRIPT_REASON); \ - } -#define ASSERT_SCRIPT_VALID_V(ret) \ - { \ - ERR_FAIL_COND_V_MSG(!can_instantiate(), ret, __ASSERT_SCRIPT_REASON); \ - } -#else -#define ASSERT_SCRIPT_VALID() -#define ASSERT_SCRIPT_VALID_V(ret) -#endif - -void PluginScript::_bind_methods() { - ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "new", &PluginScript::_new, MethodInfo("new")); -} - -PluginScriptInstance *PluginScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, Callable::CallError &r_error) { - r_error.error = Callable::CallError::CALL_OK; - - // Create instance - PluginScriptInstance *instance = memnew(PluginScriptInstance()); - - if (instance->init(this, p_owner)) { - _language->lock(); - _instances.insert(instance->get_owner()); - _language->unlock(); - } else { - r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; - memdelete(instance); - ERR_FAIL_V(nullptr); - } - - // Construct - // TODO: Support arguments in the constructor? - // There is currently no way to get the constructor function name of the script. - // instance->call("__init__", p_args, p_argcount, r_error); - if (p_argcount > 0) { - WARN_PRINT("PluginScript doesn't support arguments in the constructor"); - } - - return instance; -} - -Variant PluginScript::_new(const Variant **p_args, int p_argcount, Callable::CallError &r_error) { - r_error.error = Callable::CallError::CALL_OK; - - if (!_valid) { - r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; - return Variant(); - } - - REF ref; - Object *owner = nullptr; - - if (get_instance_base_type() == StringName()) { - owner = memnew(RefCounted); - } else { - owner = ClassDB::instantiate(get_instance_base_type()); - } - - if (!owner) { - r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; - return Variant(); - } - - RefCounted *r = Object::cast_to<RefCounted>(owner); - if (r) { - ref = REF(r); - } - - PluginScriptInstance *instance = _create_instance(p_args, p_argcount, owner, r_error); - - if (!instance) { - if (ref.is_null()) { - memdelete(owner); //no owner, sorry - } - return Variant(); - } - - if (ref.is_valid()) { - return ref; - } else { - return owner; - } -} - -#ifdef TOOLS_ENABLED - -void PluginScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) { - placeholders.erase(p_placeholder); -} - -#endif - -bool PluginScript::can_instantiate() const { - bool can = _valid || (!_tool && !ScriptServer::is_scripting_enabled()); - return can; -} - -bool PluginScript::inherits_script(const Ref<Script> &p_script) const { - Ref<PluginScript> ps = p_script; - if (ps.is_null()) { - return false; - } - - const PluginScript *s = this; - - while (s) { - if (s == p_script.ptr()) { - return true; - } - s = Object::cast_to<PluginScript>(s->_ref_base_parent.ptr()); - } - - return false; -} - -Ref<Script> PluginScript::get_base_script() const { - if (_ref_base_parent.is_valid()) { - return Ref<PluginScript>(_ref_base_parent); - } else { - return Ref<Script>(); - } -} - -StringName PluginScript::get_instance_base_type() const { - if (_native_parent) { - return _native_parent; - } - if (_ref_base_parent.is_valid()) { - return _ref_base_parent->get_instance_base_type(); - } - return StringName(); -} - -void PluginScript::update_exports() { -#ifdef TOOLS_ENABLED - ASSERT_SCRIPT_VALID(); - if (placeholders.size()) { - //update placeholders if any - Map<StringName, Variant> propdefvalues; - List<PropertyInfo> propinfos; - - get_script_property_list(&propinfos); - for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) { - E->get()->update(propinfos, _properties_default_values); - } - } -#endif -} - -// TODO: rename p_this "p_owner" ? -ScriptInstance *PluginScript::instance_create(Object *p_this) { - ASSERT_SCRIPT_VALID_V(nullptr); - // TODO check script validity ? - if (!_tool && !ScriptServer::is_scripting_enabled()) { -#ifdef TOOLS_ENABLED - // Instance a fake script for editing the values - PlaceHolderScriptInstance *si = memnew(PlaceHolderScriptInstance(get_language(), Ref<Script>(this), p_this)); - placeholders.insert(si); - update_exports(); - return si; -#else - return nullptr; -#endif - } - - StringName base_type = get_instance_base_type(); - if (base_type) { - if (!ClassDB::is_parent_class(p_this->get_class_name(), base_type)) { - String msg = "Script inherits from native type '" + String(base_type) + "', so it can't be instantiated in object of type: '" + p_this->get_class() + "'"; - // TODO: implement PluginscriptLanguage::debug_break_parse - // if (EngineDebugger::is_active()) { - // _language->debug_break_parse(get_path(), 0, msg); - // } - ERR_FAIL_V_MSG(nullptr, msg); - } - } - - Callable::CallError unchecked_error; - return _create_instance(nullptr, 0, p_this, unchecked_error); -} - -bool PluginScript::instance_has(const Object *p_this) const { - ERR_FAIL_COND_V(!_language, false); - - _language->lock(); - bool hasit = _instances.has((Object *)p_this); - _language->unlock(); - return hasit; -} - -bool PluginScript::has_source_code() const { - return !_source.is_empty(); -} - -String PluginScript::get_source_code() const { - return _source; -} - -void PluginScript::set_source_code(const String &p_code) { - if (_source == p_code) { - return; - } - _source = p_code; -} - -Error PluginScript::reload(bool p_keep_state) { - ERR_FAIL_COND_V(!_language, ERR_UNCONFIGURED); - - _language->lock(); - ERR_FAIL_COND_V(!p_keep_state && _instances.size(), ERR_ALREADY_IN_USE); - _language->unlock(); - - _valid = false; - String basedir = _path; - - if (basedir.is_empty()) { - basedir = get_path(); - } - - if (!basedir.is_empty()) { - basedir = basedir.get_base_dir(); - } - - if (_data) { - _desc->finish(_data); - } - - Error err; - godot_pluginscript_script_manifest manifest = _desc->init( - _language->_data, - (godot_string *)&_path, - (godot_string *)&_source, - (godot_error *)&err); -// Manifest's attributes must be explicitly freed -#define FREE_SCRIPT_MANIFEST(manifest) \ - { \ - godot_string_name_destroy(&manifest.name); \ - godot_string_name_destroy(&manifest.base); \ - godot_dictionary_destroy(&manifest.member_lines); \ - godot_array_destroy(&manifest.methods); \ - godot_array_destroy(&manifest.signals); \ - godot_array_destroy(&manifest.properties); \ - } - - if (err) { - FREE_SCRIPT_MANIFEST(manifest); - // TODO: GDscript uses `ScriptDebugger` here to jump into the parsing error - return err; - } - - // Script's parent is passed as base_name which can make reference to a - // ClassDB name (i.e. `Node2D`) or a resource path (i.e. `res://foo/bar.gd`) - StringName *base_name = (StringName *)&manifest.base; - if (*base_name) { - if (ClassDB::class_exists(*base_name)) { - _native_parent = *base_name; - } else { - Ref<Script> res = ResourceLoader::load(*base_name); - if (res.is_valid()) { - _ref_base_parent = res; - } else { - String name = *(StringName *)&manifest.name; - FREE_SCRIPT_MANIFEST(manifest); - ERR_FAIL_V_MSG(ERR_PARSE_ERROR, _path + ": Script '" + name + "' has an invalid parent '" + *base_name + "'."); - } - } - } - - _valid = true; - // Use the manifest to configure this script object - _data = manifest.data; - _name = *(StringName *)&manifest.name; - _tool = manifest.is_tool; - _icon_path = *(String *)&manifest.icon_path; - - Dictionary *members = (Dictionary *)&manifest.member_lines; - for (const Variant *key = members->next(); key != nullptr; key = members->next(key)) { - _member_lines[*key] = (*members)[*key]; - } - Array *methods = (Array *)&manifest.methods; - _rpc_methods.clear(); - if (_ref_base_parent.is_valid()) { - /// XXX TODO Should this be _rpc_methods.append_array(...) - _rpc_methods = _ref_base_parent->get_rpc_methods(); - } - for (int i = 0; i < methods->size(); ++i) { - Dictionary v = (*methods)[i]; - MethodInfo mi = MethodInfo::from_dict(v); - _methods_info[mi.name] = mi; - // rpc_mode is passed as an optional field and is not part of MethodInfo - Variant var = v["rpc_mode"]; - if (var != Variant()) { - Multiplayer::RPCConfig nd; - nd.name = mi.name; - nd.rpc_mode = Multiplayer::RPCMode(int(var)); - // TODO Transfer Channel - if (_rpc_methods.find(nd) == -1) { - _rpc_methods.push_back(nd); - } - } - } - - // Sort so we are 100% that they are always the same. - _rpc_methods.sort_custom<Multiplayer::SortRPCConfig>(); - - Array *signals = (Array *)&manifest.signals; - for (int i = 0; i < signals->size(); ++i) { - Variant v = (*signals)[i]; - MethodInfo mi = MethodInfo::from_dict(v); - _signals_info[mi.name] = mi; - } - Array *properties = (Array *)&manifest.properties; - for (int i = 0; i < properties->size(); ++i) { - Dictionary v = (*properties)[i]; - PropertyInfo pi = PropertyInfo::from_dict(v); - _properties_info[pi.name] = pi; - _properties_default_values[pi.name] = v["default_value"]; - } - - FREE_SCRIPT_MANIFEST(manifest); - return OK; -#undef FREE_SCRIPT_MANIFEST -} - -void PluginScript::get_script_method_list(List<MethodInfo> *r_methods) const { - ASSERT_SCRIPT_VALID(); - for (Map<StringName, MethodInfo>::Element *e = _methods_info.front(); e != nullptr; e = e->next()) { - r_methods->push_back(e->get()); - } -} - -void PluginScript::get_script_property_list(List<PropertyInfo> *r_properties) const { - ASSERT_SCRIPT_VALID(); - for (Map<StringName, PropertyInfo>::Element *e = _properties_info.front(); e != nullptr; e = e->next()) { - r_properties->push_back(e->get()); - } -} - -bool PluginScript::has_method(const StringName &p_method) const { - ASSERT_SCRIPT_VALID_V(false); - return _methods_info.has(p_method); -} - -MethodInfo PluginScript::get_method_info(const StringName &p_method) const { - ASSERT_SCRIPT_VALID_V(MethodInfo()); - const Map<StringName, MethodInfo>::Element *e = _methods_info.find(p_method); - if (e != nullptr) { - return e->get(); - } else { - return MethodInfo(); - } -} - -bool PluginScript::has_property(const StringName &p_method) const { - ASSERT_SCRIPT_VALID_V(false); - return _properties_info.has(p_method); -} - -PropertyInfo PluginScript::get_property_info(const StringName &p_property) const { - ASSERT_SCRIPT_VALID_V(PropertyInfo()); - const Map<StringName, PropertyInfo>::Element *e = _properties_info.find(p_property); - if (e != nullptr) { - return e->get(); - } else { - return PropertyInfo(); - } -} - -bool PluginScript::get_property_default_value(const StringName &p_property, Variant &r_value) const { - ASSERT_SCRIPT_VALID_V(false); -#ifdef TOOLS_ENABLED - const Map<StringName, Variant>::Element *e = _properties_default_values.find(p_property); - if (e != nullptr) { - r_value = e->get(); - return true; - } else { - return false; - } -#endif - return false; -} - -ScriptLanguage *PluginScript::get_language() const { - return _language; -} - -Error PluginScript::load_source_code(const String &p_path) { - Vector<uint8_t> sourcef; - Error err; - FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err); - ERR_FAIL_COND_V_MSG(err, err, "Cannot open file '" + p_path + "'."); - - uint64_t len = f->get_length(); - sourcef.resize(len + 1); - uint8_t *w = sourcef.ptrw(); - uint64_t r = f->get_buffer(w, len); - f->close(); - memdelete(f); - ERR_FAIL_COND_V(r != len, ERR_CANT_OPEN); - w[len] = 0; - - String s; - if (s.parse_utf8((const char *)w)) { - ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Script '" + p_path + "' contains invalid unicode (UTF-8), so it was not loaded. Please ensure that scripts are saved in valid UTF-8 unicode."); - } - - _source = s; -#ifdef TOOLS_ENABLED -// source_changed_cache=true; -#endif - _path = p_path; - return OK; -} - -bool PluginScript::has_script_signal(const StringName &p_signal) const { - ASSERT_SCRIPT_VALID_V(false); - return _signals_info.has(p_signal); -} - -void PluginScript::get_script_signal_list(List<MethodInfo> *r_signals) const { - ASSERT_SCRIPT_VALID(); - for (Map<StringName, MethodInfo>::Element *e = _signals_info.front(); e != nullptr; e = e->next()) { - r_signals->push_back(e->get()); - } -} - -int PluginScript::get_member_line(const StringName &p_member) const { -#ifdef TOOLS_ENABLED - if (_member_lines.has(p_member)) { - return _member_lines[p_member]; - } -#endif - return -1; -} - -const Vector<Multiplayer::RPCConfig> PluginScript::get_rpc_methods() const { - return _rpc_methods; -} - -PluginScript::PluginScript() : - _script_list(this) { -} - -void PluginScript::init(PluginScriptLanguage *language) { - _desc = &language->_desc.script_desc; - _language = language; - -#ifdef DEBUG_ENABLED - _language->lock(); - _language->_script_list.add(&_script_list); - _language->unlock(); -#endif -} - -PluginScript::~PluginScript() { - if (_desc && _data) { - _desc->finish(_data); - } - -#ifdef DEBUG_ENABLED - if (_language) { - _language->lock(); - _language->_script_list.remove(&_script_list); - _language->unlock(); - } -#endif -} diff --git a/modules/gdnative/pluginscript/pluginscript_script.h b/modules/gdnative/pluginscript/pluginscript_script.h deleted file mode 100644 index 73c486f6d9..0000000000 --- a/modules/gdnative/pluginscript/pluginscript_script.h +++ /dev/null @@ -1,146 +0,0 @@ -/*************************************************************************/ -/* pluginscript_script.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 PLUGINSCRIPT_SCRIPT_H -#define PLUGINSCRIPT_SCRIPT_H - -// Godot imports - -#include "core/doc_data.h" -#include "core/object/script_language.h" -// PluginScript imports -#include "pluginscript_language.h" -#include <pluginscript/godot_pluginscript.h> - -class PluginScript : public Script { - GDCLASS(PluginScript, Script); - - friend class PluginScriptInstance; - friend class PluginScriptLanguage; - -private: - godot_pluginscript_script_data *_data = nullptr; - const godot_pluginscript_script_desc *_desc = nullptr; - PluginScriptLanguage *_language = nullptr; - bool _tool = false; - bool _valid = false; - - Ref<Script> _ref_base_parent; - StringName _native_parent; - SelfList<PluginScript> _script_list; - - Map<StringName, int> _member_lines; - Map<StringName, Variant> _properties_default_values; - Map<StringName, PropertyInfo> _properties_info; - Map<StringName, MethodInfo> _signals_info; - Map<StringName, MethodInfo> _methods_info; - Vector<Multiplayer::RPCConfig> _rpc_methods; - - Set<Object *> _instances; - //exported members - String _source; - String _path; - StringName _name; - String _icon_path; - -protected: - static void _bind_methods(); - - bool inherits_script(const Ref<Script> &p_script) const override; - - PluginScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, Callable::CallError &r_error); - Variant _new(const Variant **p_args, int p_argcount, Callable::CallError &r_error); - -#ifdef TOOLS_ENABLED - Set<PlaceHolderScriptInstance *> placeholders; - //void _update_placeholder(PlaceHolderScriptInstance *p_placeholder); - virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder) override; -#endif -public: - String get_script_class_name() const { - return _name; - } - - String get_script_class_icon_path() const { - return _icon_path; - } - - virtual bool can_instantiate() const override; - - virtual Ref<Script> get_base_script() const override; //for script inheritance - - virtual StringName get_instance_base_type() const override; // this may not work in all scripts, will return empty if so - virtual ScriptInstance *instance_create(Object *p_this) override; - virtual bool instance_has(const Object *p_this) const override; - - virtual bool has_source_code() const override; - virtual String get_source_code() const override; - virtual void set_source_code(const String &p_code) override; - virtual Error reload(bool p_keep_state = false) override; - // TODO: load_source_code only allow utf-8 file, should handle bytecode as well ? - virtual Error load_source_code(const String &p_path); - -#ifdef TOOLS_ENABLED - virtual const Vector<DocData::ClassDoc> &get_documentation() const override { - static Vector<DocData::ClassDoc> docs; - return docs; - } -#endif // TOOLS_ENABLED - - virtual bool has_method(const StringName &p_method) const override; - virtual MethodInfo get_method_info(const StringName &p_method) const override; - - bool has_property(const StringName &p_method) const; - PropertyInfo get_property_info(const StringName &p_property) const; - - bool is_tool() const override { return _tool; } - bool is_valid() const override { return true; } - - virtual ScriptLanguage *get_language() const override; - - virtual bool has_script_signal(const StringName &p_signal) const override; - virtual void get_script_signal_list(List<MethodInfo> *r_signals) const override; - - virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const override; - - virtual void update_exports() override; - virtual void get_script_method_list(List<MethodInfo> *r_methods) const override; - virtual void get_script_property_list(List<PropertyInfo> *r_properties) const override; - - virtual int get_member_line(const StringName &p_member) const override; - - virtual const Vector<Multiplayer::RPCConfig> get_rpc_methods() const override; - - PluginScript(); - void init(PluginScriptLanguage *language); - virtual ~PluginScript(); -}; - -#endif // PLUGINSCRIPT_SCRIPT_H diff --git a/modules/gdnative/pluginscript/register_types.cpp b/modules/gdnative/pluginscript/register_types.cpp deleted file mode 100644 index 39c8124c17..0000000000 --- a/modules/gdnative/pluginscript/register_types.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/*************************************************************************/ -/* register_types.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 "register_types.h" - -#include "core/config/project_settings.h" -#include "core/io/dir_access.h" -#include "core/io/resource_loader.h" -#include "core/io/resource_saver.h" -#include "core/os/os.h" -#include "scene/main/scene_tree.h" - -#include "pluginscript_language.h" -#include "pluginscript_script.h" -#include <pluginscript/godot_pluginscript.h> - -static List<PluginScriptLanguage *> pluginscript_languages; - -static Error _check_language_desc(const godot_pluginscript_language_desc *desc) { - ERR_FAIL_COND_V(!desc->name, ERR_BUG); - ERR_FAIL_COND_V(!desc->type, ERR_BUG); - ERR_FAIL_COND_V(!desc->extension, ERR_BUG); - ERR_FAIL_COND_V(!desc->recognized_extensions || !desc->recognized_extensions[0], ERR_BUG); - ERR_FAIL_COND_V(!desc->init, ERR_BUG); - ERR_FAIL_COND_V(!desc->finish, ERR_BUG); - - // desc->reserved_words is not mandatory - // desc->comment_delimiters is not mandatory - // desc->string_delimiters is not mandatory - - // desc->get_template_source_code is not mandatory - // desc->validate is not mandatory - - // desc->get_template_source_code is not mandatory - // desc->validate is not mandatory - // desc->find_function is not mandatory - // desc->make_function is not mandatory - // desc->complete_code is not mandatory - // desc->auto_indent_code is not mandatory - ERR_FAIL_COND_V(!desc->add_global_constant, ERR_BUG); - // desc->debug_get_error is not mandatory - // desc->debug_get_stack_level_count is not mandatory - // desc->debug_get_stack_level_line is not mandatory - // desc->debug_get_stack_level_function is not mandatory - // desc->debug_get_stack_level_source is not mandatory - // desc->debug_get_stack_level_locals is not mandatory - // desc->debug_get_stack_level_members is not mandatory - // desc->debug_get_globals is not mandatory - // desc->debug_parse_stack_level_expression is not mandatory - // desc->profiling_start is not mandatory - // desc->profiling_stop is not mandatory - // desc->profiling_get_accumulated_data is not mandatory - // desc->profiling_get_frame_data is not mandatory - // desc->profiling_frame is not mandatory - - ERR_FAIL_COND_V(!desc->script_desc.init, ERR_BUG); - ERR_FAIL_COND_V(!desc->script_desc.finish, ERR_BUG); - - ERR_FAIL_COND_V(!desc->script_desc.instance_desc.init, ERR_BUG); - ERR_FAIL_COND_V(!desc->script_desc.instance_desc.finish, ERR_BUG); - ERR_FAIL_COND_V(!desc->script_desc.instance_desc.set_prop, ERR_BUG); - ERR_FAIL_COND_V(!desc->script_desc.instance_desc.get_prop, ERR_BUG); - ERR_FAIL_COND_V(!desc->script_desc.instance_desc.call_method, ERR_BUG); - ERR_FAIL_COND_V(!desc->script_desc.instance_desc.notification, ERR_BUG); - // desc->script_desc.instance_desc.refcount_incremented is not mandatory - // desc->script_desc.instance_desc.refcount_decremented is not mandatory - return OK; -} - -void GDAPI godot_pluginscript_register_language(const godot_pluginscript_language_desc *language_desc) { - Error ret = _check_language_desc(language_desc); - if (ret) { - ERR_FAIL(); - } - PluginScriptLanguage *language = memnew(PluginScriptLanguage(language_desc)); - ScriptServer::register_language(language); - ResourceLoader::add_resource_format_loader(language->get_resource_loader()); - ResourceSaver::add_resource_format_saver(language->get_resource_saver()); - pluginscript_languages.push_back(language); -} - -void register_pluginscript_types() { - GDREGISTER_CLASS(PluginScript); -} - -void unregister_pluginscript_types() { - for (List<PluginScriptLanguage *>::Element *e = pluginscript_languages.front(); e; e = e->next()) { - PluginScriptLanguage *language = e->get(); - ScriptServer::unregister_language(language); - ResourceLoader::remove_resource_format_loader(language->get_resource_loader()); - ResourceSaver::remove_resource_format_saver(language->get_resource_saver()); - memdelete(language); - } -} diff --git a/modules/gdnative/pluginscript/register_types.h b/modules/gdnative/pluginscript/register_types.h deleted file mode 100644 index 49e7357a98..0000000000 --- a/modules/gdnative/pluginscript/register_types.h +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************/ -/* register_types.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 PLUGINSCRIPT_REGISTER_TYPES_H -#define PLUGINSCRIPT_REGISTER_TYPES_H - -void register_pluginscript_types(); -void unregister_pluginscript_types(); - -#endif // PLUGINSCRIPT_REGISTER_TYPES_H diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp deleted file mode 100644 index 1121fd0e03..0000000000 --- a/modules/gdnative/register_types.cpp +++ /dev/null @@ -1,360 +0,0 @@ -/*************************************************************************/ -/* register_types.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 "register_types.h" - -#include "gdnative/gdnative.h" - -#include "gdnative.h" - -#include "nativescript/register_types.h" -#include "pluginscript/register_types.h" -#include "videodecoder/register_types.h" - -#include "core/config/engine.h" -#include "core/config/project_settings.h" -#include "core/io/resource_loader.h" -#include "core/io/resource_saver.h" -#include "core/os/os.h" - -#ifdef TOOLS_ENABLED -#include "editor/editor_export.h" -#include "editor/editor_node.h" -#include "gdnative_library_editor_plugin.h" -#include "gdnative_library_singleton_editor.h" - -class GDNativeExportPlugin : public EditorExportPlugin { -protected: - virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features); -}; - -struct LibrarySymbol { - const char *name; - bool is_required; -}; - -void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_type, const Set<String> &p_features) { - if (p_type != "GDNativeLibrary") { - return; - } - - Ref<GDNativeLibrary> lib = ResourceLoader::load(p_path); - - if (lib.is_null()) { - return; - } - - Ref<ConfigFile> config = lib->get_config_file(); - - { - List<String> entry_keys; - config->get_section_keys("entry", &entry_keys); - - for (const String &key : entry_keys) { - Vector<String> tags = key.split("."); - - bool skip = false; - for (int i = 0; i < tags.size(); i++) { - bool has_feature = p_features.has(tags[i]); - - if (!has_feature) { - skip = true; - break; - } - } - - if (skip) { - continue; - } - - String entry_lib_path = config->get_value("entry", key); - if (!entry_lib_path.begins_with("res://")) { - print_line("Skipping export of out-of-project library " + entry_lib_path); - continue; - } - - add_shared_object(entry_lib_path, tags); - } - } - - { - List<String> dependency_keys; - config->get_section_keys("dependencies", &dependency_keys); - - for (const String &key : dependency_keys) { - Vector<String> tags = key.split("."); - - bool skip = false; - for (int i = 0; i < tags.size(); i++) { - bool has_feature = p_features.has(tags[i]); - - if (!has_feature) { - skip = true; - break; - } - } - - if (skip) { - continue; - } - - Vector<String> dependency_paths = config->get_value("dependencies", key); - for (int i = 0; i < dependency_paths.size(); i++) { - if (!dependency_paths[i].begins_with("res://")) { - print_line("Skipping export of out-of-project library " + dependency_paths[i]); - continue; - } - add_shared_object(dependency_paths[i], tags); - } - } - } - - // Add symbols for statically linked libraries on iOS - if (p_features.has("iOS")) { - bool should_fake_dynamic = false; - - List<String> entry_keys; - config->get_section_keys("entry", &entry_keys); - - for (const String &key : entry_keys) { - Vector<String> tags = key.split("."); - - bool skip = false; - for (int i = 0; i < tags.size(); i++) { - bool has_feature = p_features.has(tags[i]); - - if (!has_feature) { - skip = true; - break; - } - } - - if (skip) { - continue; - } - - String entry_lib_path = config->get_value("entry", key); - if (entry_lib_path.begins_with("res://") && entry_lib_path.ends_with(".a")) { - // If we find static library that was used for export - // we should add a fake lookup table. - // In case of dynamic library being used, - // this symbols will not cause any issues with library loading. - should_fake_dynamic = true; - break; - } - } - - if (should_fake_dynamic) { - // Register symbols in the "fake" dynamic lookup table, because dlsym does not work well on iOS. - LibrarySymbol expected_symbols[] = { - { "gdnative_init", true }, - { "gdnative_terminate", false }, - { "nativescript_init", false }, - { "nativescript_frame", false }, - { "nativescript_thread_enter", false }, - { "nativescript_thread_exit", false }, - { "gdnative_singleton", false } - }; - String declare_pattern = "extern \"C\" void $name(void)$weak;\n"; - String additional_code = "extern void register_dynamic_symbol(char *name, void *address);\n" - "extern void add_ios_init_callback(void (*cb)());\n"; - String linker_flags = ""; - for (unsigned long i = 0; i < sizeof(expected_symbols) / sizeof(expected_symbols[0]); ++i) { - String full_name = lib->get_symbol_prefix() + expected_symbols[i].name; - String code = declare_pattern.replace("$name", full_name); - code = code.replace("$weak", expected_symbols[i].is_required ? "" : " __attribute__((weak))"); - additional_code += code; - - if (!expected_symbols[i].is_required) { - if (linker_flags.length() > 0) { - linker_flags += " "; - } - linker_flags += "-Wl,-U,_" + full_name; - } - } - - additional_code += String("void $prefixinit() {\n").replace("$prefix", lib->get_symbol_prefix()); - String register_pattern = " if (&$name) register_dynamic_symbol((char *)\"$name\", (void *)$name);\n"; - for (unsigned long i = 0; i < sizeof(expected_symbols) / sizeof(expected_symbols[0]); ++i) { - String full_name = lib->get_symbol_prefix() + expected_symbols[i].name; - additional_code += register_pattern.replace("$name", full_name); - } - additional_code += "}\n"; - additional_code += String("struct $prefixstruct {$prefixstruct() {add_ios_init_callback($prefixinit);}};\n").replace("$prefix", lib->get_symbol_prefix()); - additional_code += String("$prefixstruct $prefixstruct_instance;\n").replace("$prefix", lib->get_symbol_prefix()); - - add_ios_cpp_code(additional_code); - add_ios_linker_flags(linker_flags); - } - } -} - -static void editor_init_callback() { - GDNativeLibrarySingletonEditor *library_editor = memnew(GDNativeLibrarySingletonEditor); - library_editor->set_name(TTR("GDNative")); - ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(library_editor); - - Ref<GDNativeExportPlugin> export_plugin; - export_plugin.instantiate(); - - EditorExport::get_singleton()->add_export_plugin(export_plugin); - - EditorNode::get_singleton()->add_editor_plugin(memnew(GDNativeLibraryEditorPlugin)); -} - -#endif - -static godot_variant cb_standard_varcall(void *p_procedure_handle, godot_array *p_args) { - godot_gdnative_procedure_fn proc; - proc = (godot_gdnative_procedure_fn)p_procedure_handle; - - return proc(p_args); -} - -GDNativeCallRegistry *GDNativeCallRegistry::singleton; - -Vector<Ref<GDNative>> singleton_gdnatives; - -Ref<GDNativeLibraryResourceLoader> resource_loader_gdnlib; -Ref<GDNativeLibraryResourceSaver> resource_saver_gdnlib; - -void register_gdnative_types() { -#ifdef TOOLS_ENABLED - - EditorNode::add_init_callback(editor_init_callback); -#endif - - GDREGISTER_CLASS(GDNativeLibrary); - GDREGISTER_CLASS(GDNative); - - resource_loader_gdnlib.instantiate(); - ResourceLoader::add_resource_format_loader(resource_loader_gdnlib); - - resource_saver_gdnlib.instantiate(); - ResourceSaver::add_resource_format_saver(resource_saver_gdnlib); - - GDNativeCallRegistry::singleton = memnew(GDNativeCallRegistry); - - GDNativeCallRegistry::singleton->register_native_call_type("standard_varcall", cb_standard_varcall); - - register_nativescript_types(); - register_pluginscript_types(); - register_videodecoder_types(); - - // run singletons - - Array singletons = Array(); - if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons")) { - singletons = ProjectSettings::get_singleton()->get("gdnative/singletons"); - } - Array excluded = Array(); - if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons_disabled")) { - excluded = ProjectSettings::get_singleton()->get("gdnative/singletons_disabled"); - } - - for (int i = 0; i < singletons.size(); i++) { - String path = singletons[i]; - - if (excluded.has(path)) { - continue; - } - - Ref<GDNativeLibrary> lib = ResourceLoader::load(path); - Ref<GDNative> singleton; - singleton.instantiate(); - singleton->set_library(lib); - - if (!singleton->initialize()) { - // Can't initialize. Don't make a native_call then - continue; - } - - void *proc_ptr; - Error err = singleton->get_symbol( - lib->get_symbol_prefix() + "gdnative_singleton", - proc_ptr); - - if (err != OK) { - ERR_PRINT("No " + lib->get_symbol_prefix() + "gdnative_singleton in \"" + singleton->get_library()->get_current_library_path() + "\" found"); - } else { - singleton_gdnatives.push_back(singleton); - ((void (*)())proc_ptr)(); - } - } -} - -void unregister_gdnative_types() { - for (int i = 0; i < singleton_gdnatives.size(); i++) { - if (singleton_gdnatives[i].is_null()) { - continue; - } - - if (!singleton_gdnatives[i]->is_initialized()) { - continue; - } - - singleton_gdnatives.write[i]->terminate(); - } - singleton_gdnatives.clear(); - - unregister_videodecoder_types(); - unregister_pluginscript_types(); - unregister_nativescript_types(); - - memdelete(GDNativeCallRegistry::singleton); - - ResourceLoader::remove_resource_format_loader(resource_loader_gdnlib); - resource_loader_gdnlib.unref(); - - ResourceSaver::remove_resource_format_saver(resource_saver_gdnlib); - resource_saver_gdnlib.unref(); - - // This is for printing out the sizes of the core types - - /* - print_line(String("array:\t") + itos(sizeof(Array))); - print_line(String("basis:\t") + itos(sizeof(Basis))); - print_line(String("color:\t") + itos(sizeof(Color))); - print_line(String("dict:\t" ) + itos(sizeof(Dictionary))); - print_line(String("node_path:\t") + itos(sizeof(NodePath))); - print_line(String("plane:\t") + itos(sizeof(Plane))); - print_line(String("poolarray:\t") + itos(sizeof(PackedByteArray))); - print_line(String("quat:\t") + itos(sizeof(Quat))); - print_line(String("rect2:\t") + itos(sizeof(Rect2))); - print_line(String("aabb:\t") + itos(sizeof(AABB))); - print_line(String("rid:\t") + itos(sizeof(RID))); - print_line(String("string:\t") + itos(sizeof(String))); - print_line(String("transform:\t") + itos(sizeof(Transform3D))); - print_line(String("transfo2D:\t") + itos(sizeof(Transform2D))); - print_line(String("variant:\t") + itos(sizeof(Variant))); - print_line(String("vector2:\t") + itos(sizeof(Vector2))); - print_line(String("vector3:\t") + itos(sizeof(Vector3))); - */ -} diff --git a/modules/gdnative/register_types.h b/modules/gdnative/register_types.h deleted file mode 100644 index 0e1cb46a55..0000000000 --- a/modules/gdnative/register_types.h +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************/ -/* register_types.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 GDNATIVE_REGISTER_TYPES_H -#define GDNATIVE_REGISTER_TYPES_H - -void register_gdnative_types(); -void unregister_gdnative_types(); - -#endif // GDNATIVE_REGISTER_TYPES_H diff --git a/modules/gdnative/tests/test_variant.h b/modules/gdnative/tests/test_variant.h deleted file mode 100644 index fb6537cf42..0000000000 --- a/modules/gdnative/tests/test_variant.h +++ /dev/null @@ -1,205 +0,0 @@ -/*************************************************************************/ -/* test_variant.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 TEST_GDNATIVE_VARIANT_H -#define TEST_GDNATIVE_VARIANT_H - -#include <gdnative/gdnative.h> -#include <gdnative/variant.h> - -#include "tests/test_macros.h" - -namespace TestGDNativeVariant { - -TEST_CASE("[GDNative Variant] New Variant with copy") { - godot_variant src; - godot_variant_new_int(&src, 42); - - godot_variant copy; - godot_variant_new_copy(©, &src); - - CHECK(godot_variant_as_int(©) == 42); - CHECK(godot_variant_get_type(©) == GODOT_VARIANT_TYPE_INT); - - godot_variant_destroy(&src); - godot_variant_destroy(©); -} - -TEST_CASE("[GDNative Variant] New Variant with Nil") { - godot_variant val; - godot_variant_new_nil(&val); - - CHECK(godot_variant_get_type(&val) == GODOT_VARIANT_TYPE_NIL); - - godot_variant_destroy(&val); -} - -TEST_CASE("[GDNative Variant] New Variant with bool") { - godot_variant val; - godot_variant_new_bool(&val, true); - - CHECK(godot_variant_as_bool(&val)); - CHECK(godot_variant_get_type(&val) == GODOT_VARIANT_TYPE_BOOL); - - godot_variant_destroy(&val); -} - -TEST_CASE("[GDNative Variant] New Variant with float") { - godot_variant val; - godot_variant_new_float(&val, 4.2); - - CHECK(godot_variant_as_float(&val) == 4.2); - CHECK(godot_variant_get_type(&val) == GODOT_VARIANT_TYPE_FLOAT); - - godot_variant_destroy(&val); -} - -TEST_CASE("[GDNative Variant] New Variant with String") { - String str = "something"; - - godot_variant val; - godot_variant_new_string(&val, (godot_string *)&str); - godot_string gd_str = godot_variant_as_string(&val); - String *result = (String *)&gd_str; - - CHECK(*result == String("something")); - CHECK(godot_variant_get_type(&val) == GODOT_VARIANT_TYPE_STRING); - - godot_variant_destroy(&val); - godot_string_destroy(&gd_str); -} - -TEST_CASE("[GDNative Variant] Variant call") { - String str("something"); - godot_variant self; - godot_variant_new_string(&self, (godot_string *)&str); - - godot_variant ret; - - godot_string_name method; - godot_string_name_new_with_latin1_chars(&method, "is_valid_identifier"); - - godot_variant_call_error error; - godot_variant_call(&self, &method, nullptr, 0, &ret, &error); - - CHECK(godot_variant_get_type(&ret) == GODOT_VARIANT_TYPE_BOOL); - CHECK(godot_variant_as_bool(&ret)); - - godot_variant_destroy(&ret); - godot_variant_destroy(&self); - godot_string_name_destroy(&method); -} - -TEST_CASE("[GDNative Variant] Variant evaluate") { - godot_variant one; - godot_variant_new_int(&one, 1); - godot_variant two; - godot_variant_new_int(&two, 2); - - godot_variant three; - godot_variant_new_nil(&three); - bool valid = false; - - godot_variant_evaluate(GODOT_VARIANT_OP_ADD, &one, &two, &three, &valid); - - CHECK(godot_variant_get_type(&three) == GODOT_VARIANT_TYPE_INT); - CHECK(godot_variant_as_int(&three) == 3); - CHECK(valid); - - godot_variant_destroy(&one); - godot_variant_destroy(&two); - godot_variant_destroy(&three); -} - -TEST_CASE("[GDNative Variant] Variant set/get named") { - godot_string_name x; - godot_string_name_new_with_latin1_chars(&x, "x"); - - Vector2 vec(0, 0); - godot_variant self; - godot_variant_new_vector2(&self, (godot_vector2 *)&vec); - - godot_variant set; - godot_variant_new_float(&set, 1.0); - - bool set_valid = false; - godot_variant_set_named(&self, &x, &set, &set_valid); - - bool get_valid = false; - godot_variant get = godot_variant_get_named(&self, &x, &get_valid); - - CHECK(get_valid); - CHECK(set_valid); - CHECK(godot_variant_get_type(&get) == GODOT_VARIANT_TYPE_FLOAT); - CHECK(godot_variant_as_float(&get) == 1.0); - - godot_string_name_destroy(&x); - godot_variant_destroy(&self); - godot_variant_destroy(&set); - godot_variant_destroy(&get); -} - -TEST_CASE("[GDNative Variant] Get utility function argument name") { - godot_string_name function; - godot_string_name_new_with_latin1_chars(&function, "pow"); - - godot_string arg_name = godot_variant_get_utility_function_argument_name(&function, 0); - - String *arg_name_str = (String *)&arg_name; - - CHECK(*arg_name_str == "base"); - - godot_string_destroy(&arg_name); - godot_string_name_destroy(&function); -} - -TEST_CASE("[GDNative Variant] Get utility function list") { - int count = godot_variant_get_utility_function_count(); - - godot_string_name *c_list = (godot_string_name *)godot_alloc(count * sizeof(godot_string_name)); - godot_variant_get_utility_function_list(c_list); - - List<StringName> cpp_list; - Variant::get_utility_function_list(&cpp_list); - - godot_string_name *cur = c_list; - - for (const StringName &E : cpp_list) { - const StringName &cpp_name = E; - StringName *c_name = (StringName *)cur++; - - CHECK(*c_name == cpp_name); - } - - godot_free(c_list); -} -} // namespace TestGDNativeVariant - -#endif // TEST_GDNATIVE_VARIANT_H diff --git a/modules/gdnative/videodecoder/SCsub b/modules/gdnative/videodecoder/SCsub deleted file mode 100644 index 5948b9a3dd..0000000000 --- a/modules/gdnative/videodecoder/SCsub +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python - -Import("env") -Import("env_modules") - -env_vsdecoder_gdnative = env_modules.Clone() - -env_vsdecoder_gdnative.Prepend(CPPPATH=["#modules/gdnative/include/"]) -env_vsdecoder_gdnative.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/gdnative/videodecoder/register_types.cpp b/modules/gdnative/videodecoder/register_types.cpp deleted file mode 100644 index b28ff99bb8..0000000000 --- a/modules/gdnative/videodecoder/register_types.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************/ -/* register_types.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 "register_types.h" - -#include "core/object/class_db.h" -#include "video_stream_gdnative.h" - -static Ref<ResourceFormatLoaderVideoStreamGDNative> resource_loader_vsgdnative; - -void register_videodecoder_types() { - resource_loader_vsgdnative.instantiate(); - ResourceLoader::add_resource_format_loader(resource_loader_vsgdnative, true); - - GDREGISTER_CLASS(VideoStreamGDNative); -} - -void unregister_videodecoder_types() { - ResourceLoader::remove_resource_format_loader(resource_loader_vsgdnative); - resource_loader_vsgdnative.unref(); -} diff --git a/modules/gdnative/videodecoder/register_types.h b/modules/gdnative/videodecoder/register_types.h deleted file mode 100644 index b261c36503..0000000000 --- a/modules/gdnative/videodecoder/register_types.h +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************/ -/* register_types.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 VIDEODECODER_REGISTER_TYPES_H -#define VIDEODECODER_REGISTER_TYPES_H - -void register_videodecoder_types(); -void unregister_videodecoder_types(); - -#endif // VIDEODECODER_REGISTER_TYPES_H diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.cpp b/modules/gdnative/videodecoder/video_stream_gdnative.cpp deleted file mode 100644 index d3d295c494..0000000000 --- a/modules/gdnative/videodecoder/video_stream_gdnative.cpp +++ /dev/null @@ -1,389 +0,0 @@ -/*************************************************************************/ -/* video_stream_gdnative.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 "video_stream_gdnative.h" - -#include "core/config/project_settings.h" -#include "servers/audio_server.h" - -VideoDecoderServer *VideoDecoderServer::instance = nullptr; - -static VideoDecoderServer decoder_server; - -const int AUX_BUFFER_SIZE = 1024; // Buffer 1024 samples. - -// NOTE: Callbacks for the GDNative libraries. -extern "C" { -godot_int GDAPI godot_videodecoder_file_read(void *ptr, uint8_t *buf, int buf_size) { - // ptr is a FileAccess - FileAccess *file = reinterpret_cast<FileAccess *>(ptr); - - // if file exists - if (file) { - int64_t bytes_read = file->get_buffer(buf, buf_size); - return bytes_read; - } - return -1; -} - -int64_t GDAPI godot_videodecoder_file_seek(void *ptr, int64_t pos, int whence) { - // file - FileAccess *file = reinterpret_cast<FileAccess *>(ptr); - - if (file) { - int64_t len = file->get_length(); - switch (whence) { - case SEEK_SET: { - if (pos > len) { - return -1; - } - file->seek(pos); - return file->get_position(); - } break; - case SEEK_CUR: { - // Just in case it doesn't exist - if (pos < 0 && -pos > (int64_t)file->get_position()) { - return -1; - } - file->seek(file->get_position() + pos); - return file->get_position(); - } break; - case SEEK_END: { - // Just in case something goes wrong - if (-pos > len) { - return -1; - } - file->seek_end(pos); - return file->get_position(); - } break; - default: { - // Only 4 possible options, hence default = AVSEEK_SIZE - // Asks to return the length of file - return len; - } break; - } - } - // In case nothing works out. - return -1; -} - -void GDAPI godot_videodecoder_register_decoder(const godot_videodecoder_interface_gdnative *p_interface) { - decoder_server.register_decoder_interface(p_interface); -} -} - -// VideoStreamPlaybackGDNative starts here. - -bool VideoStreamPlaybackGDNative::open_file(const String &p_file) { - ERR_FAIL_COND_V(interface == nullptr, false); - file = FileAccess::open(p_file, FileAccess::READ); - bool file_opened = interface->open_file(data_struct, file); - - if (file_opened) { - num_channels = interface->get_channels(data_struct); - mix_rate = interface->get_mix_rate(data_struct); - - godot_vector2 vec = interface->get_texture_size(data_struct); - texture_size = *(Vector2 *)&vec; - // Only do memset if num_channels > 0 otherwise it will crash. - if (num_channels > 0) { - pcm = (float *)memalloc(num_channels * AUX_BUFFER_SIZE * sizeof(float)); - memset(pcm, 0, num_channels * AUX_BUFFER_SIZE * sizeof(float)); - } - - pcm_write_idx = -1; - samples_decoded = 0; - - Ref<Image> img; - img.instantiate(); - img->create((int)texture_size.width, false, (int)texture_size.height, Image::FORMAT_RGBA8); - - texture->create_from_image(img); - } - - return file_opened; -} - -void VideoStreamPlaybackGDNative::update(float p_delta) { - if (!playing || paused) { - return; - } - if (!file) { - return; - } - time += p_delta; - ERR_FAIL_COND(interface == nullptr); - interface->update(data_struct, p_delta); - - // Don't mix if there's no audio (num_channels == 0). - if (mix_callback && num_channels > 0) { - if (pcm_write_idx >= 0) { - // Previous remains - int mixed = mix_callback(mix_udata, pcm + pcm_write_idx * num_channels, samples_decoded); - if (mixed == samples_decoded) { - pcm_write_idx = -1; - } else { - samples_decoded -= mixed; - pcm_write_idx += mixed; - } - } - if (pcm_write_idx < 0) { - samples_decoded = interface->get_audioframe(data_struct, pcm, AUX_BUFFER_SIZE); - pcm_write_idx = mix_callback(mix_udata, pcm, samples_decoded); - if (pcm_write_idx == samples_decoded) { - pcm_write_idx = -1; - } else { - samples_decoded -= pcm_write_idx; - } - } - } - - if (seek_backward) { - update_texture(); - seek_backward = false; - } - - while (interface->get_playback_position(data_struct) < time && playing) { - update_texture(); - } -} - -void VideoStreamPlaybackGDNative::update_texture() { - PackedByteArray *pba = (PackedByteArray *)interface->get_videoframe(data_struct); - - if (pba == nullptr) { - playing = false; - return; - } - - Ref<Image> img = memnew(Image(texture_size.width, texture_size.height, 0, Image::FORMAT_RGBA8, *pba)); - - texture->update(img); -} - -// ctor and dtor - -VideoStreamPlaybackGDNative::VideoStreamPlaybackGDNative() : - texture(Ref<ImageTexture>(memnew(ImageTexture))) {} - -VideoStreamPlaybackGDNative::~VideoStreamPlaybackGDNative() { - cleanup(); -} - -void VideoStreamPlaybackGDNative::cleanup() { - if (data_struct) { - interface->destructor(data_struct); - } - if (pcm) { - memfree(pcm); - } - if (file) { - file->close(); - memdelete(file); - file = nullptr; - } - pcm = nullptr; - time = 0; - num_channels = -1; - interface = nullptr; - data_struct = nullptr; -} - -void VideoStreamPlaybackGDNative::set_interface(const godot_videodecoder_interface_gdnative *p_interface) { - ERR_FAIL_COND(p_interface == nullptr); - if (interface != nullptr) { - cleanup(); - } - interface = p_interface; - data_struct = interface->constructor((godot_object *)this); -} - -// controls - -bool VideoStreamPlaybackGDNative::is_playing() const { - return playing; -} - -bool VideoStreamPlaybackGDNative::is_paused() const { - return paused; -} - -void VideoStreamPlaybackGDNative::play() { - stop(); - - playing = true; - - delay_compensation = ProjectSettings::get_singleton()->get("audio/video/video_delay_compensation_ms"); - delay_compensation /= 1000.0; -} - -void VideoStreamPlaybackGDNative::stop() { - if (playing) { - seek(0); - } - playing = false; -} - -void VideoStreamPlaybackGDNative::seek(float p_time) { - ERR_FAIL_COND(interface == nullptr); - interface->seek(data_struct, p_time); - if (p_time < time) { - seek_backward = true; - } - time = p_time; - // reset audio buffers - memset(pcm, 0, num_channels * AUX_BUFFER_SIZE * sizeof(float)); - pcm_write_idx = -1; - samples_decoded = 0; -} - -void VideoStreamPlaybackGDNative::set_paused(bool p_paused) { - paused = p_paused; -} - -Ref<Texture2D> VideoStreamPlaybackGDNative::get_texture() const { - return texture; -} - -float VideoStreamPlaybackGDNative::get_length() const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->get_length(data_struct); -} - -float VideoStreamPlaybackGDNative::get_playback_position() const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->get_playback_position(data_struct); -} - -bool VideoStreamPlaybackGDNative::has_loop() const { - // TODO: Implement looping? - return false; -} - -void VideoStreamPlaybackGDNative::set_loop(bool p_enable) { - // Do nothing -} - -void VideoStreamPlaybackGDNative::set_audio_track(int p_idx) { - ERR_FAIL_COND(interface == nullptr); - interface->set_audio_track(data_struct, p_idx); -} - -void VideoStreamPlaybackGDNative::set_mix_callback(AudioMixCallback p_callback, void *p_userdata) { - mix_udata = p_userdata; - mix_callback = p_callback; -} - -int VideoStreamPlaybackGDNative::get_channels() const { - ERR_FAIL_COND_V(interface == nullptr, 0); - - return (num_channels > 0) ? num_channels : 0; -} - -int VideoStreamPlaybackGDNative::get_mix_rate() const { - ERR_FAIL_COND_V(interface == nullptr, 0); - - return mix_rate; -} - -/* --- NOTE VideoStreamGDNative starts here. ----- */ - -Ref<VideoStreamPlayback> VideoStreamGDNative::instance_playback() { - Ref<VideoStreamPlaybackGDNative> pb = memnew(VideoStreamPlaybackGDNative); - VideoDecoderGDNative *decoder = decoder_server.get_decoder(file.get_extension().to_lower()); - if (decoder == nullptr) { - return nullptr; - } - pb->set_interface(decoder->interface); - pb->set_audio_track(audio_track); - if (pb->open_file(file)) { - return pb; - } - return nullptr; -} - -void VideoStreamGDNative::set_file(const String &p_file) { - file = p_file; -} - -String VideoStreamGDNative::get_file() { - return file; -} - -void VideoStreamGDNative::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_file", "file"), &VideoStreamGDNative::set_file); - ClassDB::bind_method(D_METHOD("get_file"), &VideoStreamGDNative::get_file); - - ADD_PROPERTY(PropertyInfo(Variant::STRING, "file", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL), "set_file", "get_file"); -} - -void VideoStreamGDNative::set_audio_track(int p_track) { - audio_track = p_track; -} - -/* --- NOTE ResourceFormatLoaderVideoStreamGDNative starts here. ----- */ - -RES ResourceFormatLoaderVideoStreamGDNative::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) { - FileAccess *f = FileAccess::open(p_path, FileAccess::READ); - if (!f) { - if (r_error) { - *r_error = ERR_CANT_OPEN; - } - return RES(); - } - memdelete(f); - VideoStreamGDNative *stream = memnew(VideoStreamGDNative); - stream->set_file(p_path); - Ref<VideoStreamGDNative> ogv_stream = Ref<VideoStreamGDNative>(stream); - if (r_error) { - *r_error = OK; - } - return ogv_stream; -} - -void ResourceFormatLoaderVideoStreamGDNative::get_recognized_extensions(List<String> *p_extensions) const { - Map<String, int>::Element *el = VideoDecoderServer::get_instance()->get_extensions().front(); - while (el) { - p_extensions->push_back(el->key()); - el = el->next(); - } -} - -bool ResourceFormatLoaderVideoStreamGDNative::handles_type(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "VideoStream"); -} - -String ResourceFormatLoaderVideoStreamGDNative::get_resource_type(const String &p_path) const { - String el = p_path.get_extension().to_lower(); - if (VideoDecoderServer::get_instance()->get_extensions().has(el)) { - return "VideoStreamGDNative"; - } - return ""; -} diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.h b/modules/gdnative/videodecoder/video_stream_gdnative.h deleted file mode 100644 index b0a10242be..0000000000 --- a/modules/gdnative/videodecoder/video_stream_gdnative.h +++ /dev/null @@ -1,205 +0,0 @@ -/*************************************************************************/ -/* video_stream_gdnative.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 VIDEO_STREAM_GDNATIVE_H -#define VIDEO_STREAM_GDNATIVE_H - -#include "../gdnative.h" -#include "core/io/file_access.h" -#include "scene/resources/texture.h" -#include "scene/resources/video_stream.h" - -struct VideoDecoderGDNative { - const godot_videodecoder_interface_gdnative *interface = nullptr; - String plugin_name = "none"; - Vector<String> supported_extensions; - - VideoDecoderGDNative() {} - - VideoDecoderGDNative(const godot_videodecoder_interface_gdnative *p_interface) : - interface(p_interface), - plugin_name(p_interface->get_plugin_name()) { - _get_supported_extensions(); - } - -private: - void _get_supported_extensions() { - supported_extensions.clear(); - int num_ext; - const char **supported_ext = interface->get_supported_extensions(&num_ext); - for (int i = 0; i < num_ext; i++) { - supported_extensions.push_back(supported_ext[i]); - } - } -}; - -class VideoDecoderServer { -private: - Vector<VideoDecoderGDNative *> decoders; - Map<String, int> extensions; - - static VideoDecoderServer *instance; - -public: - static VideoDecoderServer *get_instance() { - return instance; - } - - const Map<String, int> &get_extensions() { - return extensions; - } - - void register_decoder_interface(const godot_videodecoder_interface_gdnative *p_interface) { - VideoDecoderGDNative *decoder = memnew(VideoDecoderGDNative(p_interface)); - int index = decoders.size(); - for (int i = 0; i < decoder->supported_extensions.size(); i++) { - extensions[decoder->supported_extensions[i]] = index; - } - decoders.push_back(decoder); - } - - VideoDecoderGDNative *get_decoder(const String &extension) { - if (extensions.size() == 0 || !extensions.has(extension)) { - return nullptr; - } - return decoders[extensions[extension]]; - } - - VideoDecoderServer() { - instance = this; - } - - ~VideoDecoderServer() { - for (int i = 0; i < decoders.size(); i++) { - memdelete(decoders[i]); - } - decoders.clear(); - instance = nullptr; - } -}; - -class VideoStreamPlaybackGDNative : public VideoStreamPlayback { - GDCLASS(VideoStreamPlaybackGDNative, VideoStreamPlayback); - - Ref<ImageTexture> texture; - bool playing = false; - bool paused = false; - - Vector2 texture_size; - - void *mix_udata = nullptr; - AudioMixCallback mix_callback = nullptr; - - int num_channels = -1; - float time = 0.0; - bool seek_backward = false; - int mix_rate = 0; - double delay_compensation = 0; - - float *pcm = nullptr; - int pcm_write_idx = 0; - int samples_decoded = 0; - - void cleanup(); - void update_texture(); - -protected: - String file_name; - - FileAccess *file = nullptr; - - const godot_videodecoder_interface_gdnative *interface = nullptr; - void *data_struct = nullptr; - -public: - VideoStreamPlaybackGDNative(); - ~VideoStreamPlaybackGDNative(); - - void set_interface(const godot_videodecoder_interface_gdnative *p_interface); - - bool open_file(const String &p_file); - - virtual void stop() override; - virtual void play() override; - - virtual bool is_playing() const override; - - virtual void set_paused(bool p_paused) override; - virtual bool is_paused() const override; - - virtual void set_loop(bool p_enable) override; - virtual bool has_loop() const override; - - virtual float get_length() const override; - - virtual float get_playback_position() const override; - virtual void seek(float p_time) override; - - virtual void set_audio_track(int p_idx) override; - - //virtual int mix(int16_t* p_buffer,int p_frames)=0; - - virtual Ref<Texture2D> get_texture() const override; - virtual void update(float p_delta) override; - - virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata) override; - virtual int get_channels() const override; - virtual int get_mix_rate() const override; -}; - -class VideoStreamGDNative : public VideoStream { - GDCLASS(VideoStreamGDNative, VideoStream); - - String file; - int audio_track = 0; - -protected: - static void - _bind_methods(); - -public: - void set_file(const String &p_file); - String get_file(); - - virtual void set_audio_track(int p_track) override; - virtual Ref<VideoStreamPlayback> instance_playback() override; - - VideoStreamGDNative() {} -}; - -class ResourceFormatLoaderVideoStreamGDNative : public ResourceFormatLoader { -public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE); - 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; -}; - -#endif |