diff --git a/binding_generator.py b/binding_generator.py index df3e299f..fbeff553 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -66,7 +66,7 @@ def generate_class_header(used_classes, c): source.append("") source.append("") - source.append("#include ") + source.append("#include ") source.append("#include ") source.append("") @@ -460,7 +460,7 @@ def generate_icall_header(icalls): source.append("") - source.append("#include ") + source.append("#include ") source.append("#include ") source.append("") @@ -510,7 +510,7 @@ def generate_icall_implementation(icalls): source.append("") - source.append("#include ") + source.append("#include ") source.append("#include ") source.append("") diff --git a/include/core/Array.hpp b/include/core/Array.hpp index 6a648721..20057402 100644 --- a/include/core/Array.hpp +++ b/include/core/Array.hpp @@ -1,7 +1,7 @@ #ifndef ARRAY_H #define ARRAY_H -#include +#include #include "String.hpp" diff --git a/include/core/Color.hpp b/include/core/Color.hpp index 5232573b..5c3cd9ed 100644 --- a/include/core/Color.hpp +++ b/include/core/Color.hpp @@ -1,7 +1,7 @@ #ifndef COLOR_H #define COLOR_H -#include +#include #include diff --git a/include/core/Dictionary.hpp b/include/core/Dictionary.hpp index 31744b73..238724de 100644 --- a/include/core/Dictionary.hpp +++ b/include/core/Dictionary.hpp @@ -5,7 +5,7 @@ #include "Array.hpp" -#include +#include namespace godot { diff --git a/include/core/Godot.hpp b/include/core/Godot.hpp index 90a73aa3..98bcf622 100644 --- a/include/core/Godot.hpp +++ b/include/core/Godot.hpp @@ -4,8 +4,8 @@ #include #include -#include -#include +#include +#include #include diff --git a/include/core/NodePath.hpp b/include/core/NodePath.hpp index f4b4b253..235c95e8 100644 --- a/include/core/NodePath.hpp +++ b/include/core/NodePath.hpp @@ -3,7 +3,7 @@ #include "String.hpp" -#include +#include namespace godot { diff --git a/include/core/PoolArrays.hpp b/include/core/PoolArrays.hpp index 6c07ae16..e10d8e97 100644 --- a/include/core/PoolArrays.hpp +++ b/include/core/PoolArrays.hpp @@ -8,7 +8,7 @@ #include "Vector2.hpp" #include "Vector3.hpp" -#include +#include namespace godot { diff --git a/include/core/RID.hpp b/include/core/RID.hpp index 3f83e791..3a968bfa 100644 --- a/include/core/RID.hpp +++ b/include/core/RID.hpp @@ -1,7 +1,7 @@ #ifndef RID_H #define RID_H -#include +#include namespace godot { diff --git a/include/core/String.hpp b/include/core/String.hpp index dec8104a..819a3002 100644 --- a/include/core/String.hpp +++ b/include/core/String.hpp @@ -1,69 +1,111 @@ #ifndef STRING_H #define STRING_H -#include +#include namespace godot { class NodePath; +class Variant; +class PoolByteArray; +class PoolRealArray; +class PoolStringArray; -class String -{ +class String { godot_string _godot_string; + public: String(); - String(const char *contents); - String(const wchar_t *contents); - String(const wchar_t c); - - String(const String& other); + String(const String &other); ~String(); + wchar_t &operator[](const int idx); + wchar_t operator[](const int idx) const; - String substr(int p_from,int p_chars) const; - - - wchar_t &operator [](const int idx); - - wchar_t operator [](const int idx) const; - - int length() const; - - void operator =(const String &s); - - bool operator ==(const String &s); - - bool operator !=(const String &s); - - String operator +(const String &s); - - void operator +=(const String &s); - - void operator +=(const wchar_t c); - - bool operator <(const String &s); - - bool operator <=(const String &s); - - bool operator >(const String &s); - - bool operator >=(const String &s); + void operator=(const String &s); + bool operator==(const String &s); + bool operator!=(const String &s); + String operator+(const String &s); + void operator+=(const String &s); + void operator+=(const wchar_t c); + bool operator<(const String &s); + bool operator<=(const String &s); + bool operator>(const String &s); + bool operator>=(const String &s); operator NodePath() const; + int length() const; const char *c_string() const; + int64_t find(String p_what) const; + int64_t find_from(String p_what, int64_t p_from) const; + bool begins_with(String &s) const; + bool begins_with_char_array(const char *p_char_array) const; + PoolStringArray bigrams() const; + String c_escape() const; + String c_unescape() const; + String capitalize() const; + bool empty() const; + bool ends_with(String &text) const; + void erase(int position, int chars) const; + int find(String what, int from = 0) const; + int find_last(String what) const; + int findn(String what, int from = 0) const; + String format(Variant values, String placeholder) const; + String get_base_dir() const; + String get_basename() const; + String get_extension() const; + String get_file() const; + int hash() const; + int hex_to_int() const; + String insert(int position, String what) const; + bool is_abs_path() const; + bool is_rel_path() const; + bool is_subsequence_of(String text) const; + bool is_subsequence_ofi(String text) const; + bool is_valid_float() const; + bool is_valid_html_color() const; + bool is_valid_identifier() const; + bool is_valid_integer() const; + bool is_valid_ip_address() const; + String json_escape() const; + String left(int position) const; + bool match(String expr) const; + bool matchn(String expr) const; + PoolByteArray md5_buffer() const; + String md5_text() const; + int ord_at(int at) const; + String pad_decimals(int digits) const; + String pad_zeros(int digits) const; + String percent_decode() const; + String percent_encode() const; + String plus_file(String file) const; + String replace(String what, String forwhat) const; + String replacen(String what, String forwhat) const; + int rfind(String what, int from = -1) const; + int rfindn(String what, int from = -1) const; + String right(int position) const; + PoolByteArray sha256_buffer() const; + String sha256_text() const; + float similarity(String text) const; + PoolStringArray split(String divisor, bool allow_empty = true) const; + PoolRealArray split_floats(String divisor, bool allow_empty = true) const; + String strip_edges(bool left = true, bool right = true) const; + String substr(int from, int len) const; + float to_float() const; + int64_t to_int() const; + String to_lower() const; + String to_upper() const; + String xml_escape() const; + String xml_unescape() const; }; -String operator +(const char *a, const String& b); - - +String operator+(const char *a, const String &b); } - - #endif // STRING_H diff --git a/include/core/Variant.hpp b/include/core/Variant.hpp index 6d9b1a71..b4741f90 100644 --- a/include/core/Variant.hpp +++ b/include/core/Variant.hpp @@ -1,7 +1,7 @@ #ifndef VARIANT_H #define VARIANT_H -#include +#include #include "Defs.hpp" @@ -259,7 +259,7 @@ public: bool hash_compare(const Variant& b) const; - bool booleanize(bool &valid) const; + bool booleanize() const; ~Variant(); diff --git a/include/core/Vector2.hpp b/include/core/Vector2.hpp index da45ccf0..3372f99b 100644 --- a/include/core/Vector2.hpp +++ b/include/core/Vector2.hpp @@ -1,7 +1,7 @@ #ifndef VECTOR2_H #define VECTOR2_H -#include +#include #include "Defs.hpp" diff --git a/src/core/Color.cpp b/src/core/Color.cpp index a41615e3..aa356e27 100644 --- a/src/core/Color.cpp +++ b/src/core/Color.cpp @@ -1,6 +1,6 @@ #include "Color.hpp" -#include +#include #include diff --git a/src/core/GodotGlobal.cpp b/src/core/GodotGlobal.cpp index 96a5fa63..823c2c12 100644 --- a/src/core/GodotGlobal.cpp +++ b/src/core/GodotGlobal.cpp @@ -2,7 +2,7 @@ #include "String.hpp" -#include +#include namespace godot { diff --git a/src/core/NodePath.cpp b/src/core/NodePath.cpp index 98c40c9a..56810363 100644 --- a/src/core/NodePath.cpp +++ b/src/core/NodePath.cpp @@ -2,7 +2,7 @@ #include "String.hpp" -#include +#include namespace godot { diff --git a/src/core/PoolArrays.cpp b/src/core/PoolArrays.cpp index e33ce0ef..fbd4d694 100644 --- a/src/core/PoolArrays.cpp +++ b/src/core/PoolArrays.cpp @@ -7,7 +7,7 @@ #include "Vector2.hpp" #include "Vector3.hpp" -#include +#include namespace godot { diff --git a/src/core/RID.cpp b/src/core/RID.cpp index 75419ba4..12b4a2e5 100644 --- a/src/core/RID.cpp +++ b/src/core/RID.cpp @@ -1,6 +1,6 @@ #include "RID.hpp" -#include +#include namespace godot { diff --git a/src/core/String.cpp b/src/core/String.cpp index 846241e4..2de76b03 100644 --- a/src/core/String.cpp +++ b/src/core/String.cpp @@ -1,140 +1,433 @@ #include "String.hpp" +#include "Array.hpp" #include "NodePath.hpp" +#include "PoolArrays.hpp" +#include "Variant.hpp" -#include +#include #include namespace godot { -godot::String::String() -{ +godot::String::String() { godot_string_new(&_godot_string); } -String::String(const char *contents) -{ +String::String(const char *contents) { godot_string_new_data(&_godot_string, contents, strlen(contents)); } -String::String(const wchar_t *contents) -{ +String::String(const wchar_t *contents) { // @Todo // godot_string_new_data(&_godot_string, contents, strlen(contents)); godot_string_new(&_godot_string); } -String::String(const wchar_t c) -{ +String::String(const wchar_t c) { // @Todo godot_string_new(&_godot_string); } -String::String(const String& other) -{ +String::String(const String &other) { godot_string_new_copy(&_godot_string, &other._godot_string); } -String::~String() -{ +String::~String() { godot_string_destroy(&_godot_string); } - -String String::substr(int p_from,int p_chars) const -{ - return String(); // @Todo -} - - -wchar_t &String::operator [](const int idx) -{ +wchar_t &String::operator[](const int idx) { return *godot_string_operator_index(&_godot_string, idx); } -wchar_t String::operator [](const int idx) const -{ - return *godot_string_operator_index((godot_string *) &_godot_string, idx); +wchar_t String::operator[](const int idx) const { + return *godot_string_operator_index((godot_string *)&_godot_string, idx); } -int String::length() const -{ +int String::length() const { int len = 0; godot_string_get_data(&_godot_string, nullptr, &len); return len; } -void String::operator =(const String &s) -{ +void String::operator=(const String &s) { godot_string_destroy(&_godot_string); godot_string_new_copy(&_godot_string, &s._godot_string); } -bool String::operator ==(const String &s) -{ +bool String::operator==(const String &s) { return godot_string_operator_equal(&_godot_string, &s._godot_string); } -bool String::operator !=(const String &s) -{ +bool String::operator!=(const String &s) { return !(*this == s); } -String String::operator +(const String &s) -{ +String String::operator+(const String &s) { String new_string = *this; - new_string._godot_string = godot_string_operator_plus(&new_string._godot_string, &s._godot_string); + new_string._godot_string = + godot_string_operator_plus(&new_string._godot_string, &s._godot_string); return new_string; } -void String::operator +=(const String &s) -{ +void String::operator+=(const String &s) { _godot_string = godot_string_operator_plus(&_godot_string, &s._godot_string); } -void String::operator +=(const wchar_t c) -{ +void String::operator+=(const wchar_t c) { // @Todo } -bool String::operator <(const String &s) -{ +bool String::operator<(const String &s) { return godot_string_operator_less(&_godot_string, &s._godot_string); } -bool String::operator <=(const String &s) -{ - return godot_string_operator_less(&_godot_string, &s._godot_string) || (*this == s); +bool String::operator<=(const String &s) { + return godot_string_operator_less(&_godot_string, &s._godot_string) || + (*this == s); } -bool String::operator >(const String &s) -{ +bool String::operator>(const String &s) { return !(*this <= s); } -bool String::operator >=(const String &s) -{ +bool String::operator>=(const String &s) { return !(*this < s); } -String::operator NodePath() const -{ +String::operator NodePath() const { return NodePath(*this); } -const char *String::c_string() const -{ +const char *String::c_string() const { return godot_string_c_str(&_godot_string); } - -String operator +(const char *a, const String& b) -{ +String operator+(const char *a, const String &b) { return String(a) + b; } - - +bool String::begins_with(String &p_string) const { + return godot_string_begins_with(&_godot_string, &p_string._godot_string); +} + +bool String::begins_with_char_array(const char *p_char_array) const { + return godot_string_begins_with_char_array(&_godot_string, p_char_array); +} + +PoolStringArray String::bigrams() const { + godot_array arr = godot_string_bigrams(&_godot_string); + + return *(PoolStringArray *)&arr; +} + +String String::c_escape() const { + String new_string; + new_string._godot_string = godot_string_c_escape(&_godot_string); + + return new_string; +} + +String String::c_unescape() const { + String new_string; + new_string._godot_string = godot_string_c_unescape(&_godot_string); + + return new_string; +} + +String String::capitalize() const { + String new_string; + new_string._godot_string = godot_string_capitalize(&_godot_string); + + return new_string; +} + +bool String::empty() const { + return godot_string_empty(&_godot_string); +} + +bool String::ends_with(String &p_string) const { + return godot_string_ends_with(&_godot_string, &p_string._godot_string); +} + +void String::erase(int position, int chars) const { + godot_string_erase(&_godot_string, position, chars); +} + +int String::find(String p_what, int p_from) const { + return godot_string_find(&_godot_string, p_what._godot_string); +} + +int String::find_last(String what) const { + return godot_string_find_last(&_godot_string, what._godot_string); +} + +int String::findn(String what, int from) const { + return godot_string_findn(&_godot_string, what._godot_string); +} + +String String::format(Variant values, String placeholder) const { + String new_string; + new_string._godot_string = godot_string_format(&_godot_string, (godot_variant *)&values); + + return new_string; +} + +String String::get_base_dir() const { + String new_string; + new_string._godot_string = godot_string_get_base_dir(&_godot_string); + + return new_string; +} + +String String::get_basename() const { + godot_string new_string = godot_string_get_basename(&_godot_string); + return *(String *)&new_string; +} + +String String::get_extension() const { + godot_string new_string = godot_string_get_extension(&_godot_string); + return *(String *)&new_string; +} + +String String::get_file() const { + godot_string new_string = godot_string_get_file(&_godot_string); + return *(String *)&new_string; +} + +int String::hash() const { + return godot_string_hash(&_godot_string); +} + +int String::hex_to_int() const { + return godot_string_hex_to_int(&_godot_string); +} + +String String::insert(int position, String what) const { + String new_string; + new_string._godot_string = godot_string_insert(&_godot_string, position, what._godot_string); + + return new_string; +} + +bool String::is_abs_path() const { + return godot_string_is_abs_path(&_godot_string); +} + +bool String::is_rel_path() const { + return godot_string_is_rel_path(&_godot_string); +} + +bool String::is_subsequence_of(String text) const { + return godot_string_is_subsequence_of(&_godot_string, &text._godot_string); +} + +bool String::is_subsequence_ofi(String text) const { + return godot_string_is_subsequence_ofi(&_godot_string, &text._godot_string); +} + +bool String::is_valid_float() const { + return godot_string_is_valid_float(&_godot_string); +} + +bool String::is_valid_html_color() const { + return godot_string_is_valid_html_color(&_godot_string); +} + +bool String::is_valid_identifier() const { + return godot_string_is_valid_identifier(&_godot_string); +} + +bool String::is_valid_integer() const { + return godot_string_is_numeric(&_godot_string); +} + +bool String::is_valid_ip_address() const { + return godot_string_is_valid_ip_address(&_godot_string); +} + +String String::json_escape() const { + String new_string; + new_string._godot_string = godot_string_json_escape(&_godot_string); + + return new_string; +} + +String String::left(int position) const { + String new_string; + new_string._godot_string = godot_string_left(&_godot_string, position); + + return new_string; +} + +bool String::match(String expr) const { + return godot_string_match(&_godot_string, &expr._godot_string); +} + +bool String::matchn(String expr) const { + return godot_string_match(&_godot_string, &expr._godot_string); +} + +PoolByteArray String::md5_buffer() const { + godot_pool_byte_array arr = godot_string_md5_buffer(&_godot_string); + return *(PoolByteArray *)&arr; +} + +String String::md5_text() const { + String new_string; + new_string._godot_string = godot_string_md5_text(&_godot_string); + + return new_string; +} + +int String::ord_at(int at) const { + return godot_string_ord_at(&_godot_string, at); +} + +String String::pad_decimals(int digits) const { + String new_string; + new_string._godot_string = godot_string_pad_decimals(&_godot_string, digits); + + return new_string; +} + +String String::pad_zeros(int digits) const { + String new_string; + new_string._godot_string = godot_string_pad_zeros(&_godot_string, digits); + + return new_string; +} + +String String::percent_decode() const { + String new_string; + new_string._godot_string = godot_string_percent_decode(&_godot_string); + + return new_string; +} + +String String::percent_encode() const { + String new_string; + new_string._godot_string = godot_string_percent_encode(&_godot_string); + + return new_string; +} + +String String::plus_file(String file) const { + String new_string; + new_string._godot_string = godot_string_plus_file(&_godot_string, &file._godot_string); + + return new_string; +} + +String String::replace(String p_key, String p_with) const { + String new_string; + new_string._godot_string = godot_string_replace(&_godot_string, p_key._godot_string, p_with._godot_string); + + return new_string; +} + +String String::replacen(String what, String forwhat) const { + String new_string; + new_string._godot_string = godot_string_replacen(&_godot_string, what._godot_string, forwhat._godot_string); + + return new_string; +} + +int String::rfind(String what, int from) const { + return godot_string_rfind(&_godot_string, what._godot_string); +} + +int String::rfindn(String what, int from) const { + // From -1 + return godot_string_rfindn(&_godot_string, what._godot_string); +} + +String String::right(int position) const { + String new_string; + new_string._godot_string = godot_string_right(&_godot_string, position); + + return new_string; +} + +PoolByteArray String::sha256_buffer() const { + godot_pool_byte_array arr = godot_string_sha256_buffer(&_godot_string); + + return *(PoolByteArray *)&arr; +} + +String String::sha256_text() const { + String new_string; + new_string._godot_string = godot_string_sha256_text(&_godot_string); + + return new_string; +} + +float String::similarity(String text) const { + return godot_string_similarity(&_godot_string, &text._godot_string); +} + +PoolStringArray String::split(String divisor, bool allow_empty) const { + godot_array arr = godot_string_split(&_godot_string, &divisor._godot_string); + + return *(PoolStringArray *)&arr; +} + +PoolRealArray String::split_floats(String divisor, bool allow_empty) const { + godot_array arr = godot_string_split_floats(&_godot_string, &divisor._godot_string); + + return *(PoolRealArray *)&arr; +} + +String String::strip_edges(bool left, bool right) const { + String new_string; + new_string._godot_string = godot_string_strip_edges(&_godot_string, left, right); + + return new_string; +} + +String String::substr(int from, int len) const { + String new_string; + new_string._godot_string = godot_string_substr(&_godot_string, from, len); + + return new_string; +} + +float String::to_float() const { + return godot_string_to_float(&_godot_string); +} + +int64_t String::to_int() const { + return godot_string_to_int(&_godot_string); +} + +String String::to_lower() const { + String new_string; + new_string._godot_string = godot_string_to_lower(&_godot_string); + + return new_string; +} + +String String::to_upper() const { + String new_string; + new_string._godot_string = godot_string_to_upper(&_godot_string); + + return new_string; +} + +String String::xml_escape() const { + String new_string; + new_string._godot_string = godot_string_xml_escape(&_godot_string); + + return new_string; +} + +String String::xml_unescape() const { + String new_string; + new_string._godot_string = godot_string_xml_unescape(&_godot_string); + + return new_string; +} } diff --git a/src/core/Variant.cpp b/src/core/Variant.cpp index fa72b669..24109dd5 100644 --- a/src/core/Variant.cpp +++ b/src/core/Variant.cpp @@ -1,6 +1,6 @@ #include "Variant.hpp" -#include +#include #include "Defs.hpp" @@ -199,9 +199,7 @@ Variant &Variant::operator =(const Variant& v) Variant::operator bool() const { - bool valid = false; - bool result = booleanize(valid); - return valid && result; + return booleanize(); } Variant::operator signed int() const { @@ -423,9 +421,9 @@ bool Variant::hash_compare(const Variant& b) const return godot_variant_hash_compare(&_godot_variant, &b._godot_variant); } -bool Variant::booleanize(bool &valid) const +bool Variant::booleanize() const { - return godot_variant_booleanize(&_godot_variant, &valid); + return godot_variant_booleanize(&_godot_variant); } Variant::~Variant() diff --git a/src/core/Vector2.cpp b/src/core/Vector2.cpp index 46f11257..7dc78b69 100644 --- a/src/core/Vector2.cpp +++ b/src/core/Vector2.cpp @@ -2,7 +2,7 @@ #include -#include +#include #include "String.hpp"