diff options
Diffstat (limited to 'modules/gdnative')
35 files changed, 77 insertions, 3296 deletions
diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub index 21ee39f3ed..f7f21a433e 100644 --- a/modules/gdnative/SCsub +++ b/modules/gdnative/SCsub @@ -16,10 +16,8 @@ env_gdnative.Prepend(CPPPATH=["#modules/gdnative/include/"]) Export("env_gdnative") -SConscript("net/SCsub") SConscript("pluginscript/SCsub") SConscript("videodecoder/SCsub") -SConscript("text/SCsub") import gdnative_builders diff --git a/modules/gdnative/config.py b/modules/gdnative/config.py index fa985501b5..026a84a70f 100644 --- a/modules/gdnative/config.py +++ b/modules/gdnative/config.py @@ -10,14 +10,9 @@ def get_doc_classes(): return [ "GDNative", "GDNativeLibrary", - "MultiplayerPeerGDNative", "NativeScript", - "PacketPeerGDNative", "PluginScript", - "StreamPeerGDNative", "VideoStreamGDNative", - "WebRTCPeerConnectionGDNative", - "WebRTCDataChannelGDNative", ] diff --git a/modules/gdnative/doc_classes/GDNativeLibrary.xml b/modules/gdnative/doc_classes/GDNativeLibrary.xml index 3654870b09..6b3bd714b9 100644 --- a/modules/gdnative/doc_classes/GDNativeLibrary.xml +++ b/modules/gdnative/doc_classes/GDNativeLibrary.xml @@ -7,8 +7,8 @@ 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">https://docs.godotengine.org/en/latest/tutorials/plugins/gdnative/gdnative-c-example.html</link> - <link title="GDNative C++ example">https://docs.godotengine.org/en/latest/tutorials/plugins/gdnative/gdnative-cpp-example.html</link> + <link title="GDNative C example">https://docs.godotengine.org/en/latest/tutorials/scripting/gdnative/gdnative_c_example.html</link> + <link title="GDNative C++ example">https://docs.godotengine.org/en/latest/tutorials/scripting/gdnative/gdnative_cpp_example.html</link> </tutorials> <methods> <method name="get_current_dependencies" qualifiers="const"> diff --git a/modules/gdnative/doc_classes/MultiplayerPeerGDNative.xml b/modules/gdnative/doc_classes/MultiplayerPeerGDNative.xml deleted file mode 100644 index 40f3121525..0000000000 --- a/modules/gdnative/doc_classes/MultiplayerPeerGDNative.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="MultiplayerPeerGDNative" inherits="MultiplayerPeer" version="4.0"> - <brief_description> - </brief_description> - <description> - </description> - <tutorials> - </tutorials> -</class> diff --git a/modules/gdnative/doc_classes/NativeScript.xml b/modules/gdnative/doc_classes/NativeScript.xml index 9d34e89f02..221374a7a4 100644 --- a/modules/gdnative/doc_classes/NativeScript.xml +++ b/modules/gdnative/doc_classes/NativeScript.xml @@ -38,7 +38,7 @@ <return type="Variant" /> <description> Constructs a new object of the base type with a script of this type already attached. - [i]Note[/i]: 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. + [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> diff --git a/modules/gdnative/doc_classes/PacketPeerGDNative.xml b/modules/gdnative/doc_classes/PacketPeerGDNative.xml deleted file mode 100644 index 32863f8422..0000000000 --- a/modules/gdnative/doc_classes/PacketPeerGDNative.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="PacketPeerGDNative" inherits="PacketPeer" version="4.0"> - <brief_description> - </brief_description> - <description> - </description> - <tutorials> - </tutorials> -</class> diff --git a/modules/gdnative/doc_classes/StreamPeerGDNative.xml b/modules/gdnative/doc_classes/StreamPeerGDNative.xml deleted file mode 100644 index a505de2106..0000000000 --- a/modules/gdnative/doc_classes/StreamPeerGDNative.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="StreamPeerGDNative" inherits="StreamPeer" version="4.0"> - <brief_description> - </brief_description> - <description> - </description> - <tutorials> - </tutorials> -</class> diff --git a/modules/gdnative/doc_classes/WebRTCDataChannelGDNative.xml b/modules/gdnative/doc_classes/WebRTCDataChannelGDNative.xml deleted file mode 100644 index ddf354763c..0000000000 --- a/modules/gdnative/doc_classes/WebRTCDataChannelGDNative.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="WebRTCDataChannelGDNative" inherits="WebRTCDataChannel" version="4.0"> - <brief_description> - </brief_description> - <description> - </description> - <tutorials> - </tutorials> -</class> diff --git a/modules/gdnative/doc_classes/WebRTCPeerConnectionGDNative.xml b/modules/gdnative/doc_classes/WebRTCPeerConnectionGDNative.xml deleted file mode 100644 index 821779a0ff..0000000000 --- a/modules/gdnative/doc_classes/WebRTCPeerConnectionGDNative.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="WebRTCPeerConnectionGDNative" inherits="WebRTCPeerConnection" version="4.0"> - <brief_description> - </brief_description> - <description> - </description> - <tutorials> - </tutorials> -</class> diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json index 66d2dc267d..cf1c7dc01f 100644 --- a/modules/gdnative/gdnative_api.json +++ b/modules/gdnative/gdnative_api.json @@ -5103,580 +5103,6 @@ ] } ] - }, - { - "name": "net", - "type": "NET", - "version": { - "major": 4, - "minor": 0 - }, - "next": null, - "api": [ - { - "name": "godot_net_bind_stream_peer", - "return_type": "void", - "arguments": [ - [ - "godot_object *", - "p_obj" - ], - [ - "const godot_net_stream_peer *", - "p_interface" - ] - ] - }, - { - "name": "godot_net_bind_packet_peer", - "return_type": "void", - "arguments": [ - [ - "godot_object *", - "p_obj" - ], - [ - "const godot_net_packet_peer *", - "p_interface" - ] - ] - }, - { - "name": "godot_net_bind_multiplayer_peer", - "return_type": "void", - "arguments": [ - [ - "godot_object *", - "p_obj" - ], - [ - "const godot_net_multiplayer_peer *", - "p_interface" - ] - ] - }, - { - "name": "godot_net_set_webrtc_library", - "return_type": "godot_error", - "arguments": [ - [ - "const godot_net_webrtc_library *", - "p_library" - ] - ] - }, - { - "name": "godot_net_bind_webrtc_peer_connection", - "return_type": "void", - "arguments": [ - [ - "godot_object *", - "p_obj" - ], - [ - "const godot_net_webrtc_peer_connection *", - "p_interface" - ] - ] - }, - { - "name": "godot_net_bind_webrtc_data_channel", - "return_type": "void", - "arguments": [ - [ - "godot_object *", - "p_obj" - ], - [ - "const godot_net_webrtc_data_channel *", - "p_interface" - ] - ] - } - ] - }, - { - "name": "text", - "type": "TEXT", - "version": { - "major": 1, - "minor": 0 - }, - "next": null, - "api": [ - { - "name": "godot_text_register_interface", - "return_type": "void", - "arguments": [ - [ - "const godot_text_interface_gdnative *", - "p_interface" - ], - [ - "const godot_string *", - "p_name" - ], - [ - "uint32_t", - "p_features" - ] - ] - }, - { - "name": "godot_glyph_new", - "return_type": "void", - "arguments": [ - [ - "godot_glyph *", - "r_dest" - ] - ] - }, - { - "name": "godot_glyph_get_range", - "return_type": "godot_vector2i", - "arguments": [ - [ - "const godot_glyph *", - "p_self" - ] - ] - }, - { - "name": "godot_glyph_set_range", - "return_type": "void", - "arguments": [ - [ - "godot_glyph *", - "p_self" - ], - [ - "const godot_vector2i *", - "p_range" - ] - ] - }, - { - "name": "godot_glyph_get_count", - "return_type": "godot_int", - "arguments": [ - [ - "const godot_glyph *", - "p_self" - ] - ] - }, - { - "name": "godot_glyph_set_count", - "return_type": "void", - "arguments": [ - [ - "godot_glyph *", - "p_self" - ], - [ - "godot_int", - "p_count" - ] - ] - }, - { - "name": "godot_glyph_get_repeat", - "return_type": "godot_int", - "arguments": [ - [ - "const godot_glyph *", - "p_self" - ] - ] - }, - { - "name": "godot_glyph_set_repeat", - "return_type": "void", - "arguments": [ - [ - "godot_glyph *", - "p_self" - ], - [ - "godot_int", - "p_repeat" - ] - ] - }, - { - "name": "godot_glyph_get_flags", - "return_type": "godot_int", - "arguments": [ - [ - "const godot_glyph *", - "p_self" - ] - ] - }, - { - "name": "godot_glyph_set_flags", - "return_type": "void", - "arguments": [ - [ - "godot_glyph *", - "p_self" - ], - [ - "godot_int", - "p_flags" - ] - ] - }, - { - "name": "godot_glyph_get_offset", - "return_type": "godot_vector2", - "arguments": [ - [ - "const godot_glyph *", - "p_self" - ] - ] - }, - { - "name": "godot_glyph_set_offset", - "return_type": "void", - "arguments": [ - [ - "godot_glyph *", - "p_self" - ], - [ - "const godot_vector2 *", - "p_offset" - ] - ] - }, - { - "name": "godot_glyph_get_advance", - "return_type": "godot_real_t", - "arguments": [ - [ - "const godot_glyph *", - "p_self" - ] - ] - }, - { - "name": "godot_glyph_set_advance", - "return_type": "void", - "arguments": [ - [ - "godot_glyph *", - "p_self" - ], - [ - "godot_real_t", - "p_advance" - ] - ] - }, - { - "name": "godot_glyph_get_font", - "return_type": "godot_rid", - "arguments": [ - [ - "const godot_glyph *", - "p_self" - ] - ] - }, - { - "name": "godot_glyph_set_font", - "return_type": "void", - "arguments": [ - [ - "godot_glyph *", - "p_self" - ], - [ - "godot_rid *", - "p_font" - ] - ] - }, - { - "name": "godot_glyph_get_font_size", - "return_type": "godot_int", - "arguments": [ - [ - "const godot_glyph *", - "p_self" - ] - ] - }, - { - "name": "godot_glyph_set_font_size", - "return_type": "void", - "arguments": [ - [ - "godot_glyph *", - "p_self" - ], - [ - "godot_int", - "p_size" - ] - ] - }, - { - "name": "godot_glyph_get_index", - "return_type": "godot_int", - "arguments": [ - [ - "const godot_glyph *", - "p_self" - ] - ] - }, - { - "name": "godot_glyph_set_index", - "return_type": "void", - "arguments": [ - [ - "godot_glyph *", - "p_self" - ], - [ - "godot_int", - "p_index" - ] - ] - }, - { - "name": "godot_packed_glyph_array_new", - "return_type": "void", - "arguments": [ - [ - "godot_packed_glyph_array *", - "r_dest" - ] - ] - }, - { - "name": "godot_packed_glyph_array_new_copy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_glyph_array *", - "r_dest" - ], - [ - "const godot_packed_glyph_array *", - "p_src" - ] - ] - }, - { - "name": "godot_packed_glyph_array_is_empty", - "return_type": "godot_bool", - "arguments": [ - [ - "const godot_packed_glyph_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_glyph_array_append", - "return_type": "void", - "arguments": [ - [ - "godot_packed_glyph_array *", - "p_self" - ], - [ - "const godot_glyph *", - "p_data" - ] - ] - }, - { - "name": "godot_packed_glyph_array_append_array", - "return_type": "void", - "arguments": [ - [ - "godot_packed_glyph_array *", - "p_self" - ], - [ - "const godot_packed_glyph_array *", - "p_array" - ] - ] - }, - { - "name": "godot_packed_glyph_array_insert", - "return_type": "godot_error", - "arguments": [ - [ - "godot_packed_glyph_array *", - "p_self" - ], - [ - "const godot_int", - "p_idx" - ], - [ - "const godot_glyph *", - "p_data" - ] - ] - }, - { - "name": "godot_packed_glyph_array_has", - "return_type": "godot_bool", - "arguments": [ - [ - "godot_packed_glyph_array *", - "p_self" - ], - [ - "const godot_glyph *", - "p_value" - ] - ] - }, - { - "name": "godot_packed_glyph_array_sort", - "return_type": "void", - "arguments": [ - [ - "godot_packed_glyph_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_glyph_array_reverse", - "return_type": "void", - "arguments": [ - [ - "godot_packed_glyph_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_glyph_array_push_back", - "return_type": "void", - "arguments": [ - [ - "godot_packed_glyph_array *", - "p_self" - ], - [ - "const godot_glyph *", - "p_data" - ] - ] - }, - { - "name": "godot_packed_glyph_array_remove", - "return_type": "void", - "arguments": [ - [ - "godot_packed_glyph_array *", - "p_self" - ], - [ - "const godot_int", - "p_idx" - ] - ] - }, - { - "name": "godot_packed_glyph_array_resize", - "return_type": "void", - "arguments": [ - [ - "godot_packed_glyph_array *", - "p_self" - ], - [ - "const godot_int", - "p_size" - ] - ] - }, - { - "name": "godot_packed_glyph_array_ptr", - "return_type": "const godot_glyph *", - "arguments": [ - [ - "const godot_packed_glyph_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_glyph_array_ptrw", - "return_type": "godot_glyph *", - "arguments": [ - [ - "godot_packed_glyph_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_glyph_array_set", - "return_type": "void", - "arguments": [ - [ - "godot_packed_glyph_array *", - "p_self" - ], - [ - "const godot_int", - "p_idx" - ], - [ - "const godot_glyph *", - "p_data" - ] - ] - }, - { - "name": "godot_packed_glyph_array_get", - "return_type": "godot_glyph", - "arguments": [ - [ - "const godot_packed_glyph_array *", - "p_self" - ], - [ - "const godot_int", - "p_idx" - ] - ] - }, - { - "name": "godot_packed_glyph_array_size", - "return_type": "godot_int", - "arguments": [ - [ - "const godot_packed_glyph_array *", - "p_self" - ] - ] - }, - { - "name": "godot_packed_glyph_array_destroy", - "return_type": "void", - "arguments": [ - [ - "godot_packed_glyph_array *", - "p_self" - ] - ] - } - ] } ] } diff --git a/modules/gdnative/gdnative_builders.py b/modules/gdnative/gdnative_builders.py index 181fd71b82..6c96e23426 100644 --- a/modules/gdnative/gdnative_builders.py +++ b/modules/gdnative/gdnative_builders.py @@ -20,10 +20,8 @@ def _build_gdnative_api_struct_header(api): "#include <gdnative/gdnative.h>", "#include <android/godot_android.h>", "#include <nativescript/godot_nativescript.h>", - "#include <net/godot_net.h>", "#include <pluginscript/godot_pluginscript.h>", "#include <videodecoder/godot_videodecoder.h>", - "#include <text/godot_text.h>", "", "#ifdef __cplusplus", 'extern "C" {', diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp index f965bcd014..9dad13a615 100644 --- a/modules/gdnative/gdnative_library_editor_plugin.cpp +++ b/modules/gdnative/gdnative_library_editor_plugin.cpp @@ -38,9 +38,9 @@ void GDNativeLibraryEditor::edit(Ref<GDNativeLibrary> p_library) { library = p_library; Ref<ConfigFile> config = p_library->get_config_file(); - for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) { - for (List<String>::Element *it = E->value().entries.front(); it; it = it->next()) { - String target = E->key() + "." + it->get(); + 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()); @@ -245,9 +245,9 @@ void GDNativeLibraryEditor::_translate_to_config_file() { config->erase_section("entry"); config->erase_section("dependencies"); - for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) { - for (List<String>::Element *it = E->value().entries.front(); it; it = it->next()) { - String target = E->key() + "." + it->get(); + 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; } @@ -341,9 +341,9 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() { filter_list->set_hide_on_checkable_item_selection(false); int idx = 0; - for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) { - filter_list->add_check_item(E->get().name, idx); - filter_list->set_item_metadata(idx, E->key()); + 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; } diff --git a/modules/gdnative/include/nativescript/godot_nativescript.h b/modules/gdnative/include/nativescript/godot_nativescript.h index 09eac2492f..5390d30c9f 100644 --- a/modules/gdnative/include/nativescript/godot_nativescript.h +++ b/modules/gdnative/include/nativescript/godot_nativescript.h @@ -39,7 +39,7 @@ extern "C" { typedef enum { GODOT_METHOD_RPC_MODE_DISABLED, - GODOT_METHOD_RPC_MODE_ANY, + GODOT_METHOD_RPC_MODE_ANY_PEER, GODOT_METHOD_RPC_MODE_AUTHORITY, } godot_nativescript_method_rpc_mode; diff --git a/modules/gdnative/include/net/godot_net.h b/modules/gdnative/include/net/godot_net.h deleted file mode 100644 index 3fb7b9e1cc..0000000000 --- a/modules/gdnative/include/net/godot_net.h +++ /dev/null @@ -1,122 +0,0 @@ -/*************************************************************************/ -/* godot_net.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 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_NATIVENET_H -#define GODOT_NATIVENET_H - -#include <gdnative/gdnative.h> - -#ifdef __cplusplus -extern "C" { -#endif - -// For future versions of the API we should only add new functions at the end of the structure and use the -// version info to detect whether a call is available - -// Use these to populate version in your plugin -#define GODOT_NET_API_MAJOR 3 -#define GODOT_NET_API_MINOR 1 - -typedef struct { - godot_gdnative_api_version version; /* version of our API */ - godot_object *data; /* User reference */ - - /* This is StreamPeer */ - godot_error (*get_data)(void *user, uint8_t *p_buffer, int p_bytes); - godot_error (*get_partial_data)(void *user, uint8_t *p_buffer, int p_bytes, int *r_received); - godot_error (*put_data)(void *user, const uint8_t *p_data, int p_bytes); - godot_error (*put_partial_data)(void *user, const uint8_t *p_data, int p_bytes, int *r_sent); - - int (*get_available_bytes)(const void *user); - - void *next; /* For extension? */ -} godot_net_stream_peer; - -/* Binds a StreamPeerGDNative to the provided interface */ -void godot_net_bind_stream_peer(godot_object *p_obj, const godot_net_stream_peer *p_interface); - -typedef struct { - godot_gdnative_api_version version; /* version of our API */ - - godot_object *data; /* User reference */ - - /* This is PacketPeer */ - godot_error (*get_packet)(void *, const uint8_t **, int *); - godot_error (*put_packet)(void *, const uint8_t *, int); - godot_int (*get_available_packet_count)(const void *); - godot_int (*get_max_packet_size)(const void *); - - void *next; /* For extension? */ -} godot_net_packet_peer; - -/* Binds a PacketPeerGDNative to the provided interface */ -void GDAPI godot_net_bind_packet_peer(godot_object *p_obj, const godot_net_packet_peer *); - -typedef struct { - godot_gdnative_api_version version; /* version of our API */ - - godot_object *data; /* User reference */ - - /* This is PacketPeer */ - godot_error (*get_packet)(void *, const uint8_t **, int *); - godot_error (*put_packet)(void *, const uint8_t *, int); - godot_int (*get_available_packet_count)(const void *); - godot_int (*get_max_packet_size)(const void *); - - /* This is MultiplayerPeer */ - void (*set_transfer_channel)(void *, godot_int); - godot_int (*get_transfer_channel)(void *); - void (*set_transfer_mode)(void *, godot_int); - godot_int (*get_transfer_mode)(const void *); - // 0 = broadcast, 1 = server, <0 = all but abs(value) - void (*set_target_peer)(void *, godot_int); - godot_int (*get_packet_peer)(const void *); - godot_bool (*is_server)(const void *); - void (*poll)(void *); - // Must be > 0, 1 is for server - int32_t (*get_unique_id)(const void *); - void (*set_refuse_new_connections)(void *, godot_bool); - godot_bool (*is_refusing_new_connections)(const void *); - godot_int (*get_connection_status)(const void *); - - void *next; /* For extension? Or maybe not... */ -} godot_net_multiplayer_peer; - -/* Binds a MultiplayerPeerGDNative to the provided interface */ -void GDAPI godot_net_bind_multiplayer_peer(godot_object *p_obj, const godot_net_multiplayer_peer *); - -#ifdef __cplusplus -} -#endif - -// WebRTC Bindings -#include "net/godot_webrtc.h" - -#endif /* GODOT_NATIVENET_H */ diff --git a/modules/gdnative/include/net/godot_webrtc.h b/modules/gdnative/include/net/godot_webrtc.h deleted file mode 100644 index 52006e56ec..0000000000 --- a/modules/gdnative/include/net/godot_webrtc.h +++ /dev/null @@ -1,123 +0,0 @@ -/*************************************************************************/ -/* godot_webrtc.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 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_NATIVEWEBRTC_H -#define GODOT_NATIVEWEBRTC_H - -#include <gdnative/gdnative.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define GODOT_NET_WEBRTC_API_MAJOR 4 -#define GODOT_NET_WEBRTC_API_MINOR 0 - -/* Library Interface (used to set default GDNative WebRTC implementation */ -typedef struct { - godot_gdnative_api_version version; /* version of our API */ - - /* Called when the library is unset as default interface via godot_net_set_webrtc_library */ - void (*unregistered)(); - - /* Used by WebRTCPeerConnection create when GDNative is the default implementation. */ - /* Takes a pointer to WebRTCPeerConnectionGDNative, should bind and return OK, failure if binding was unsuccessful. */ - godot_error (*create_peer_connection)(godot_object *); - - void *next; /* For extension */ -} godot_net_webrtc_library; - -/* WebRTCPeerConnection interface */ -typedef struct { - godot_gdnative_api_version version; /* version of our API */ - - godot_object *data; /* User reference */ - - /* This is WebRTCPeerConnection */ - godot_int (*get_connection_state)(const void *); - - godot_error (*initialize)(void *, const godot_dictionary *); - godot_object *(*create_data_channel)(void *, const char *p_channel_name, const godot_dictionary *); - godot_error (*create_offer)(void *); - godot_error (*create_answer)(void *); /* unused for now, should be done automatically on set_local_description */ - godot_error (*set_remote_description)(void *, const char *, const char *); - godot_error (*set_local_description)(void *, const char *, const char *); - godot_error (*add_ice_candidate)(void *, const char *, int, const char *); - godot_error (*poll)(void *); - void (*close)(void *); - - void *next; /* For extension? */ -} godot_net_webrtc_peer_connection; - -/* WebRTCDataChannel interface */ -typedef struct { - godot_gdnative_api_version version; /* version of our API */ - - godot_object *data; /* User reference */ - - /* This is PacketPeer */ - godot_error (*get_packet)(void *, const uint8_t **, int *); - godot_error (*put_packet)(void *, const uint8_t *, int); - godot_int (*get_available_packet_count)(const void *); - godot_int (*get_max_packet_size)(const void *); - - /* This is WebRTCDataChannel */ - void (*set_write_mode)(void *, godot_int); - godot_int (*get_write_mode)(const void *); - bool (*was_string_packet)(const void *); - - godot_int (*get_ready_state)(const void *); - const char *(*get_label)(const void *); - bool (*is_ordered)(const void *); - int (*get_id)(const void *); - int (*get_max_packet_life_time)(const void *); - int (*get_max_retransmits)(const void *); - const char *(*get_protocol)(const void *); - bool (*is_negotiated)(const void *); - int (*get_buffered_amount)(const void *); - - godot_error (*poll)(void *); - void (*close)(void *); - - void *next; /* For extension? */ -} godot_net_webrtc_data_channel; - -/* Set the default GDNative library */ -godot_error GDAPI godot_net_set_webrtc_library(const godot_net_webrtc_library *); -/* Binds a WebRTCPeerConnectionGDNative to the provided interface */ -void GDAPI godot_net_bind_webrtc_peer_connection(godot_object *p_obj, const godot_net_webrtc_peer_connection *); -/* Binds a WebRTCDataChannelGDNative to the provided interface */ -void GDAPI godot_net_bind_webrtc_data_channel(godot_object *p_obj, const godot_net_webrtc_data_channel *); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/modules/gdnative/include/text/godot_text.h b/modules/gdnative/include/text/godot_text.h deleted file mode 100644 index 940cfd11f8..0000000000 --- a/modules/gdnative/include/text/godot_text.h +++ /dev/null @@ -1,283 +0,0 @@ -/*************************************************************************/ -/* godot_text.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 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_NATIVETEXT_H -#define GODOT_NATIVETEXT_H - -#include <gdnative/gdnative.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define GODOT_TEXT_API_MAJOR 1 -#define GODOT_TEXT_API_MINOR 0 - -#define GODOT_GLYPH_SIZE 40 - -#ifndef GODOT_TEXT_API_GODOT_GLYPH_TYPE_DEFINED -#define GODOT_TEXT_API_GODOT_GLYPH_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_GLYPH_SIZE]; -} godot_glyph; -#endif - -#define GODOT_PACKED_GLYPH_ARRAY_SIZE (2 * sizeof(void *)) - -#ifndef GODOT_TEXT_API_GODOT_PACKED_GLYPH_ARRAY_TYPE_DEFINED -#define GODOT_TEXT_API_GODOT_PACKED_GLYPH_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_PACKED_GLYPH_ARRAY_SIZE]; -} godot_packed_glyph_array; -#endif - -typedef struct { - godot_gdnative_api_version version; - - void *(*constructor)(godot_object *); - void (*destructor)(void *); - - godot_string (*get_name)(const void *); - godot_bool (*has_feature)(const void *, godot_int); - - void (*free)(void *, godot_rid *); - bool (*has)(void *, godot_rid *); - - bool (*load_support_data)(void *, const godot_string *); - godot_string (*get_support_data_filename)(const void *); - godot_string (*get_support_data_info)(const void *); - bool (*save_support_data)(void *, const godot_string *); - - bool (*is_locale_right_to_left)(void *, const godot_string *); - int32_t (*name_to_tag)(const void *, const godot_string *); - godot_string (*tag_to_name)(const void *, int32_t); - - godot_rid (*create_font)(void *); - void (*font_set_data)(void *, godot_rid *, const godot_packed_byte_array *); - void (*font_set_data_ptr)(void *, godot_rid *, const uint8_t *, size_t); - void (*font_set_antialiased)(void *, godot_rid *, bool); - bool (*font_is_antialiased)(const void *, godot_rid *); - void (*font_set_multichannel_signed_distance_field)(void *, godot_rid *, bool); - bool (*font_is_multichannel_signed_distance_field)(const void *, godot_rid *); - void (*font_set_msdf_pixel_range)(void *, godot_rid *, godot_int); - godot_int (*font_get_msdf_pixel_range)(const void *, godot_rid *); - void (*font_set_msdf_size)(void *, godot_rid *, godot_int); - godot_int (*font_get_msdf_size)(const void *, godot_rid *); - void (*font_set_fixed_size)(void *, godot_rid *, godot_int); - godot_int (*font_get_fixed_size)(const void *, godot_rid *); - void (*font_set_force_autohinter)(void *, godot_rid *, bool); - bool (*font_is_force_autohinter)(const void *, godot_rid *); - void (*font_set_hinting)(void *, godot_rid *, godot_int); - godot_int (*font_get_hinting)(const void *, godot_rid *); - void (*font_set_variation_coordinates)(void *, godot_rid *, const godot_dictionary *); - godot_dictionary (*font_get_variation_coordinates)(const void *, godot_rid *); - void (*font_set_oversampling)(void *, godot_rid *, godot_real_t); - godot_real_t (*font_get_oversampling)(const void *, godot_rid *); - godot_array (*font_get_size_cache_list)(const void *, godot_rid *); - void (*font_clear_size_cache)(void *, godot_rid *); - void (*font_remove_size_cache)(void *, godot_rid *, const godot_vector2i *); - void (*font_set_ascent)(void *, godot_rid *, godot_int, godot_real_t); - godot_real_t (*font_get_ascent)(const void *, godot_rid *, godot_int); - void (*font_set_descent)(void *, godot_rid *, godot_int, godot_real_t); - godot_real_t (*font_get_descent)(const void *, godot_rid *, godot_int); - void (*font_set_underline_position)(void *, godot_rid *, godot_int, godot_real_t); - godot_real_t (*font_get_underline_position)(const void *, godot_rid *, godot_int); - void (*font_set_underline_thickness)(void *, godot_rid *, godot_int, godot_real_t); - godot_real_t (*font_get_underline_thickness)(const void *, godot_rid *, godot_int); - void (*font_set_scale)(void *, godot_rid *, godot_int, godot_real_t); - godot_real_t (*font_get_scale)(const void *, godot_rid *, godot_int); - void (*font_set_spacing)(void *, godot_rid *, godot_int, godot_int, godot_int); - godot_int (*font_get_spacing)(const void *, godot_rid *, godot_int, godot_int); - godot_int (*font_get_texture_count)(const void *, godot_rid *, const godot_vector2i *); - void (*font_clear_textures)(void *, godot_rid *, const godot_vector2i *); - void (*font_remove_texture)(void *, godot_rid *, const godot_vector2i *, godot_int); - void (*font_set_texture_image)(void *, godot_rid *, const godot_vector2i *, godot_int, const godot_object *); - godot_object *(*font_get_texture_image)(const void *, godot_rid *, const godot_vector2i *, godot_int); - void (*font_set_texture_offsets)(void *, godot_rid *, const godot_vector2i *, godot_int, const godot_packed_int32_array *); - godot_packed_int32_array (*font_get_texture_offsets)(const void *, godot_rid *, const godot_vector2i *, godot_int); - godot_array (*font_get_glyph_list)(const void *, godot_rid *, const godot_vector2i *); - void (*font_clear_glyphs)(void *, godot_rid *, const godot_vector2i *); - void (*font_remove_glyph)(void *, godot_rid *, const godot_vector2i *, int32_t); - godot_vector2 (*font_get_glyph_advance)(const void *, godot_rid *, godot_int, int32_t); - void (*font_set_glyph_advance)(void *, godot_rid *, godot_int, int32_t, const godot_vector2 *); - godot_vector2 (*font_get_glyph_offset)(const void *, godot_rid *, const godot_vector2i *, int32_t); - void (*font_set_glyph_offset)(void *, godot_rid *, const godot_vector2i *, int32_t, const godot_vector2 *); - godot_vector2 (*font_get_glyph_size)(const void *, godot_rid *, const godot_vector2i *, int32_t); - void (*font_set_glyph_size)(void *, godot_rid *, const godot_vector2i *, int32_t, const godot_vector2 *); - godot_rect2 (*font_get_glyph_uv_rect)(const void *, godot_rid *, const godot_vector2i *, int32_t); - void (*font_set_glyph_uv_rect)(void *, godot_rid *, const godot_vector2i *, int32_t, const godot_rect2 *); - godot_int (*font_get_glyph_texture_idx)(const void *, godot_rid *, const godot_vector2i *, int32_t); - void (*font_set_glyph_texture_idx)(void *, godot_rid *, const godot_vector2i *, int32_t, godot_int); - bool (*font_get_glyph_contours)(const void *, godot_rid *, godot_int, int32_t, godot_packed_vector3_array *, godot_packed_int32_array *, bool *); - godot_array (*font_get_kerning_list)(const void *, godot_rid *, godot_int); - void (*font_clear_kerning_map)(void *, godot_rid *, godot_int); - void (*font_remove_kerning)(void *, godot_rid *, godot_int, const godot_vector2i *); - void (*font_set_kerning)(void *, godot_rid *, godot_int, const godot_vector2i *, const godot_vector2 *); - godot_vector2 (*font_get_kerning)(const void *, godot_rid *, godot_int, const godot_vector2i *); - int32_t (*font_get_glyph_index)(const void *, godot_rid *, godot_int, char32_t, char32_t); - bool (*font_has_char)(const void *, godot_rid *, char32_t); - godot_string (*font_get_supported_chars)(const void *, godot_rid *); - void (*font_render_range)(void *, godot_rid *, const godot_vector2i *, char32_t, char32_t); - void (*font_render_glyph)(void *, godot_rid *, const godot_vector2i *, int32_t); - void (*font_draw_glyph)(const void *, godot_rid *, godot_rid *, godot_int, const godot_vector2 *, int32_t, const godot_color *); - void (*font_draw_glyph_outline)(const void *, godot_rid *, godot_rid *, godot_int, godot_int, const godot_vector2 *, int32_t, const godot_color *); - bool (*font_is_language_supported)(const void *, godot_rid *, const godot_string *); - void (*font_set_language_support_override)(void *, godot_rid *, const godot_string *, bool); - bool (*font_get_language_support_override)(const void *, godot_rid *, const godot_string *); - void (*font_remove_language_support_override)(void *, godot_rid *, const godot_string *); - godot_packed_string_array (*font_get_language_support_overrides)(const void *, godot_rid *); - bool (*font_is_script_supported)(const void *, godot_rid *, const godot_string *); - void (*font_set_script_support_override)(void *, godot_rid *, const godot_string *, bool); - bool (*font_get_script_support_override)(const void *, godot_rid *, const godot_string *); - void (*font_remove_script_support_override)(void *, godot_rid *, const godot_string *); - godot_packed_string_array (*font_get_script_support_overrides)(const void *, godot_rid *); - godot_dictionary (*font_supported_feature_list)(const void *, godot_rid *); - godot_dictionary (*font_supported_variation_list)(const void *, godot_rid *); - godot_real_t (*font_get_global_oversampling)(const void *); - void (*font_set_global_oversampling)(void *, godot_real_t); - - godot_rid (*create_shaped_text)(void *, godot_int, godot_int); - void (*shaped_text_clear)(void *, godot_rid *); - void (*shaped_text_set_direction)(void *, godot_rid *, godot_int); - godot_int (*shaped_text_get_direction)(void *, godot_rid *); - void (*shaped_text_set_bidi_override)(void *, godot_rid *, const godot_packed_vector2i_array *); - void (*shaped_text_set_orientation)(void *, godot_rid *, godot_int); - godot_int (*shaped_text_get_orientation)(void *, godot_rid *); - void (*shaped_text_set_preserve_invalid)(void *, godot_rid *, bool); - bool (*shaped_text_get_preserve_invalid)(void *, godot_rid *); - void (*shaped_text_set_preserve_control)(void *, godot_rid *, bool); - bool (*shaped_text_get_preserve_control)(void *, godot_rid *); - bool (*shaped_text_add_string)(void *, godot_rid *, const godot_string *, const godot_rid **, int, const godot_dictionary *, const godot_string *); - bool (*shaped_text_add_object)(void *, godot_rid *, const godot_variant *, const godot_vector2 *, godot_int, godot_int); - bool (*shaped_text_resize_object)(void *, godot_rid *, const godot_variant *, const godot_vector2 *, godot_int); - godot_rid (*shaped_text_substr)(void *, godot_rid *, godot_int, godot_int); - godot_rid (*shaped_text_get_parent)(void *, godot_rid *); - godot_real_t (*shaped_text_fit_to_width)(void *, godot_rid *, godot_real_t, uint8_t); - godot_real_t (*shaped_text_tab_align)(void *, godot_rid *, godot_packed_float32_array *); - bool (*shaped_text_shape)(void *, godot_rid *); - bool (*shaped_text_update_breaks)(void *, godot_rid *); - bool (*shaped_text_update_justification_ops)(void *, godot_rid *); - void (*shaped_text_overrun_trim_to_width)(void *, godot_rid *, godot_real_t, uint8_t); - bool (*shaped_text_is_ready)(void *, godot_rid *); - godot_packed_glyph_array (*shaped_text_get_glyphs)(void *, godot_rid *); - godot_vector2i (*shaped_text_get_range)(void *, godot_rid *); - godot_packed_glyph_array (*shaped_text_sort_logical)(void *, godot_rid *); - godot_packed_vector2i_array (*shaped_text_get_line_breaks_adv)(void *, godot_rid *, godot_packed_float32_array *, int, bool, uint8_t); - godot_packed_vector2i_array (*shaped_text_get_line_breaks)(void *, godot_rid *, godot_real_t, int, uint8_t); - godot_packed_vector2i_array (*shaped_text_get_word_breaks)(void *, godot_rid *, int); - godot_array (*shaped_text_get_objects)(void *, godot_rid *); - godot_rect2 (*shaped_text_get_object_rect)(void *, godot_rid *, const godot_variant *); - godot_vector2 (*shaped_text_get_size)(void *, godot_rid *); - godot_real_t (*shaped_text_get_ascent)(void *, godot_rid *); - godot_real_t (*shaped_text_get_descent)(void *, godot_rid *); - godot_real_t (*shaped_text_get_width)(void *, godot_rid *); - godot_real_t (*shaped_text_get_underline_position)(void *, godot_rid *); - godot_real_t (*shaped_text_get_underline_thickness)(void *, godot_rid *); - - godot_string (*format_number)(void *, const godot_string *, const godot_string *); - godot_string (*parse_number)(void *, const godot_string *, const godot_string *); - godot_string (*percent_sign)(void *, const godot_string *); -} godot_text_interface_gdnative; - -void GDAPI godot_text_register_interface(const godot_text_interface_gdnative *p_interface, const godot_string *p_name, uint32_t p_features); - -// Glyph - -void GDAPI godot_glyph_new(godot_glyph *r_dest); - -godot_vector2i GDAPI godot_glyph_get_range(const godot_glyph *p_self); -void GDAPI godot_glyph_set_range(godot_glyph *p_self, const godot_vector2i *p_range); - -godot_int GDAPI godot_glyph_get_count(const godot_glyph *p_self); -void GDAPI godot_glyph_set_count(godot_glyph *p_self, godot_int p_count); - -godot_int GDAPI godot_glyph_get_repeat(const godot_glyph *p_self); -void GDAPI godot_glyph_set_repeat(godot_glyph *p_self, godot_int p_repeat); - -godot_int GDAPI godot_glyph_get_flags(const godot_glyph *p_self); -void GDAPI godot_glyph_set_flags(godot_glyph *p_self, godot_int p_flags); - -godot_vector2 GDAPI godot_glyph_get_offset(const godot_glyph *p_self); -void GDAPI godot_glyph_set_offset(godot_glyph *p_self, const godot_vector2 *p_offset); - -godot_real_t GDAPI godot_glyph_get_advance(const godot_glyph *p_self); -void GDAPI godot_glyph_set_advance(godot_glyph *p_self, godot_real_t p_advance); - -godot_rid GDAPI godot_glyph_get_font(const godot_glyph *p_self); -void GDAPI godot_glyph_set_font(godot_glyph *p_self, godot_rid *p_font); - -godot_int GDAPI godot_glyph_get_font_size(const godot_glyph *p_self); -void GDAPI godot_glyph_set_font_size(godot_glyph *p_self, godot_int p_size); - -godot_int GDAPI godot_glyph_get_index(const godot_glyph *p_self); -void GDAPI godot_glyph_set_index(godot_glyph *p_self, godot_int p_index); - -// GlyphArray - -void GDAPI godot_packed_glyph_array_new(godot_packed_glyph_array *r_dest); -void GDAPI godot_packed_glyph_array_new_copy(godot_packed_glyph_array *r_dest, const godot_packed_glyph_array *p_src); - -const godot_glyph GDAPI *godot_packed_glyph_array_ptr(const godot_packed_glyph_array *p_self); -godot_glyph GDAPI *godot_packed_glyph_array_ptrw(godot_packed_glyph_array *p_self); - -void GDAPI godot_packed_glyph_array_append(godot_packed_glyph_array *p_self, const godot_glyph *p_data); - -void GDAPI godot_packed_glyph_array_append_array(godot_packed_glyph_array *p_self, const godot_packed_glyph_array *p_array); - -godot_error GDAPI godot_packed_glyph_array_insert(godot_packed_glyph_array *p_self, const godot_int p_idx, const godot_glyph *p_data); - -godot_bool GDAPI godot_packed_glyph_array_has(godot_packed_glyph_array *p_self, const godot_glyph *p_value); - -void GDAPI godot_packed_glyph_array_sort(godot_packed_glyph_array *p_self); - -void GDAPI godot_packed_glyph_array_reverse(godot_packed_glyph_array *p_self); - -void GDAPI godot_packed_glyph_array_push_back(godot_packed_glyph_array *p_self, const godot_glyph *p_data); - -void GDAPI godot_packed_glyph_array_remove(godot_packed_glyph_array *p_self, godot_int p_idx); - -void GDAPI godot_packed_glyph_array_resize(godot_packed_glyph_array *p_self, godot_int p_size); - -void GDAPI godot_packed_glyph_array_set(godot_packed_glyph_array *p_self, godot_int p_idx, const godot_glyph *p_data); -godot_glyph GDAPI godot_packed_glyph_array_get(const godot_packed_glyph_array *p_self, godot_int p_idx); - -godot_int GDAPI godot_packed_glyph_array_size(const godot_packed_glyph_array *p_self); - -godot_bool GDAPI godot_packed_glyph_array_is_empty(const godot_packed_glyph_array *p_self); - -void GDAPI godot_packed_glyph_array_destroy(godot_packed_glyph_array *p_self); - -// Grapheme - -#ifdef __cplusplus -} -#endif - -#endif /* !GODOT_NATIVETEXT_H */ diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp index 2d9b45cb07..598f7c7ad0 100644 --- a/modules/gdnative/nativescript/api_generator.cpp +++ b/modules/gdnative/nativescript/api_generator.cpp @@ -223,8 +223,8 @@ List<ClassAPI> generate_c_api_classes() { enum_api_map[enum_name] = enum_api; } } - for (const Map<StringName, EnumAPI>::Element *E = enum_api_map.front(); E; E = E->next()) { - global_constants_api.enums.push_back(E->get()); + 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); diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 92ba9bd452..fb46bafb3c 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -360,8 +360,8 @@ void NativeScript::get_script_signal_list(List<MethodInfo> *r_signals) const { Set<MethodInfo> signals_; while (script_data) { - for (Map<StringName, NativeScriptDesc::Signal>::Element *S = script_data->signals_.front(); S; S = S->next()) { - signals_.insert(S->get().signal); + for (const KeyValue<StringName, NativeScriptDesc::Signal> &S : script_data->signals_) { + signals_.insert(S.value.signal); } script_data = script_data->base_data; @@ -401,8 +401,8 @@ void NativeScript::get_script_method_list(List<MethodInfo> *p_list) const { Set<MethodInfo> methods; while (script_data) { - for (Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.front(); E; E = E->next()) { - methods.insert(E->get().info); + for (const KeyValue<StringName, NativeScriptDesc::Method> &E : script_data->methods) { + methods.insert(E.value.info); } script_data = script_data->base_data; @@ -857,9 +857,9 @@ NativeScriptLanguage *NativeScriptLanguage::singleton; void NativeScriptLanguage::_unload_stuff(bool p_reload) { Map<String, Ref<GDNative>> erase_and_unload; - for (Map<String, Map<StringName, NativeScriptDesc>>::Element *L = library_classes.front(); L; L = L->next()) { - String lib_path = L->key(); - Map<StringName, NativeScriptDesc> classes = L->get(); + 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); @@ -890,9 +890,9 @@ void NativeScriptLanguage::_unload_stuff(bool p_reload) { gdn = E->get(); } - for (Map<StringName, NativeScriptDesc>::Element *C = classes.front(); C; C = C->next()) { + for (KeyValue<StringName, NativeScriptDesc> &C : classes) { // free property stuff first - for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C->get().properties.front(); P; P = P.next()) { + 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); } @@ -903,28 +903,28 @@ void NativeScriptLanguage::_unload_stuff(bool p_reload) { } // free method stuff - for (Map<StringName, NativeScriptDesc::Method>::Element *M = C->get().methods.front(); M; M = M->next()) { - if (M->get().method.free_func) { - M->get().method.free_func(M->get().method.method_data); + 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->get().create_func.free_func) { - C->get().create_func.free_func(C->get().create_func.method_data); + if (C.value.create_func.free_func) { + C.value.create_func.free_func(C.value.create_func.method_data); } - if (C->get().destroy_func.free_func) { - C->get().destroy_func.free_func(C->get().destroy_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 (Map<String, Ref<GDNative>>::Element *E = erase_and_unload.front(); E; E = E->next()) { - String lib_path = E->key(); - Ref<GDNative> gdn = E->get(); + for (KeyValue<String, Ref<GDNative>> &E : erase_and_unload) { + String lib_path = E.key; + Ref<GDNative> gdn = E.value; library_classes.erase(lib_path); @@ -957,8 +957,8 @@ NativeScriptLanguage::NativeScriptLanguage() { } NativeScriptLanguage::~NativeScriptLanguage() { - for (Map<String, Ref<GDNative>>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { - Ref<GDNative> lib = L->get(); + 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 @@ -1157,15 +1157,15 @@ int NativeScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_a int current = 0; - for (Map<StringName, ProfileData>::Element *d = profile_data.front(); d; d = d->next()) { + for (const KeyValue<StringName, ProfileData> &d : profile_data) { if (current >= p_info_max) { break; } - p_info_arr[current].call_count = d->get().call_count; - p_info_arr[current].self_time = d->get().self_time; - p_info_arr[current].total_time = d->get().total_time; - p_info_arr[current].signature = d->get().signature; + 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++; } @@ -1181,16 +1181,16 @@ int NativeScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, in int current = 0; - for (Map<StringName, ProfileData>::Element *d = profile_data.front(); d; d = d->next()) { + for (const KeyValue<StringName, ProfileData> &d : profile_data) { if (current >= p_info_max) { break; } - if (d->get().last_frame_call_count) { - p_info_arr[current].call_count = d->get().last_frame_call_count; - p_info_arr[current].self_time = d->get().last_frame_self_time; - p_info_arr[current].total_time = d->get().last_frame_total_time; - p_info_arr[current].signature = d->get().signature; + 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++; } } @@ -1503,9 +1503,9 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) { if (L) { Map<StringName, NativeScriptDesc> classes = L->get(); - for (Map<StringName, NativeScriptDesc>::Element *C = classes.front(); C; C = C->next()) { + for (KeyValue<StringName, NativeScriptDesc> &C : classes) { // free property stuff first - for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C->get().properties.front(); P; P = P.next()) { + 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); } @@ -1516,19 +1516,19 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) { } // free method stuff - for (Map<StringName, NativeScriptDesc::Method>::Element *M = C->get().methods.front(); M; M = M->next()) { - if (M->get().method.free_func) { - M->get().method.free_func(M->get().method.method_data); + 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->get().create_func.free_func) { - C->get().create_func.free_func(C->get().create_func.method_data); + if (C.value.create_func.free_func) { + C.value.create_func.free_func(C.value.create_func.method_data); } - if (C->get().destroy_func.free_func) { - C->get().destroy_func.free_func(C->get().destroy_func.method_data); + if (C.value.destroy_func.free_func) { + C.value.destroy_func.free_func(C.value.destroy_func.method_data); } } @@ -1548,14 +1548,14 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) { 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 (Map<String, Ref<GDNative>>::Element *L = library_gdnatives.front(); L; L = L->next()) { - if (L->get().is_null()) { + for (KeyValue<String, Ref<GDNative>> &L : library_gdnatives) { + if (L.value.is_null()) { continue; } - if (L->get()->is_initialized()) { + if (L.value->is_initialized()) { void *proc_ptr; - Error err = L->get()->get_symbol(L->get()->get_library()->get_symbol_prefix() + name, proc_ptr); + Error err = L.value->get_symbol(L.value->get_library()->get_symbol_prefix() + name, proc_ptr); if (!err) { ((void (*)())proc_ptr)(); @@ -1584,13 +1584,13 @@ void NativeScriptLanguage::frame() { { MutexLock lock(mutex); - for (Map<StringName, ProfileData>::Element *d = profile_data.front(); d; d = d->next()) { - d->get().last_frame_call_count = d->get().frame_call_count; - d->get().last_frame_self_time = d->get().frame_self_time; - d->get().last_frame_total_time = d->get().frame_total_time; - d->get().frame_call_count = 0; - d->get().frame_self_time = 0; - d->get().frame_total_time = 0; + 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 @@ -1651,8 +1651,8 @@ void NativeReloadNode::_notification(int p_what) { MutexLock lock(NSL->mutex); NSL->_unload_stuff(true); - for (Map<String, Ref<GDNative>>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { - Ref<GDNative> gdn = L->get(); + for (KeyValue<String, Ref<GDNative>> &L : NSL->library_gdnatives) { + Ref<GDNative> gdn = L.value; if (gdn.is_null()) { continue; @@ -1685,8 +1685,8 @@ void NativeReloadNode::_notification(int p_what) { MutexLock lock(NSL->mutex); Set<StringName> libs_to_remove; - for (Map<String, Ref<GDNative>>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { - Ref<GDNative> gdn = L->get(); + for (KeyValue<String, Ref<GDNative>> &L : NSL->library_gdnatives) { + Ref<GDNative> gdn = L.value; if (gdn.is_null()) { continue; @@ -1703,24 +1703,24 @@ void NativeReloadNode::_notification(int p_what) { } if (!gdn->initialize()) { - libs_to_remove.insert(L->key()); + libs_to_remove.insert(L.key); continue; } - NSL->library_classes.insert(L->key(), Map<StringName, NativeScriptDesc>()); + 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()); + ERR_PRINT(String("No godot_nativescript_init in \"" + L.key + "\" found").utf8().get_data()); } else { - ((void (*)(void *))proc_ptr)((void *)&L->key()); + ((void (*)(void *))proc_ptr)((void *)&L.key); } - for (Map<String, Set<NativeScript *>>::Element *U = NSL->library_script_users.front(); U; U = U->next()) { - for (Set<NativeScript *>::Element *S = U->get().front(); S; S = S->next()) { + 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) { diff --git a/modules/gdnative/net/SCsub b/modules/gdnative/net/SCsub deleted file mode 100644 index b76500c003..0000000000 --- a/modules/gdnative/net/SCsub +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python - -Import("env") -Import("env_gdnative") - -env_net = env_gdnative.Clone() - -has_webrtc = env_net["module_webrtc_enabled"] -if has_webrtc: - env_net.Append(CPPDEFINES=["WEBRTC_GDNATIVE_ENABLED"]) - -env_net.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/gdnative/net/multiplayer_peer_gdnative.cpp b/modules/gdnative/net/multiplayer_peer_gdnative.cpp deleted file mode 100644 index 575d5f5060..0000000000 --- a/modules/gdnative/net/multiplayer_peer_gdnative.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/*************************************************************************/ -/* multiplayer_peer_gdnative.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 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 "multiplayer_peer_gdnative.h" - -MultiplayerPeerGDNative::MultiplayerPeerGDNative() { - interface = nullptr; -} - -MultiplayerPeerGDNative::~MultiplayerPeerGDNative() { -} - -void MultiplayerPeerGDNative::set_native_multiplayer_peer(const godot_net_multiplayer_peer *p_interface) { - interface = p_interface; -} - -Error MultiplayerPeerGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { - ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); - return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size); -} - -Error MultiplayerPeerGDNative::put_packet(const uint8_t *p_buffer, int p_buffer_size) { - ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); - return (Error)interface->put_packet(interface->data, p_buffer, p_buffer_size); -} - -int MultiplayerPeerGDNative::get_max_packet_size() const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->get_max_packet_size(interface->data); -} - -int MultiplayerPeerGDNative::get_available_packet_count() const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->get_available_packet_count(interface->data); -} - -/* MultiplayerPeer */ -void MultiplayerPeerGDNative::set_transfer_channel(int p_channel) { - ERR_FAIL_COND(interface == nullptr); - return interface->set_transfer_channel(interface->data, p_channel); -} - -int MultiplayerPeerGDNative::get_transfer_channel() const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->get_transfer_channel(interface->data); -} - -void MultiplayerPeerGDNative::set_transfer_mode(Multiplayer::TransferMode p_mode) { - ERR_FAIL_COND(interface == nullptr); - interface->set_transfer_mode(interface->data, (godot_int)p_mode); -} - -Multiplayer::TransferMode MultiplayerPeerGDNative::get_transfer_mode() const { - ERR_FAIL_COND_V(interface == nullptr, Multiplayer::TRANSFER_MODE_UNRELIABLE); - return (Multiplayer::TransferMode)interface->get_transfer_mode(interface->data); -} - -void MultiplayerPeerGDNative::set_target_peer(int p_peer_id) { - ERR_FAIL_COND(interface == nullptr); - interface->set_target_peer(interface->data, p_peer_id); -} - -int MultiplayerPeerGDNative::get_packet_peer() const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->get_packet_peer(interface->data); -} - -bool MultiplayerPeerGDNative::is_server() const { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->is_server(interface->data); -} - -void MultiplayerPeerGDNative::poll() { - ERR_FAIL_COND(interface == nullptr); - interface->poll(interface->data); -} - -int MultiplayerPeerGDNative::get_unique_id() const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->get_unique_id(interface->data); -} - -void MultiplayerPeerGDNative::set_refuse_new_connections(bool p_enable) { - ERR_FAIL_COND(interface == nullptr); - interface->set_refuse_new_connections(interface->data, p_enable); -} - -bool MultiplayerPeerGDNative::is_refusing_new_connections() const { - ERR_FAIL_COND_V(interface == nullptr, true); - return interface->is_refusing_new_connections(interface->data); -} - -MultiplayerPeer::ConnectionStatus MultiplayerPeerGDNative::get_connection_status() const { - ERR_FAIL_COND_V(interface == nullptr, CONNECTION_DISCONNECTED); - return (ConnectionStatus)interface->get_connection_status(interface->data); -} - -void MultiplayerPeerGDNative::_bind_methods() { - ADD_PROPERTY_DEFAULT("transfer_channel", 0); - ADD_PROPERTY_DEFAULT("transfer_mode", Multiplayer::TRANSFER_MODE_UNRELIABLE); - ADD_PROPERTY_DEFAULT("refuse_new_connections", true); -} - -extern "C" { - -void GDAPI godot_net_bind_multiplayer_peer(godot_object *p_obj, const godot_net_multiplayer_peer *p_impl) { - ((MultiplayerPeerGDNative *)p_obj)->set_native_multiplayer_peer(p_impl); -} -} diff --git a/modules/gdnative/net/multiplayer_peer_gdnative.h b/modules/gdnative/net/multiplayer_peer_gdnative.h deleted file mode 100644 index 33e424d284..0000000000 --- a/modules/gdnative/net/multiplayer_peer_gdnative.h +++ /dev/null @@ -1,79 +0,0 @@ -/*************************************************************************/ -/* multiplayer_peer_gdnative.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 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 MULTIPLAYER_PEER_GDNATIVE_H -#define MULTIPLAYER_PEER_GDNATIVE_H - -#include "core/multiplayer/multiplayer_peer.h" -#include "modules/gdnative/gdnative.h" -#include "modules/gdnative/include/net/godot_net.h" - -class MultiplayerPeerGDNative : public MultiplayerPeer { - GDCLASS(MultiplayerPeerGDNative, MultiplayerPeer); - -protected: - static void _bind_methods(); - const godot_net_multiplayer_peer *interface; - -public: - MultiplayerPeerGDNative(); - ~MultiplayerPeerGDNative(); - - /* Sets the interface implementation from GDNative */ - void set_native_multiplayer_peer(const godot_net_multiplayer_peer *p_impl); - - /* Specific to PacketPeer */ - virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) override; - virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size) override; - virtual int get_max_packet_size() const override; - virtual int get_available_packet_count() const override; - - /* Specific to MultiplayerPeer */ - virtual void set_transfer_channel(int p_channel) override; - virtual int get_transfer_channel() const override; - virtual void set_transfer_mode(Multiplayer::TransferMode p_mode) override; - virtual Multiplayer::TransferMode get_transfer_mode() const override; - virtual void set_target_peer(int p_peer_id) override; - - virtual int get_packet_peer() const override; - - virtual bool is_server() const override; - - virtual void poll() override; - - virtual int get_unique_id() const override; - - virtual void set_refuse_new_connections(bool p_enable) override; - virtual bool is_refusing_new_connections() const override; - - virtual ConnectionStatus get_connection_status() const override; -}; - -#endif // MULTIPLAYER_PEER_GDNATIVE_H diff --git a/modules/gdnative/net/packet_peer_gdnative.cpp b/modules/gdnative/net/packet_peer_gdnative.cpp deleted file mode 100644 index 3bcdfed8ff..0000000000 --- a/modules/gdnative/net/packet_peer_gdnative.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/*************************************************************************/ -/* packet_peer_gdnative.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 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 "packet_peer_gdnative.h" - -PacketPeerGDNative::PacketPeerGDNative() { - interface = nullptr; -} - -PacketPeerGDNative::~PacketPeerGDNative() { -} - -void PacketPeerGDNative::set_native_packet_peer(const godot_net_packet_peer *p_impl) { - interface = p_impl; -} - -void PacketPeerGDNative::_bind_methods() { -} - -Error PacketPeerGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { - ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); - return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size); -} - -Error PacketPeerGDNative::put_packet(const uint8_t *p_buffer, int p_buffer_size) { - ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); - return (Error)interface->put_packet(interface->data, p_buffer, p_buffer_size); -} - -int PacketPeerGDNative::get_max_packet_size() const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->get_max_packet_size(interface->data); -} - -int PacketPeerGDNative::get_available_packet_count() const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->get_available_packet_count(interface->data); -} - -extern "C" { - -void GDAPI godot_net_bind_packet_peer(godot_object *p_obj, const godot_net_packet_peer *p_impl) { - ((PacketPeerGDNative *)p_obj)->set_native_packet_peer(p_impl); -} -} diff --git a/modules/gdnative/net/packet_peer_gdnative.h b/modules/gdnative/net/packet_peer_gdnative.h deleted file mode 100644 index 29013f9367..0000000000 --- a/modules/gdnative/net/packet_peer_gdnative.h +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************/ -/* packet_peer_gdnative.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 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 PACKET_PEER_GDNATIVE_H -#define PACKET_PEER_GDNATIVE_H - -#include "core/io/packet_peer.h" -#include "modules/gdnative/gdnative.h" -#include "modules/gdnative/include/net/godot_net.h" - -class PacketPeerGDNative : public PacketPeer { - GDCLASS(PacketPeerGDNative, PacketPeer); - -protected: - static void _bind_methods(); - const godot_net_packet_peer *interface; - -public: - PacketPeerGDNative(); - ~PacketPeerGDNative(); - - /* Sets the interface implementation from GDNative */ - void set_native_packet_peer(const godot_net_packet_peer *p_impl); - - /* Specific to PacketPeer */ - virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) override; - virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size) override; - virtual int get_max_packet_size() const override; - virtual int get_available_packet_count() const override; -}; - -#endif // PACKET_PEER_GDNATIVE_H diff --git a/modules/gdnative/net/register_types.cpp b/modules/gdnative/net/register_types.cpp deleted file mode 100644 index 46c383e5ae..0000000000 --- a/modules/gdnative/net/register_types.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/*************************************************************************/ -/* register_types.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 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 "multiplayer_peer_gdnative.h" -#include "packet_peer_gdnative.h" -#include "stream_peer_gdnative.h" - -void register_net_types() { - GDREGISTER_CLASS(MultiplayerPeerGDNative); - GDREGISTER_CLASS(PacketPeerGDNative); - GDREGISTER_CLASS(StreamPeerGDNative); -} - -void unregister_net_types() { -} diff --git a/modules/gdnative/net/register_types.h b/modules/gdnative/net/register_types.h deleted file mode 100644 index c99c6f6fbf..0000000000 --- a/modules/gdnative/net/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-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 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 NET_REGISTER_TYPES_H -#define NET_REGISTER_TYPES_H - -void register_net_types(); -void unregister_net_types(); - -#endif // NET_REGISTER_TYPES_H diff --git a/modules/gdnative/net/stream_peer_gdnative.cpp b/modules/gdnative/net/stream_peer_gdnative.cpp deleted file mode 100644 index 72ab72323d..0000000000 --- a/modules/gdnative/net/stream_peer_gdnative.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/*************************************************************************/ -/* stream_peer_gdnative.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 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 "stream_peer_gdnative.h" - -StreamPeerGDNative::StreamPeerGDNative() { - interface = nullptr; -} - -StreamPeerGDNative::~StreamPeerGDNative() { -} - -void StreamPeerGDNative::set_native_stream_peer(const godot_net_stream_peer *p_interface) { - interface = p_interface; -} - -void StreamPeerGDNative::_bind_methods() { -} - -Error StreamPeerGDNative::put_data(const uint8_t *p_data, int p_bytes) { - ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); - return (Error)(interface->put_data(interface->data, p_data, p_bytes)); -} - -Error StreamPeerGDNative::put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) { - ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); - return (Error)(interface->put_partial_data(interface->data, p_data, p_bytes, &r_sent)); -} - -Error StreamPeerGDNative::get_data(uint8_t *p_buffer, int p_bytes) { - ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); - return (Error)(interface->get_data(interface->data, p_buffer, p_bytes)); -} - -Error StreamPeerGDNative::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) { - ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); - return (Error)(interface->get_partial_data(interface->data, p_buffer, p_bytes, &r_received)); -} - -int StreamPeerGDNative::get_available_bytes() const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->get_available_bytes(interface->data); -} - -extern "C" { - -void GDAPI godot_net_bind_stream_peer(godot_object *p_obj, const godot_net_stream_peer *p_interface) { - ((StreamPeerGDNative *)p_obj)->set_native_stream_peer(p_interface); -} -} diff --git a/modules/gdnative/net/stream_peer_gdnative.h b/modules/gdnative/net/stream_peer_gdnative.h deleted file mode 100644 index dd5abceb83..0000000000 --- a/modules/gdnative/net/stream_peer_gdnative.h +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************/ -/* stream_peer_gdnative.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 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 STREAM_PEER_GDNATIVE_H -#define STREAM_PEER_GDNATIVE_H - -#include "core/io/stream_peer.h" -#include "modules/gdnative/gdnative.h" -#include "modules/gdnative/include/net/godot_net.h" - -class StreamPeerGDNative : public StreamPeer { - GDCLASS(StreamPeerGDNative, StreamPeer); - -protected: - static void _bind_methods(); - const godot_net_stream_peer *interface; - -public: - StreamPeerGDNative(); - ~StreamPeerGDNative(); - - /* Sets the interface implementation from GDNative */ - void set_native_stream_peer(const godot_net_stream_peer *p_interface); - - /* Specific to StreamPeer */ - Error put_data(const uint8_t *p_data, int p_bytes) override; - Error put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) override; - Error get_data(uint8_t *p_buffer, int p_bytes) override; - Error get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) override; - int get_available_bytes() const override; -}; - -#endif // STREAM_PEER_GDNATIVE_H diff --git a/modules/gdnative/net/webrtc_gdnative.cpp b/modules/gdnative/net/webrtc_gdnative.cpp deleted file mode 100644 index 76ccbad009..0000000000 --- a/modules/gdnative/net/webrtc_gdnative.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************/ -/* webrtc_gdnative.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 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" -#include "modules/gdnative/include/net/godot_net.h" - -#ifdef WEBRTC_GDNATIVE_ENABLED -#include "modules/webrtc/webrtc_data_channel_gdnative.h" -#include "modules/webrtc/webrtc_peer_connection_gdnative.h" -#endif - -extern "C" { - -void GDAPI godot_net_bind_webrtc_peer_connection(godot_object *p_obj, const godot_net_webrtc_peer_connection *p_impl) { -#ifdef WEBRTC_GDNATIVE_ENABLED - ((WebRTCPeerConnectionGDNative *)p_obj)->set_native_webrtc_peer_connection(p_impl); -#endif -} - -void GDAPI godot_net_bind_webrtc_data_channel(godot_object *p_obj, const godot_net_webrtc_data_channel *p_impl) { -#ifdef WEBRTC_GDNATIVE_ENABLED - ((WebRTCDataChannelGDNative *)p_obj)->set_native_webrtc_data_channel(p_impl); -#endif -} - -godot_error GDAPI godot_net_set_webrtc_library(const godot_net_webrtc_library *p_lib) { -#ifdef WEBRTC_GDNATIVE_ENABLED - return (godot_error)WebRTCPeerConnectionGDNative::set_default_library(p_lib); -#else - return (godot_error)ERR_UNAVAILABLE; -#endif -} -} diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp index e4c2b20224..a4ab5663ef 100644 --- a/modules/gdnative/register_types.cpp +++ b/modules/gdnative/register_types.cpp @@ -35,7 +35,6 @@ #include "gdnative.h" #include "nativescript/register_types.h" -#include "net/register_types.h" #include "pluginscript/register_types.h" #include "videodecoder/register_types.h" @@ -265,7 +264,6 @@ void register_gdnative_types() { GDNativeCallRegistry::singleton->register_native_call_type("standard_varcall", cb_standard_varcall); - register_net_types(); register_nativescript_types(); register_pluginscript_types(); register_videodecoder_types(); @@ -329,7 +327,6 @@ void unregister_gdnative_types() { unregister_videodecoder_types(); unregister_pluginscript_types(); unregister_nativescript_types(); - unregister_net_types(); memdelete(GDNativeCallRegistry::singleton); diff --git a/modules/gdnative/text/SCsub b/modules/gdnative/text/SCsub deleted file mode 100644 index 0b2db3b504..0000000000 --- a/modules/gdnative/text/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/text/config.py b/modules/gdnative/text/config.py deleted file mode 100644 index d22f9454ed..0000000000 --- a/modules/gdnative/text/config.py +++ /dev/null @@ -1,6 +0,0 @@ -def can_build(env, platform): - return True - - -def configure(env): - pass diff --git a/modules/gdnative/text/register_types.cpp b/modules/gdnative/text/register_types.cpp deleted file mode 100644 index 67385d2fbf..0000000000 --- a/modules/gdnative/text/register_types.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/*************************************************************************/ -/* register_types.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 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 "text_server_gdnative.h" - -void register_text_server_gdn_types() {} - -void unregister_text_server_gdn_types() {} diff --git a/modules/gdnative/text/register_types.h b/modules/gdnative/text/register_types.h deleted file mode 100644 index cd4f2a3089..0000000000 --- a/modules/gdnative/text/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-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 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 TEXT_REGISTER_TYPES_H -#define TEXT_REGISTER_TYPES_H - -void register_text_server_gdn_types(); -void unregister_text_server_gdn_types(); - -#endif // TEXT_REGISTER_TYPES_H diff --git a/modules/gdnative/text/text_server_gdnative.cpp b/modules/gdnative/text/text_server_gdnative.cpp deleted file mode 100644 index 39db8ae636..0000000000 --- a/modules/gdnative/text/text_server_gdnative.cpp +++ /dev/null @@ -1,1086 +0,0 @@ -/*************************************************************************/ -/* text_server_gdnative.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 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 "text_server_gdnative.h" - -bool TextServerGDNative::has_feature(Feature p_feature) { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->has_feature(data, (godot_int)p_feature); -} - -String TextServerGDNative::get_name() const { - ERR_FAIL_COND_V(interface == nullptr, String()); - godot_string result = interface->get_name(data); - String name = *(String *)&result; - godot_string_destroy(&result); - return name; -} - -void TextServerGDNative::free(RID p_rid) { - ERR_FAIL_COND(interface == nullptr); - interface->free(data, (godot_rid *)&p_rid); -} - -bool TextServerGDNative::has(RID p_rid) { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->has(data, (godot_rid *)&p_rid); -} - -bool TextServerGDNative::load_support_data(const String &p_filename) { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->load_support_data(data, (godot_string *)&p_filename); -} - -#ifdef TOOLS_ENABLED - -String TextServerGDNative::get_support_data_filename() { - ERR_FAIL_COND_V(interface == nullptr, String()); - godot_string result = interface->get_support_data_filename(data); - String name = *(String *)&result; - godot_string_destroy(&result); - return name; -} - -String TextServerGDNative::get_support_data_info() { - ERR_FAIL_COND_V(interface == nullptr, String()); - godot_string result = interface->get_support_data_info(data); - String info = *(String *)&result; - godot_string_destroy(&result); - return info; -} - -bool TextServerGDNative::save_support_data(const String &p_filename) { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->save_support_data(data, (godot_string *)&p_filename); -} - -#endif - -bool TextServerGDNative::is_locale_right_to_left(const String &p_locale) { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->is_locale_right_to_left(data, (godot_string *)&p_locale); -} - -int32_t TextServerGDNative::name_to_tag(const String &p_name) const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->name_to_tag(data, (godot_string *)&p_name); -} - -String TextServerGDNative::tag_to_name(int32_t p_tag) const { - ERR_FAIL_COND_V(interface == nullptr, String()); - godot_string result = interface->tag_to_name(data, p_tag); - String name = *(String *)&result; - godot_string_destroy(&result); - return name; -} - -/*************************************************************************/ -/* Font */ -/*************************************************************************/ - -RID TextServerGDNative::create_font() { - ERR_FAIL_COND_V(interface == nullptr, RID()); - godot_rid result = interface->create_font(data); - RID rid = *(RID *)&result; - return rid; -} - -void TextServerGDNative::font_set_data(RID p_font_rid, const PackedByteArray &p_data) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_data(data, (godot_rid *)&p_font_rid, (const godot_packed_byte_array *)&p_data); -} - -void TextServerGDNative::font_set_data_ptr(RID p_font_rid, const uint8_t *p_data_ptr, size_t p_data_size) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_data_ptr(data, (godot_rid *)&p_font_rid, p_data_ptr, p_data_size); -} - -void TextServerGDNative::font_set_antialiased(RID p_font_rid, bool p_antialiased) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_antialiased(data, (godot_rid *)&p_font_rid, p_antialiased); -} - -bool TextServerGDNative::font_is_antialiased(RID p_font_rid) const { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->font_is_antialiased(data, (godot_rid *)&p_font_rid); -} - -void TextServerGDNative::font_set_multichannel_signed_distance_field(RID p_font_rid, bool p_msdf) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_multichannel_signed_distance_field(data, (godot_rid *)&p_font_rid, p_msdf); -} - -bool TextServerGDNative::font_is_multichannel_signed_distance_field(RID p_font_rid) const { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->font_is_multichannel_signed_distance_field(data, (godot_rid *)&p_font_rid); -} - -void TextServerGDNative::font_set_msdf_pixel_range(RID p_font_rid, int p_msdf_pixel_range) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_msdf_pixel_range(data, (godot_rid *)&p_font_rid, p_msdf_pixel_range); -} - -int TextServerGDNative::font_get_msdf_pixel_range(RID p_font_rid) const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->font_get_msdf_pixel_range(data, (godot_rid *)&p_font_rid); -} - -void TextServerGDNative::font_set_msdf_size(RID p_font_rid, int p_msdf_size) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_msdf_size(data, (godot_rid *)&p_font_rid, p_msdf_size); -} - -int TextServerGDNative::font_get_msdf_size(RID p_font_rid) const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->font_get_msdf_size(data, (godot_rid *)&p_font_rid); -} - -void TextServerGDNative::font_set_fixed_size(RID p_font_rid, int p_fixed_size) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_fixed_size(data, (godot_rid *)&p_font_rid, p_fixed_size); -} - -int TextServerGDNative::font_get_fixed_size(RID p_font_rid) const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->font_get_fixed_size(data, (godot_rid *)&p_font_rid); -} - -void TextServerGDNative::font_set_force_autohinter(RID p_font_rid, bool p_force_autohinter) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_force_autohinter(data, (godot_rid *)&p_font_rid, p_force_autohinter); -} - -bool TextServerGDNative::font_is_force_autohinter(RID p_font_rid) const { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->font_is_force_autohinter(data, (godot_rid *)&p_font_rid); -} - -void TextServerGDNative::font_set_hinting(RID p_font_rid, TextServer::Hinting p_hinting) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_hinting(data, (godot_rid *)&p_font_rid, (godot_int)p_hinting); -} - -TextServer::Hinting TextServerGDNative::font_get_hinting(RID p_font_rid) const { - ERR_FAIL_COND_V(interface == nullptr, TextServer::HINTING_NONE); - return (TextServer::Hinting)interface->font_get_hinting(data, (godot_rid *)&p_font_rid); -} - -void TextServerGDNative::font_set_variation_coordinates(RID p_font_rid, const Dictionary &p_variation_coordinates) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_variation_coordinates(data, (godot_rid *)&p_font_rid, (const godot_dictionary *)&p_variation_coordinates); -} - -Dictionary TextServerGDNative::font_get_variation_coordinates(RID p_font_rid) const { - ERR_FAIL_COND_V(interface == nullptr, Dictionary()); - godot_dictionary result = interface->font_get_variation_coordinates(data, (godot_rid *)&p_font_rid); - Dictionary dict = *(Dictionary *)&result; - godot_dictionary_destroy(&result); - return dict; -} - -void TextServerGDNative::font_set_oversampling(RID p_font_rid, real_t p_oversampling) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_oversampling(data, (godot_rid *)&p_font_rid, p_oversampling); -} - -real_t TextServerGDNative::font_get_oversampling(RID p_font_rid) const { - ERR_FAIL_COND_V(interface == nullptr, 0.0f); - return interface->font_get_oversampling(data, (godot_rid *)&p_font_rid); -} - -Array TextServerGDNative::font_get_size_cache_list(RID p_font_rid) const { - ERR_FAIL_COND_V(interface == nullptr, Array()); - godot_array result = interface->font_get_size_cache_list(data, (godot_rid *)&p_font_rid); - Array list = *(Array *)&result; - godot_array_destroy(&result); - return list; -} - -void TextServerGDNative::font_clear_size_cache(RID p_font_rid) { - ERR_FAIL_COND(interface == nullptr); - interface->font_clear_size_cache(data, (godot_rid *)&p_font_rid); -} - -void TextServerGDNative::font_remove_size_cache(RID p_font_rid, const Vector2i &p_size) { - ERR_FAIL_COND(interface == nullptr); - interface->font_remove_size_cache(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size); -} - -void TextServerGDNative::font_set_ascent(RID p_font_rid, int p_size, real_t p_ascent) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_ascent(data, (godot_rid *)&p_font_rid, p_size, p_ascent); -} - -real_t TextServerGDNative::font_get_ascent(RID p_font_rid, int p_size) const { - ERR_FAIL_COND_V(interface == nullptr, 0.0f); - return interface->font_get_ascent(data, (godot_rid *)&p_font_rid, p_size); -} - -void TextServerGDNative::font_set_descent(RID p_font_rid, int p_size, real_t p_descent) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_descent(data, (godot_rid *)&p_font_rid, p_size, p_descent); -} - -real_t TextServerGDNative::font_get_descent(RID p_font_rid, int p_size) const { - ERR_FAIL_COND_V(interface == nullptr, 0.0f); - return interface->font_get_descent(data, (godot_rid *)&p_font_rid, p_size); -} - -void TextServerGDNative::font_set_underline_position(RID p_font_rid, int p_size, real_t p_underline_position) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_underline_position(data, (godot_rid *)&p_font_rid, p_size, p_underline_position); -} - -real_t TextServerGDNative::font_get_underline_position(RID p_font_rid, int p_size) const { - ERR_FAIL_COND_V(interface == nullptr, 0.0f); - return interface->font_get_underline_position(data, (godot_rid *)&p_font_rid, p_size); -} - -void TextServerGDNative::font_set_underline_thickness(RID p_font_rid, int p_size, real_t p_underline_thickness) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_underline_thickness(data, (godot_rid *)&p_font_rid, p_size, p_underline_thickness); -} - -real_t TextServerGDNative::font_get_underline_thickness(RID p_font_rid, int p_size) const { - ERR_FAIL_COND_V(interface == nullptr, 0.0f); - return interface->font_get_underline_thickness(data, (godot_rid *)&p_font_rid, p_size); -} - -void TextServerGDNative::font_set_scale(RID p_font_rid, int p_size, real_t p_scale) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_scale(data, (godot_rid *)&p_font_rid, p_size, p_scale); -} - -real_t TextServerGDNative::font_get_scale(RID p_font_rid, int p_size) const { - ERR_FAIL_COND_V(interface == nullptr, 0.0f); - return interface->font_get_scale(data, (godot_rid *)&p_font_rid, p_size); -} - -void TextServerGDNative::font_set_spacing(RID p_font_rid, int p_size, TextServer::SpacingType p_spacing, int p_value) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_spacing(data, (godot_rid *)&p_font_rid, p_size, (godot_int)p_spacing, p_value); -} - -int TextServerGDNative::font_get_spacing(RID p_font_rid, int p_size, TextServer::SpacingType p_spacing) const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->font_get_spacing(data, (godot_rid *)&p_font_rid, p_size, (godot_int)p_spacing); -} - -int TextServerGDNative::font_get_texture_count(RID p_font_rid, const Vector2i &p_size) const { - ERR_FAIL_COND_V(interface == nullptr, -1); - return interface->font_get_texture_count(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size); -} - -void TextServerGDNative::font_clear_textures(RID p_font_rid, const Vector2i &p_size) { - ERR_FAIL_COND(interface == nullptr); - interface->font_clear_textures(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size); -} - -void TextServerGDNative::font_remove_texture(RID p_font_rid, const Vector2i &p_size, int p_texture_index) { - ERR_FAIL_COND(interface == nullptr); - interface->font_remove_texture(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size, p_texture_index); -} - -void TextServerGDNative::font_set_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const Ref<Image> &p_image) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_texture_image(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size, p_texture_index, (const godot_object *)p_image.ptr()); -} - -Ref<Image> TextServerGDNative::font_get_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const { - ERR_FAIL_COND_V(interface == nullptr, Ref<Image>()); - godot_object *result = interface->font_get_texture_image(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size, p_texture_index); - return Ref<Image>((Image *)result); -} - -void TextServerGDNative::font_set_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const PackedInt32Array &p_offset) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_texture_offsets(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size, p_texture_index, (const godot_packed_int32_array *)&p_offset); -} - -PackedInt32Array TextServerGDNative::font_get_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const { - ERR_FAIL_COND_V(interface == nullptr, PackedInt32Array()); - godot_packed_int32_array result = interface->font_get_texture_offsets(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size, p_texture_index); - PackedInt32Array offset = *(PackedInt32Array *)&result; - godot_packed_int32_array_destroy(&result); - return offset; -} - -Array TextServerGDNative::font_get_glyph_list(RID p_font_rid, const Vector2i &p_size) const { - ERR_FAIL_COND_V(interface == nullptr, Array()); - godot_array result = interface->font_get_glyph_list(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size); - Array list = *(Array *)&result; - godot_array_destroy(&result); - return list; -} - -void TextServerGDNative::font_clear_glyphs(RID p_font_rid, const Vector2i &p_size) { - ERR_FAIL_COND(interface == nullptr); - interface->font_clear_glyphs(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size); -} - -void TextServerGDNative::font_remove_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) { - ERR_FAIL_COND(interface == nullptr); - interface->font_remove_glyph(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size, p_glyph); -} - -Vector2 TextServerGDNative::font_get_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph) const { - ERR_FAIL_COND_V(interface == nullptr, Vector2()); - godot_vector2 result = interface->font_get_glyph_advance(data, (godot_rid *)&p_font_rid, p_size, p_glyph); - Vector2 adv = *(Vector2 *)&result; - return adv; -} - -void TextServerGDNative::font_set_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph, const Vector2 &p_advance) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_glyph_advance(data, (godot_rid *)&p_font_rid, p_size, p_glyph, (const godot_vector2 *)&p_advance); -} - -Vector2 TextServerGDNative::font_get_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const { - ERR_FAIL_COND_V(interface == nullptr, Vector2()); - godot_vector2 result = interface->font_get_glyph_offset(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size, p_glyph); - Vector2 off = *(Vector2 *)&result; - return off; -} - -void TextServerGDNative::font_set_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_offset) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_glyph_offset(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size, p_glyph, (const godot_vector2 *)&p_offset); -} - -Vector2 TextServerGDNative::font_get_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const { - ERR_FAIL_COND_V(interface == nullptr, Vector2()); - godot_vector2 result = interface->font_get_glyph_size(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size, p_glyph); - Vector2 sz = *(Vector2 *)&result; - return sz; -} - -void TextServerGDNative::font_set_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_gl_size) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_glyph_size(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size, p_glyph, (const godot_vector2 *)&p_gl_size); -} - -Rect2 TextServerGDNative::font_get_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const { - ERR_FAIL_COND_V(interface == nullptr, Rect2()); - godot_rect2 result = interface->font_get_glyph_uv_rect(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size, p_glyph); - Rect2 uv = *(Rect2 *)&result; - return uv; -} - -void TextServerGDNative::font_set_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Rect2 &p_uv_rect) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_glyph_uv_rect(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size, p_glyph, (const godot_rect2 *)&p_uv_rect); -} - -int TextServerGDNative::font_get_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const { - ERR_FAIL_COND_V(interface == nullptr, -1); - return interface->font_get_glyph_texture_idx(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size, p_glyph); -} - -void TextServerGDNative::font_set_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, int p_texture_idx) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_glyph_texture_idx(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size, p_glyph, p_texture_idx); -} - -bool TextServerGDNative::font_get_glyph_contours(RID p_font_rid, int p_size, int32_t p_index, Vector<Vector3> &r_points, Vector<int32_t> &r_contours, bool &r_orientation) const { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->font_get_glyph_contours(data, (godot_rid *)&p_font_rid, p_size, p_index, (godot_packed_vector3_array *)&r_points, (godot_packed_int32_array *)&r_contours, &r_orientation); -} - -Array TextServerGDNative::font_get_kerning_list(RID p_font_rid, int p_size) const { - ERR_FAIL_COND_V(interface == nullptr, Array()); - godot_array result = interface->font_get_kerning_list(data, (godot_rid *)&p_font_rid, p_size); - Array list = *(Array *)&result; - godot_array_destroy(&result); - return list; -} - -void TextServerGDNative::font_clear_kerning_map(RID p_font_rid, int p_size) { - ERR_FAIL_COND(interface == nullptr); - interface->font_clear_kerning_map(data, (godot_rid *)&p_font_rid, p_size); -} - -void TextServerGDNative::font_remove_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) { - ERR_FAIL_COND(interface == nullptr); - interface->font_remove_kerning(data, (godot_rid *)&p_font_rid, p_size, (const godot_vector2i *)&p_glyph_pair); -} - -void TextServerGDNative::font_set_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_kerning(data, (godot_rid *)&p_font_rid, p_size, (const godot_vector2i *)&p_glyph_pair, (const godot_vector2 *)&p_kerning); -} - -Vector2 TextServerGDNative::font_get_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) const { - ERR_FAIL_COND_V(interface == nullptr, Vector2()); - godot_vector2 result = interface->font_get_kerning(data, (godot_rid *)&p_font_rid, p_size, (const godot_vector2i *)&p_glyph_pair); - Vector2 kern = *(Vector2 *)&result; - return kern; -} - -int32_t TextServerGDNative::font_get_glyph_index(RID p_font_rid, int p_size, char32_t p_char, char32_t p_variation_selector) const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->font_get_glyph_index(data, (godot_rid *)&p_font_rid, p_size, p_char, p_variation_selector); -} - -bool TextServerGDNative::font_has_char(RID p_font_rid, char32_t p_char) const { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->font_has_char(data, (godot_rid *)&p_font_rid, p_char); -} - -String TextServerGDNative::font_get_supported_chars(RID p_font_rid) const { - ERR_FAIL_COND_V(interface == nullptr, String()); - godot_string result = interface->font_get_supported_chars(data, (godot_rid *)&p_font_rid); - String chars = *(String *)&result; - godot_string_destroy(&result); - return chars; -} - -void TextServerGDNative::font_render_range(RID p_font_rid, const Vector2i &p_size, char32_t p_start, char32_t p_end) { - ERR_FAIL_COND(interface == nullptr); - interface->font_render_range(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size, p_start, p_end); -} - -void TextServerGDNative::font_render_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_index) { - ERR_FAIL_COND(interface == nullptr); - interface->font_render_glyph(data, (godot_rid *)&p_font_rid, (const godot_vector2i *)&p_size, p_index); -} - -void TextServerGDNative::font_draw_glyph(RID p_font_rid, RID p_canvas, int p_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color) const { - ERR_FAIL_COND(interface == nullptr); - interface->font_draw_glyph(data, (godot_rid *)&p_font_rid, (godot_rid *)&p_canvas, p_size, (const godot_vector2 *)&p_pos, p_index, (const godot_color *)&p_color); -} - -void TextServerGDNative::font_draw_glyph_outline(RID p_font_rid, RID p_canvas, int p_size, int p_outline_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color) const { - ERR_FAIL_COND(interface == nullptr); - interface->font_draw_glyph_outline(data, (godot_rid *)&p_font_rid, (godot_rid *)&p_canvas, p_size, p_outline_size, (const godot_vector2 *)&p_pos, p_index, (const godot_color *)&p_color); -} - -bool TextServerGDNative::font_is_language_supported(RID p_font_rid, const String &p_language) const { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->font_is_language_supported(data, (godot_rid *)&p_font_rid, (const godot_string *)&p_language); -} - -void TextServerGDNative::font_set_language_support_override(RID p_font_rid, const String &p_language, bool p_supported) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_language_support_override(data, (godot_rid *)&p_font_rid, (const godot_string *)&p_language, p_supported); -} - -bool TextServerGDNative::font_get_language_support_override(RID p_font_rid, const String &p_language) { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->font_get_language_support_override(data, (godot_rid *)&p_font_rid, (const godot_string *)&p_language); -} - -void TextServerGDNative::font_remove_language_support_override(RID p_font_rid, const String &p_language) { - ERR_FAIL_COND(interface == nullptr); - interface->font_remove_language_support_override(data, (godot_rid *)&p_font_rid, (const godot_string *)&p_language); -} - -Vector<String> TextServerGDNative::font_get_language_support_overrides(RID p_font_rid) { - ERR_FAIL_COND_V(interface == nullptr, PackedStringArray()); - godot_packed_string_array result = interface->font_get_language_support_overrides(data, (godot_rid *)&p_font_rid); - PackedStringArray list = *(PackedStringArray *)&result; - godot_packed_string_array_destroy(&result); - return list; -} - -bool TextServerGDNative::font_is_script_supported(RID p_font_rid, const String &p_script) const { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->font_is_script_supported(data, (godot_rid *)&p_font_rid, (const godot_string *)&p_script); -} - -void TextServerGDNative::font_set_script_support_override(RID p_font_rid, const String &p_script, bool p_supported) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_script_support_override(data, (godot_rid *)&p_font_rid, (const godot_string *)&p_script, p_supported); -} - -bool TextServerGDNative::font_get_script_support_override(RID p_font_rid, const String &p_script) { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->font_get_script_support_override(data, (godot_rid *)&p_font_rid, (const godot_string *)&p_script); -} - -void TextServerGDNative::font_remove_script_support_override(RID p_font_rid, const String &p_script) { - ERR_FAIL_COND(interface == nullptr); - interface->font_remove_script_support_override(data, (godot_rid *)&p_font_rid, (const godot_string *)&p_script); -} - -Vector<String> TextServerGDNative::font_get_script_support_overrides(RID p_font_rid) { - ERR_FAIL_COND_V(interface == nullptr, PackedStringArray()); - godot_packed_string_array result = interface->font_get_script_support_overrides(data, (godot_rid *)&p_font_rid); - PackedStringArray list = *(PackedStringArray *)&result; - godot_packed_string_array_destroy(&result); - return list; -} - -Dictionary TextServerGDNative::font_supported_feature_list(RID p_font_rid) const { - ERR_FAIL_COND_V(interface == nullptr, Dictionary()); - godot_dictionary result = interface->font_supported_feature_list(data, (godot_rid *)&p_font_rid); - Dictionary dict = *(Dictionary *)&result; - godot_dictionary_destroy(&result); - return dict; -} - -Dictionary TextServerGDNative::font_supported_variation_list(RID p_font_rid) const { - ERR_FAIL_COND_V(interface == nullptr, Dictionary()); - godot_dictionary result = interface->font_supported_variation_list(data, (godot_rid *)&p_font_rid); - Dictionary dict = *(Dictionary *)&result; - godot_dictionary_destroy(&result); - return dict; -} - -real_t TextServerGDNative::font_get_global_oversampling() const { - ERR_FAIL_COND_V(interface == nullptr, 0.0f); - return interface->font_get_global_oversampling(data); -} - -void TextServerGDNative::font_set_global_oversampling(real_t p_oversampling) { - ERR_FAIL_COND(interface == nullptr); - interface->font_set_global_oversampling(data, p_oversampling); -} - -/*************************************************************************/ -/* Shaped text buffer interface */ -/*************************************************************************/ - -RID TextServerGDNative::create_shaped_text(TextServer::Direction p_direction, TextServer::Orientation p_orientation) { - ERR_FAIL_COND_V(interface == nullptr, RID()); - godot_rid result = interface->create_shaped_text(data, (godot_int)p_direction, (godot_int)p_orientation); - RID rid = *(RID *)&result; - return rid; -} - -void TextServerGDNative::shaped_text_clear(RID p_shaped) { - ERR_FAIL_COND(interface == nullptr); - interface->shaped_text_clear(data, (godot_rid *)&p_shaped); -} - -void TextServerGDNative::shaped_text_set_direction(RID p_shaped, TextServer::Direction p_direction) { - ERR_FAIL_COND(interface == nullptr); - interface->shaped_text_set_direction(data, (godot_rid *)&p_shaped, (godot_int)p_direction); -} - -TextServer::Direction TextServerGDNative::shaped_text_get_direction(RID p_shaped) const { - ERR_FAIL_COND_V(interface == nullptr, TextServer::DIRECTION_LTR); - return (TextServer::Direction)interface->shaped_text_get_direction(data, (godot_rid *)&p_shaped); -} - -void TextServerGDNative::shaped_text_set_orientation(RID p_shaped, TextServer::Orientation p_orientation) { - ERR_FAIL_COND(interface == nullptr); - interface->shaped_text_set_orientation(data, (godot_rid *)&p_shaped, (godot_int)p_orientation); -} - -TextServer::Orientation TextServerGDNative::shaped_text_get_orientation(RID p_shaped) const { - ERR_FAIL_COND_V(interface == nullptr, TextServer::ORIENTATION_HORIZONTAL); - return (TextServer::Orientation)interface->shaped_text_get_orientation(data, (godot_rid *)&p_shaped); -} - -void TextServerGDNative::shaped_text_set_bidi_override(RID p_shaped, const Vector<Vector2i> &p_override) { - ERR_FAIL_COND(interface == nullptr); - interface->shaped_text_set_bidi_override(data, (godot_rid *)&p_shaped, (const godot_packed_vector2i_array *)&p_override); -} - -void TextServerGDNative::shaped_text_set_preserve_invalid(RID p_shaped, bool p_enabled) { - ERR_FAIL_COND(interface == nullptr); - interface->shaped_text_set_preserve_invalid(data, (godot_rid *)&p_shaped, p_enabled); -} - -bool TextServerGDNative::shaped_text_get_preserve_invalid(RID p_shaped) const { - ERR_FAIL_COND_V(interface == nullptr, false); - return (TextServer::Orientation)interface->shaped_text_get_preserve_invalid(data, (godot_rid *)&p_shaped); -} - -void TextServerGDNative::shaped_text_set_preserve_control(RID p_shaped, bool p_enabled) { - ERR_FAIL_COND(interface == nullptr); - interface->shaped_text_set_preserve_control(data, (godot_rid *)&p_shaped, p_enabled); -} - -bool TextServerGDNative::shaped_text_get_preserve_control(RID p_shaped) const { - ERR_FAIL_COND_V(interface == nullptr, false); - return (TextServer::Orientation)interface->shaped_text_get_preserve_control(data, (godot_rid *)&p_shaped); -} - -bool TextServerGDNative::shaped_text_add_string(RID p_shaped, const String &p_text, const Vector<RID> &p_fonts, int p_size, const Dictionary &p_opentype_features, const String &p_language) { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->shaped_text_add_string(data, (godot_rid *)&p_shaped, (const godot_string *)&p_text, (const godot_rid **)p_fonts.ptr(), p_size, (const godot_dictionary *)&p_opentype_features, (const godot_string *)&p_language); -} - -bool TextServerGDNative::shaped_text_add_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlign p_inline_align, int p_length) { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->shaped_text_add_object(data, (godot_rid *)&p_shaped, (const godot_variant *)&p_key, (const godot_vector2 *)&p_size, (godot_int)p_inline_align, p_length); -} - -bool TextServerGDNative::shaped_text_resize_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlign p_inline_align) { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->shaped_text_resize_object(data, (godot_rid *)&p_shaped, (const godot_variant *)&p_key, (const godot_vector2 *)&p_size, (godot_int)p_inline_align); -} - -RID TextServerGDNative::shaped_text_substr(RID p_shaped, int p_start, int p_length) const { - ERR_FAIL_COND_V(interface == nullptr, RID()); - godot_rid result = interface->shaped_text_substr(data, (godot_rid *)&p_shaped, (godot_int)p_start, (godot_int)p_length); - RID rid = *(RID *)&result; - return rid; -} - -RID TextServerGDNative::shaped_text_get_parent(RID p_shaped) const { - ERR_FAIL_COND_V(interface == nullptr, RID()); - godot_rid result = interface->shaped_text_get_parent(data, (godot_rid *)&p_shaped); - RID rid = *(RID *)&result; - return rid; -} - -real_t TextServerGDNative::shaped_text_fit_to_width(RID p_shaped, real_t p_width, uint8_t p_jst_flags) { - ERR_FAIL_COND_V(interface == nullptr, 0.f); - return interface->shaped_text_fit_to_width(data, (godot_rid *)&p_shaped, p_width, p_jst_flags); -} - -real_t TextServerGDNative::shaped_text_tab_align(RID p_shaped, const Vector<real_t> &p_tab_stops) { - ERR_FAIL_COND_V(interface == nullptr, 0.f); - return interface->shaped_text_tab_align(data, (godot_rid *)&p_shaped, (godot_packed_float32_array *)&p_tab_stops); -} - -bool TextServerGDNative::shaped_text_shape(RID p_shaped) { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->shaped_text_shape(data, (godot_rid *)&p_shaped); -} - -bool TextServerGDNative::shaped_text_update_breaks(RID p_shaped) { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->shaped_text_update_breaks(data, (godot_rid *)&p_shaped); -} - -bool TextServerGDNative::shaped_text_update_justification_ops(RID p_shaped) { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->shaped_text_update_justification_ops(data, (godot_rid *)&p_shaped); -} - -void TextServerGDNative::shaped_text_overrun_trim_to_width(RID p_shaped_line, real_t p_width, uint8_t p_trim_flags) { - ERR_FAIL_COND(interface == nullptr); - interface->shaped_text_overrun_trim_to_width(data, (godot_rid *)&p_shaped_line, p_width, p_trim_flags); -}; - -bool TextServerGDNative::shaped_text_is_ready(RID p_shaped) const { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->shaped_text_is_ready(data, (godot_rid *)&p_shaped); -} - -Vector<TextServer::Glyph> TextServerGDNative::shaped_text_get_glyphs(RID p_shaped) const { - ERR_FAIL_COND_V(interface == nullptr, Vector<TextServer::Glyph>()); - godot_packed_glyph_array result = interface->shaped_text_get_glyphs(data, (godot_rid *)&p_shaped); - Vector<TextServer::Glyph> glyphs = *(Vector<TextServer::Glyph> *)&result; - godot_packed_glyph_array_destroy(&result); - return glyphs; -} - -Vector2i TextServerGDNative::shaped_text_get_range(RID p_shaped) const { - ERR_FAIL_COND_V(interface == nullptr, Vector2i()); - godot_vector2i result = interface->shaped_text_get_range(data, (godot_rid *)&p_shaped); - Vector2i range = *(Vector2i *)&result; - return range; -} - -Vector<TextServer::Glyph> TextServerGDNative::shaped_text_sort_logical(RID p_shaped) { - ERR_FAIL_COND_V(interface == nullptr, Vector<TextServer::Glyph>()); - godot_packed_glyph_array result = interface->shaped_text_sort_logical(data, (godot_rid *)&p_shaped); - Vector<TextServer::Glyph> glyphs = *(Vector<TextServer::Glyph> *)&result; - godot_packed_glyph_array_destroy(&result); - return glyphs; -} - -Vector<Vector2i> TextServerGDNative::shaped_text_get_line_breaks_adv(RID p_shaped, const Vector<real_t> &p_width, int p_start, bool p_once, uint8_t p_break_flags) const { - ERR_FAIL_COND_V(interface == nullptr, Vector<Vector2i>()); - if (interface->shaped_text_get_line_breaks_adv != nullptr) { - godot_packed_vector2i_array result = interface->shaped_text_get_line_breaks_adv(data, (godot_rid *)&p_shaped, (godot_packed_float32_array *)&p_width, p_start, p_once, p_break_flags); - Vector<Vector2i> breaks = *(Vector<Vector2i> *)&result; - godot_packed_vector2i_array_destroy(&result); - return breaks; - } else { - return TextServer::shaped_text_get_line_breaks_adv(p_shaped, p_width, p_break_flags); - } -} - -Vector<Vector2i> TextServerGDNative::shaped_text_get_line_breaks(RID p_shaped, real_t p_width, int p_start, uint8_t p_break_flags) const { - ERR_FAIL_COND_V(interface == nullptr, Vector<Vector2i>()); - if (interface->shaped_text_get_line_breaks != nullptr) { - godot_packed_vector2i_array result = interface->shaped_text_get_line_breaks(data, (godot_rid *)&p_shaped, p_width, p_start, p_break_flags); - Vector<Vector2i> breaks = *(Vector<Vector2i> *)&result; - godot_packed_vector2i_array_destroy(&result); - return breaks; - } else { - return TextServer::shaped_text_get_line_breaks(p_shaped, p_width, p_break_flags); - } -} - -Vector<Vector2i> TextServerGDNative::shaped_text_get_word_breaks(RID p_shaped, int p_grapheme_flags) const { - ERR_FAIL_COND_V(interface == nullptr, Vector<Vector2i>()); - if (interface->shaped_text_get_word_breaks != nullptr) { - godot_packed_vector2i_array result = interface->shaped_text_get_word_breaks(data, (godot_rid *)&p_shaped, p_grapheme_flags); - Vector<Vector2i> breaks = *(Vector<Vector2i> *)&result; - godot_packed_vector2i_array_destroy(&result); - return breaks; - } else { - return TextServer::shaped_text_get_word_breaks(p_shaped, p_grapheme_flags); - } -} - -Array TextServerGDNative::shaped_text_get_objects(RID p_shaped) const { - ERR_FAIL_COND_V(interface == nullptr, Array()); - godot_array result = interface->shaped_text_get_objects(data, (godot_rid *)&p_shaped); - Array rect = *(Array *)&result; - return rect; -} - -Rect2 TextServerGDNative::shaped_text_get_object_rect(RID p_shaped, Variant p_key) const { - ERR_FAIL_COND_V(interface == nullptr, Rect2()); - godot_rect2 result = interface->shaped_text_get_object_rect(data, (godot_rid *)&p_shaped, (const godot_variant *)&p_key); - Rect2 rect = *(Rect2 *)&result; - return rect; -} - -Size2 TextServerGDNative::shaped_text_get_size(RID p_shaped) const { - ERR_FAIL_COND_V(interface == nullptr, Size2()); - godot_vector2 result = interface->shaped_text_get_size(data, (godot_rid *)&p_shaped); - Size2 size = *(Size2 *)&result; - return size; -} - -real_t TextServerGDNative::shaped_text_get_ascent(RID p_shaped) const { - ERR_FAIL_COND_V(interface == nullptr, 0.f); - return interface->shaped_text_get_ascent(data, (godot_rid *)&p_shaped); -} - -real_t TextServerGDNative::shaped_text_get_descent(RID p_shaped) const { - ERR_FAIL_COND_V(interface == nullptr, 0.f); - return interface->shaped_text_get_descent(data, (godot_rid *)&p_shaped); -} - -real_t TextServerGDNative::shaped_text_get_width(RID p_shaped) const { - ERR_FAIL_COND_V(interface == nullptr, 0.f); - return interface->shaped_text_get_width(data, (godot_rid *)&p_shaped); -} - -real_t TextServerGDNative::shaped_text_get_underline_position(RID p_shaped) const { - ERR_FAIL_COND_V(interface == nullptr, 0.f); - return interface->shaped_text_get_underline_position(data, (godot_rid *)&p_shaped); -} - -real_t TextServerGDNative::shaped_text_get_underline_thickness(RID p_shaped) const { - ERR_FAIL_COND_V(interface == nullptr, 0.f); - return interface->shaped_text_get_underline_thickness(data, (godot_rid *)&p_shaped); -} - -String TextServerGDNative::format_number(const String &p_string, const String &p_language) const { - ERR_FAIL_COND_V(interface == nullptr, String()); - godot_string result = interface->format_number(data, (const godot_string *)&p_string, (const godot_string *)&p_language); - if (interface->format_number == nullptr) { - return p_string; - } - String ret = *(String *)&result; - godot_string_destroy(&result); - return ret; -} - -String TextServerGDNative::parse_number(const String &p_string, const String &p_language) const { - ERR_FAIL_COND_V(interface == nullptr, String()); - if (interface->parse_number == nullptr) { - return p_string; - } - godot_string result = interface->parse_number(data, (const godot_string *)&p_string, (const godot_string *)&p_language); - String ret = *(String *)&result; - godot_string_destroy(&result); - return ret; -} - -String TextServerGDNative::percent_sign(const String &p_language) const { - ERR_FAIL_COND_V(interface == nullptr, String()); - if (interface->percent_sign == nullptr) { - return "%"; - } - godot_string result = interface->percent_sign(data, (const godot_string *)&p_language); - String ret = *(String *)&result; - godot_string_destroy(&result); - return ret; -} - -TextServer *TextServerGDNative::create_func(Error &r_error, void *p_user_data) { - const godot_text_interface_gdnative *interface = (const godot_text_interface_gdnative *)p_user_data; - r_error = OK; - - TextServerGDNative *server = memnew(TextServerGDNative()); - server->interface = interface; - server->data = interface->constructor((godot_object *)server); - - return server; -} - -TextServerGDNative::TextServerGDNative() { - data = nullptr; - interface = nullptr; -} - -TextServerGDNative::~TextServerGDNative() { - if (interface != nullptr) { - interface->destructor(data); - data = nullptr; - interface = nullptr; - } -} - -/*************************************************************************/ -/* GDNative functions */ -/*************************************************************************/ - -#ifdef __cplusplus -extern "C" { -#endif - -static_assert(sizeof(godot_glyph) == sizeof(TextServer::Glyph), "Glyph size mismatch"); -static_assert(sizeof(godot_packed_glyph_array) == sizeof(Vector<TextServer::Glyph>), "Vector<Glyph> size mismatch"); - -void GDAPI godot_text_register_interface(const godot_text_interface_gdnative *p_interface, const godot_string *p_name, uint32_t p_features) { - ERR_FAIL_COND(p_interface->version.major != 1); - String name = *(String *)p_name; - TextServerManager::register_create_function(name + "(GDNative)", p_features, TextServerGDNative::create_func, (void *)p_interface); -} - -// Glyph - -void GDAPI godot_glyph_new(godot_glyph *r_dest) { - TextServer::Glyph *dest = (TextServer::Glyph *)r_dest; - *dest = TextServer::Glyph(); -} - -godot_vector2i GDAPI godot_glyph_get_range(const godot_glyph *p_self) { - godot_vector2i dest; - Vector2i *d = (Vector2i *)&dest; - const TextServer::Glyph *self = (const TextServer::Glyph *)p_self; - d->x = self->start; - d->y = self->end; - return dest; -} - -void GDAPI godot_glyph_set_range(godot_glyph *p_self, const godot_vector2i *p_range) { - TextServer::Glyph *self = (TextServer::Glyph *)p_self; - const Vector2i *range = (const Vector2i *)p_range; - self->start = range->x; - self->end = range->y; -} - -godot_int GDAPI godot_glyph_get_count(const godot_glyph *p_self) { - const TextServer::Glyph *self = (const TextServer::Glyph *)p_self; - return self->count; -} - -void GDAPI godot_glyph_set_count(godot_glyph *p_self, godot_int p_count) { - TextServer::Glyph *self = (TextServer::Glyph *)p_self; - self->count = p_count; -} - -godot_int GDAPI godot_glyph_get_repeat(const godot_glyph *p_self) { - const TextServer::Glyph *self = (const TextServer::Glyph *)p_self; - return self->repeat; -} - -void GDAPI godot_glyph_set_repeat(godot_glyph *p_self, godot_int p_repeat) { - TextServer::Glyph *self = (TextServer::Glyph *)p_self; - self->repeat = p_repeat; -} - -godot_int GDAPI godot_glyph_get_flags(const godot_glyph *p_self) { - const TextServer::Glyph *self = (const TextServer::Glyph *)p_self; - return self->flags; -} - -void GDAPI godot_glyph_set_flags(godot_glyph *p_self, godot_int p_flags) { - TextServer::Glyph *self = (TextServer::Glyph *)p_self; - self->flags = p_flags; -} - -godot_vector2 GDAPI godot_glyph_get_offset(const godot_glyph *p_self) { - godot_vector2 dest; - Vector2 *d = (Vector2 *)&dest; - const TextServer::Glyph *self = (const TextServer::Glyph *)p_self; - d->x = self->x_off; - d->y = self->y_off; - return dest; -} - -void GDAPI godot_glyph_set_offset(godot_glyph *p_self, const godot_vector2 *p_offset) { - TextServer::Glyph *self = (TextServer::Glyph *)p_self; - const Vector2 *offset = (const Vector2 *)p_offset; - self->x_off = offset->x; - self->y_off = offset->y; -} - -godot_real_t GDAPI godot_glyph_get_advance(const godot_glyph *p_self) { - const TextServer::Glyph *self = (const TextServer::Glyph *)p_self; - return self->advance; -} - -void GDAPI godot_glyph_set_advance(godot_glyph *p_self, godot_real_t p_advance) { - TextServer::Glyph *self = (TextServer::Glyph *)p_self; - self->advance = p_advance; -} - -godot_rid GDAPI godot_glyph_get_font(const godot_glyph *p_self) { - godot_rid dest; - RID *d = (RID *)&dest; - const TextServer::Glyph *self = (const TextServer::Glyph *)p_self; - *d = self->font_rid; - return dest; -} - -void GDAPI godot_glyph_set_font(godot_glyph *p_self, godot_rid *p_font) { - TextServer::Glyph *self = (TextServer::Glyph *)p_self; - const RID *font = (const RID *)p_font; - self->font_rid = *font; -} - -godot_int GDAPI godot_glyph_get_font_size(const godot_glyph *p_self) { - const TextServer::Glyph *self = (const TextServer::Glyph *)p_self; - return self->font_size; -} - -void GDAPI godot_glyph_set_font_size(godot_glyph *p_self, godot_int p_size) { - TextServer::Glyph *self = (TextServer::Glyph *)p_self; - self->font_size = p_size; -} - -godot_int GDAPI godot_glyph_get_index(const godot_glyph *p_self) { - const TextServer::Glyph *self = (const TextServer::Glyph *)p_self; - return self->index; -} - -void GDAPI godot_glyph_set_index(godot_glyph *p_self, godot_int p_index) { - TextServer::Glyph *self = (TextServer::Glyph *)p_self; - self->index = p_index; -} - -// GlyphArray - -void GDAPI godot_packed_glyph_array_new(godot_packed_glyph_array *r_dest) { - Vector<TextServer::Glyph> *dest = (Vector<TextServer::Glyph> *)r_dest; - memnew_placement(dest, Vector<TextServer::Glyph>); -} - -void GDAPI godot_packed_glyph_array_new_copy(godot_packed_glyph_array *r_dest, const godot_packed_glyph_array *p_src) { - Vector<TextServer::Glyph> *dest = (Vector<TextServer::Glyph> *)r_dest; - const Vector<TextServer::Glyph> *src = (const Vector<TextServer::Glyph> *)p_src; - memnew_placement(dest, Vector<TextServer::Glyph>(*src)); -} - -const godot_glyph GDAPI *godot_packed_glyph_array_ptr(const godot_packed_glyph_array *p_self) { - const Vector<TextServer::Glyph> *self = (const Vector<TextServer::Glyph> *)p_self; - return (const godot_glyph *)self->ptr(); -} - -godot_glyph GDAPI *godot_packed_glyph_array_ptrw(godot_packed_glyph_array *p_self) { - Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self; - return (godot_glyph *)self->ptrw(); -} - -void GDAPI godot_packed_glyph_array_append(godot_packed_glyph_array *p_self, const godot_glyph *p_data) { - Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self; - TextServer::Glyph &s = *(TextServer::Glyph *)p_data; - self->push_back(s); -} - -void GDAPI godot_packed_glyph_array_append_array(godot_packed_glyph_array *p_self, const godot_packed_glyph_array *p_array) { - Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self; - Vector<TextServer::Glyph> *array = (Vector<TextServer::Glyph> *)p_array; - self->append_array(*array); -} - -godot_error GDAPI godot_packed_glyph_array_insert(godot_packed_glyph_array *p_self, const godot_int p_idx, const godot_glyph *p_data) { - Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self; - TextServer::Glyph &s = *(TextServer::Glyph *)p_data; - return (godot_error)self->insert(p_idx, s); -} - -godot_bool GDAPI godot_packed_glyph_array_has(godot_packed_glyph_array *p_self, const godot_glyph *p_value) { - Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self; - TextServer::Glyph &v = *(TextServer::Glyph *)p_value; - return (godot_bool)self->has(v); -} - -void GDAPI godot_packed_glyph_array_sort(godot_packed_glyph_array *p_self) { - Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self; - self->sort(); -} - -void GDAPI godot_packed_glyph_array_reverse(godot_packed_glyph_array *p_self) { - Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self; - self->reverse(); -} - -void GDAPI godot_packed_glyph_array_push_back(godot_packed_glyph_array *p_self, const godot_glyph *p_data) { - Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self; - TextServer::Glyph &s = *(TextServer::Glyph *)p_data; - self->push_back(s); -} - -void GDAPI godot_packed_glyph_array_remove(godot_packed_glyph_array *p_self, const godot_int p_idx) { - Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self; - self->remove(p_idx); -} - -void GDAPI godot_packed_glyph_array_resize(godot_packed_glyph_array *p_self, const godot_int p_size) { - Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self; - self->resize(p_size); -} - -void GDAPI godot_packed_glyph_array_set(godot_packed_glyph_array *p_self, const godot_int p_idx, const godot_glyph *p_data) { - Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self; - TextServer::Glyph &s = *(TextServer::Glyph *)p_data; - self->set(p_idx, s); -} - -godot_glyph GDAPI godot_packed_glyph_array_get(const godot_packed_glyph_array *p_self, const godot_int p_idx) { - const Vector<TextServer::Glyph> *self = (const Vector<TextServer::Glyph> *)p_self; - godot_glyph v; - TextServer::Glyph *s = (TextServer::Glyph *)&v; - *s = self->get(p_idx); - return v; -} - -godot_int GDAPI godot_packed_glyph_array_size(const godot_packed_glyph_array *p_self) { - const Vector<TextServer::Glyph> *self = (const Vector<TextServer::Glyph> *)p_self; - return self->size(); -} - -godot_bool GDAPI godot_packed_glyph_array_is_empty(const godot_packed_glyph_array *p_self) { - const Vector<TextServer::Glyph> *self = (const Vector<TextServer::Glyph> *)p_self; - return self->is_empty(); -} - -void GDAPI godot_packed_glyph_array_destroy(godot_packed_glyph_array *p_self) { - ((Vector<TextServer::Glyph> *)p_self)->~Vector(); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/text/text_server_gdnative.h b/modules/gdnative/text/text_server_gdnative.h deleted file mode 100644 index f081637e23..0000000000 --- a/modules/gdnative/text/text_server_gdnative.h +++ /dev/null @@ -1,254 +0,0 @@ -/*************************************************************************/ -/* text_server_gdnative.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 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 TEXT_SERVER_GDNATIVE_H -#define TEXT_SERVER_GDNATIVE_H - -#include "modules/gdnative/gdnative.h" - -#include "servers/text_server.h" - -class TextServerGDNative : public TextServer { - GDCLASS(TextServerGDNative, TextServer); - - const godot_text_interface_gdnative *interface = nullptr; - void *data = nullptr; - -protected: - static void _bind_methods(){}; - -public: - virtual bool has_feature(Feature p_feature) override; - virtual String get_name() const override; - - virtual void free(RID p_rid) override; - virtual bool has(RID p_rid) override; - virtual bool load_support_data(const String &p_filename) override; - -#ifdef TOOLS_ENABLED - virtual String get_support_data_filename() override; - virtual String get_support_data_info() override; - virtual bool save_support_data(const String &p_filename) override; -#endif - - virtual bool is_locale_right_to_left(const String &p_locale) override; - - virtual int32_t name_to_tag(const String &p_name) const override; - virtual String tag_to_name(int32_t p_tag) const override; - - /* Font interface */ - virtual RID create_font() override; - - virtual void font_set_data(RID p_font_rid, const PackedByteArray &p_data) override; - virtual void font_set_data_ptr(RID p_font_rid, const uint8_t *p_data_ptr, size_t p_data_size) override; - - virtual void font_set_antialiased(RID p_font_rid, bool p_antialiased) override; - virtual bool font_is_antialiased(RID p_font_rid) const override; - - virtual void font_set_multichannel_signed_distance_field(RID p_font_rid, bool p_msdf) override; - virtual bool font_is_multichannel_signed_distance_field(RID p_font_rid) const override; - - virtual void font_set_msdf_pixel_range(RID p_font_rid, int p_msdf_pixel_range) override; - virtual int font_get_msdf_pixel_range(RID p_font_rid) const override; - - virtual void font_set_msdf_size(RID p_font_rid, int p_msdf_size) override; - virtual int font_get_msdf_size(RID p_font_rid) const override; - - virtual void font_set_fixed_size(RID p_font_rid, int p_fixed_size) override; - virtual int font_get_fixed_size(RID p_font_rid) const override; - - virtual void font_set_force_autohinter(RID p_font_rid, bool p_force_autohinter) override; - virtual bool font_is_force_autohinter(RID p_font_rid) const override; - - virtual void font_set_hinting(RID p_font_rid, TextServer::Hinting p_hinting) override; - virtual TextServer::Hinting font_get_hinting(RID p_font_rid) const override; - - virtual void font_set_variation_coordinates(RID p_font_rid, const Dictionary &p_variation_coordinates) override; - virtual Dictionary font_get_variation_coordinates(RID p_font_rid) const override; - - virtual void font_set_oversampling(RID p_font_rid, real_t p_oversampling) override; - virtual real_t font_get_oversampling(RID p_font_rid) const override; - - virtual Array font_get_size_cache_list(RID p_font_rid) const override; - virtual void font_clear_size_cache(RID p_font_rid) override; - virtual void font_remove_size_cache(RID p_font_rid, const Vector2i &p_size) override; - - virtual void font_set_ascent(RID p_font_rid, int p_size, real_t p_ascent) override; - virtual real_t font_get_ascent(RID p_font_rid, int p_size) const override; - - virtual void font_set_descent(RID p_font_rid, int p_size, real_t p_descent) override; - virtual real_t font_get_descent(RID p_font_rid, int p_size) const override; - - virtual void font_set_underline_position(RID p_font_rid, int p_size, real_t p_underline_position) override; - virtual real_t font_get_underline_position(RID p_font_rid, int p_size) const override; - - virtual void font_set_underline_thickness(RID p_font_rid, int p_size, real_t p_underline_thickness) override; - virtual real_t font_get_underline_thickness(RID p_font_rid, int p_size) const override; - - virtual void font_set_scale(RID p_font_rid, int p_size, real_t p_scale) override; - virtual real_t font_get_scale(RID p_font_rid, int p_size) const override; - - virtual void font_set_spacing(RID p_font_rid, int p_size, SpacingType p_spacing, int p_value) override; - virtual int font_get_spacing(RID p_font_rid, int p_size, SpacingType p_spacing) const override; - - virtual int font_get_texture_count(RID p_font_rid, const Vector2i &p_size) const override; - virtual void font_clear_textures(RID p_font_rid, const Vector2i &p_size) override; - virtual void font_remove_texture(RID p_font_rid, const Vector2i &p_size, int p_texture_index) override; - - virtual void font_set_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const Ref<Image> &p_image) override; - virtual Ref<Image> font_get_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const override; - - virtual void font_set_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const PackedInt32Array &p_offset) override; - virtual PackedInt32Array font_get_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const override; - - virtual Array font_get_glyph_list(RID p_font_rid, const Vector2i &p_size) const override; - virtual void font_clear_glyphs(RID p_font_rid, const Vector2i &p_size) override; - virtual void font_remove_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) override; - - virtual Vector2 font_get_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph) const override; - virtual void font_set_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph, const Vector2 &p_advance) override; - - virtual Vector2 font_get_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const override; - virtual void font_set_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_offset) override; - - virtual Vector2 font_get_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const override; - virtual void font_set_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_gl_size) override; - - virtual Rect2 font_get_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const override; - virtual void font_set_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Rect2 &p_uv_rect) override; - - virtual int font_get_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const override; - virtual void font_set_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, int p_texture_idx) override; - - virtual bool font_get_glyph_contours(RID p_font, int p_size, int32_t p_index, Vector<Vector3> &r_points, Vector<int32_t> &r_contours, bool &r_orientation) const override; - - virtual Array font_get_kerning_list(RID p_font_rid, int p_size) const override; - virtual void font_clear_kerning_map(RID p_font_rid, int p_size) override; - virtual void font_remove_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) override; - - virtual void font_set_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) override; - virtual Vector2 font_get_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) const override; - - virtual int32_t font_get_glyph_index(RID p_font_rid, int p_size, char32_t p_char, char32_t p_variation_selector = 0) const override; - - virtual bool font_has_char(RID p_font_rid, char32_t p_char) const override; - virtual String font_get_supported_chars(RID p_font_rid) const override; - - virtual void font_render_range(RID p_font, const Vector2i &p_size, char32_t p_start, char32_t p_end) override; - virtual void font_render_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_index) override; - - virtual void font_draw_glyph(RID p_font, RID p_canvas, int p_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color = Color(1, 1, 1)) const override; - virtual void font_draw_glyph_outline(RID p_font, RID p_canvas, int p_size, int p_outline_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color = Color(1, 1, 1)) const override; - - virtual bool font_is_language_supported(RID p_font_rid, const String &p_language) const override; - virtual void font_set_language_support_override(RID p_font_rid, const String &p_language, bool p_supported) override; - virtual bool font_get_language_support_override(RID p_font_rid, const String &p_language) override; - virtual void font_remove_language_support_override(RID p_font_rid, const String &p_language) override; - virtual Vector<String> font_get_language_support_overrides(RID p_font_rid) override; - - virtual bool font_is_script_supported(RID p_font_rid, const String &p_script) const override; - virtual void font_set_script_support_override(RID p_font_rid, const String &p_script, bool p_supported) override; - virtual bool font_get_script_support_override(RID p_font_rid, const String &p_script) override; - virtual void font_remove_script_support_override(RID p_font_rid, const String &p_script) override; - virtual Vector<String> font_get_script_support_overrides(RID p_font_rid) override; - - virtual Dictionary font_supported_feature_list(RID p_font_rid) const override; - virtual Dictionary font_supported_variation_list(RID p_font_rid) const override; - - virtual real_t font_get_global_oversampling() const override; - virtual void font_set_global_oversampling(real_t p_oversampling) override; - - /* Shaped text buffer interface */ - - virtual RID create_shaped_text(Direction p_direction = DIRECTION_AUTO, Orientation p_orientation = ORIENTATION_HORIZONTAL) override; - - virtual void shaped_text_clear(RID p_shaped) override; - - virtual void shaped_text_set_direction(RID p_shaped, Direction p_direction = DIRECTION_AUTO) override; - virtual Direction shaped_text_get_direction(RID p_shaped) const override; - - virtual void shaped_text_set_bidi_override(RID p_shaped, const Vector<Vector2i> &p_override) override; - - virtual void shaped_text_set_orientation(RID p_shaped, Orientation p_orientation = ORIENTATION_HORIZONTAL) override; - virtual Orientation shaped_text_get_orientation(RID p_shaped) const override; - - virtual void shaped_text_set_preserve_invalid(RID p_shaped, bool p_enabled) override; - virtual bool shaped_text_get_preserve_invalid(RID p_shaped) const override; - - virtual void shaped_text_set_preserve_control(RID p_shaped, bool p_enabled) override; - virtual bool shaped_text_get_preserve_control(RID p_shaped) const override; - - virtual bool shaped_text_add_string(RID p_shaped, const String &p_text, const Vector<RID> &p_fonts, int p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "") override; - virtual bool shaped_text_add_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlign p_inline_align = INLINE_ALIGN_CENTER, int p_length = 1) override; - virtual bool shaped_text_resize_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlign p_inline_align = INLINE_ALIGN_CENTER) override; - - virtual RID shaped_text_substr(RID p_shaped, int p_start, int p_length) const override; - virtual RID shaped_text_get_parent(RID p_shaped) const override; - - virtual real_t shaped_text_fit_to_width(RID p_shaped, real_t p_width, uint8_t /*JustificationFlag*/ p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) override; - virtual real_t shaped_text_tab_align(RID p_shaped, const Vector<real_t> &p_tab_stops) override; - - virtual bool shaped_text_shape(RID p_shaped) override; - virtual bool shaped_text_update_breaks(RID p_shaped) override; - virtual bool shaped_text_update_justification_ops(RID p_shaped) override; - - virtual void shaped_text_overrun_trim_to_width(RID p_shaped, real_t p_width, uint8_t p_trim_flags) override; - - virtual bool shaped_text_is_ready(RID p_shaped) const override; - - virtual Vector<Glyph> shaped_text_get_glyphs(RID p_shaped) const override; - - virtual Vector2i shaped_text_get_range(RID p_shaped) const override; - - virtual Vector<Glyph> shaped_text_sort_logical(RID p_shaped) override; - virtual Vector<Vector2i> shaped_text_get_line_breaks_adv(RID p_shaped, const Vector<real_t> &p_width, int p_start = 0, bool p_once = true, uint8_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const override; - virtual Vector<Vector2i> shaped_text_get_line_breaks(RID p_shaped, real_t p_width, int p_start = 0, uint8_t p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const override; - virtual Vector<Vector2i> shaped_text_get_word_breaks(RID p_shaped, int p_grapheme_flags = GRAPHEME_IS_SPACE | GRAPHEME_IS_PUNCTUATION) const override; - virtual Array shaped_text_get_objects(RID p_shaped) const override; - virtual Rect2 shaped_text_get_object_rect(RID p_shaped, Variant p_key) const override; - - virtual Size2 shaped_text_get_size(RID p_shaped) const override; - virtual real_t shaped_text_get_ascent(RID p_shaped) const override; - virtual real_t shaped_text_get_descent(RID p_shaped) const override; - virtual real_t shaped_text_get_width(RID p_shaped) const override; - virtual real_t shaped_text_get_underline_position(RID p_shaped) const override; - virtual real_t shaped_text_get_underline_thickness(RID p_shaped) const override; - - virtual String format_number(const String &p_string, const String &p_language = "") const override; - virtual String parse_number(const String &p_string, const String &p_language = "") const override; - virtual String percent_sign(const String &p_language = "") const override; - - static TextServer *create_func(Error &r_error, void *p_user_data); - - TextServerGDNative(); - ~TextServerGDNative(); -}; - -#endif // TEXT_SERVER_GDNATIVE_H |