[GDExtension] Add binds for missing methods, operators, and constants required for GDExtension TextServer implementation.

This commit is contained in:
bruvzg 2022-02-08 09:49:14 +02:00
parent d6ba4a223f
commit b801742b77
No known key found for this signature in database
GPG key ID: 7960FCF39844EC38
10 changed files with 78 additions and 0 deletions

View file

@ -165,6 +165,9 @@ void register_global_constants() {
BIND_CORE_ENUM_CONSTANT(INLINE_ALIGNMENT_CENTER);
BIND_CORE_ENUM_CONSTANT(INLINE_ALIGNMENT_BOTTOM);
BIND_CORE_ENUM_CONSTANT(INLINE_ALIGNMENT_IMAGE_MASK);
BIND_CORE_ENUM_CONSTANT(INLINE_ALIGNMENT_TEXT_MASK);
BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, SPECIAL);
BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ESCAPE);
BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, TAB);

View file

@ -925,6 +925,7 @@ bool TranslationServer::is_placeholder(String &p_message, int p_index) const {
void TranslationServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_locale", "locale"), &TranslationServer::set_locale);
ClassDB::bind_method(D_METHOD("get_locale"), &TranslationServer::get_locale);
ClassDB::bind_method(D_METHOD("get_tool_locale"), &TranslationServer::get_tool_locale);
ClassDB::bind_method(D_METHOD("compare_locales", "locale_a", "locale_b"), &TranslationServer::compare_locales);
ClassDB::bind_method(D_METHOD("standardize_locale", "locale"), &TranslationServer::standardize_locale);

View file

@ -1371,6 +1371,8 @@ static void _register_variant_builtin_methods() {
bind_method(String, length, sarray(), varray());
bind_method(String, substr, sarray("from", "len"), varray(-1));
bind_method(String, get_slice, sarray("delimiter", "slice"), varray());
bind_method(String, get_slicec, sarray("delimiter", "slice"), varray());
bind_method(String, get_slice_count, sarray("delimiter"), varray());
bind_methodv(String, find, static_cast<int (String::*)(const String &, int) const>(&String::find), sarray("what", "from"), varray(0));
bind_method(String, count, sarray("what", "from", "to"), varray(0, 0));
bind_method(String, countn, sarray("what", "from", "to"), varray(0, 0));
@ -1667,6 +1669,7 @@ static void _register_variant_builtin_methods() {
/* RID */
bind_method(RID, is_valid, sarray(), varray());
bind_method(RID, get_id, sarray(), varray());
/* NodePath */

View file

@ -176,6 +176,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorAdd<double, double, int64_t>>(Variant::OP_ADD, Variant::FLOAT, Variant::INT);
register_op<OperatorEvaluatorAdd<double, double, double>>(Variant::OP_ADD, Variant::FLOAT, Variant::FLOAT);
register_op<OperatorEvaluatorAdd<String, String, String>>(Variant::OP_ADD, Variant::STRING, Variant::STRING);
register_op<OperatorEvaluatorAdd<String, char32_t, String>>(Variant::OP_ADD, Variant::INT, Variant::STRING);
register_op<OperatorEvaluatorAdd<Vector2, Vector2, Vector2>>(Variant::OP_ADD, Variant::VECTOR2, Variant::VECTOR2);
register_op<OperatorEvaluatorAdd<Vector2i, Vector2i, Vector2i>>(Variant::OP_ADD, Variant::VECTOR2I, Variant::VECTOR2I);
register_op<OperatorEvaluatorAdd<Vector3, Vector3, Vector3>>(Variant::OP_ADD, Variant::VECTOR3, Variant::VECTOR3);
@ -622,6 +623,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorLess<double, int64_t>>(Variant::OP_LESS, Variant::FLOAT, Variant::INT);
register_op<OperatorEvaluatorLess<double, double>>(Variant::OP_LESS, Variant::FLOAT, Variant::FLOAT);
register_op<OperatorEvaluatorLess<String, String>>(Variant::OP_LESS, Variant::STRING, Variant::STRING);
register_op<OperatorEvaluatorLess<StringName, StringName>>(Variant::OP_LESS, Variant::STRING_NAME, Variant::STRING_NAME);
register_op<OperatorEvaluatorLess<Vector2, Vector2>>(Variant::OP_LESS, Variant::VECTOR2, Variant::VECTOR2);
register_op<OperatorEvaluatorLess<Vector2i, Vector2i>>(Variant::OP_LESS, Variant::VECTOR2I, Variant::VECTOR2I);
register_op<OperatorEvaluatorLess<Vector3, Vector3>>(Variant::OP_LESS, Variant::VECTOR3, Variant::VECTOR3);
@ -634,6 +636,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorLessEqual<double, int64_t>>(Variant::OP_LESS_EQUAL, Variant::FLOAT, Variant::INT);
register_op<OperatorEvaluatorLessEqual<double, double>>(Variant::OP_LESS_EQUAL, Variant::FLOAT, Variant::FLOAT);
register_op<OperatorEvaluatorLessEqual<String, String>>(Variant::OP_LESS_EQUAL, Variant::STRING, Variant::STRING);
register_op<OperatorEvaluatorLessEqual<StringName, StringName>>(Variant::OP_LESS_EQUAL, Variant::STRING_NAME, Variant::STRING_NAME);
register_op<OperatorEvaluatorLessEqual<Vector2, Vector2>>(Variant::OP_LESS_EQUAL, Variant::VECTOR2, Variant::VECTOR2);
register_op<OperatorEvaluatorLessEqual<Vector2i, Vector2i>>(Variant::OP_LESS_EQUAL, Variant::VECTOR2I, Variant::VECTOR2I);
register_op<OperatorEvaluatorLessEqual<Vector3, Vector3>>(Variant::OP_LESS_EQUAL, Variant::VECTOR3, Variant::VECTOR3);
@ -647,6 +650,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorGreater<double, int64_t>>(Variant::OP_GREATER, Variant::FLOAT, Variant::INT);
register_op<OperatorEvaluatorGreater<double, double>>(Variant::OP_GREATER, Variant::FLOAT, Variant::FLOAT);
register_op<OperatorEvaluatorGreater<String, String>>(Variant::OP_GREATER, Variant::STRING, Variant::STRING);
register_op<OperatorEvaluatorGreater<StringName, StringName>>(Variant::OP_GREATER, Variant::STRING_NAME, Variant::STRING_NAME);
register_op<OperatorEvaluatorGreater<Vector2, Vector2>>(Variant::OP_GREATER, Variant::VECTOR2, Variant::VECTOR2);
register_op<OperatorEvaluatorGreater<Vector2i, Vector2i>>(Variant::OP_GREATER, Variant::VECTOR2I, Variant::VECTOR2I);
register_op<OperatorEvaluatorGreater<Vector3, Vector3>>(Variant::OP_GREATER, Variant::VECTOR3, Variant::VECTOR3);
@ -659,6 +663,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorGreaterEqual<double, int64_t>>(Variant::OP_GREATER_EQUAL, Variant::FLOAT, Variant::INT);
register_op<OperatorEvaluatorGreaterEqual<double, double>>(Variant::OP_GREATER_EQUAL, Variant::FLOAT, Variant::FLOAT);
register_op<OperatorEvaluatorGreaterEqual<String, String>>(Variant::OP_GREATER_EQUAL, Variant::STRING, Variant::STRING);
register_op<OperatorEvaluatorGreaterEqual<StringName, StringName>>(Variant::OP_GREATER_EQUAL, Variant::STRING_NAME, Variant::STRING_NAME);
register_op<OperatorEvaluatorGreaterEqual<Vector2, Vector2>>(Variant::OP_GREATER_EQUAL, Variant::VECTOR2, Variant::VECTOR2);
register_op<OperatorEvaluatorGreaterEqual<Vector2i, Vector2i>>(Variant::OP_GREATER_EQUAL, Variant::VECTOR2I, Variant::VECTOR2I);
register_op<OperatorEvaluatorGreaterEqual<Vector3, Vector3>>(Variant::OP_GREATER_EQUAL, Variant::VECTOR3, Variant::VECTOR3);

View file

@ -1267,6 +1267,12 @@
<constant name="INLINE_ALIGNMENT_BOTTOM" value="14" enum="InlineAlignment">
Aligns bottom of the inline object (e.g. image, table) to the bottom of the text. Equivalent to [code]INLINE_ALIGNMENT_BOTTOM_TO | INLINE_ALIGNMENT_TO_BOTTOM[/code].
</constant>
<constant name="INLINE_ALIGNMENT_IMAGE_MASK" value="3" enum="InlineAlignment">
A bit mask for [code]INLINE_ALIGNMENT_*_TO[/code] alignment constants.
</constant>
<constant name="INLINE_ALIGNMENT_TEXT_MASK" value="12" enum="InlineAlignment">
A bit mask for [code]INLINE_ALIGNMENT_TO_*[/code] alignment constants.
</constant>
<constant name="KEY_SPECIAL" value="16777216" enum="Key">
Keycodes with this bit applied are non-printable.
</constant>

View file

@ -30,6 +30,12 @@
Returns the ID of the referenced resource.
</description>
</method>
<method name="is_valid" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if [RID] is valid.
</description>
</method>
</methods>
<operators>
<operator name="operator !=">

View file

@ -222,6 +222,22 @@
[/codeblock]
</description>
</method>
<method name="get_slice_count" qualifiers="const">
<return type="int" />
<argument index="0" name="delimiter" type="String" />
<description>
Splits a string using a [code]delimiter[/code] and returns a number of slices.
</description>
</method>
<method name="get_slicec" qualifiers="const">
<return type="String" />
<argument index="0" name="delimiter" type="int" />
<argument index="1" name="slice" type="int" />
<description>
Splits a string using a Unicode character with code [code]delimiter[/code] and returns a substring at index [code]slice[/code]. Returns an empty string if the index doesn't exist.
This is a more performant alternative to [method split] for cases when you need only one element from the array at a fixed index.
</description>
</method>
<method name="hash" qualifiers="const">
<return type="int" />
<description>

View file

@ -48,6 +48,18 @@
<description>
</description>
</operator>
<operator name="operator &lt;">
<return type="bool" />
<argument index="0" name="right" type="StringName" />
<description>
</description>
</operator>
<operator name="operator &lt;=">
<return type="bool" />
<argument index="0" name="right" type="StringName" />
<description>
</description>
</operator>
<operator name="operator ==">
<return type="bool" />
<description>
@ -65,5 +77,17 @@
<description>
</description>
</operator>
<operator name="operator &gt;">
<return type="bool" />
<argument index="0" name="right" type="StringName" />
<description>
</description>
</operator>
<operator name="operator &gt;=">
<return type="bool" />
<argument index="0" name="right" type="StringName" />
<description>
</description>
</operator>
</operators>
</class>

View file

@ -91,6 +91,13 @@
Returns readable script name for the [code]script[/code] code.
</description>
</method>
<method name="get_tool_locale">
<return type="String" />
<description>
Returns the current locale of the editor.
[b]Note:[/b] When called from an exported project returns the same value as [method get_locale].
</description>
</method>
<method name="get_translation_object">
<return type="Translation" />
<argument index="0" name="locale" type="String" />

View file

@ -176,6 +176,13 @@
Multiplies two [int]s.
</description>
</operator>
<operator name="operator +">
<return type="String" />
<argument index="0" name="right" type="String" />
<description>
Adds Unicode character with code [int] to the [String].
</description>
</operator>
<operator name="operator +">
<return type="float" />
<argument index="0" name="right" type="float" />