29enum class EncodedType {
48EncodedType EncodedTypeForValue(
const EncodableValue&
value) {
49 switch (
value.index()) {
53 return std::get<bool>(
value) ? EncodedType::kTrue : EncodedType::kFalse;
59 return EncodedType::kFloat64;
61 return EncodedType::kString;
63 return EncodedType::kUInt8List;
65 return EncodedType::kInt32List;
67 return EncodedType::kInt64List;
69 return EncodedType::kFloat64List;
73 return EncodedType::kMap;
75 return EncodedType::kFloat32List;
100 stream->WriteByte(
static_cast<uint8_t
>(EncodedTypeForValue(
value)));
102 switch (
value.index()) {
114 stream->WriteAlignment(8);
118 const auto& string_value = std::get<std::string>(
value);
119 size_t size = string_value.size();
123 reinterpret_cast<const uint8_t*
>(string_value.data()),
size);
140 const auto& list = std::get<EncodableList>(
value);
142 for (
const auto& item : list) {
148 const auto&
map = std::get<EncodableMap>(
value);
150 for (
const auto& pair :
map) {
158 <<
"Unhandled custom type in StandardCodecSerializer::WriteValue. "
159 <<
"Custom types require codec extensions." << std::endl;
171 switch (
static_cast<EncodedType
>(
type)) {
174 case EncodedType::kTrue:
176 case EncodedType::kFalse:
182 case EncodedType::kFloat64:
185 case EncodedType::kLargeInt:
186 case EncodedType::kString: {
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);
204 list_value.reserve(
length);
210 case EncodedType::kMap: {
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;
230 uint8_t
byte =
stream->ReadByte();
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);
263 std::vector<T> vector;
264 vector.resize(
count);
265 uint8_t type_size =
static_cast<uint8_t
>(
sizeof(
T));
267 stream->ReadAlignment(type_size);
269 stream->ReadBytes(
reinterpret_cast<uint8_t*
>(vector.data()),
271 return EncodableValue(vector);
275void StandardCodecSerializer::WriteVector(
const std::vector<T> vector,
276 ByteStreamWriter*
stream)
const {
277 size_t count = vector.size();
282 uint8_t type_size =
static_cast<uint8_t
>(
sizeof(
T));
284 stream->WriteAlignment(type_size);
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));
328std::unique_ptr<std::vector<uint8_t>>
331 auto encoded = std::make_unique<std::vector<uint8_t>>();
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) {}
365std::unique_ptr<MethodCall<EncodableValue>>
367 size_t message_size)
const {
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."
378 return std::make_unique<MethodCall<EncodableValue>>(*method_name,
379 std::move(arguments));
382std::unique_ptr<std::vector<uint8_t>>
385 auto encoded = std::make_unique<std::vector<uint8_t>>();
396std::unique_ptr<std::vector<uint8_t>>
399 auto encoded = std::make_unique<std::vector<uint8_t>>();
410std::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()) {
433 const uint8_t* response,
434 size_t response_size,
441 if (
value.IsNull()) {
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);
virtual void WriteValue(const EncodableValue &value, ByteStreamWriter *stream) const
virtual ~StandardCodecSerializer()
void WriteSize(size_t size, ByteStreamWriter *stream) const
StandardCodecSerializer()
static const StandardCodecSerializer & GetInstance()
EncodableValue ReadValue(ByteStreamReader *stream) const
virtual EncodableValue ReadValueOfType(uint8_t type, ByteStreamReader *stream) const
size_t ReadSize(ByteStreamReader *stream) const
static const StandardMessageCodec & GetInstance(const StandardCodecSerializer *serializer=nullptr)
std::unique_ptr< EncodableValue > DecodeMessageInternal(const uint8_t *binary_message, const size_t message_size) const override
StandardMessageCodec(StandardMessageCodec const &)=delete
std::unique_ptr< std::vector< uint8_t > > EncodeMessageInternal(const EncodableValue &message) const override
std::unique_ptr< std::vector< uint8_t > > EncodeErrorEnvelopeInternal(const std::string &error_code, const std::string &error_message, const EncodableValue *error_details) const override
std::unique_ptr< std::vector< uint8_t > > EncodeMethodCallInternal(const MethodCall< EncodableValue > &method_call) const override
StandardMethodCodec(StandardMethodCodec const &)=delete
std::unique_ptr< std::vector< uint8_t > > EncodeSuccessEnvelopeInternal(const EncodableValue *result) const override
std::unique_ptr< MethodCall< EncodableValue > > DecodeMethodCallInternal(const uint8_t *message, size_t message_size) const override
static const StandardMethodCodec & GetInstance(const StandardCodecSerializer *serializer=nullptr)
bool DecodeAndProcessResponseEnvelopeInternal(const uint8_t *response, size_t response_size, MethodResult< EncodableValue > *result) const override
FlutterSemanticsFlag flag
G_BEGIN_DECLS G_MODULE_EXPORT FlMethodCall * method_call
static constexpr const char * kList
std::vector< EncodableValue > EncodableList
std::map< EncodableValue, EncodableValue > EncodableMap
it will be possible to load the file into Perfetto s trace viewer 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
const myers::Point & get(const myers::Segment &)
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>