[TextServer, GDExtension] Fix building text servers as GDExtension, expose new/changed low-level methods to GDExtension API.

pull/1479/head
bruvzg 2024-06-02 21:22:06 +03:00
parent c5986e666f
commit 2360f84513
No known key found for this signature in database
GPG Key ID: 7960FCF39844EC38
7 changed files with 519 additions and 16 deletions

View File

@ -733,9 +733,9 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
# Special cases.
if class_name == "String":
result.append("\tstatic String utf8(const char *from, int64_t len = -1);")
result.append("\tvoid parse_utf8(const char *from, int64_t len = -1);")
result.append("\tError parse_utf8(const char *from, int64_t len = -1);")
result.append("\tstatic String utf16(const char16_t *from, int64_t len = -1);")
result.append("\tvoid parse_utf16(const char16_t *from, int64_t len = -1);")
result.append("\tError parse_utf16(const char16_t *from, int64_t len = -1, bool default_little_endian = true);")
result.append("\tCharString utf8() const;")
result.append("\tCharString ascii() const;")
result.append("\tChar16String utf16() const;")
@ -1601,6 +1601,10 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
if class_name == "XMLParser":
result.append("\tError _open_buffer(const uint8_t *p_buffer, size_t p_size);")
if class_name == "Image":
result.append("\tuint8_t *ptrw();")
result.append("\tconst uint8_t *ptr();")
if class_name == "FileAccess":
result.append("\tuint64_t get_buffer(uint8_t *p_dst, uint64_t p_length) const;")
result.append("\tvoid store_buffer(const uint8_t *p_src, uint64_t p_length);")

View File

@ -3,9 +3,9 @@
"version_major": 4,
"version_minor": 3,
"version_patch": 0,
"version_status": "beta1",
"version_build": "official",
"version_full_name": "Godot Engine v4.3.beta1.official"
"version_status": "beta",
"version_build": "custom_build",
"version_full_name": "Godot Engine v4.3.beta.custom_build"
},
"builtin_class_sizes": [
{
@ -20086,6 +20086,24 @@
"is_const": true,
"is_static": false,
"hash": 3918633141
},
{
"name": "recursive_equal",
"return_type": "bool",
"is_vararg": false,
"is_const": true,
"is_static": false,
"hash": 1404404751,
"arguments": [
{
"name": "dictionary",
"type": "Dictionary"
},
{
"name": "recursion_count",
"type": "int"
}
]
}
],
"constructors": [
@ -28951,7 +28969,7 @@
"is_vararg": false,
"is_static": false,
"is_virtual": false,
"hash": 189695464,
"hash": 4230953007,
"hash_compatibility": [
3245197284,
3898229885
@ -28980,6 +28998,11 @@
"name": "limit",
"type": "bool",
"default_value": "false"
},
{
"name": "backward",
"type": "bool",
"default_value": "false"
}
]
},
@ -83264,6 +83287,53 @@
}
]
},
{
"name": "_goto_script_line",
"is_const": false,
"is_static": false,
"is_vararg": false,
"is_virtual": true,
"arguments": [
{
"name": "script",
"type": "Script"
},
{
"name": "line",
"type": "int",
"meta": "int32"
}
]
},
{
"name": "_breakpoints_cleared_in_tree",
"is_const": false,
"is_static": false,
"is_vararg": false,
"is_virtual": true
},
{
"name": "_breakpoint_set_in_tree",
"is_const": false,
"is_static": false,
"is_vararg": false,
"is_virtual": true,
"arguments": [
{
"name": "script",
"type": "Script"
},
{
"name": "line",
"type": "int",
"meta": "int32"
},
{
"name": "enabled",
"type": "bool"
}
]
},
{
"name": "get_session",
"is_const": false,
@ -83410,6 +83480,29 @@
"type": "Control"
}
]
},
{
"name": "set_breakpoint",
"is_const": false,
"is_vararg": false,
"is_static": false,
"is_virtual": false,
"hash": 4108344793,
"arguments": [
{
"name": "path",
"type": "String"
},
{
"name": "line",
"type": "int",
"meta": "int32"
},
{
"name": "enabled",
"type": "bool"
}
]
}
],
"signals": [
@ -92682,6 +92775,14 @@
}
]
},
{
"name": "line_poll",
"is_const": false,
"is_vararg": false,
"is_static": false,
"is_virtual": false,
"hash": 3218959716
},
{
"name": "send_message",
"is_const": false,
@ -92699,6 +92800,183 @@
"type": "Array"
}
]
},
{
"name": "debug",
"is_const": false,
"is_vararg": false,
"is_static": false,
"is_virtual": false,
"hash": 2751962654,
"arguments": [
{
"name": "can_continue",
"type": "bool",
"default_value": "true"
},
{
"name": "is_error_breakpoint",
"type": "bool",
"default_value": "false"
}
]
},
{
"name": "script_debug",
"is_const": false,
"is_vararg": false,
"is_static": false,
"is_virtual": false,
"hash": 2442343672,
"arguments": [
{
"name": "language",
"type": "ScriptLanguage"
},
{
"name": "can_continue",
"type": "bool",
"default_value": "true"
},
{
"name": "is_error_breakpoint",
"type": "bool",
"default_value": "false"
}
]
},
{
"name": "set_lines_left",
"is_const": false,
"is_vararg": false,
"is_static": false,
"is_virtual": false,
"hash": 1286410249,
"arguments": [
{
"name": "lines",
"type": "int",
"meta": "int32"
}
]
},
{
"name": "get_lines_left",
"is_const": true,
"is_vararg": false,
"is_static": false,
"is_virtual": false,
"hash": 3905245786,
"return_value": {
"type": "int",
"meta": "int32"
}
},
{
"name": "set_depth",
"is_const": false,
"is_vararg": false,
"is_static": false,
"is_virtual": false,
"hash": 1286410249,
"arguments": [
{
"name": "depth",
"type": "int",
"meta": "int32"
}
]
},
{
"name": "get_depth",
"is_const": true,
"is_vararg": false,
"is_static": false,
"is_virtual": false,
"hash": 3905245786,
"return_value": {
"type": "int",
"meta": "int32"
}
},
{
"name": "is_breakpoint",
"is_const": true,
"is_vararg": false,
"is_static": false,
"is_virtual": false,
"hash": 921227809,
"return_value": {
"type": "bool"
},
"arguments": [
{
"name": "line",
"type": "int",
"meta": "int32"
},
{
"name": "source",
"type": "StringName"
}
]
},
{
"name": "is_skipping_breakpoints",
"is_const": true,
"is_vararg": false,
"is_static": false,
"is_virtual": false,
"hash": 36873697,
"return_value": {
"type": "bool"
}
},
{
"name": "insert_breakpoint",
"is_const": false,
"is_vararg": false,
"is_static": false,
"is_virtual": false,
"hash": 3780747571,
"arguments": [
{
"name": "line",
"type": "int",
"meta": "int32"
},
{
"name": "source",
"type": "StringName"
}
]
},
{
"name": "remove_breakpoint",
"is_const": false,
"is_vararg": false,
"is_static": false,
"is_virtual": false,
"hash": 3780747571,
"arguments": [
{
"name": "line",
"type": "int",
"meta": "int32"
},
{
"name": "source",
"type": "StringName"
}
]
},
{
"name": "clear_breakpoints",
"is_const": false,
"is_vararg": false,
"is_static": false,
"is_virtual": false,
"hash": 3218959716
}
]
},
@ -119369,6 +119647,18 @@
"type": "PackedByteArray"
}
},
{
"name": "get_data_size",
"is_const": true,
"is_vararg": false,
"is_static": false,
"is_virtual": false,
"hash": 3905245786,
"return_value": {
"type": "int",
"meta": "int64"
}
},
{
"name": "convert",
"is_const": false,
@ -119563,6 +119853,37 @@
}
]
},
{
"name": "create_empty",
"is_const": false,
"is_vararg": false,
"is_static": true,
"is_virtual": false,
"hash": 986942177,
"return_value": {
"type": "Image"
},
"arguments": [
{
"name": "width",
"type": "int",
"meta": "int32"
},
{
"name": "height",
"type": "int",
"meta": "int32"
},
{
"name": "use_mipmaps",
"type": "bool"
},
{
"name": "format",
"type": "enum::Image.Format"
}
]
},
{
"name": "create_from_data",
"is_const": false,
@ -141461,6 +141782,23 @@
}
]
},
{
"name": "is_opened",
"is_const": true,
"is_vararg": false,
"is_static": false,
"is_virtual": false,
"hash": 4155700596,
"return_value": {
"type": "bool"
},
"arguments": [
{
"name": "rid",
"type": "RID"
}
]
},
{
"name": "add_submenu_item",
"is_const": false,
@ -230851,6 +231189,23 @@
}
]
},
{
"name": "_debug_get_stack_level_source",
"is_const": true,
"is_static": false,
"is_vararg": false,
"is_virtual": true,
"return_value": {
"type": "String"
},
"arguments": [
{
"name": "level",
"type": "int",
"meta": "int32"
}
]
},
{
"name": "_debug_get_stack_level_locals",
"is_const": false,
@ -233841,6 +234196,17 @@
}
]
},
{
"name": "get_concatenated_bone_names",
"is_const": true,
"is_vararg": false,
"is_static": false,
"is_virtual": false,
"hash": 2002593661,
"return_value": {
"type": "StringName"
}
},
{
"name": "get_bone_parent",
"is_const": true,
@ -237238,6 +237604,17 @@
"is_vararg": false,
"is_virtual": true
},
{
"name": "get_skeleton",
"is_const": true,
"is_vararg": false,
"is_static": false,
"is_virtual": false,
"hash": 1488626673,
"return_value": {
"type": "Skeleton3D"
}
},
{
"name": "set_active",
"is_const": false,
@ -256177,7 +256554,7 @@
{
"name": "baseline_offset",
"type": "float",
"meta": "float"
"meta": "double"
}
]
},
@ -256190,7 +256567,7 @@
"hash": 866169185,
"return_value": {
"type": "float",
"meta": "float"
"meta": "double"
},
"arguments": [
{
@ -259603,7 +259980,8 @@
"arguments": [
{
"name": "unicode",
"type": "int"
"type": "int",
"meta": "uint64"
}
]
},
@ -260691,7 +261069,7 @@
{
"name": "baseline_offset",
"type": "float",
"meta": "float"
"meta": "double"
}
]
},
@ -260703,7 +261081,7 @@
"is_virtual": true,
"return_value": {
"type": "float",
"meta": "float"
"meta": "double"
},
"arguments": [
{
@ -263806,7 +264184,8 @@
"arguments": [
{
"name": "unicode",
"type": "int"
"type": "int",
"meta": "uint64"
}
]
},
@ -263985,6 +264364,13 @@
}
]
},
{
"name": "TextServerFallback",
"is_refcounted": true,
"is_instantiable": true,
"inherits": "TextServerExtension",
"api_type": "core"
},
{
"name": "TextServerManager",
"is_refcounted": false,
@ -270333,6 +270719,31 @@
"meta": "int32"
}
},
{
"name": "set_x_draw_order_reversed",
"is_const": false,
"is_vararg": false,
"is_static": false,
"is_virtual": false,
"hash": 2586408642,
"arguments": [
{
"name": "x_draw_order_reversed",
"type": "bool"
}
]
},
{
"name": "is_x_draw_order_reversed",
"is_const": true,
"is_vararg": false,
"is_static": false,
"is_virtual": false,
"hash": 36873697,
"return_value": {
"type": "bool"
}
},
{
"name": "set_rendering_quadrant_size",
"is_const": false,
@ -270541,6 +270952,12 @@
"setter": "set_y_sort_origin",
"getter": "get_y_sort_origin"
},
{
"type": "bool",
"name": "x_draw_order_reversed",
"setter": "set_x_draw_order_reversed",
"getter": "is_x_draw_order_reversed"
},
{
"type": "int",
"name": "rendering_quadrant_size",

View File

@ -1582,6 +1582,7 @@ typedef void (*GDExtensionInterfaceStringNewWithLatin1CharsAndLen)(GDExtensionUn
/**
* @name string_new_with_utf8_chars_and_len
* @since 4.1
* @deprecated in Godot 4.3. Use `string_new_with_utf8_chars_and_len2` instead.
*
* Creates a String from a UTF-8 encoded C string with the given length.
*
@ -1591,9 +1592,24 @@ typedef void (*GDExtensionInterfaceStringNewWithLatin1CharsAndLen)(GDExtensionUn
*/
typedef void (*GDExtensionInterfaceStringNewWithUtf8CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
/**
* @name string_new_with_utf8_chars_and_len2
* @since 4.3
*
* Creates a String from a UTF-8 encoded C string with the given length.
*
* @param r_dest A pointer to a Variant to hold the newly created String.
* @param p_contents A pointer to a UTF-8 encoded C string.
* @param p_size The number of bytes (not code units).
*
* @return Error code signifying if the operation successful.
*/
typedef GDExtensionInt (*GDExtensionInterfaceStringNewWithUtf8CharsAndLen2)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
/**
* @name string_new_with_utf16_chars_and_len
* @since 4.1
* @deprecated in Godot 4.3. Use `string_new_with_utf16_chars_and_len2` instead.
*
* Creates a String from a UTF-16 encoded C string with the given length.
*
@ -1603,6 +1619,21 @@ typedef void (*GDExtensionInterfaceStringNewWithUtf8CharsAndLen)(GDExtensionUnin
*/
typedef void (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_char_count);
/**
* @name string_new_with_utf16_chars_and_len2
* @since 4.3
*
* Creates a String from a UTF-16 encoded C string with the given length.
*
* @param r_dest A pointer to a Variant to hold the newly created String.
* @param p_contents A pointer to a UTF-16 encoded C string.
* @param p_size The number of characters (not bytes).
* @param p_default_little_endian If true, UTF-16 use little endian.
*
* @return Error code signifying if the operation successful.
*/
typedef GDExtensionInt (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen2)(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_char_count, GDExtensionBool p_default_little_endian);
/**
* @name string_new_with_utf32_chars_and_len
* @since 4.1
@ -1899,6 +1930,36 @@ typedef void (*GDExtensionInterfaceFileAccessStoreBuffer)(GDExtensionObjectPtr p
*/
typedef uint64_t (*GDExtensionInterfaceFileAccessGetBuffer)(GDExtensionConstObjectPtr p_instance, uint8_t *p_dst, uint64_t p_length);
/* INTERFACE: Image Utilities */
/**
* @name image_ptrw
* @since 4.3
*
* Returns writable pointer to internal Image buffer.
*
* @param p_instance A pointer to a Image object.
*
* @return Pointer to internal Image buffer.
*
* @see Image::ptrw()
*/
typedef uint8_t *(*GDExtensionInterfaceImagePtrw)(GDExtensionObjectPtr p_instance);
/**
* @name image_ptr
* @since 4.3
*
* Returns read only pointer to internal Image buffer.
*
* @param p_instance A pointer to a Image object.
*
* @return Pointer to internal Image buffer.
*
* @see Image::ptr()
*/
typedef const uint8_t *(*GDExtensionInterfaceImagePtr)(GDExtensionObjectPtr p_instance);
/* INTERFACE: WorkerThreadPool Utilities */
/**

View File

@ -108,7 +108,9 @@ extern "C" GDExtensionInterfaceStringNewWithUtf32Chars gdextension_interface_str
extern "C" GDExtensionInterfaceStringNewWithWideChars gdextension_interface_string_new_with_wide_chars;
extern "C" GDExtensionInterfaceStringNewWithLatin1CharsAndLen gdextension_interface_string_new_with_latin1_chars_and_len;
extern "C" GDExtensionInterfaceStringNewWithUtf8CharsAndLen gdextension_interface_string_new_with_utf8_chars_and_len;
extern "C" GDExtensionInterfaceStringNewWithUtf8CharsAndLen2 gdextension_interface_string_new_with_utf8_chars_and_len2;
extern "C" GDExtensionInterfaceStringNewWithUtf16CharsAndLen gdextension_interface_string_new_with_utf16_chars_and_len;
extern "C" GDExtensionInterfaceStringNewWithUtf16CharsAndLen2 gdextension_interface_string_new_with_utf16_chars_and_len2;
extern "C" GDExtensionInterfaceStringNewWithUtf32CharsAndLen gdextension_interface_string_new_with_utf32_chars_and_len;
extern "C" GDExtensionInterfaceStringNewWithWideCharsAndLen gdextension_interface_string_new_with_wide_chars_and_len;
extern "C" GDExtensionInterfaceStringToLatin1Chars gdextension_interface_string_to_latin1_chars;
@ -195,6 +197,8 @@ extern "C" GDExtensionInterfaceEditorAddPlugin gdextension_interface_editor_add_
extern "C" GDExtensionInterfaceEditorRemovePlugin gdextension_interface_editor_remove_plugin;
extern "C" GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8Chars gdextension_interface_editor_help_load_xml_from_utf8_chars;
extern "C" GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8CharsAndLen gdextension_interface_editor_help_load_xml_from_utf8_chars_and_len;
extern "C" GDExtensionInterfaceImagePtrw gdextension_interface_image_ptrw;
extern "C" GDExtensionInterfaceImagePtr gdextension_interface_image_ptr;
class DocDataRegistration {
public:

View File

@ -29,6 +29,7 @@
/**************************************************************************/
#include <godot_cpp/classes/file_access.hpp>
#include <godot_cpp/classes/image.hpp>
#include <godot_cpp/classes/worker_thread_pool.hpp>
#include <godot_cpp/classes/xml_parser.hpp>
@ -55,4 +56,12 @@ WorkerThreadPool::GroupID WorkerThreadPool::add_native_group_task(void (*p_func)
return (GroupID)internal::gdextension_interface_worker_thread_pool_add_native_group_task(_owner, p_func, p_userdata, p_elements, p_tasks, p_high_priority, (GDExtensionConstStringPtr)&p_description);
}
uint8_t *Image::ptrw() {
return internal::gdextension_interface_image_ptrw(_owner);
}
const uint8_t *Image::ptr() {
return internal::gdextension_interface_image_ptr(_owner);
}
} // namespace godot

View File

@ -114,7 +114,9 @@ GDExtensionInterfaceStringNewWithUtf32Chars gdextension_interface_string_new_wit
GDExtensionInterfaceStringNewWithWideChars gdextension_interface_string_new_with_wide_chars = nullptr;
GDExtensionInterfaceStringNewWithLatin1CharsAndLen gdextension_interface_string_new_with_latin1_chars_and_len = nullptr;
GDExtensionInterfaceStringNewWithUtf8CharsAndLen gdextension_interface_string_new_with_utf8_chars_and_len = nullptr;
GDExtensionInterfaceStringNewWithUtf8CharsAndLen2 gdextension_interface_string_new_with_utf8_chars_and_len2 = nullptr;
GDExtensionInterfaceStringNewWithUtf16CharsAndLen gdextension_interface_string_new_with_utf16_chars_and_len = nullptr;
GDExtensionInterfaceStringNewWithUtf16CharsAndLen2 gdextension_interface_string_new_with_utf16_chars_and_len2 = nullptr;
GDExtensionInterfaceStringNewWithUtf32CharsAndLen gdextension_interface_string_new_with_utf32_chars_and_len = nullptr;
GDExtensionInterfaceStringNewWithWideCharsAndLen gdextension_interface_string_new_with_wide_chars_and_len = nullptr;
GDExtensionInterfaceStringToLatin1Chars gdextension_interface_string_to_latin1_chars = nullptr;
@ -201,6 +203,8 @@ GDExtensionInterfaceEditorAddPlugin gdextension_interface_editor_add_plugin = nu
GDExtensionInterfaceEditorRemovePlugin gdextension_interface_editor_remove_plugin = nullptr;
GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8Chars gdextension_interface_editor_help_load_xml_from_utf8_chars = nullptr;
GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8CharsAndLen gdextension_interface_editor_help_load_xml_from_utf8_chars_and_len = nullptr;
GDExtensionInterfaceImagePtrw gdextension_interface_image_ptrw = nullptr;
GDExtensionInterfaceImagePtr gdextension_interface_image_ptr = nullptr;
struct DocData {
const char *hash = nullptr;
@ -389,7 +393,9 @@ GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_ge
LOAD_PROC_ADDRESS(string_new_with_wide_chars, GDExtensionInterfaceStringNewWithWideChars);
LOAD_PROC_ADDRESS(string_new_with_latin1_chars_and_len, GDExtensionInterfaceStringNewWithLatin1CharsAndLen);
LOAD_PROC_ADDRESS(string_new_with_utf8_chars_and_len, GDExtensionInterfaceStringNewWithUtf8CharsAndLen);
LOAD_PROC_ADDRESS(string_new_with_utf8_chars_and_len2, GDExtensionInterfaceStringNewWithUtf8CharsAndLen2);
LOAD_PROC_ADDRESS(string_new_with_utf16_chars_and_len, GDExtensionInterfaceStringNewWithUtf16CharsAndLen);
LOAD_PROC_ADDRESS(string_new_with_utf16_chars_and_len2, GDExtensionInterfaceStringNewWithUtf16CharsAndLen2);
LOAD_PROC_ADDRESS(string_new_with_utf32_chars_and_len, GDExtensionInterfaceStringNewWithUtf32CharsAndLen);
LOAD_PROC_ADDRESS(string_new_with_wide_chars_and_len, GDExtensionInterfaceStringNewWithWideCharsAndLen);
LOAD_PROC_ADDRESS(string_to_latin1_chars, GDExtensionInterfaceStringToLatin1Chars);
@ -476,6 +482,8 @@ GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_ge
LOAD_PROC_ADDRESS(editor_remove_plugin, GDExtensionInterfaceEditorRemovePlugin);
LOAD_PROC_ADDRESS(editor_help_load_xml_from_utf8_chars, GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8Chars);
LOAD_PROC_ADDRESS(editor_help_load_xml_from_utf8_chars_and_len, GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8CharsAndLen);
LOAD_PROC_ADDRESS(image_ptrw, GDExtensionInterfaceImagePtrw);
LOAD_PROC_ADDRESS(image_ptr, GDExtensionInterfaceImagePtr);
r_initialization->initialize = initialize_level;
r_initialization->deinitialize = deinitialize_level;

View File

@ -178,8 +178,8 @@ String String::utf8(const char *from, int64_t len) {
return ret;
}
void String::parse_utf8(const char *from, int64_t len) {
internal::gdextension_interface_string_new_with_utf8_chars_and_len(_native_ptr(), from, len);
Error String::parse_utf8(const char *from, int64_t len) {
return (Error)internal::gdextension_interface_string_new_with_utf8_chars_and_len2(_native_ptr(), from, len);
}
String String::utf16(const char16_t *from, int64_t len) {
@ -188,8 +188,8 @@ String String::utf16(const char16_t *from, int64_t len) {
return ret;
}
void String::parse_utf16(const char16_t *from, int64_t len) {
internal::gdextension_interface_string_new_with_utf16_chars_and_len(_native_ptr(), from, len);
Error String::parse_utf16(const char16_t *from, int64_t len, bool default_little_endian) {
return (Error)internal::gdextension_interface_string_new_with_utf16_chars_and_len2(_native_ptr(), from, len, default_little_endian);
}
String String::num_real(double p_num, bool p_trailing) {