Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
dart::TwoByteStringMessageDeserializationCluster Class Reference
Inheritance diagram for dart::TwoByteStringMessageDeserializationCluster:
dart::MessageDeserializationCluster dart::ZoneAllocated

Public Member Functions

 TwoByteStringMessageDeserializationCluster (bool is_canonical)
 
 ~TwoByteStringMessageDeserializationCluster ()
 
void ReadNodes (MessageDeserializer *d)
 
void ReadNodesApi (ApiMessageDeserializer *d)
 
- Public Member Functions inherited from dart::MessageDeserializationCluster
 MessageDeserializationCluster (const char *name, bool is_canonical=false)
 
virtual ~MessageDeserializationCluster ()
 
virtual void ReadNodes (MessageDeserializer *d)=0
 
virtual void ReadEdges (MessageDeserializer *d)
 
virtual ObjectPtr PostLoad (MessageDeserializer *d)
 
virtual void ReadNodesApi (ApiMessageDeserializer *d)
 
virtual void ReadEdgesApi (ApiMessageDeserializer *d)
 
virtual void PostLoadApi (ApiMessageDeserializer *d)
 
void ReadNodesWrapped (MessageDeserializer *d)
 
void ReadNodesWrappedApi (ApiMessageDeserializer *d)
 
const char * name () const
 
bool is_canonical () const
 
- Public Member Functions inherited from dart::ZoneAllocated
 ZoneAllocated ()
 
void * operator new (size_t size)
 
void * operator new (size_t size, Zone *zone)
 
void operator delete (void *pointer)
 

Additional Inherited Members

- Protected Member Functions inherited from dart::MessageDeserializationCluster
ObjectPtr PostLoadAbstractType (MessageDeserializer *d)
 
ObjectPtr PostLoadLinkedHash (MessageDeserializer *d)
 
 DISALLOW_COPY_AND_ASSIGN (MessageDeserializationCluster)
 
- Protected Attributes inherited from dart::MessageDeserializationCluster
const char *const name_
 
const bool is_canonical_
 
intptr_t start_index_
 
intptr_t stop_index_
 

Detailed Description

Definition at line 2632 of file message_snapshot.cc.

Constructor & Destructor Documentation

◆ TwoByteStringMessageDeserializationCluster()

dart::TwoByteStringMessageDeserializationCluster::TwoByteStringMessageDeserializationCluster ( bool  is_canonical)
inlineexplicit

Definition at line 2635 of file message_snapshot.cc.

2636 : MessageDeserializationCluster("TwoByteString", is_canonical) {}
MessageDeserializationCluster(const char *name, bool is_canonical=false)

◆ ~TwoByteStringMessageDeserializationCluster()

dart::TwoByteStringMessageDeserializationCluster::~TwoByteStringMessageDeserializationCluster ( )
inline

Definition at line 2637 of file message_snapshot.cc.

2637{}

Member Function Documentation

◆ ReadNodes()

void dart::TwoByteStringMessageDeserializationCluster::ReadNodes ( MessageDeserializer d)
inlinevirtual

Implements dart::MessageDeserializationCluster.

Definition at line 2639 of file message_snapshot.cc.

2639 {
2640 const intptr_t count = d->ReadUnsigned();
2641 for (intptr_t i = 0; i < count; i++) {
2642 intptr_t length = d->ReadUnsigned();
2643 const uint16_t* data =
2644 reinterpret_cast<const uint16_t*>(d->CurrentBufferAddress());
2645 d->Advance(length * sizeof(uint16_t));
2646 d->AssignRef(is_canonical()
2647 ? Symbols::FromUTF16(d->thread(), data, length)
2648 : String::FromUTF16(data, length));
2649 }
2650 }
int count
Definition: FontMgrTest.cpp:50
static StringPtr FromUTF16(Thread *thread, const uint16_t *utf16_array, intptr_t len)
Definition: symbols.cc:229
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition: main.cc:19
size_t length
static int8_t data[kExtLength]

◆ ReadNodesApi()

void dart::TwoByteStringMessageDeserializationCluster::ReadNodesApi ( ApiMessageDeserializer d)
inlinevirtual

Reimplemented from dart::MessageDeserializationCluster.

Definition at line 2652 of file message_snapshot.cc.

2652 {
2653 intptr_t count = d->ReadUnsigned();
2654 for (intptr_t j = 0; j < count; j++) {
2655 // Read all the UTF-16 code units.
2656 intptr_t utf16_length = d->ReadUnsigned();
2657 const uint16_t* utf16 =
2658 reinterpret_cast<const uint16_t*>(d->CurrentBufferAddress());
2659 d->Advance(utf16_length * sizeof(uint16_t));
2660
2661 // Calculate the UTF-8 length and check if the string can be
2662 // UTF-8 encoded.
2663 intptr_t utf8_len = 0;
2664 bool valid = true;
2665 intptr_t i = 0;
2666 while (i < utf16_length && valid) {
2667 int32_t ch = Utf16::Next(utf16, &i, utf16_length);
2668 utf8_len += Utf8::Length(ch);
2669 valid = !Utf16::IsSurrogate(ch);
2670 }
2671 if (!valid) {
2672 d->AssignRef(d->Allocate(Dart_CObject_kUnsupported));
2673 } else {
2674 Dart_CObject* str = d->Allocate(Dart_CObject_kString);
2675 char* utf8 = d->zone()->Alloc<char>(utf8_len + 1);
2676 str->value.as_string = utf8;
2677 i = 0;
2678 while (i < utf16_length) {
2679 utf8 += Utf8::Encode(Utf16::Next(utf16, &i, utf16_length), utf8);
2680 }
2681 *utf8 = '\0';
2682 d->AssignRef(str);
2683 }
2684 }
2685 }
static bool IsSurrogate(uint32_t ch)
Definition: unicode.h:123
static int32_t Next(const uint16_t *characters, intptr_t *i, intptr_t len)
Definition: unicode.h:137
static intptr_t Length(int32_t ch)
Definition: unicode.cc:98
static intptr_t Encode(int32_t ch, char *dst)
Definition: unicode.cc:110
@ Dart_CObject_kString
@ Dart_CObject_kUnsupported
union _Dart_CObject::@86 value
const char * as_string

The documentation for this class was generated from the following file: