summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2019-07-19 10:33:31 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2019-08-21 16:59:38 +0200
commit3495d1bfa04606062a1ffa3b58eb3bdf51bb673c (patch)
tree053280bd8dd0286408bcb9f94fc3a2fcc26685d6
parent1b36aa662cb8df7b9236963c7b8eb9e9424395ca (diff)
Add hex_encode function to PoolByteArray
-rw-r--r--core/variant_call.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index a3803d8701..02c6cd73d8 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -606,6 +606,13 @@ struct _VariantCall {
r_ret = s;
}
+ static void _call_PoolByteArray_hex_encode(Variant &r_ret, Variant &p_self, const Variant **p_args) {
+ PoolByteArray *ba = reinterpret_cast<PoolByteArray *>(p_self._data._mem);
+ PoolByteArray::Read r = ba->read();
+ String s = String::hex_encode_buffer(&r[0], ba->size());
+ r_ret = s;
+ }
+
VCALL_LOCALMEM0R(PoolByteArray, size);
VCALL_LOCALMEM2(PoolByteArray, set);
VCALL_LOCALMEM1R(PoolByteArray, get);
@@ -1763,6 +1770,7 @@ void register_variant_methods() {
ADDFUNC0R(POOL_BYTE_ARRAY, STRING, PoolByteArray, get_string_from_ascii, varray());
ADDFUNC0R(POOL_BYTE_ARRAY, STRING, PoolByteArray, get_string_from_utf8, varray());
ADDFUNC0R(POOL_BYTE_ARRAY, STRING, PoolByteArray, sha256_string, varray());
+ ADDFUNC0R(POOL_BYTE_ARRAY, STRING, PoolByteArray, hex_encode, varray());
ADDFUNC1R(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, compress, INT, "compression_mode", varray(0));
ADDFUNC2R(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, decompress, INT, "buffer_size", INT, "compression_mode", varray(0));