MCPcopy Create free account
hub / github.com/apache/thrift / binary_deserialize

Function binary_deserialize

lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp:506–672  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

504}
505
506static
507void binary_deserialize(int8_t thrift_typeID, PHPInputTransport& transport, zval* return_value, HashTable* fieldspec) {
508 ZVAL_NULL(return_value);
509
510 switch (thrift_typeID) {
511 case T_STOP:
512 case T_VOID:
513 RETURN_NULL();
514 return;
515 case T_STRUCT: {
516 zval* val_ptr = zend_hash_str_find(fieldspec, "class", sizeof("class")-1);
517 if (val_ptr == nullptr) {
518 throw_tprotocolexception("no class type in spec", INVALID_DATA);
519 skip_element(T_STRUCT, transport);
520 RETURN_NULL();
521 }
522
523 char* structType = Z_STRVAL_P(val_ptr);
524 // Create an object in PHP userland based on our spec
525 createObject(structType, return_value);
526 if (Z_TYPE_P(return_value) == IS_NULL) {
527 // unable to create class entry
528 skip_element(T_STRUCT, transport);
529 RETURN_NULL();
530 }
531
532 zval* spec = zend_read_static_property(Z_OBJCE_P(return_value), "_TSPEC", sizeof("_TSPEC")-1, false);
533 ZVAL_DEREF(spec);
534 if (EG(exception)) {
535 zend_object *ex = EG(exception);
536 EG(exception) = nullptr;
537 throw PHPExceptionWrapper(ex);
538 }
539 if (Z_TYPE_P(spec) != IS_ARRAY) {
540 char errbuf[128];
541 snprintf(errbuf, 128, "spec for %s is wrong type: %d\n", structType, Z_TYPE_P(spec));
542 throw_tprotocolexception(errbuf, INVALID_DATA);
543 RETURN_NULL();
544 }
545 binary_deserialize_spec(return_value, transport, Z_ARRVAL_P(spec));
546 return;
547 } break;
548 case T_BOOL: {
549 uint8_t c;
550 transport.readBytes(&c, 1);
551 RETURN_BOOL(c != 0);
552 }
553 //case T_I08: // same numeric value as T_BYTE
554 case T_BYTE: {
555 uint8_t c;
556 transport.readBytes(&c, 1);
557 RETURN_LONG((int8_t)c);
558 }
559 case T_I16: {
560 uint16_t c;
561 transport.readBytes(&c, 2);
562 RETURN_LONG((int16_t)ntohs(c));
563 }

Callers 1

binary_deserialize_specFunction · 0.85

Calls 10

throw_tprotocolexceptionFunction · 0.85
skip_elementFunction · 0.85
createObjectFunction · 0.85
PHPExceptionWrapperClass · 0.85
binary_deserialize_specFunction · 0.85
ntohllFunction · 0.85
convert_to_stringFunction · 0.85
readBytesMethod · 0.80
readU32Method · 0.80
readI8Method · 0.45

Tested by

no test coverage detected