From 3495d1bfa04606062a1ffa3b58eb3bdf51bb673c Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Fri, 19 Jul 2019 10:33:31 +0200 Subject: [PATCH] Add hex_encode function to PoolByteArray --- core/variant_call.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/variant_call.cpp b/core/variant_call.cpp index a3803d8701c..02c6cd73d85 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(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));