diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-11-28 14:47:55 +0200 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2023-01-19 13:12:21 +0200 |
commit | abca497b7223eed94ae4cbd65119ddfce7941027 (patch) | |
tree | f9c7ff27533e4ee848746ddedcb11e4be0ea2e23 /src | |
parent | 69b525494bf41097edc86d44b1d4b11ddfeb2440 (diff) | |
download | redot-cpp-abca497b7223eed94ae4cbd65119ddfce7941027.tar.gz |
Expose some low level functions and String operators.
Diffstat (limited to 'src')
-rw-r--r-- | src/classes/low_level.cpp | 58 | ||||
-rw-r--r-- | src/variant/char_string.cpp | 49 |
2 files changed, 99 insertions, 8 deletions
diff --git a/src/classes/low_level.cpp b/src/classes/low_level.cpp new file mode 100644 index 0000000..b984187 --- /dev/null +++ b/src/classes/low_level.cpp @@ -0,0 +1,58 @@ +/**************************************************************************/ +/* low_level.cpp */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* 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 <godot_cpp/classes/file_access.hpp> +#include <godot_cpp/classes/worker_thread_pool.hpp> +#include <godot_cpp/classes/xml_parser.hpp> + +#include <godot_cpp/godot.hpp> + +namespace godot { +Error XMLParser::_open_buffer(const uint8_t *p_buffer, size_t p_size) { + return (Error)internal::gde_interface->xml_parser_open_buffer(_owner, p_buffer, p_size); +} + +uint64_t FileAccess::get_buffer(uint8_t *p_dst, uint64_t p_length) const { + return internal::gde_interface->file_access_get_buffer(_owner, p_dst, p_length); +} + +void FileAccess::store_buffer(const uint8_t *p_src, uint64_t p_length) { + internal::gde_interface->file_access_store_buffer(_owner, p_src, p_length); +} + +WorkerThreadPool::TaskID WorkerThreadPool::add_native_task(void (*p_func)(void *), void *p_userdata, bool p_high_priority, const String &p_description) { + return (TaskID)internal::gde_interface->worker_thread_pool_add_native_task(_owner, p_func, p_userdata, p_high_priority, (const GDExtensionStringPtr)&p_description); +} + +WorkerThreadPool::GroupID WorkerThreadPool::add_native_group_task(void (*p_func)(void *, uint32_t), void *p_userdata, int p_elements, int p_tasks, bool p_high_priority, const String &p_description) { + return (GroupID)internal::gde_interface->worker_thread_pool_add_native_group_task(_owner, p_func, p_userdata, p_elements, p_tasks, p_high_priority, (const GDExtensionStringPtr)&p_description); +} + +} // namespace godot diff --git a/src/variant/char_string.cpp b/src/variant/char_string.cpp index e6b596f..a9c170e 100644 --- a/src/variant/char_string.cpp +++ b/src/variant/char_string.cpp @@ -332,20 +332,49 @@ bool String::operator!=(const char32_t *p_str) const { return *this != String(p_str); } -String String::operator+(const char *p_chr) { - return *this + String(p_chr); +String String::operator+(const char *p_str) { + return *this + String(p_str); } -String String::operator+(const wchar_t *p_chr) { - return *this + String(p_chr); +String String::operator+(const wchar_t *p_str) { + return *this + String(p_str); } -String String::operator+(const char16_t *p_chr) { - return *this + String(p_chr); +String String::operator+(const char16_t *p_str) { + return *this + String(p_str); } -String String::operator+(const char32_t *p_chr) { - return *this + String(p_chr); +String String::operator+(const char32_t *p_str) { + return *this + String(p_str); +} + +String String::operator+(const char32_t p_char) { + return *this + String::chr(p_char); +} + +String &String::operator+=(const String &p_str) { + internal::gde_interface->string_operator_plus_eq_string((GDExtensionStringPtr)this, (const GDExtensionStringPtr)&p_str); + return *this; +} + +String &String::operator+=(char32_t p_char) { + internal::gde_interface->string_operator_plus_eq_char((GDExtensionStringPtr)this, p_char); + return *this; +} + +String &String::operator+=(const char *p_str) { + internal::gde_interface->string_operator_plus_eq_cstr((GDExtensionStringPtr)this, p_str); + return *this; +} + +String &String::operator+=(const wchar_t *p_str) { + internal::gde_interface->string_operator_plus_eq_wcstr((GDExtensionStringPtr)this, p_str); + return *this; +} + +String &String::operator+=(const char32_t *p_str) { + internal::gde_interface->string_operator_plus_eq_c32str((GDExtensionStringPtr)this, p_str); + return *this; } const char32_t &String::operator[](int p_index) const { @@ -412,6 +441,10 @@ String operator+(const char32_t *p_chr, const String &p_str) { return String(p_chr) + p_str; } +String operator+(char32_t p_char, const String &p_str) { + return String::chr(p_char) + p_str; +} + StringName::StringName(const char *from) : StringName(String(from)) {} |