MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / decode_variant_3

Method decode_variant_3

compat/variant_decoder_compat.cpp:501–1154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

499}
500
501Error VariantDecoderCompat::decode_variant_3(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len, bool p_allow_objects) {
502 const uint8_t *buf = p_buffer;
503 int len = p_len;
504
505 ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
506
507 uint32_t type = decode_uint32(buf);
508
509 ERR_FAIL_COND_V((type & ENCODE_MASK) >= V3Type::VARIANT_MAX, ERR_INVALID_DATA);
510
511 buf += 4;
512 len -= 4;
513 if (r_len) {
514 *r_len = 4;
515 }
516
517 switch (type & ENCODE_MASK) {
518 case V3Type::NIL: {
519 r_variant = Variant();
520 } break;
521 case V3Type::BOOL: {
522 ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
523 bool val = decode_uint32(buf);
524 r_variant = val;
525 if (r_len) {
526 (*r_len) += 4;
527 }
528 } break;
529 case V3Type::INT: {
530 if (type & ENCODE_FLAG_64) {
531 ERR_FAIL_COND_V(len < 8, ERR_INVALID_DATA);
532 int64_t val = decode_uint64(buf);
533 r_variant = val;
534 if (r_len) {
535 (*r_len) += 8;
536 }
537
538 } else {
539 ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
540 int32_t val = decode_uint32(buf);
541 r_variant = val;
542 if (r_len) {
543 (*r_len) += 4;
544 }
545 }
546
547 } break;
548 case V3Type::REAL: {
549 if (type & ENCODE_FLAG_64) {
550 ERR_FAIL_COND_V(len < 8, ERR_INVALID_DATA);
551 double val = decode_double(buf);
552 r_variant = val;
553 if (r_len) {
554 (*r_len) += 8;
555 }
556 } else {
557 ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
558 float val = decode_float(buf);

Callers

nothing calls this directly

Calls 7

_decode_stringFunction · 0.85
push_backMethod · 0.80
setMethod · 0.80
is_validMethod · 0.45
set_original_classMethod · 0.45
convertMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected