49 switch (value.index()) {
53 return std::get<bool>(
value) ? EncodedType::kTrue : EncodedType::kFalse;
55 return EncodedType::kInt32;
57 return EncodedType::kInt64;
59 return EncodedType::kFloat64;
61 return EncodedType::kString;
63 return EncodedType::kUInt8List;
65 return EncodedType::kInt32List;
67 return EncodedType::kInt64List;
69 return EncodedType::kFloat64List;
71 return EncodedType::kList;
73 return EncodedType::kMap;
75 return EncodedType::kFloat32List;
95 return ReadValueOfType(type, stream);
100 stream->
WriteByte(static_cast<uint8_t>(EncodedTypeForValue(value)));
102 switch (value.index()) {
118 const auto& string_value = std::get<std::string>(
value);
119 size_t size = string_value.size();
120 WriteSize(size, stream);
123 reinterpret_cast<const uint8_t*>(string_value.data()), size);
128 WriteVector(std::get<std::vector<uint8_t>>(value), stream);
131 WriteVector(std::get<std::vector<int32_t>>(value), stream);
134 WriteVector(std::get<std::vector<int64_t>>(value), stream);
137 WriteVector(std::get<std::vector<double>>(value), stream);
140 const auto& list = std::get<EncodableList>(
value);
141 WriteSize(list.size(), stream);
142 for (
const auto& item : list) {
143 WriteValue(item, stream);
148 const auto& map = std::get<EncodableMap>(
value);
149 WriteSize(map.size(), stream);
150 for (
const auto& pair : map) {
151 WriteValue(pair.first, stream);
152 WriteValue(pair.second, stream);
158 <<
"Unhandled custom type in StandardCodecSerializer::WriteValue. " 159 <<
"Custom types require codec extensions." << std::endl;
162 WriteVector(std::get<std::vector<float>>(value), stream);
171 switch (static_cast<EncodedType>(type)) {
174 case EncodedType::kTrue:
176 case EncodedType::kFalse:
178 case EncodedType::kInt32:
180 case EncodedType::kInt64:
182 case EncodedType::kFloat64:
185 case EncodedType::kLargeInt:
186 case EncodedType::kString: {
187 size_t size = ReadSize(stream);
188 std::string string_value;
189 string_value.resize(size);
190 stream->
ReadBytes(reinterpret_cast<uint8_t*>(&string_value[0]), size);
193 case EncodedType::kUInt8List:
194 return ReadVector<uint8_t>(stream);
195 case EncodedType::kInt32List:
196 return ReadVector<int32_t>(stream);
197 case EncodedType::kInt64List:
198 return ReadVector<int64_t>(stream);
199 case EncodedType::kFloat64List:
200 return ReadVector<double>(stream);
201 case EncodedType::kList: {
202 size_t length = ReadSize(stream);
204 list_value.reserve(length);
205 for (
size_t i = 0; i <
length; ++i) {
206 list_value.push_back(ReadValue(stream));
210 case EncodedType::kMap: {
211 size_t length = ReadSize(stream);
213 for (
size_t i = 0; i <
length; ++i) {
216 map_value.emplace(std::move(key), std::move(value));
220 case EncodedType::kFloat32List: {
221 return ReadVector<float>(stream);
224 std::cerr <<
"Unknown type in StandardCodecSerializer::ReadValueOfType: " 225 <<
static_cast<int>(
type) << std::endl;
233 }
else if (byte == 254) {
235 stream->
ReadBytes(reinterpret_cast<uint8_t*>(&value), 2);
239 stream->
ReadBytes(reinterpret_cast<uint8_t*>(&value), 4);
247 stream->
WriteByte(static_cast<uint8_t>(size));
248 }
else if (size <= 0xffff) {
250 uint16_t
value =
static_cast<uint16_t
>(
size);
251 stream->
WriteBytes(reinterpret_cast<uint8_t*>(&value), 2);
254 uint32_t
value =
static_cast<uint32_t
>(
size);
255 stream->
WriteBytes(reinterpret_cast<uint8_t*>(&value), 4);
259 template <
typename T>
262 size_t count = ReadSize(stream);
263 std::vector<T> vector;
264 vector.resize(count);
265 uint8_t type_size =
static_cast<uint8_t
>(
sizeof(T));
269 stream->
ReadBytes(reinterpret_cast<uint8_t*>(vector.data()),
274 template <
typename T>
275 void StandardCodecSerializer::WriteVector(
const std::vector<T> vector,
277 size_t count = vector.size();
278 WriteSize(count, stream);
282 uint8_t type_size =
static_cast<uint8_t
>(
sizeof(T));
286 stream->
WriteBytes(reinterpret_cast<const uint8_t*>(vector.data()),
299 std::unique_ptr<StandardMessageCodec>>;
300 auto it = sInstances->find(serializer);
301 if (it == sInstances->end()) {
304 auto emplace_result = sInstances->emplace(
305 serializer, std::unique_ptr<StandardMessageCodec>(
307 it = emplace_result.first;
309 return *(it->second);
314 : serializer_(serializer) {}
319 const uint8_t* binary_message,
320 size_t message_size)
const {
321 if (!binary_message) {
322 return std::make_unique<EncodableValue>();
325 return std::make_unique<EncodableValue>(serializer_->ReadValue(&stream));
328 std::unique_ptr<std::vector<uint8_t>>
331 auto encoded = std::make_unique<std::vector<uint8_t>>();
333 serializer_->WriteValue(message, &stream);
346 std::unique_ptr<StandardMethodCodec>>;
347 auto it = sInstances->find(serializer);
348 if (it == sInstances->end()) {
351 auto emplace_result = sInstances->emplace(
352 serializer, std::unique_ptr<StandardMethodCodec>(
354 it = emplace_result.first;
356 return *(it->second);
361 : serializer_(serializer) {}
365 std::unique_ptr<MethodCall<EncodableValue>>
367 size_t message_size)
const {
369 EncodableValue method_name_value = serializer_->ReadValue(&stream);
370 const auto* method_name = std::get_if<std::string>(&method_name_value);
372 std::cerr <<
"Invalid method call; method name is not a string." 377 std::make_unique<EncodableValue>(serializer_->ReadValue(&stream));
378 return std::make_unique<MethodCall<EncodableValue>>(*method_name,
379 std::move(arguments));
382 std::unique_ptr<std::vector<uint8_t>>
385 auto encoded = std::make_unique<std::vector<uint8_t>>();
389 serializer_->WriteValue(*method_call.
arguments(), &stream);
396 std::unique_ptr<std::vector<uint8_t>>
399 auto encoded = std::make_unique<std::vector<uint8_t>>();
403 serializer_->WriteValue(*result, &stream);
410 std::unique_ptr<std::vector<uint8_t>>
412 const std::string& error_code,
413 const std::string& error_message,
415 auto encoded = std::make_unique<std::vector<uint8_t>>();
419 if (error_message.empty()) {
425 serializer_->WriteValue(*error_details, &stream);
433 const uint8_t* response,
434 size_t response_size,
452 const std::string& message_string =
455 result->
Error(std::get<std::string>(code), message_string);
457 result->
Error(std::get<std::string>(code), message_string, details);
size_t ReadSize(ByteStreamReader *stream) const
virtual void WriteAlignment(uint8_t alignment)=0
G_BEGIN_DECLS FlMethodCall * method_call
virtual void WriteValue(const EncodableValue &value, ByteStreamWriter *stream) const
virtual void ReadAlignment(uint8_t alignment)=0
const T * arguments() const
virtual void ReadBytes(uint8_t *buffer, size_t length)=0
virtual void WriteByte(uint8_t byte)=0
std::unique_ptr< std::vector< uint8_t > > EncodeErrorEnvelopeInternal(const std::string &error_code, const std::string &error_message, const EncodableValue *error_details) const override
void Error(const std::string &error_code, const std::string &error_message, const T &error_details)
StandardMessageCodec(StandardMessageCodec const &)=delete
enum flutter::testing::@1969::KeyboardChange::Type type
EncodableValue ReadValue(ByteStreamReader *stream) const
void WriteDouble(double value)
StandardCodecSerializer()
static const StandardCodecSerializer & GetInstance()
static const StandardMessageCodec & GetInstance(const StandardCodecSerializer *serializer=nullptr)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data observatory The hostname IP address on which the Dart Observatory should be served If not defaults to or::depending on whether ipv6 is specified disable Disable the Dart Observatory The observatory is never available in release mode Bind to the IPv6 localhost address for the Dart Observatory Ignored if observatory host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent Remove all existing persistent cache This is mainly for debugging purposes such as reproducing the shader compilation jank use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
uint8_t ReadByte() override
void Success(const T &result)
virtual ~StandardCodecSerializer()
std::unique_ptr< EncodableValue > DecodeMessageInternal(const uint8_t *binary_message, const size_t message_size) const override
virtual void WriteBytes(const uint8_t *bytes, size_t length)=0
void WriteInt32(int32_t value)
FlutterSemanticsFlag flag
std::unique_ptr< std::vector< uint8_t > > EncodeMessageInternal(const EncodableValue &message) const override
virtual EncodableValue ReadValueOfType(uint8_t type, ByteStreamReader *stream) const
std::vector< EncodableValue > EncodableList
bool DecodeAndProcessResponseEnvelopeInternal(const uint8_t *response, size_t response_size, MethodResult< EncodableValue > *result) const override
static const StandardMethodCodec & GetInstance(const StandardCodecSerializer *serializer=nullptr)
std::unique_ptr< std::vector< uint8_t > > EncodeSuccessEnvelopeInternal(const EncodableValue *result) const override
void WriteInt64(int64_t value)
void WriteSize(size_t size, ByteStreamWriter *stream) const
StandardMethodCodec(StandardMethodCodec const &)=delete
std::map< EncodableValue, EncodableValue > EncodableMap
std::unique_ptr< MethodCall< EncodableValue > > DecodeMethodCallInternal(const uint8_t *message, size_t message_size) const override
const std::string & method_name() const
virtual uint8_t ReadByte()=0
std::unique_ptr< std::vector< uint8_t > > EncodeMethodCallInternal(const MethodCall< EncodableValue > &method_call) const override