diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-12-27 09:08:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-27 09:08:07 +0100 |
commit | e2d9035806aebc7cf079d043ea4e7ea65c184327 (patch) | |
tree | b34a0274ca900f53659a8755d6fd85f46ec3f57d | |
parent | e86418f7a92a498208c325446c9d7f654c48f359 (diff) | |
parent | b8f1fe9ed8f1d027104df6c70dd363726d7bf7ad (diff) |
Merge pull request #24586 from Xrayez/valid-hex-number-bind
Bind `is_valid_hex_number` string method to GDScript
-rw-r--r-- | core/variant_call.cpp | 2 | ||||
-rw-r--r-- | doc/classes/String.xml | 9 |
2 files changed, 11 insertions, 0 deletions
diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 0c6e43fe36..aa180cd4ac 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -291,6 +291,7 @@ struct _VariantCall { VCALL_LOCALMEM0R(String, is_valid_identifier); VCALL_LOCALMEM0R(String, is_valid_integer); VCALL_LOCALMEM0R(String, is_valid_float); + VCALL_LOCALMEM1R(String, is_valid_hex_number); VCALL_LOCALMEM0R(String, is_valid_html_color); VCALL_LOCALMEM0R(String, is_valid_ip_address); VCALL_LOCALMEM0R(String, to_int); @@ -1534,6 +1535,7 @@ void register_variant_methods() { ADDFUNC0R(STRING, BOOL, String, is_valid_identifier, varray()); ADDFUNC0R(STRING, BOOL, String, is_valid_integer, varray()); ADDFUNC0R(STRING, BOOL, String, is_valid_float, varray()); + ADDFUNC1R(STRING, BOOL, String, is_valid_hex_number, BOOL, "with_prefix", varray(false)); ADDFUNC0R(STRING, BOOL, String, is_valid_html_color, varray()); ADDFUNC0R(STRING, BOOL, String, is_valid_ip_address, varray()); ADDFUNC0R(STRING, INT, String, to_int, varray()); diff --git a/doc/classes/String.xml b/doc/classes/String.xml index 536165487d..dbef84fc15 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -439,6 +439,15 @@ Returns [code]true[/code] if this string contains a valid float. </description> </method> + <method name="is_valid_hex_number"> + <return type="bool"> + </return> + <argument index="0" name="with_prefix" type="bool" default="False"> + </argument> + <description> + Returns [code]true[/code] if this string contains a valid hexadecimal number. If [code]with_prefix[/code] is [code]true[/code], then a validity of the hexadecimal number is determined by [code]0x[/code] prefix, for instance: [code]0xDEADC0DE[/code]. + </description> + </method> <method name="is_valid_html_color"> <return type="bool"> </return> |