diff options
Diffstat (limited to 'modules')
22 files changed, 1513 insertions, 92 deletions
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp index 738bd27ed3..68d5c9e611 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -508,7 +508,7 @@ uint32_t NetworkedMultiplayerENet::_gen_unique_id() const { (uint32_t)OS::get_singleton()->get_data_dir().hash64(), hash); /* hash = hash_djb2_one_32( - (uint32_t)OS::get_singleton()->get_unique_ID().hash64(), hash ); + (uint32_t)OS::get_singleton()->get_unique_id().hash64(), hash ); */ hash = hash_djb2_one_32( (uint32_t)((uint64_t)this), hash); //rely on aslr heap diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp index 07dba921b1..440cc45479 100644 --- a/modules/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative.cpp @@ -169,8 +169,8 @@ void GDNative::_compile_dummy_for_api() { } void GDNative::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_library", "library:GDNativeLibrary"), &GDNative::set_library); - ClassDB::bind_method(D_METHOD("get_library:GDNativeLibrary"), &GDNative::get_library); + ClassDB::bind_method(D_METHOD("set_library", "library"), &GDNative::set_library); + ClassDB::bind_method(D_METHOD("get_library"), &GDNative::get_library); ClassDB::bind_method(D_METHOD("initialize"), &GDNative::initialize); ClassDB::bind_method(D_METHOD("terminate"), &GDNative::terminate); @@ -178,7 +178,7 @@ void GDNative::_bind_methods() { // TODO(karroffel): get_native_(raw_)call_types binding? // TODO(karroffel): make this a varargs function? - ClassDB::bind_method(D_METHOD("call_native:Variant", "procedure_name", "arguments:Array"), &GDNative::call_native); + ClassDB::bind_method(D_METHOD("call_native", "procedure_name", "arguments"), &GDNative::call_native); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "GDNativeLibrary"), "set_library", "get_library"); } diff --git a/modules/gdnative/godot/node_path.cpp b/modules/gdnative/godot/node_path.cpp index e718a9e55f..f4179361be 100644 --- a/modules/gdnative/godot/node_path.cpp +++ b/modules/gdnative/godot/node_path.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include <godot/node_path.h> -#include "core/path_db.h" +#include "core/node_path.h" #include "core/variant.h" #ifdef __cplusplus diff --git a/modules/gdnative/godot/string.cpp b/modules/gdnative/godot/string.cpp index 3573f266ac..76cf1fba12 100644 --- a/modules/gdnative/godot/string.cpp +++ b/modules/gdnative/godot/string.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include <godot/string.h> +#include "core/variant.h" #include "string_db.h" #include "ustring.h" @@ -112,6 +113,1155 @@ void GDAPI godot_string_destroy(godot_string *p_self) { self->~String(); } +/* Standard size stuff */ + +godot_int GDAPI godot_string_length(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->length(); +} + +/* Helpers */ + +godot_bool GDAPI godot_string_begins_with(const godot_string *p_self, const godot_string *p_string) { + const String *self = (const String *)p_self; + const String *string = (const String *)p_string; + + return self->begins_with(*string); +} + +godot_bool GDAPI godot_string_begins_with_char_array(const godot_string *p_self, const char *p_char_array) { + const String *self = (const String *)p_self; + + return self->begins_with(p_char_array); +} + +godot_array GDAPI godot_string_bigrams(const godot_string *p_self) { + const String *self = (const String *)p_self; + Vector<String> return_value = self->bigrams(); + + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_string GDAPI godot_string_chr(wchar_t p_character) { + godot_string result; + memnew_placement(&result, String(String::chr(p_character))); + + return result; +} + +godot_bool GDAPI godot_string_ends_with(const godot_string *p_self, const godot_string *p_string) { + const String *self = (const String *)p_self; + const String *string = (const String *)p_string; + + return self->ends_with(*string); +} + +godot_int GDAPI godot_string_find(const godot_string *p_self, godot_string p_what) { + const String *self = (const String *)p_self; + String *what = (String *)&p_what; + + return self->find(*what); +} + +godot_int GDAPI godot_string_find_from(const godot_string *p_self, godot_string p_what, godot_int p_from) { + const String *self = (const String *)p_self; + String *what = (String *)&p_what; + + return self->find(*what, p_from); +} + +godot_int GDAPI godot_string_findmk(const godot_string *p_self, const godot_array *p_keys) { + const String *self = (const String *)p_self; + + Vector<String> keys; + Array *keys_proxy = (Array *)p_keys; + keys.resize(keys_proxy->size()); + for (int i = 0; i < keys_proxy->size(); i++) { + keys[i] = (*keys_proxy)[i]; + } + + return self->findmk(keys); +} + +godot_int GDAPI godot_string_findmk_from(const godot_string *p_self, const godot_array *p_keys, godot_int p_from) { + const String *self = (const String *)p_self; + + Vector<String> keys; + Array *keys_proxy = (Array *)p_keys; + keys.resize(keys_proxy->size()); + for (int i = 0; i < keys_proxy->size(); i++) { + keys[i] = (*keys_proxy)[i]; + } + + return self->findmk(keys, p_from); +} + +godot_int GDAPI godot_string_findmk_from_in_place(const godot_string *p_self, const godot_array *p_keys, godot_int p_from, godot_int *r_key) { + const String *self = (const String *)p_self; + + Vector<String> keys; + Array *keys_proxy = (Array *)p_keys; + keys.resize(keys_proxy->size()); + for (int i = 0; i < keys_proxy->size(); i++) { + keys[i] = (*keys_proxy)[i]; + } + + return self->findmk(keys, p_from, r_key); +} + +godot_int GDAPI godot_string_findn(const godot_string *p_self, godot_string p_what) { + const String *self = (const String *)p_self; + String *what = (String *)&p_what; + + return self->findn(*what); +} + +godot_int GDAPI godot_string_findn_from(const godot_string *p_self, godot_string p_what, godot_int p_from) { + const String *self = (const String *)p_self; + String *what = (String *)&p_what; + + return self->findn(*what, p_from); +} + +godot_int GDAPI find_last(const godot_string *p_self, godot_string p_what) { + const String *self = (const String *)p_self; + String *what = (String *)&p_what; + + return self->find_last(*what); +} + +godot_string GDAPI godot_string_format(const godot_string *p_self, const godot_variant *p_values) { + const String *self = (const String *)p_self; + const Variant *values = (const Variant *)p_values; + godot_string result; + memnew_placement(&result, String(self->format(*values))); + + return result; +} + +godot_string GDAPI godot_string_format_with_custom_placeholder(const godot_string *p_self, const godot_variant *p_values, const char *p_placeholder) { + const String *self = (const String *)p_self; + const Variant *values = (const Variant *)p_values; + String placeholder = String(p_placeholder); + godot_string result; + memnew_placement(&result, String(self->format(*values, placeholder))); + + return result; +} + +godot_string GDAPI godot_string_hex_encode_buffer(const uint8_t *p_buffer, godot_int p_len) { + godot_string result; + memnew_placement(&result, String(String::hex_encode_buffer(p_buffer, p_len))); + + return result; +} + +godot_int GDAPI godot_string_hex_to_int(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->hex_to_int(); +} + +godot_int GDAPI godot_string_hex_to_int_without_prefix(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->hex_to_int(true); +} + +godot_string GDAPI godot_string_insert(const godot_string *p_self, godot_int at_pos, godot_string p_content) { + const String *self = (const String *)p_self; + String *content = (String *)&p_content; + godot_string result; + memnew_placement(&result, String(self->insert(at_pos, *content))); + + return result; +} + +godot_bool GDAPI godot_string_is_numeric(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->is_numeric(); +} + +godot_bool GDAPI godot_string_is_subsequence_of(const godot_string *p_self, const godot_string *p_string) { + const String *self = (const String *)p_self; + const String *string = (const String *)p_string; + + return self->is_subsequence_of(*string); +} + +godot_bool GDAPI godot_string_is_subsequence_ofi(const godot_string *p_self, const godot_string *p_string) { + const String *self = (const String *)p_self; + const String *string = (const String *)p_string; + + return self->is_subsequence_ofi(*string); +} + +godot_string GDAPI godot_string_lpad(const godot_string *p_self, godot_int p_min_length) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->lpad(p_min_length))); + + return result; +} + +godot_string GDAPI godot_string_lpad_with_custom_character(const godot_string *p_self, godot_int p_min_length, const godot_string *p_character) { + const String *self = (const String *)p_self; + const String *character = (const String *)p_character; + godot_string result; + memnew_placement(&result, String(self->lpad(p_min_length, *character))); + + return result; +} + +godot_bool GDAPI godot_string_match(const godot_string *p_self, const godot_string *p_wildcard) { + const String *self = (const String *)p_self; + const String *wildcard = (const String *)p_wildcard; + + return self->match(*wildcard); +} + +godot_bool GDAPI godot_string_matchn(const godot_string *p_self, const godot_string *p_wildcard) { + const String *self = (const String *)p_self; + const String *wildcard = (const String *)p_wildcard; + + return self->matchn(*wildcard); +} + +godot_string GDAPI godot_string_md5(const uint8_t *p_md5) { + godot_string result; + memnew_placement(&result, String(String::md5(p_md5))); + + return result; +} + +godot_string GDAPI godot_string_num(double p_num) { + godot_string result; + memnew_placement(&result, String(String::num(p_num))); + + return result; +} + +godot_string GDAPI godot_string_num_int64(int64_t p_num, godot_int p_base) { + godot_string result; + memnew_placement(&result, String(String::num_int64(p_num, p_base))); + + return result; +} + +godot_string GDAPI godot_string_num_int64_capitalized(int64_t p_num, godot_int p_base, godot_bool p_capitalize_hex) { + godot_string result; + memnew_placement(&result, String(String::num_int64(p_num, p_base, true))); + + return result; +} + +godot_string GDAPI godot_string_num_real(double p_num) { + godot_string result; + memnew_placement(&result, String(String::num_real(p_num))); + + return result; +} + +godot_string GDAPI godot_string_num_scientific(double p_num) { + godot_string result; + memnew_placement(&result, String(String::num_scientific(p_num))); + + return result; +} + +godot_string GDAPI godot_string_num_with_decimals(double p_num, godot_int p_decimals) { + godot_string result; + memnew_placement(&result, String(String::num(p_num, p_decimals))); + + return result; +} + +godot_string GDAPI godot_string_pad_decimals(const godot_string *p_self, godot_int p_digits) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->pad_decimals(p_digits))); + + return result; +} + +godot_string GDAPI godot_string_pad_zeros(const godot_string *p_self, godot_int p_digits) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->pad_zeros(p_digits))); + + return result; +} + +godot_string GDAPI godot_string_replace(const godot_string *p_self, godot_string p_key, godot_string p_with) { + const String *self = (const String *)p_self; + String *key = (String *)&p_key; + String *with = (String *)&p_with; + godot_string result; + memnew_placement(&result, String(self->replace(*key, *with))); + + return result; +} + +godot_string GDAPI godot_string_replacen(const godot_string *p_self, godot_string p_key, godot_string p_with) { + const String *self = (const String *)p_self; + String *key = (String *)&p_key; + String *with = (String *)&p_with; + godot_string result; + memnew_placement(&result, String(self->replacen(*key, *with))); + + return result; +} + +godot_int GDAPI godot_string_rfind(const godot_string *p_self, godot_string p_what) { + const String *self = (const String *)p_self; + String *what = (String *)&p_what; + + return self->rfind(*what); +} + +godot_int GDAPI godot_string_rfindn(const godot_string *p_self, godot_string p_what) { + const String *self = (const String *)p_self; + String *what = (String *)&p_what; + + return self->rfindn(*what); +} + +godot_int GDAPI godot_string_rfind_from(const godot_string *p_self, godot_string p_what, godot_int p_from) { + const String *self = (const String *)p_self; + String *what = (String *)&p_what; + + return self->rfind(*what, p_from); +} + +godot_int GDAPI godot_string_rfindn_from(const godot_string *p_self, godot_string p_what, godot_int p_from) { + const String *self = (const String *)p_self; + String *what = (String *)&p_what; + + return self->rfindn(*what, p_from); +} + +godot_string GDAPI godot_string_replace_first(const godot_string *p_self, godot_string p_key, godot_string p_with) { + const String *self = (const String *)p_self; + String *key = (String *)&p_key; + String *with = (String *)&p_with; + godot_string result; + memnew_placement(&result, String(self->replace_first(*key, *with))); + + return result; +} + +godot_string GDAPI godot_string_rpad(const godot_string *p_self, godot_int p_min_length) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->rpad(p_min_length))); + + return result; +} + +godot_string GDAPI godot_string_rpad_with_custom_character(const godot_string *p_self, godot_int p_min_length, const godot_string *p_character) { + const String *self = (const String *)p_self; + const String *character = (const String *)p_character; + godot_string result; + memnew_placement(&result, String(self->rpad(p_min_length, *character))); + + return result; +} + +godot_real GDAPI godot_string_similarity(const godot_string *p_self, const godot_string *p_string) { + const String *self = (const String *)p_self; + const String *string = (const String *)p_string; + + return self->similarity(*string); +} + +godot_string GDAPI godot_string_sprintf(const godot_string *p_self, const godot_array *p_values, godot_bool *p_error) { + const String *self = (const String *)p_self; + const Array *values = (const Array *)p_values; + + godot_string result; + String return_value = self->sprintf(*values, p_error); + memnew_placement(&result, String(return_value)); + + return result; +} + +godot_string GDAPI godot_string_substr(const godot_string *p_self, godot_int p_from, godot_int p_chars) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->substr(p_from, p_chars))); + + return result; +} + +double GDAPI godot_string_to_double(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->to_double(); +} + +godot_real GDAPI godot_string_to_float(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->to_float(); +} + +godot_int GDAPI godot_string_to_int(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->to_int(); +} + +godot_string GDAPI godot_string_capitalize(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->capitalize())); + + return result; +}; + +godot_string GDAPI godot_string_camelcase_to_underscore(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->camelcase_to_underscore(false))); + + return result; +}; + +godot_string GDAPI godot_string_camelcase_to_underscore_lowercased(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->camelcase_to_underscore())); + + return result; +}; + +double GDAPI godot_string_char_to_double(const char *p_what) { + return String::to_double(p_what); +}; + +godot_int GDAPI godot_string_char_to_int(const char *p_what) { + return String::to_int(p_what); +}; + +int64_t GDAPI godot_string_wchar_to_int(const wchar_t *p_str) { + return String::to_int(p_str); +}; + +godot_int GDAPI godot_string_char_to_int_with_len(const char *p_what, godot_int p_len) { + return String::to_int(p_what, p_len); +}; + +int64_t GDAPI godot_string_char_to_int64_with_len(const wchar_t *p_str, int p_len) { + return String::to_int(p_str, p_len); +}; + +int64_t GDAPI godot_string_hex_to_int64(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->hex_to_int64(false); +}; + +int64_t GDAPI godot_string_hex_to_int64_with_prefix(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->hex_to_int64(); +}; + +int64_t GDAPI godot_string_to_int64(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->to_int64(); +}; + +double GDAPI godot_string_unicode_char_to_double(const wchar_t *p_str, const wchar_t **r_end) { + return String::to_double(p_str, r_end); +} + +godot_string GDAPI godot_string_get_slice(const godot_string *p_self, godot_string p_splitter, godot_int p_slice) { + const String *self = (const String *)p_self; + String *splitter = (String *)&p_splitter; + godot_string result; + memnew_placement(&result, String(self->get_slice(*splitter, p_slice))); + + return result; +}; + +godot_string GDAPI godot_string_get_slicec(const godot_string *p_self, wchar_t p_splitter, godot_int p_slice) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->get_slicec(p_splitter, p_slice))); + + return result; +}; + +godot_array GDAPI godot_string_split(const godot_string *p_self, const godot_string *p_splitter) { + const String *self = (const String *)p_self; + const String *splitter = (const String *)p_splitter; + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector<String> return_value = self->split(*splitter, false); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_array GDAPI godot_string_split_allow_empty(const godot_string *p_self, const godot_string *p_splitter) { + const String *self = (const String *)p_self; + const String *splitter = (const String *)p_splitter; + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector<String> return_value = self->split(*splitter); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_array GDAPI godot_string_split_floats(const godot_string *p_self, const godot_string *p_splitter) { + const String *self = (const String *)p_self; + const String *splitter = (const String *)p_splitter; + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector<float> return_value = self->split_floats(*splitter, false); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_array GDAPI godot_string_split_floats_allows_empty(const godot_string *p_self, const godot_string *p_splitter) { + const String *self = (const String *)p_self; + const String *splitter = (const String *)p_splitter; + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector<float> return_value = self->split_floats(*splitter); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_array GDAPI godot_string_split_floats_mk(const godot_string *p_self, const godot_array *p_splitters) { + const String *self = (const String *)p_self; + + Vector<String> splitters; + Array *splitter_proxy = (Array *)p_splitters; + splitters.resize(splitter_proxy->size()); + for (int i = 0; i < splitter_proxy->size(); i++) { + splitters[i] = (*splitter_proxy)[i]; + } + + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector<float> return_value = self->split_floats_mk(splitters, false); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_array GDAPI godot_string_split_floats_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters) { + const String *self = (const String *)p_self; + + Vector<String> splitters; + Array *splitter_proxy = (Array *)p_splitters; + splitters.resize(splitter_proxy->size()); + for (int i = 0; i < splitter_proxy->size(); i++) { + splitters[i] = (*splitter_proxy)[i]; + } + + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector<float> return_value = self->split_floats_mk(splitters); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_array GDAPI godot_string_split_ints(const godot_string *p_self, const godot_string *p_splitter) { + const String *self = (const String *)p_self; + const String *splitter = (const String *)p_splitter; + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector<int> return_value = self->split_ints(*splitter, false); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_array GDAPI godot_string_split_ints_allows_empty(const godot_string *p_self, const godot_string *p_splitter) { + const String *self = (const String *)p_self; + const String *splitter = (const String *)p_splitter; + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector<int> return_value = self->split_ints(*splitter); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_array GDAPI godot_string_split_ints_mk(const godot_string *p_self, const godot_array *p_splitters) { + const String *self = (const String *)p_self; + + Vector<String> splitters; + Array *splitter_proxy = (Array *)p_splitters; + splitters.resize(splitter_proxy->size()); + for (int i = 0; i < splitter_proxy->size(); i++) { + splitters[i] = (*splitter_proxy)[i]; + } + + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector<int> return_value = self->split_ints_mk(splitters, false); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_array GDAPI godot_string_split_ints_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters) { + const String *self = (const String *)p_self; + + Vector<String> splitters; + Array *splitter_proxy = (Array *)p_splitters; + splitters.resize(splitter_proxy->size()); + for (int i = 0; i < splitter_proxy->size(); i++) { + splitters[i] = (*splitter_proxy)[i]; + } + + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector<int> return_value = self->split_ints_mk(splitters); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_array GDAPI godot_string_split_spaces(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector<String> return_value = self->split_spaces(); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_int GDAPI godot_string_get_slice_count(const godot_string *p_self, godot_string p_splitter) { + const String *self = (const String *)p_self; + String *splitter = (String *)&p_splitter; + + return self->get_slice_count(*splitter); +}; + +wchar_t GDAPI godot_string_char_lowercase(wchar_t p_char) { + return String::char_lowercase(p_char); +}; + +wchar_t GDAPI godot_string_char_uppercase(wchar_t p_char) { + return String::char_uppercase(p_char); +}; + +godot_string GDAPI godot_string_to_lower(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->to_lower())); + + return result; +}; + +godot_string GDAPI godot_string_to_upper(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->to_upper())); + + return result; +}; + +godot_string GDAPI godot_string_get_basename(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->get_basename())); + + return result; +}; + +godot_string GDAPI godot_string_get_extension(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->get_extension())); + + return result; +}; + +godot_string GDAPI godot_string_left(const godot_string *p_self, godot_int p_pos) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->left(p_pos))); + + return result; +}; + +wchar_t GDAPI godot_string_ord_at(const godot_string *p_self, godot_int p_idx) { + const String *self = (const String *)p_self; + + return self->ord_at(p_idx); +}; + +godot_string GDAPI godot_string_plus_file(const godot_string *p_self, const godot_string *p_file) { + const String *self = (const String *)p_self; + const String *file = (const String *)p_file; + godot_string result; + memnew_placement(&result, String(self->plus_file(*file))); + + return result; +}; + +godot_string GDAPI godot_string_right(const godot_string *p_self, godot_int p_pos) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->right(p_pos))); + + return result; +}; + +godot_string GDAPI godot_string_strip_edges(const godot_string *p_self, godot_bool p_left, godot_bool p_right) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->strip_edges(p_left, p_right))); + + return result; +}; + +godot_string GDAPI godot_string_strip_escapes(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->strip_escapes())); + + return result; +}; + +void GDAPI godot_string_erase(godot_string *p_self, godot_int p_pos, godot_int p_chars) { + String *self = (String *)p_self; + + return self->erase(p_pos, p_chars); +}; + +void GDAPI godot_string_ascii(godot_string *p_self, char *result) { + String *self = (String *)p_self; + Vector<char> return_value = self->ascii(); + + for (int i = 0; i < return_value.size(); i++) { + result[i] = return_value[i]; + } +} + +void GDAPI godot_string_ascii_extended(godot_string *p_self, char *result) { + String *self = (String *)p_self; + Vector<char> return_value = self->ascii(true); + + for (int i = 0; i < return_value.size(); i++) { + result[i] = return_value[i]; + } +} + +void GDAPI godot_string_utf8(godot_string *p_self, char *result) { + String *self = (String *)p_self; + Vector<char> return_value = self->utf8(); + + for (int i = 0; i < return_value.size(); i++) { + result[i] = return_value[i]; + } +} + +godot_bool GDAPI godot_string_parse_utf8(godot_string *p_self, const char *p_utf8) { + String *self = (String *)p_self; + + return self->parse_utf8(p_utf8); +}; + +godot_bool GDAPI godot_string_parse_utf8_with_len(godot_string *p_self, const char *p_utf8, godot_int p_len) { + String *self = (String *)p_self; + + return self->parse_utf8(p_utf8, p_len); +}; + +godot_string GDAPI godot_string_chars_to_utf8(const char *p_utf8) { + godot_string result; + memnew_placement(&result, String(String::utf8(p_utf8))); + + return result; +}; + +godot_string GDAPI godot_string_chars_to_utf8_with_len(const char *p_utf8, godot_int p_len) { + godot_string result; + memnew_placement(&result, String(String::utf8(p_utf8, p_len))); + + return result; +}; + +uint32_t GDAPI godot_string_hash(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->hash(); +}; + +uint64_t GDAPI godot_string_hash64(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->hash64(); +}; + +uint32_t GDAPI godot_string_hash_chars(const char *p_cstr) { + return String::hash(p_cstr); +}; + +uint32_t GDAPI godot_string_hash_chars_with_len(const char *p_cstr, godot_int p_len) { + return String::hash(p_cstr, p_len); +}; + +uint32_t GDAPI godot_string_hash_utf8_chars(const wchar_t *p_str) { + return String::hash(p_str); +}; + +uint32_t GDAPI godot_string_hash_utf8_chars_with_len(const wchar_t *p_str, godot_int p_len) { + return String::hash(p_str, p_len); +}; + +godot_pool_byte_array GDAPI godot_string_md5_buffer(const godot_string *p_self) { + const String *self = (const String *)p_self; + Vector<uint8_t> tmp_result = self->md5_buffer(); + + godot_pool_byte_array result; + memnew_placement(&result, PoolByteArray); + PoolByteArray *proxy = (PoolByteArray *)&result; + PoolByteArray::Write proxy_writer = proxy->write(); + proxy->resize(tmp_result.size()); + + for (int i = 0; i < tmp_result.size(); i++) { + proxy_writer[i] = tmp_result[i]; + } + + return result; +}; + +godot_string GDAPI godot_string_md5_text(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->md5_text())); + + return result; +}; + +godot_pool_byte_array GDAPI godot_string_sha256_buffer(const godot_string *p_self) { + const String *self = (const String *)p_self; + Vector<uint8_t> tmp_result = self->sha256_buffer(); + + godot_pool_byte_array result; + memnew_placement(&result, PoolByteArray); + PoolByteArray *proxy = (PoolByteArray *)&result; + PoolByteArray::Write proxy_writer = proxy->write(); + proxy->resize(tmp_result.size()); + + for (int i = 0; i < tmp_result.size(); i++) { + proxy_writer[i] = tmp_result[i]; + } + + return result; +}; + +godot_string GDAPI godot_string_sha256_text(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->sha256_text())); + + return result; +}; + +godot_bool godot_string_empty(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->empty(); +}; + +// path functions +godot_string GDAPI godot_string_get_base_dir(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->get_base_dir(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_get_file(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->get_file(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_humanize_size(size_t p_size) { + godot_string result; + String return_value = String::humanize_size(p_size); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_bool GDAPI godot_string_is_abs_path(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->is_abs_path(); +}; + +godot_bool GDAPI godot_string_is_rel_path(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->is_rel_path(); +}; + +godot_bool GDAPI godot_string_is_resource_file(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->is_resource_file(); +}; + +godot_string GDAPI godot_string_path_to(const godot_string *p_self, const godot_string *p_path) { + const String *self = (const String *)p_self; + String *path = (String *)p_path; + godot_string result; + String return_value = self->path_to(*path); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_path_to_file(const godot_string *p_self, const godot_string *p_path) { + const String *self = (const String *)p_self; + String *path = (String *)p_path; + godot_string result; + String return_value = self->path_to_file(*path); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_simplify_path(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->simplify_path(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_c_escape(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->c_escape(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_c_escape_multiline(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->c_escape_multiline(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_c_unescape(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->c_unescape(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_http_escape(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->http_escape(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_http_unescape(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->http_unescape(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_json_escape(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->json_escape(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_word_wrap(const godot_string *p_self, godot_int p_chars_per_line) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->word_wrap(p_chars_per_line); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_xml_escape(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->xml_escape(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_xml_escape_with_quotes(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->xml_escape(true); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_xml_unescape(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->xml_unescape(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_percent_decode(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->percent_decode(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_percent_encode(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->percent_encode(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_bool GDAPI godot_string_is_valid_float(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->is_valid_float(); +}; + +godot_bool GDAPI godot_string_is_valid_hex_number(const godot_string *p_self, godot_bool p_with_prefix) { + const String *self = (const String *)p_self; + + return self->is_valid_hex_number(p_with_prefix); +}; + +godot_bool GDAPI godot_string_is_valid_html_color(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->is_valid_html_color(); +}; + +godot_bool GDAPI godot_string_is_valid_identifier(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->is_valid_identifier(); +}; + +godot_bool GDAPI godot_string_is_valid_integer(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->is_valid_integer(); +}; + +godot_bool GDAPI godot_string_is_valid_ip_address(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->is_valid_ip_address(); +}; + #ifdef __cplusplus } #endif diff --git a/modules/gdnative/godot/string.h b/modules/gdnative/godot/string.h index 9013326454..bfe66aa5ec 100644 --- a/modules/gdnative/godot/string.h +++ b/modules/gdnative/godot/string.h @@ -47,6 +47,7 @@ typedef struct { #endif #include <godot/gdnative.h> +#include <godot/variant.h> void GDAPI godot_string_new(godot_string *r_dest); void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src); @@ -63,9 +64,160 @@ godot_bool GDAPI godot_string_operator_equal(const godot_string *p_self, const g godot_bool GDAPI godot_string_operator_less(const godot_string *p_self, const godot_string *p_b); godot_string GDAPI godot_string_operator_plus(const godot_string *p_self, const godot_string *p_b); -// @Incomplete -// hmm, I guess exposing the whole API doesn't make much sense -// since the language used in the library has its own string funcs +/* Standard size stuff */ + +godot_int GDAPI godot_string_length(const godot_string *p_self); + +/* Helpers */ + +godot_bool GDAPI godot_string_begins_with(const godot_string *p_self, const godot_string *p_string); +godot_bool GDAPI godot_string_begins_with_char_array(const godot_string *p_self, const char *p_char_array); +godot_array GDAPI godot_string_bigrams(const godot_string *p_self); +godot_string GDAPI godot_string_chr(wchar_t p_character); +godot_bool GDAPI godot_string_ends_with(const godot_string *p_self, const godot_string *p_string); +godot_int GDAPI godot_string_find(const godot_string *p_self, godot_string p_what); +godot_int GDAPI godot_string_find_from(const godot_string *p_self, godot_string p_what, godot_int p_from); +godot_int GDAPI godot_string_findmk(const godot_string *p_self, const godot_array *p_keys); +godot_int GDAPI godot_string_findmk_from(const godot_string *p_self, const godot_array *p_keys, godot_int p_from); +godot_int GDAPI godot_string_findmk_from_in_place(const godot_string *p_self, const godot_array *p_keys, godot_int p_from, godot_int *r_key); +godot_int GDAPI godot_string_findn(const godot_string *p_self, godot_string p_what); +godot_int GDAPI godot_string_findn_from(const godot_string *p_self, godot_string p_what, godot_int p_from); +godot_int GDAPI find_last(const godot_string *p_self, godot_string p_what); +godot_string GDAPI godot_string_format(const godot_string *p_self, const godot_variant *values); +godot_string GDAPI godot_string_format_with_custom_placeholder(const godot_string *p_self, const godot_variant *values, const char *placeholder); +godot_string GDAPI godot_string_hex_encode_buffer(const uint8_t *p_buffer, godot_int p_len); +godot_int GDAPI godot_string_hex_to_int(const godot_string *p_self); +godot_int GDAPI godot_string_hex_to_int_without_prefix(const godot_string *p_self); +godot_string GDAPI godot_string_insert(const godot_string *p_self, godot_int p_at_pos, godot_string p_string); +godot_bool GDAPI godot_string_is_numeric(const godot_string *p_self); +godot_bool GDAPI godot_string_is_subsequence_of(const godot_string *p_self, const godot_string *p_string); +godot_bool GDAPI godot_string_is_subsequence_ofi(const godot_string *p_self, const godot_string *p_string); +godot_string GDAPI godot_string_lpad(const godot_string *p_self, godot_int p_min_length); +godot_string GDAPI godot_string_lpad_with_custom_character(const godot_string *p_self, godot_int p_min_length, const godot_string *p_character); +godot_bool GDAPI godot_string_match(const godot_string *p_self, const godot_string *p_wildcard); +godot_bool GDAPI godot_string_matchn(const godot_string *p_self, const godot_string *p_wildcard); +godot_string GDAPI godot_string_md5(const uint8_t *p_md5); +godot_string GDAPI godot_string_num(double p_num); +godot_string GDAPI godot_string_num_int64(int64_t p_num, godot_int p_base); +godot_string GDAPI godot_string_num_int64_capitalized(int64_t p_num, godot_int p_base, godot_bool p_capitalize_hex); +godot_string GDAPI godot_string_num_real(double p_num); +godot_string GDAPI godot_string_num_scientific(double p_num); +godot_string GDAPI godot_string_num_with_decimals(double p_num, godot_int p_decimals); +godot_string GDAPI godot_string_pad_decimals(const godot_string *p_self, godot_int p_digits); +godot_string GDAPI godot_string_pad_zeros(const godot_string *p_self, godot_int p_digits); +godot_string GDAPI godot_string_replace_first(const godot_string *p_self, godot_string p_key, godot_string p_with); +godot_string GDAPI godot_string_replace(const godot_string *p_self, godot_string p_key, godot_string p_with); +godot_string GDAPI godot_string_replacen(const godot_string *p_self, godot_string p_key, godot_string p_with); +godot_int GDAPI godot_string_rfind(const godot_string *p_self, godot_string p_what); +godot_int GDAPI godot_string_rfindn(const godot_string *p_self, godot_string p_what); +godot_int GDAPI godot_string_rfind_from(const godot_string *p_self, godot_string p_what, godot_int p_from); +godot_int GDAPI godot_string_rfindn_from(const godot_string *p_self, godot_string p_what, godot_int p_from); +godot_string GDAPI godot_string_rpad(const godot_string *p_self, godot_int p_min_length); +godot_string GDAPI godot_string_rpad_with_custom_character(const godot_string *p_self, godot_int p_min_length, const godot_string *p_character); +godot_real GDAPI godot_string_similarity(const godot_string *p_self, const godot_string *p_string); +godot_string GDAPI godot_string_sprintf(const godot_string *p_self, const godot_array *p_values, godot_bool *p_error); +godot_string GDAPI godot_string_substr(const godot_string *p_self, godot_int p_from, godot_int p_chars); +double GDAPI godot_string_to_double(const godot_string *p_self); +godot_real GDAPI godot_string_to_float(const godot_string *p_self); +godot_int GDAPI godot_string_to_int(const godot_string *p_self); + +godot_string GDAPI godot_string_camelcase_to_underscore(const godot_string *p_self); +godot_string GDAPI godot_string_camelcase_to_underscore_lowercased(const godot_string *p_self); +godot_string GDAPI godot_string_capitalize(const godot_string *p_self); +double GDAPI godot_string_char_to_double(const char *p_what); +godot_int GDAPI godot_string_char_to_int(const char *p_what); +int64_t GDAPI godot_string_wchar_to_int(const wchar_t *p_str); +godot_int GDAPI godot_string_char_to_int_with_len(const char *p_what, godot_int p_len); +int64_t GDAPI godot_string_char_to_int64_with_len(const wchar_t *p_str, int p_len); +int64_t GDAPI godot_string_hex_to_int64(const godot_string *p_self); +int64_t GDAPI godot_string_hex_to_int64_with_prefix(const godot_string *p_self); +int64_t GDAPI godot_string_to_int64(const godot_string *p_self); +double GDAPI godot_string_unicode_char_to_double(const wchar_t *p_str, const wchar_t **r_end); + +godot_int GDAPI godot_string_get_slice_count(const godot_string *p_self, godot_string p_splitter); +godot_string GDAPI godot_string_get_slice(const godot_string *p_self, godot_string p_splitter, godot_int p_slice); +godot_string GDAPI godot_string_get_slicec(const godot_string *p_self, wchar_t p_splitter, godot_int p_slice); + +godot_array GDAPI godot_string_split(const godot_string *p_self, const godot_string *p_splitter); +godot_array GDAPI godot_string_split_allow_empty(const godot_string *p_self, const godot_string *p_splitter); +godot_array GDAPI godot_string_split_floats(const godot_string *p_self, const godot_string *p_splitter); +godot_array GDAPI godot_string_split_floats_allows_empty(const godot_string *p_self, const godot_string *p_splitter); +godot_array GDAPI godot_string_split_floats_mk(const godot_string *p_self, const godot_array *p_splitters); +godot_array GDAPI godot_string_split_floats_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters); +godot_array GDAPI godot_string_split_ints(const godot_string *p_self, const godot_string *p_splitter); +godot_array GDAPI godot_string_split_ints_allows_empty(const godot_string *p_self, const godot_string *p_splitter); +godot_array GDAPI godot_string_split_ints_mk(const godot_string *p_self, const godot_array *p_splitters); +godot_array GDAPI godot_string_split_ints_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters); +godot_array GDAPI godot_string_split_spaces(const godot_string *p_self); + +wchar_t GDAPI godot_string_char_lowercase(wchar_t p_char); +wchar_t GDAPI godot_string_char_uppercase(wchar_t p_char); +godot_string GDAPI godot_string_to_lower(const godot_string *p_self); +godot_string GDAPI godot_string_to_upper(const godot_string *p_self); + +godot_string GDAPI godot_string_get_basename(const godot_string *p_self); +godot_string GDAPI godot_string_get_extension(const godot_string *p_self); +godot_string GDAPI godot_string_left(const godot_string *p_self, godot_int p_pos); +wchar_t GDAPI godot_string_ord_at(const godot_string *p_self, godot_int p_idx); +godot_string GDAPI godot_string_plus_file(const godot_string *p_self, const godot_string *p_file); +godot_string GDAPI godot_string_right(const godot_string *p_self, godot_int p_pos); +godot_string GDAPI godot_string_strip_edges(const godot_string *p_self, godot_bool p_left, godot_bool p_right); +godot_string GDAPI godot_string_strip_escapes(const godot_string *p_self); + +void GDAPI godot_string_erase(godot_string *p_self, godot_int p_pos, godot_int p_chars); + +void GDAPI godot_string_ascii(godot_string *p_self, char *result); +void GDAPI godot_string_ascii_extended(godot_string *p_self, char *result); +void GDAPI godot_string_utf8(godot_string *p_self, char *result); +godot_bool GDAPI godot_string_parse_utf8(godot_string *p_self, const char *p_utf8); +godot_bool GDAPI godot_string_parse_utf8_with_len(godot_string *p_self, const char *p_utf8, godot_int p_len); +godot_string GDAPI godot_string_chars_to_utf8(const char *p_utf8); +godot_string GDAPI godot_string_chars_utf8_with_len(const char *p_utf8, godot_int p_len); + +uint32_t GDAPI godot_string_hash(const godot_string *p_self); +uint64_t GDAPI godot_string_hash64(const godot_string *p_self); +uint32_t GDAPI godot_string_hash_chars(const char *p_cstr); +uint32_t GDAPI godot_string_hash_chars_with_len(const char *p_cstr, godot_int p_len); +uint32_t GDAPI godot_string_hash_utf8_chars(const wchar_t *p_str); +uint32_t GDAPI godot_string_hash_utf8_chars_with_len(const wchar_t *p_str, godot_int p_len); +godot_pool_byte_array GDAPI godot_string_md5_buffer(const godot_string *p_self); +godot_string GDAPI godot_string_md5_text(const godot_string *p_self); +godot_pool_byte_array GDAPI godot_string_sha256_buffer(const godot_string *p_self); +godot_string GDAPI godot_string_sha256_text(const godot_string *p_self); + +godot_bool godot_string_empty(const godot_string *p_self); + +// path functions +godot_string GDAPI godot_string_get_base_dir(const godot_string *p_self); +godot_string GDAPI godot_string_get_file(const godot_string *p_self); +godot_string GDAPI godot_string_humanize_size(size_t p_size); +godot_bool GDAPI godot_string_is_abs_path(const godot_string *p_self); +godot_bool GDAPI godot_string_is_rel_path(const godot_string *p_self); +godot_bool GDAPI godot_string_is_resource_file(const godot_string *p_self); +godot_string GDAPI godot_string_path_to(const godot_string *p_self, const godot_string *p_path); +godot_string GDAPI godot_string_path_to_file(const godot_string *p_self, const godot_string *p_path); +godot_string GDAPI godot_string_simplify_path(const godot_string *p_self); + +godot_string GDAPI godot_string_c_escape(const godot_string *p_self); +godot_string GDAPI godot_string_c_escape_multiline(const godot_string *p_self); +godot_string GDAPI godot_string_c_unescape(const godot_string *p_self); +godot_string GDAPI godot_string_http_escape(const godot_string *p_self); +godot_string GDAPI godot_string_http_unescape(const godot_string *p_self); +godot_string GDAPI godot_string_json_escape(const godot_string *p_self); +godot_string GDAPI godot_string_word_wrap(const godot_string *p_self, godot_int p_chars_per_line); +godot_string GDAPI godot_string_xml_escape(const godot_string *p_self); +godot_string GDAPI godot_string_xml_escape_with_quotes(const godot_string *p_self); +godot_string GDAPI godot_string_xml_unescape(const godot_string *p_self); + +godot_string GDAPI godot_string_percent_decode(const godot_string *p_self); +godot_string GDAPI godot_string_percent_encode(const godot_string *p_self); + +godot_bool GDAPI godot_string_is_valid_float(const godot_string *p_self); +godot_bool GDAPI godot_string_is_valid_hex_number(const godot_string *p_self, godot_bool p_with_prefix); +godot_bool GDAPI godot_string_is_valid_html_color(const godot_string *p_self); +godot_bool GDAPI godot_string_is_valid_identifier(const godot_string *p_self); +godot_bool GDAPI godot_string_is_valid_integer(const godot_string *p_self); +godot_bool GDAPI godot_string_is_valid_ip_address(const godot_string *p_self); void GDAPI godot_string_destroy(godot_string *p_self); diff --git a/modules/gdnative/godot/variant.cpp b/modules/gdnative/godot/variant.cpp index 506614583c..d814ef913c 100644 --- a/modules/gdnative/godot/variant.cpp +++ b/modules/gdnative/godot/variant.cpp @@ -433,7 +433,6 @@ godot_variant GDAPI godot_variant_call(godot_variant *p_self, const godot_string Variant *dest = (Variant *)&raw_dest; Variant::CallError error; memnew_placement_custom(dest, Variant, Variant(self->call(*method, args, p_argcount, error))); - *dest = self->call(StringName(*method), args, p_argcount, r_error); if (r_error) { r_error->error = (godot_variant_call_error_error)error.error; r_error->argument = error.argument; diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index c88889767c..f8b45af85a 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -157,7 +157,7 @@ Script *GDScriptLanguage::create_script() const { bool GDScriptLanguage::debug_break_parse(const String &p_file, int p_line, const String &p_error) { //break because of parse error - if (ScriptDebugger::get_singleton() && Thread::get_caller_ID() == Thread::get_main_ID()) { + if (ScriptDebugger::get_singleton() && Thread::get_caller_id() == Thread::get_main_id()) { _debug_parse_err_line = p_line; _debug_parse_err_file = p_file; @@ -171,7 +171,7 @@ bool GDScriptLanguage::debug_break_parse(const String &p_file, int p_line, const bool GDScriptLanguage::debug_break(const String &p_error, bool p_allow_continue) { - if (ScriptDebugger::get_singleton() && Thread::get_caller_ID() == Thread::get_main_ID()) { + if (ScriptDebugger::get_singleton() && Thread::get_caller_id() == Thread::get_main_id()) { _debug_parse_err_line = -1; _debug_parse_err_file = ""; diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp index 795371af60..cafcc1e965 100644 --- a/modules/gdscript/gd_function.cpp +++ b/modules/gdscript/gd_function.cpp @@ -888,8 +888,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a gdfs->state._class = _class; gdfs->state.ip = ip + ipofs; gdfs->state.line = line; - gdfs->state.instance_id = (p_instance && p_instance->get_owner()) ? p_instance->get_owner()->get_instance_ID() : 0; - gdfs->state.script_id = _class->get_instance_ID(); + gdfs->state.instance_id = (p_instance && p_instance->get_owner()) ? p_instance->get_owner()->get_instance_id() : 0; + gdfs->state.script_id = _class->get_instance_id(); //gdfs->state.result_pos=ip+ipofs-1; gdfs->state.defarg = defarg; gdfs->state.instance = p_instance; @@ -1507,7 +1507,7 @@ Variant GDFunctionState::resume(const Variant &p_arg) { void GDFunctionState::_bind_methods() { - ClassDB::bind_method(D_METHOD("resume:Variant", "arg"), &GDFunctionState::resume, DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("resume", "arg"), &GDFunctionState::resume, DEFVAL(Variant())); ClassDB::bind_method(D_METHOD("is_valid", "extended_check"), &GDFunctionState::is_valid, DEFVAL(false)); ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "_signal_callback", &GDFunctionState::_signal_callback, MethodInfo("_signal_callback")); diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index 8bc3b24a5e..209bdadd67 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -113,6 +113,7 @@ const char *GDFunctions::get_func_name(Function p_func) { "ColorN", "print_stack", "instance_from_id", + "len", }; return _names[p_func]; @@ -1154,6 +1155,62 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, r_ret = ObjectDB::get_instance(id); } break; + case LEN: { + + VALIDATE_ARG_COUNT(1); + switch (p_args[0]->get_type()) { + case Variant::DICTIONARY: { + Dictionary d = *p_args[0]; + r_ret = d.size(); + } break; + case Variant::ARRAY: { + Array d = *p_args[0]; + r_ret = d.size(); + } break; + case Variant::POOL_BYTE_ARRAY: { + PoolVector<uint8_t> d = *p_args[0]; + r_ret = d.size(); + + } break; + case Variant::POOL_INT_ARRAY: { + PoolVector<int> d = *p_args[0]; + r_ret = d.size(); + } break; + case Variant::POOL_REAL_ARRAY: { + + PoolVector<real_t> d = *p_args[0]; + r_ret = d.size(); + } break; + case Variant::POOL_STRING_ARRAY: { + PoolVector<String> d = *p_args[0]; + r_ret = d.size(); + + } break; + case Variant::POOL_VECTOR2_ARRAY: { + PoolVector<Vector2> d = *p_args[0]; + r_ret = d.size(); + + } break; + case Variant::POOL_VECTOR3_ARRAY: { + + PoolVector<Vector3> d = *p_args[0]; + r_ret = d.size(); + } break; + case Variant::POOL_COLOR_ARRAY: { + + PoolVector<Color> d = *p_args[0]; + r_ret = d.size(); + } break; + default: { + r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument = 0; + r_error.expected = Variant::OBJECT; + r_ret = Variant(); + r_ret = RTR("Object can't provide a length."); + } + } + + } break; case FUNC_MAX: { ERR_FAIL(); @@ -1210,6 +1267,7 @@ bool GDFunctions::is_deterministic(Function p_func) { case TEXT_CHAR: case TEXT_STR: case COLOR8: + case LEN: // enable for debug only, otherwise not desirable - case GEN_RANGE: return true; default: @@ -1621,6 +1679,11 @@ MethodInfo GDFunctions::get_info(Function p_func) { mi.return_val.type = Variant::OBJECT; return mi; } break; + case LEN: { + MethodInfo mi("len", PropertyInfo(Variant::NIL, "var")); + mi.return_val.type = Variant::INT; + return mi; + } break; case FUNC_MAX: { diff --git a/modules/gdscript/gd_functions.h b/modules/gdscript/gd_functions.h index 4d52abaeab..93cb524118 100644 --- a/modules/gdscript/gd_functions.h +++ b/modules/gdscript/gd_functions.h @@ -105,6 +105,7 @@ public: COLORN, PRINT_STACK, INSTANCE_FROM_ID, + LEN, FUNC_MAX }; diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 36aa249398..9023fd4bf4 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -2369,8 +2369,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { check_block = check_block->parent_block; } - p_block->variables.push_back(n); //line? - p_block->variable_lines.push_back(tokenizer->get_token_line()); + int var_line = tokenizer->get_token_line(); //must know when the local variable is declared LocalVarNode *lv = alloc_node<LocalVarNode>(); @@ -2400,6 +2399,10 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { c->value = Variant(); assigned = c; } + //must be added later, to avoid self-referencing. + p_block->variables.push_back(n); //line? + p_block->variable_lines.push_back(var_line); + IdentifierNode *id = alloc_node<IdentifierNode>(); id->name = n; diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index fe87433a89..9d304c6d34 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -479,7 +479,7 @@ bool GDScript::_update_exports() { const GDParser::ClassNode *c = static_cast<const GDParser::ClassNode *>(root); if (base_cache.is_valid()) { - base_cache->inheriters_cache.erase(get_instance_ID()); + base_cache->inheriters_cache.erase(get_instance_id()); base_cache = Ref<GDScript>(); } @@ -505,7 +505,7 @@ bool GDScript::_update_exports() { //print_line("parent is: "+bf->get_path()); base_cache = bf; - bf->inheriters_cache.insert(get_instance_ID()); + bf->inheriters_cache.insert(get_instance_id()); //bf->_update_exports(p_instances,true,false); } @@ -1693,7 +1693,7 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so if (obj->get_script_instance()) { obj->get_script_instance()->get_property_state(state); - map[obj->get_instance_ID()] = state; + map[obj->get_instance_id()] = state; obj->set_script(RefPtr()); } } @@ -1709,7 +1709,7 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so if (obj->get_script_instance()) { obj->get_script_instance()->get_property_state(state); - map[obj->get_instance_ID()] = state; + map[obj->get_instance_id()] = state; obj->set_script(RefPtr()); } else { // no instance found. Let's remove it so we don't loop forever @@ -1743,8 +1743,8 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so obj->set_script(scr.get_ref_ptr()); if (!obj->get_script_instance()) { //failed, save reload state for next time if not saved - if (!scr->pending_reload_state.has(obj->get_instance_ID())) { - scr->pending_reload_state[obj->get_instance_ID()] = F->get(); + if (!scr->pending_reload_state.has(obj->get_instance_id())) { + scr->pending_reload_state[obj->get_instance_id()] = F->get(); } continue; } @@ -1753,7 +1753,7 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so obj->get_script_instance()->set(G->get().first, G->get().second); } - scr->pending_reload_state.erase(obj->get_instance_ID()); //as it reloaded, remove pending state + scr->pending_reload_state.erase(obj->get_instance_id()); //as it reloaded, remove pending state } //if instance states were saved, set them! diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h index 0add348ca9..17e7b0bc03 100644 --- a/modules/gdscript/gd_script.h +++ b/modules/gdscript/gd_script.h @@ -298,7 +298,7 @@ public: _FORCE_INLINE_ void enter_function(GDInstance *p_instance, GDFunction *p_function, Variant *p_stack, int *p_ip, int *p_line) { - if (Thread::get_main_ID() != Thread::get_caller_ID()) + if (Thread::get_main_id() != Thread::get_caller_id()) return; //no support for other threads than main for now if (ScriptDebugger::get_singleton()->get_lines_left() > 0 && ScriptDebugger::get_singleton()->get_depth() >= 0) @@ -321,7 +321,7 @@ public: _FORCE_INLINE_ void exit_function() { - if (Thread::get_main_ID() != Thread::get_caller_ID()) + if (Thread::get_main_id() != Thread::get_caller_id()) return; //no support for other threads than main for now if (ScriptDebugger::get_singleton()->get_lines_left() > 0 && ScriptDebugger::get_singleton()->get_depth() >= 0) @@ -338,7 +338,7 @@ public: } virtual Vector<StackInfo> debug_get_current_stack_info() { - if (Thread::get_main_ID() != Thread::get_caller_ID()) + if (Thread::get_main_id() != Thread::get_caller_id()) return Vector<StackInfo>(); Vector<StackInfo> csi; diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 8c2c2ea345..f241a96e58 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -345,7 +345,7 @@ void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) { Octant *g = memnew(Octant); g->dirty = true; g->static_body = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC); - PhysicsServer::get_singleton()->body_attach_object_instance_ID(g->static_body, get_instance_ID()); + PhysicsServer::get_singleton()->body_attach_object_instance_id(g->static_body, get_instance_id()); if (is_inside_world()) PhysicsServer::get_singleton()->body_set_space(g->static_body, get_world()->get_space()); @@ -830,8 +830,8 @@ void GridMap::_update_dirty_map_callback() { void GridMap::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_theme", "theme:MeshLibrary"), &GridMap::set_theme); - ClassDB::bind_method(D_METHOD("get_theme:MeshLibrary"), &GridMap::get_theme); + ClassDB::bind_method(D_METHOD("set_theme", "theme"), &GridMap::set_theme); + ClassDB::bind_method(D_METHOD("get_theme"), &GridMap::get_theme); ClassDB::bind_method(D_METHOD("set_cell_size", "size"), &GridMap::set_cell_size); ClassDB::bind_method(D_METHOD("get_cell_size"), &GridMap::get_cell_size); @@ -857,7 +857,7 @@ void GridMap::_bind_methods() { ClassDB::bind_method(D_METHOD("set_clip", "enabled", "clipabove", "floor", "axis"), &GridMap::set_clip, DEFVAL(true), DEFVAL(0), DEFVAL(Vector3::AXIS_X)); ClassDB::bind_method(D_METHOD("create_area", "id", "area"), &GridMap::create_area); - ClassDB::bind_method(D_METHOD("area_get_bounds", "area", "bounds"), &GridMap::area_get_bounds); + ClassDB::bind_method(D_METHOD("area_get_bounds", "area"), &GridMap::area_get_bounds); ClassDB::bind_method(D_METHOD("area_set_exterior_portal", "area", "enable"), &GridMap::area_set_exterior_portal); ClassDB::bind_method(D_METHOD("area_set_name", "area", "name"), &GridMap::area_set_name); ClassDB::bind_method(D_METHOD("area_get_name", "area"), &GridMap::area_get_name); @@ -867,7 +867,7 @@ void GridMap::_bind_methods() { ClassDB::bind_method(D_METHOD("area_set_portal_disable_color", "area", "color"), &GridMap::area_set_portal_disable_color); ClassDB::bind_method(D_METHOD("area_get_portal_disable_color", "area"), &GridMap::area_get_portal_disable_color); ClassDB::bind_method(D_METHOD("erase_area", "area"), &GridMap::erase_area); - ClassDB::bind_method(D_METHOD("get_unused_area_id", "area"), &GridMap::get_unused_area_id); + ClassDB::bind_method(D_METHOD("get_unused_area_id"), &GridMap::get_unused_area_id); ClassDB::bind_method(D_METHOD("clear"), &GridMap::clear); diff --git a/modules/nativescript/nativescript.cpp b/modules/nativescript/nativescript.cpp index fb334e573c..101928a668 100644 --- a/modules/nativescript/nativescript.cpp +++ b/modules/nativescript/nativescript.cpp @@ -55,11 +55,11 @@ ////// Script stuff void NativeScript::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_class_name", "class_name:String"), &NativeScript::set_class_name); - ClassDB::bind_method(D_METHOD("get_class_name:String"), &NativeScript::get_class_name); + ClassDB::bind_method(D_METHOD("set_class_name", "class_name"), &NativeScript::set_class_name); + ClassDB::bind_method(D_METHOD("get_class_name"), &NativeScript::get_class_name); - ClassDB::bind_method(D_METHOD("set_library", "library:GDNativeLibrary"), &NativeScript::set_library); - ClassDB::bind_method(D_METHOD("get_library:GDNativeLibrary"), &NativeScript::get_library); + ClassDB::bind_method(D_METHOD("set_library", "library"), &NativeScript::set_library); + ClassDB::bind_method(D_METHOD("get_library"), &NativeScript::get_library); ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "class_name"), "set_class_name", "get_class_name"); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "GDNativeLibrary"), "set_library", "get_library"); @@ -77,14 +77,12 @@ void NativeScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) ERR_FAIL_COND(!script_data); List<PropertyInfo> info; + get_script_property_list(&info); Map<StringName, Variant> values; - - for (Map<StringName, NativeScriptDesc::Property>::Element *E = script_data->properties.front(); E; E = E->next()) { - PropertyInfo p = E->get().info; - p.name = String(E->key()); - - info.push_back(p); - values[p.name] = E->get().default_value; + for (List<PropertyInfo>::Element *E = info.front(); E; E = E->next()) { + Variant value; + get_property_default_value(E->get().name, value); + values[E->get().name] = value; } p_placeholder->update(info, values); @@ -113,7 +111,7 @@ void NativeScript::set_library(Ref<GDNativeLibrary> p_library) { lib_path = library->get_active_library_path(); #ifndef NO_THREADS - if (Thread::get_caller_ID() != Thread::get_main_ID()) { + if (Thread::get_caller_id() != Thread::get_main_id()) { NSL->defer_init_library(p_library, this); } else #endif @@ -317,11 +315,11 @@ void NativeScript::get_script_signal_list(List<MethodInfo> *r_signals) const { bool NativeScript::get_property_default_value(const StringName &p_property, Variant &r_value) const { NativeScriptDesc *script_data = get_script_desc(); - if (!script_data) - return false; - - Map<StringName, NativeScriptDesc::Property>::Element *P = script_data->properties.find(p_property); - + Map<StringName, NativeScriptDesc::Property>::Element *P = NULL; + while (!P && script_data) { + P = script_data->properties.find(p_property); + script_data = script_data->base_data; + } if (!P) return false; diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp index c3e97e357d..c728657d6b 100644 --- a/modules/regex/regex.cpp +++ b/modules/regex/regex.cpp @@ -1496,7 +1496,7 @@ void RegEx::_bind_methods() { ClassDB::bind_method(D_METHOD("clear"), &RegEx::clear); ClassDB::bind_method(D_METHOD("compile", "pattern"), &RegEx::compile); - ClassDB::bind_method(D_METHOD("search:RegExMatch", "text", "start", "end"), &RegEx::search, DEFVAL(0), DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("search", "text", "start", "end"), &RegEx::search, DEFVAL(0), DEFVAL(-1)); ClassDB::bind_method(D_METHOD("sub", "text", "replacement", "all", "start", "end"), &RegEx::sub, DEFVAL(false), DEFVAL(0), DEFVAL(-1)); ClassDB::bind_method(D_METHOD("is_valid"), &RegEx::is_valid); ClassDB::bind_method(D_METHOD("get_pattern"), &RegEx::get_pattern); diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index f15abec7e2..d1cf0f1dce 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -122,9 +122,9 @@ Array VisualScriptNode::_get_default_input_values() const { void VisualScriptNode::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_visual_script:VisualScript"), &VisualScriptNode::get_visual_script); - ClassDB::bind_method(D_METHOD("set_default_input_value", "port_idx", "value:Variant"), &VisualScriptNode::set_default_input_value); - ClassDB::bind_method(D_METHOD("get_default_input_value:Variant", "port_idx"), &VisualScriptNode::get_default_input_value); + ClassDB::bind_method(D_METHOD("get_visual_script"), &VisualScriptNode::get_visual_script); + ClassDB::bind_method(D_METHOD("set_default_input_value", "port_idx", "value"), &VisualScriptNode::set_default_input_value); + ClassDB::bind_method(D_METHOD("get_default_input_value", "port_idx"), &VisualScriptNode::get_default_input_value); ClassDB::bind_method(D_METHOD("_set_default_input_values", "values"), &VisualScriptNode::_set_default_input_values); ClassDB::bind_method(D_METHOD("_get_default_input_values"), &VisualScriptNode::_get_default_input_values); @@ -1058,6 +1058,10 @@ MethodInfo VisualScript::get_method_info(const StringName &p_method) const { arg.type = func->get_argument_type(i); mi.arguments.push_back(arg); } + + if (!func->is_sequenced()) { + mi.flags |= METHOD_FLAG_CONST; + } } } @@ -1267,11 +1271,11 @@ void VisualScript::_bind_methods() { ClassDB::bind_method(D_METHOD("set_function_scroll", "name", "ofs"), &VisualScript::set_function_scroll); ClassDB::bind_method(D_METHOD("get_function_scroll", "name"), &VisualScript::get_function_scroll); - ClassDB::bind_method(D_METHOD("add_node", "func", "id", "node:VisualScriptNode", "pos"), &VisualScript::add_node, DEFVAL(Point2())); + ClassDB::bind_method(D_METHOD("add_node", "func", "id", "node", "pos"), &VisualScript::add_node, DEFVAL(Point2())); ClassDB::bind_method(D_METHOD("remove_node", "func", "id"), &VisualScript::remove_node); ClassDB::bind_method(D_METHOD("get_function_node_id", "name"), &VisualScript::get_function_node_id); - ClassDB::bind_method(D_METHOD("get_node:VisualScriptNode", "func", "id"), &VisualScript::get_node); + ClassDB::bind_method(D_METHOD("get_node", "func", "id"), &VisualScript::get_node); ClassDB::bind_method(D_METHOD("has_node", "func", "id"), &VisualScript::has_node); ClassDB::bind_method(D_METHOD("set_node_pos", "func", "id", "pos"), &VisualScript::set_node_pos); ClassDB::bind_method(D_METHOD("get_node_pos", "func", "id"), &VisualScript::get_node_pos); @@ -1401,6 +1405,10 @@ void VisualScriptInstance::get_method_list(List<MethodInfo> *p_list) const { mi.arguments.push_back(arg); } + if (!vsf->is_sequenced()) { //assumed constant if not sequenced + mi.flags |= METHOD_FLAG_CONST; + } + //vsf->Get_ for now at least it does not return.. } } @@ -1607,8 +1615,8 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p } //step 1, capture all state - state->instance_id = get_owner_ptr()->get_instance_ID(); - state->script_id = get_script()->get_instance_ID(); + state->instance_id = get_owner_ptr()->get_instance_id(); + state->script_id = get_script()->get_instance_id(); state->instance = this; state->function = p_method; state->working_mem_index = node->working_mem_idx; @@ -2318,7 +2326,7 @@ Variant VisualScriptFunctionState::resume(Array p_args) { void VisualScriptFunctionState::_bind_methods() { ClassDB::bind_method(D_METHOD("connect_to_signal", "obj", "signals", "args"), &VisualScriptFunctionState::connect_to_signal); - ClassDB::bind_method(D_METHOD("resume:Array", "args"), &VisualScriptFunctionState::resume, DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("resume", "args"), &VisualScriptFunctionState::resume, DEFVAL(Variant())); ClassDB::bind_method(D_METHOD("is_valid"), &VisualScriptFunctionState::is_valid); ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "_signal_callback", &VisualScriptFunctionState::_signal_callback, MethodInfo("_signal_callback")); } @@ -2417,7 +2425,7 @@ void VisualScriptLanguage::add_global_constant(const StringName &p_variable, con bool VisualScriptLanguage::debug_break_parse(const String &p_file, int p_node, const String &p_error) { //break because of parse error - if (ScriptDebugger::get_singleton() && Thread::get_caller_ID() == Thread::get_main_ID()) { + if (ScriptDebugger::get_singleton() && Thread::get_caller_id() == Thread::get_main_id()) { _debug_parse_err_node = p_node; _debug_parse_err_file = p_file; @@ -2431,7 +2439,7 @@ bool VisualScriptLanguage::debug_break_parse(const String &p_file, int p_node, c bool VisualScriptLanguage::debug_break(const String &p_error, bool p_allow_continue) { - if (ScriptDebugger::get_singleton() && Thread::get_caller_ID() == Thread::get_main_ID()) { + if (ScriptDebugger::get_singleton() && Thread::get_caller_id() == Thread::get_main_id()) { _debug_parse_err_node = -1; _debug_parse_err_file = ""; diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index cdd7eded18..63ac5769c6 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -509,7 +509,7 @@ public: _FORCE_INLINE_ void enter_function(VisualScriptInstance *p_instance, const StringName *p_function, Variant *p_stack, Variant **p_work_mem, int *current_id) { - if (Thread::get_main_ID() != Thread::get_caller_ID()) + if (Thread::get_main_id() != Thread::get_caller_id()) return; //no support for other threads than main for now if (ScriptDebugger::get_singleton()->get_lines_left() > 0 && ScriptDebugger::get_singleton()->get_depth() >= 0) @@ -532,7 +532,7 @@ public: _FORCE_INLINE_ void exit_function() { - if (Thread::get_main_ID() != Thread::get_caller_ID()) + if (Thread::get_main_id() != Thread::get_caller_id()) return; //no support for other threads than main for now if (ScriptDebugger::get_singleton()->get_lines_left() > 0 && ScriptDebugger::get_singleton()->get_depth() >= 0) diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 35358d5a1f..8912227692 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -615,7 +615,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { Ref<Resource> res = value; Array arr; - arr.push_back(button->get_instance_ID()); + arr.push_back(button->get_instance_id()); arr.push_back(String(value)); EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res, this, "_button_resource_previewed", arr); @@ -869,15 +869,27 @@ void VisualScriptEditor::_member_edited() { } selected = new_name; - _update_graph(); - + int node_id = script->get_function_node_id(name); + Ref<VisualScriptFunction> func; + if (script->has_node(name, node_id)) { + func = script->get_node(name, node_id); + } undo_redo->create_action(TTR("Rename Function")); undo_redo->add_do_method(script.ptr(), "rename_function", name, new_name); undo_redo->add_undo_method(script.ptr(), "rename_function", new_name, name); + if (func.is_valid()) { + + undo_redo->add_do_method(func.ptr(), "set_name", new_name); + undo_redo->add_undo_method(func.ptr(), "set_name", name); + } undo_redo->add_do_method(this, "_update_members"); undo_redo->add_undo_method(this, "_update_members"); + undo_redo->add_do_method(this, "_update_graph"); + undo_redo->add_undo_method(this, "_update_graph"); undo_redo->commit_action(); + // _update_graph(); + return; //or crash because it will become invalid } @@ -1969,7 +1981,7 @@ String VisualScriptEditor::get_name() { } else if (script->get_name() != "") name = script->get_name(); else - name = script->get_class() + "(" + itos(script->get_instance_ID()) + ")"; + name = script->get_class() + "(" + itos(script->get_instance_id()) + ")"; return name; } diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp index c438edd21f..3c057cdbd5 100644 --- a/modules/visual_script/visual_script_func_nodes.cpp +++ b/modules/visual_script/visual_script_func_nodes.cpp @@ -603,13 +603,13 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const } else if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) { property.hint = PROPERTY_HINT_METHOD_OF_SCRIPT; - property.hint_string = itos(get_visual_script()->get_instance_ID()); + property.hint_string = itos(get_visual_script()->get_instance_id()); } else if (call_mode == CALL_MODE_SINGLETON) { Object *obj = ProjectSettings::get_singleton()->get_singleton_object(singleton); if (obj) { property.hint = PROPERTY_HINT_METHOD_OF_INSTANCE; - property.hint_string = itos(obj->get_instance_ID()); + property.hint_string = itos(obj->get_instance_id()); } else { property.hint = PROPERTY_HINT_METHOD_OF_BASE_TYPE; @@ -631,7 +631,7 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const if (script.is_valid()) { property.hint = PROPERTY_HINT_METHOD_OF_SCRIPT; - property.hint_string = itos(script->get_instance_ID()); + property.hint_string = itos(script->get_instance_id()); } } } @@ -640,7 +640,7 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const Node *node = _get_base_node(); if (node) { property.hint = PROPERTY_HINT_METHOD_OF_INSTANCE; - property.hint_string = itos(node->get_instance_ID()); + property.hint_string = itos(node->get_instance_id()); } else { property.hint = PROPERTY_HINT_METHOD_OF_BASE_TYPE; property.hint_string = get_base_type(); @@ -1379,7 +1379,7 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const { } else if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) { property.hint = PROPERTY_HINT_PROPERTY_OF_SCRIPT; - property.hint_string = itos(get_visual_script()->get_instance_ID()); + property.hint_string = itos(get_visual_script()->get_instance_id()); } else if (call_mode == CALL_MODE_INSTANCE) { property.hint = PROPERTY_HINT_PROPERTY_OF_BASE_TYPE; property.hint_string = base_type; @@ -1396,7 +1396,7 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const { if (script.is_valid()) { property.hint = PROPERTY_HINT_PROPERTY_OF_SCRIPT; - property.hint_string = itos(script->get_instance_ID()); + property.hint_string = itos(script->get_instance_id()); } } } @@ -1405,7 +1405,7 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const { Node *node = _get_base_node(); if (node) { property.hint = PROPERTY_HINT_PROPERTY_OF_INSTANCE; - property.hint_string = itos(node->get_instance_ID()); + property.hint_string = itos(node->get_instance_id()); } else { property.hint = PROPERTY_HINT_PROPERTY_OF_BASE_TYPE; property.hint_string = get_base_type(); @@ -2095,7 +2095,7 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const { } else if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) { property.hint = PROPERTY_HINT_PROPERTY_OF_SCRIPT; - property.hint_string = itos(get_visual_script()->get_instance_ID()); + property.hint_string = itos(get_visual_script()->get_instance_id()); } else if (call_mode == CALL_MODE_INSTANCE) { property.hint = PROPERTY_HINT_PROPERTY_OF_BASE_TYPE; property.hint_string = base_type; @@ -2112,7 +2112,7 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const { if (script.is_valid()) { property.hint = PROPERTY_HINT_PROPERTY_OF_SCRIPT; - property.hint_string = itos(script->get_instance_ID()); + property.hint_string = itos(script->get_instance_id()); } } } @@ -2120,7 +2120,7 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const { Node *node = _get_base_node(); if (node) { property.hint = PROPERTY_HINT_PROPERTY_OF_INSTANCE; - property.hint_string = itos(node->get_instance_ID()); + property.hint_string = itos(node->get_instance_id()); } else { property.hint = PROPERTY_HINT_PROPERTY_OF_BASE_TYPE; property.hint_string = get_base_type(); diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index 69aa10ebca..923e425997 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -95,6 +95,12 @@ bool VisualScriptFunction::_set(const StringName &p_name, const Variant &p_value return true; } + if (p_name == "sequenced/sequenced") { + sequenced = p_value; + ports_changed_notify(); + return true; + } + return false; } @@ -133,6 +139,11 @@ bool VisualScriptFunction::_get(const StringName &p_name, Variant &r_ret) const return true; } + if (p_name == "sequenced/sequenced") { + r_ret = sequenced; + return true; + } + return false; } void VisualScriptFunction::_get_property_list(List<PropertyInfo> *p_list) const { @@ -147,6 +158,9 @@ void VisualScriptFunction::_get_property_list(List<PropertyInfo> *p_list) const p_list->push_back(PropertyInfo(Variant::INT, "argument_" + itos(i + 1) + "/type", PROPERTY_HINT_ENUM, argt)); p_list->push_back(PropertyInfo(Variant::STRING, "argument_" + itos(i + 1) + "/name")); } + + p_list->push_back(PropertyInfo(Variant::BOOL, "sequenced/sequenced")); + if (!stack_less) { p_list->push_back(PropertyInfo(Variant::INT, "stack/size", PROPERTY_HINT_RANGE, "1,100000")); } @@ -302,6 +316,7 @@ VisualScriptFunction::VisualScriptFunction() { stack_size = 256; stack_less = false; + sequenced = true; rpc_mode = ScriptInstance::RPC_MODE_DISABLED; } @@ -314,6 +329,16 @@ bool VisualScriptFunction::is_stack_less() const { return stack_less; } +void VisualScriptFunction::set_sequenced(bool p_enable) { + + sequenced = p_enable; +} + +bool VisualScriptFunction::is_sequenced() const { + + return sequenced; +} + void VisualScriptFunction::set_stack_size(int p_size) { ERR_FAIL_COND(p_size < 1 || p_size > 100000); @@ -1076,7 +1101,7 @@ void VisualScriptConstant::_bind_methods() { ClassDB::bind_method(D_METHOD("get_constant_type"), &VisualScriptConstant::get_constant_type); ClassDB::bind_method(D_METHOD("set_constant_value", "value"), &VisualScriptConstant::set_constant_value); - ClassDB::bind_method(D_METHOD("get_constant_value:Variant"), &VisualScriptConstant::get_constant_value); + ClassDB::bind_method(D_METHOD("get_constant_value"), &VisualScriptConstant::get_constant_value); String argt = "Null"; for (int i = 1; i < Variant::VARIANT_MAX; i++) { @@ -1190,8 +1215,8 @@ Ref<Resource> VisualScriptPreload::get_preload() const { void VisualScriptPreload::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_preload", "resource:Resource"), &VisualScriptPreload::set_preload); - ClassDB::bind_method(D_METHOD("get_preload:Resource"), &VisualScriptPreload::get_preload); + ClassDB::bind_method(D_METHOD("set_preload", "resource"), &VisualScriptPreload::set_preload); + ClassDB::bind_method(D_METHOD("get_preload"), &VisualScriptPreload::get_preload); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), "set_preload", "get_preload"); } @@ -1467,7 +1492,7 @@ void VisualScriptGlobalConstant::_bind_methods() { cc += ","; cc += GlobalConstants::get_global_constant_name(i); } - ADD_PROPERTY(PropertyInfo(Variant::INT, "constant", PROPERTY_HINT_ENUM, cc), "set_global_constant", "get_global_constant"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "constant/constant", PROPERTY_HINT_ENUM, cc), "set_global_constant", "get_global_constant"); } VisualScriptGlobalConstant::VisualScriptGlobalConstant() { @@ -1572,7 +1597,7 @@ VisualScriptNodeInstance *VisualScriptClassConstant::instance(VisualScriptInstan void VisualScriptClassConstant::_validate_property(PropertyInfo &property) const { - if (property.name == "constant") { + if (property.name == "constant/constant") { List<String> constants; ClassDB::get_integer_constant_list(base_type, &constants, true); @@ -1596,7 +1621,7 @@ void VisualScriptClassConstant::_bind_methods() { ClassDB::bind_method(D_METHOD("get_base_type"), &VisualScriptClassConstant::get_base_type); ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant", PROPERTY_HINT_ENUM, ""), "set_class_constant", "get_class_constant"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant/constant", PROPERTY_HINT_ENUM, ""), "set_class_constant", "get_class_constant"); } VisualScriptClassConstant::VisualScriptClassConstant() { @@ -1701,7 +1726,7 @@ VisualScriptNodeInstance *VisualScriptBasicTypeConstant::instance(VisualScriptIn void VisualScriptBasicTypeConstant::_validate_property(PropertyInfo &property) const { - if (property.name == "constant") { + if (property.name == "constant/constant") { List<StringName> constants; Variant::get_numeric_constants_for_type(type, &constants); @@ -1734,7 +1759,7 @@ void VisualScriptBasicTypeConstant::_bind_methods() { } ADD_PROPERTY(PropertyInfo(Variant::INT, "basic_type", PROPERTY_HINT_ENUM, argt), "set_basic_type", "get_basic_type"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant", PROPERTY_HINT_ENUM, ""), "set_basic_type_constant", "get_basic_type_constant"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant/constant", PROPERTY_HINT_ENUM, ""), "set_basic_type_constant", "get_basic_type_constant"); } VisualScriptBasicTypeConstant::VisualScriptBasicTypeConstant() { @@ -1855,7 +1880,7 @@ void VisualScriptMathConstant::_bind_methods() { cc += ","; cc += const_name[i]; } - ADD_PROPERTY(PropertyInfo(Variant::INT, "constant", PROPERTY_HINT_ENUM, cc), "set_math_constant", "get_math_constant"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "constant/constant", PROPERTY_HINT_ENUM, cc), "set_math_constant", "get_math_constant"); } VisualScriptMathConstant::VisualScriptMathConstant() { @@ -1976,7 +2001,7 @@ void VisualScriptEngineSingleton::_bind_methods() { cc += E->get().name; } - ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant", PROPERTY_HINT_ENUM, cc), "set_singleton", "get_singleton"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant/constant", PROPERTY_HINT_ENUM, cc), "set_singleton", "get_singleton"); } VisualScriptEngineSingleton::VisualScriptEngineSingleton() { @@ -2798,7 +2823,7 @@ public: r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; return 0; } - *p_outputs[0] = subcall->call(VisualScriptLanguage::singleton->_subcall, p_inputs, input_args, r_error_str); + *p_outputs[0] = subcall->call(VisualScriptLanguage::singleton->_subcall, p_inputs, input_args, r_error); return 0; } }; @@ -2819,7 +2844,7 @@ VisualScriptNodeInstance *VisualScriptSubCall::instance(VisualScriptInstance *p_ void VisualScriptSubCall::_bind_methods() { - BIND_VMETHOD(MethodInfo(Variant::NIL, "_subcall", PropertyInfo(Variant::NIL, "arguments:Variant"))); + BIND_VMETHOD(MethodInfo(Variant::NIL, "_subcall:Variant", PropertyInfo(Variant::NIL, "arguments:Variant"))); } VisualScriptSubCall::VisualScriptSubCall() { @@ -3702,11 +3727,11 @@ void register_visual_script_nodes() { VisualScriptLanguage::singleton->add_register_func("data/preload", create_node_generic<VisualScriptPreload>); VisualScriptLanguage::singleton->add_register_func("data/action", create_node_generic<VisualScriptInputAction>); - VisualScriptLanguage::singleton->add_register_func("constants/constant", create_node_generic<VisualScriptConstant>); - VisualScriptLanguage::singleton->add_register_func("constants/math_constant", create_node_generic<VisualScriptMathConstant>); - VisualScriptLanguage::singleton->add_register_func("constants/class_constant", create_node_generic<VisualScriptClassConstant>); - VisualScriptLanguage::singleton->add_register_func("constants/global_constant", create_node_generic<VisualScriptGlobalConstant>); - VisualScriptLanguage::singleton->add_register_func("constants/basic_type_constant", create_node_generic<VisualScriptBasicTypeConstant>); + VisualScriptLanguage::singleton->add_register_func("constant/constants/constant", create_node_generic<VisualScriptConstant>); + VisualScriptLanguage::singleton->add_register_func("constant/constants/math_constant", create_node_generic<VisualScriptMathConstant>); + VisualScriptLanguage::singleton->add_register_func("constant/constants/class_constant", create_node_generic<VisualScriptClassConstant>); + VisualScriptLanguage::singleton->add_register_func("constant/constants/global_constant", create_node_generic<VisualScriptGlobalConstant>); + VisualScriptLanguage::singleton->add_register_func("constant/constants/basic_type_constant", create_node_generic<VisualScriptBasicTypeConstant>); VisualScriptLanguage::singleton->add_register_func("custom/custom_node", create_node_generic<VisualScriptCustomNode>); VisualScriptLanguage::singleton->add_register_func("custom/sub_call", create_node_generic<VisualScriptSubCall>); diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h index 7a3b26fe55..ff49417114 100644 --- a/modules/visual_script/visual_script_nodes.h +++ b/modules/visual_script/visual_script_nodes.h @@ -46,6 +46,7 @@ class VisualScriptFunction : public VisualScriptNode { bool stack_less; int stack_size; ScriptInstance::RPCMode rpc_mode; + bool sequenced; protected: bool _set(const StringName &p_name, const Variant &p_value); @@ -79,9 +80,18 @@ public: void set_stack_less(bool p_enable); bool is_stack_less() const; + void set_sequenced(bool p_enable); + bool is_sequenced() const; + void set_stack_size(int p_size); int get_stack_size() const; + void set_return_type_enabled(bool p_returns); + bool is_return_type_enabled() const; + + void set_return_type(Variant::Type p_type); + Variant::Type get_return_type() const; + void set_rpc_mode(ScriptInstance::RPCMode p_mode); ScriptInstance::RPCMode get_rpc_mode() const; |