| Flutter Linux Embedder |

Functions | Variables
fl_standard_message_codec.cc File Reference
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_standard_message_codec.h"`
`#include <gmodule.h>`
`#include <cstring>`

Go to the source code of this file.

## Functions
| G_DEFINE_TYPE (FlStandardMessageCodec, fl_standard_message_codec, fl_message_codec_get_type()) static void write_uint8(GByteArray *buffer
static void | write_uint16 (GByteArray *buffer, uint16_t value)
static void | write_uint32 (GByteArray *buffer, uint32_t value)
static void | write_int32 (GByteArray *buffer, int32_t value)
static void | write_int64 (GByteArray *buffer, int64_t value)
static void | write_float64 (GByteArray *buffer, double value)
static void | write_align (GByteArray *buffer, guint align)
static gboolean | check_size (GBytes *buffer, size_t offset, size_t required, GError **error)
static gboolean | read_align (GBytes *buffer, size_t *offset, size_t align, GError **error)
static const uint8_t * | get_data (GBytes *buffer, size_t *offset)
static gboolean | read_uint8 (GBytes *buffer, size_t *offset, uint8_t *value, GError **error)
static gboolean | read_uint16 (GBytes *buffer, size_t *offset, uint16_t *value, GError **error)
static gboolean | read_uint32 (GBytes *buffer, size_t *offset, uint32_t *value, GError **error)
static FlValue * | read_int32_value (GBytes *buffer, size_t *offset, GError **error)
static FlValue * | read_int64_value (GBytes *buffer, size_t *offset, GError **error)
static FlValue * | read_float64_value (GBytes *buffer, size_t *offset, GError **error)
static FlValue * | read_string_value (FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
static FlValue * | read_uint8_list_value (FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
static FlValue * | read_int32_list_value (FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
static FlValue * | read_int64_list_value (FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
static FlValue * | read_float32_list_value (FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
static FlValue * | read_float64_list_value (FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
static FlValue * | read_list_value (FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
static FlValue * | read_map_value (FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
static GBytes * | fl_standard_message_codec_encode_message (FlMessageCodec *codec, FlValue *message, GError **error)
static FlValue * | fl_standard_message_codec_decode_message (FlMessageCodec *codec, GBytes *message, GError **error)
static gboolean | fl_standard_message_codec_real_write_value (FlStandardMessageCodec *self, GByteArray *buffer, FlValue *value, GError **error)
static FlValue * | fl_standard_message_codec_read_value_of_type (FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, int type, GError **error)
static void | fl_standard_message_codec_class_init (FlStandardMessageCodecClass *klass)
static void | fl_standard_message_codec_init (FlStandardMessageCodec *self)
G_MODULE_EXPORT FlStandardMessageCodec * | fl_standard_message_codec_new ()
G_MODULE_EXPORT void | fl_standard_message_codec_write_size (FlStandardMessageCodec *codec, GByteArray *buffer, uint32_t size)
G_MODULE_EXPORT gboolean | fl_standard_message_codec_read_size (FlStandardMessageCodec *codec, GBytes *buffer, size_t *offset, uint32_t *value, GError **error)
G_MODULE_EXPORT gboolean | fl_standard_message_codec_write_value (FlStandardMessageCodec *self, GByteArray *buffer, FlValue *value, GError **error)
G_MODULE_EXPORT FlValue * | fl_standard_message_codec_read_value (FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)

## Variables
static constexpr int | kValueNull = 0
static constexpr int | kValueTrue = 1
static constexpr int | kValueFalse = 2
static constexpr int | kValueInt32 = 3
static constexpr int | kValueInt64 = 4
static constexpr int | kValueFloat64 = 6
static constexpr int | kValueString = 7
static constexpr int | kValueUint8List = 8
static constexpr int | kValueInt32List = 9
static constexpr int | kValueInt64List = 10
static constexpr int | kValueFloat64List = 11
static constexpr int | kValueList = 12
static constexpr int | kValueMap = 13
static constexpr int | kValueFloat32List = 14
uint8_t | value

## Function Documentation

## ◆ check_size()

static gboolean check_size | ( | GBytes * | buffer,
|  | size_t | offset,
|  | size_t | required,
|  | GError ** | error
| ) |  |
| static

Definition at line 73 of file fl_standard_message_codec.cc.

76 {
77 if (offset + required > g_bytes_get_size(buffer)) {
78 g_set_error(error, FL_MESSAGE_CODEC_ERROR,
79 FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA, "Unexpected end of data");
80 return FALSE;
81 }
82 return TRUE;
83 }
TRUE
return TRUE
Definition: fl_compositor_software.cc:69
FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA
@ FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA
Definition: fl_message_codec.h:34
FL_MESSAGE_CODEC_ERROR
#define FL_MESSAGE_CODEC_ERROR
Definition: fl_message_codec.h:30
buffer
static const uint8_t buffer[]
Definition: fl_pixel_buffer_texture_test.cc:44
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40

References buffer, error, FL_MESSAGE_CODEC_ERROR, FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA, and TRUE.

Referenced by read_align(), read_float32_list_value(), read_float64_list_value(), read_float64_value(), read_int32_list_value(), read_int32_value(), read_int64_list_value(), read_int64_value(), read_string_value(), read_uint16(), read_uint32(), read_uint8(), and read_uint8_list_value().

## ◆ fl_standard_message_codec_class_init()

static void fl_standard_message_codec_class_init | ( | FlStandardMessageCodecClass * | klass | ) |
| static

Definition at line 625 of file fl_standard_message_codec.cc.

626 {
627 FL_MESSAGE_CODEC_CLASS(klass)->encode_message =
628 fl_standard_message_codec_encode_message;
629 FL_MESSAGE_CODEC_CLASS(klass)->decode_message =
630 fl_standard_message_codec_decode_message;
631 klass->write_value = fl_standard_message_codec_real_write_value;
632 klass->read_value_of_type = fl_standard_message_codec_read_value_of_type;
633 }
fl_standard_message_codec_read_value_of_type
static FlValue * fl_standard_message_codec_read_value_of_type(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, int type, GError **error)
Definition: fl_standard_message_codec.cc:580
fl_standard_message_codec_real_write_value
static gboolean fl_standard_message_codec_real_write_value(FlStandardMessageCodec *self, GByteArray *buffer, FlValue *value, GError **error)
Definition: fl_standard_message_codec.cc:444
fl_standard_message_codec_encode_message
static GBytes * fl_standard_message_codec_encode_message(FlMessageCodec *codec, FlValue *message, GError **error)
Definition: fl_standard_message_codec.cc:400
fl_standard_message_codec_decode_message
static FlValue * fl_standard_message_codec_decode_message(FlMessageCodec *codec, GBytes *message, GError **error)
Definition: fl_standard_message_codec.cc:415

References fl_standard_message_codec_decode_message(), fl_standard_message_codec_encode_message(), fl_standard_message_codec_read_value_of_type(), and fl_standard_message_codec_real_write_value().

## ◆ fl_standard_message_codec_decode_message()

static FlValue* fl_standard_message_codec_decode_message | ( | FlMessageCodec * | codec,
|  | GBytes * | message,
|  | GError ** | error
| ) |  |
| static

Definition at line 415 of file fl_standard_message_codec.cc.

417 {
418 if (g_bytes_get_size(message) == 0) {
419 return fl_value_new_null();
420 }
421
422 FlStandardMessageCodec* self =
423 reinterpret_cast<FlStandardMessageCodec*>(codec);
424
425 size_t offset = 0;
426 g_autoptr(FlValue) value =
427 fl_standard_message_codec_read_value(self, message, &offset, error);
428 if (value == nullptr) {
429 return nullptr;
430 }
431
432 if (offset != g_bytes_get_size(message)) {
433 g_set_error(error, FL_MESSAGE_CODEC_ERROR,
434 FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA,
435 "Unused %zi bytes after standard message",
436 g_bytes_get_size(message) - offset);
437 return nullptr;
438 }
439
440 return fl_value_ref(value);
441 }
g_autoptr
g_autoptr(GMutexLocker) locker
FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA
@ FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA
Definition: fl_message_codec.h:35
fl_standard_message_codec_read_value
G_MODULE_EXPORT FlValue * fl_standard_message_codec_read_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
Definition: fl_standard_message_codec.cc:694
value
uint8_t value
Definition: fl_standard_message_codec.cc:36
fl_value_ref
G_MODULE_EXPORT FlValue * fl_value_ref(FlValue *self)
Definition: fl_value.cc:394
fl_value_new_null
G_MODULE_EXPORT FlValue * fl_value_new_null()
Definition: fl_value.cc:251
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42

References error, FL_MESSAGE_CODEC_ERROR, FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA, fl_standard_message_codec_read_value(), fl_value_new_null(), fl_value_ref(), g_autoptr(), and value.

Referenced by fl_standard_message_codec_class_init().

## ◆ fl_standard_message_codec_encode_message()

static GBytes* fl_standard_message_codec_encode_message | ( | FlMessageCodec * | codec,
|  | FlValue * | message,
|  | GError ** | error
| ) |  |
| static

Definition at line 400 of file fl_standard_message_codec.cc.

402 {
403 FlStandardMessageCodec* self =
404 reinterpret_cast<FlStandardMessageCodec*>(codec);
405
406 g_autoptr(GByteArray) buffer = g_byte_array_new();
407 if (!fl_standard_message_codec_write_value(self, buffer, message, error)) {
408 return nullptr;
409 }
410 return g_byte_array_free_to_bytes(
411 static_cast<GByteArray*>(g_steal_pointer(&buffer)));
412 }
fl_standard_message_codec_write_value
G_MODULE_EXPORT gboolean fl_standard_message_codec_write_value(FlStandardMessageCodec *self, GByteArray *buffer, FlValue *value, GError **error)
Definition: fl_standard_message_codec.cc:685

References buffer, error, fl_standard_message_codec_write_value(), and g_autoptr().

Referenced by fl_standard_message_codec_class_init().

## ◆ fl_standard_message_codec_init()

static void fl_standard_message_codec_init | ( | FlStandardMessageCodec * | self | ) |
| static

Definition at line 635 of file fl_standard_message_codec.cc.

635 {}

## ◆ fl_standard_message_codec_new()

G_MODULE_EXPORT FlStandardMessageCodec* fl_standard_message_codec_new | ( |  | ) |

Definition at line 637 of file fl_standard_message_codec.cc.

637 {
638 return static_cast<FlStandardMessageCodec*>(
639 g_object_new(fl_standard_message_codec_get_type(), nullptr));
640 }

Referenced by decode_error_value(), decode_message(), decode_semantic_data(), encode_message(), fl_accessible_text_field_perform_action(), fl_standard_method_codec_new(), perform_set_selection_action(), perform_set_text_action(), and TEST().

## ◆ fl_standard_message_codec_read_size()

G_MODULE_EXPORT gboolean fl_standard_message_codec_read_size | ( | FlStandardMessageCodec * | codec,
|  | GBytes * | buffer,
|  | size_t * | offset,
|  | uint32_t * | value,
|  | GError ** | error
| ) |  |

fl_standard_message_codec_read_size: @codec: an #FlStandardMessageCodec. @buffer: buffer to read from. @offset: (inout): read position in @buffer. @value: location to read size. @error: (allow-none): #GError location to store the error occurring, or NULL.

Reads a size field in Flutter Standard encoding.

This method is intended for use by subclasses overriding FlStandardMessageCodec::read_value_of_type.

Returns: TRUE on success.

Definition at line 657 of file fl_standard_message_codec.cc.

662 {
663 uint8_t value8;
664 if (!read_uint8(buffer, offset, &value8, error)) {
665 return FALSE;
666 }
667
668 if (value8 == 255) {
669 if (!read_uint32(buffer, offset, value, error)) {
670 return FALSE;
671 }
672 } else if (value8 == 254) {
673 uint16_t value16;
674 if (!read_uint16(buffer, offset, &value16, error)) {
675 return FALSE;
676 }
677 *value = value16;
678 } else {
679 *value = value8;
680 }
681
682 return TRUE;
683 }
read_uint32
static gboolean read_uint32(GBytes *buffer, size_t *offset, uint32_t *value, GError **error)
Definition: fl_standard_message_codec.cc:141
read_uint16
static gboolean read_uint16(GBytes *buffer, size_t *offset, uint16_t *value, GError **error)
Definition: fl_standard_message_codec.cc:126
read_uint8
static gboolean read_uint8(GBytes *buffer, size_t *offset, uint8_t *value, GError **error)
Definition: fl_standard_message_codec.cc:111

References buffer, error, read_uint16(), read_uint32(), read_uint8(), TRUE, and value.

Referenced by read_custom_value(), read_custom_value1(), read_float32_list_value(), read_float64_list_value(), read_int32_list_value(), read_int64_list_value(), read_list_value(), read_map_value(), read_string_value(), and read_uint8_list_value().

## ◆ fl_standard_message_codec_read_value()

G_MODULE_EXPORT FlValue* fl_standard_message_codec_read_value | ( | FlStandardMessageCodec * | codec,
|  | GBytes * | buffer,
|  | size_t * | offset,
|  | GError ** | error
| ) |  |

fl_standard_message_codec_read_value: @codec: an #FlStandardMessageCodec. @buffer: buffer to read from. @offset: (inout): read position in @buffer. @value: location to read size. @error: (allow-none): #GError location to store the error occurring, or NULL.

Reads an FlValue in Flutter Standard encoding.

This method is intended for use by subclasses overriding FlStandardMessageCodec::read_value_of_type.

Returns: a new FlValue or NULL on error.

Definition at line 694 of file fl_standard_message_codec.cc.

698 {
699 uint8_t type;
700 if (!read_uint8(buffer, offset, &type, error)) {
701 return nullptr;
702 }
703
704 return FL_STANDARD_MESSAGE_CODEC_GET_CLASS(self)->read_value_of_type(
705 self, buffer, offset, type, error);
706 }
type
uint8_t type
Definition: fl_standard_message_codec_test.cc:1117

References buffer, error, read_uint8(), and type.

Referenced by fl_standard_message_codec_decode_message(), fl_standard_method_codec_decode_method_call(), fl_standard_method_codec_decode_response(), read_list_value(), and read_map_value().

## ◆ fl_standard_message_codec_read_value_of_type()

static FlValue* fl_standard_message_codec_read_value_of_type | ( | FlStandardMessageCodec * | self,
|  | GBytes * | buffer,
|  | size_t * | offset,
|  | int | type,
|  | GError ** | error
| ) |  |
| static

Definition at line 580 of file fl_standard_message_codec.cc.

585 {
586 g_autoptr(FlValue) value = nullptr;
587 if (type == kValueNull) {
588 return fl_value_new_null();
589 } else if (type == kValueTrue) {
590 return fl_value_new_bool(TRUE);
591 } else if (type == kValueFalse) {
592 return fl_value_new_bool(FALSE);
593 } else if (type == kValueInt32) {
594 value = read_int32_value(buffer, offset, error);
595 } else if (type == kValueInt64) {
596 value = read_int64_value(buffer, offset, error);
597 } else if (type == kValueFloat64) {
598 value = read_float64_value(buffer, offset, error);
599 } else if (type == kValueString) {
600 value = read_string_value(self, buffer, offset, error);
601 } else if (type == kValueUint8List) {
602 value = read_uint8_list_value(self, buffer, offset, error);
603 } else if (type == kValueInt32List) {
604 value = read_int32_list_value(self, buffer, offset, error);
605 } else if (type == kValueInt64List) {
606 value = read_int64_list_value(self, buffer, offset, error);
607 } else if (type == kValueFloat32List) {
608 value = read_float32_list_value(self, buffer, offset, error);
609 } else if (type == kValueFloat64List) {
610 value = read_float64_list_value(self, buffer, offset, error);
611 } else if (type == kValueList) {
612 value = read_list_value(self, buffer, offset, error);
613 } else if (type == kValueMap) {
614 value = read_map_value(self, buffer, offset, error);
615 } else {
616 g_set_error(error, FL_MESSAGE_CODEC_ERROR,
617 FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE,
618 "Unexpected standard codec type %02x", type);
619 return nullptr;
620 }
621
622 return value == nullptr ? nullptr : fl_value_ref(value);
623 }
FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE
@ FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE
Definition: fl_message_codec.h:36
kValueNull
static constexpr int kValueNull
Definition: fl_standard_message_codec.cc:15
kValueString
static constexpr int kValueString
Definition: fl_standard_message_codec.cc:21
read_int32_value
static FlValue * read_int32_value(GBytes *buffer, size_t *offset, GError **error)
Definition: fl_standard_message_codec.cc:157
read_float32_list_value
static FlValue * read_float32_list_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
Definition: fl_standard_message_codec.cc:297
read_float64_value
static FlValue * read_float64_value(GBytes *buffer, size_t *offset, GError **error)
Definition: fl_standard_message_codec.cc:189
kValueTrue
static constexpr int kValueTrue
Definition: fl_standard_message_codec.cc:16
read_string_value
static FlValue * read_string_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
Definition: fl_standard_message_codec.cc:208
kValueInt64List
static constexpr int kValueInt64List
Definition: fl_standard_message_codec.cc:24
kValueFloat64List
static constexpr int kValueFloat64List
Definition: fl_standard_message_codec.cc:25
kValueFloat32List
static constexpr int kValueFloat32List
Definition: fl_standard_message_codec.cc:28
read_list_value
static FlValue * read_list_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
Definition: fl_standard_message_codec.cc:345
read_uint8_list_value
static FlValue * read_uint8_list_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
Definition: fl_standard_message_codec.cc:229
kValueUint8List
static constexpr int kValueUint8List
Definition: fl_standard_message_codec.cc:22
read_int32_list_value
static FlValue * read_int32_list_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
Definition: fl_standard_message_codec.cc:249
kValueInt32
static constexpr int kValueInt32
Definition: fl_standard_message_codec.cc:18
read_map_value
static FlValue * read_map_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
Definition: fl_standard_message_codec.cc:371
kValueList
static constexpr int kValueList
Definition: fl_standard_message_codec.cc:26
kValueFloat64
static constexpr int kValueFloat64
Definition: fl_standard_message_codec.cc:20
kValueMap
static constexpr int kValueMap
Definition: fl_standard_message_codec.cc:27
kValueInt32List
static constexpr int kValueInt32List
Definition: fl_standard_message_codec.cc:23
read_int64_value
static FlValue * read_int64_value(GBytes *buffer, size_t *offset, GError **error)
Definition: fl_standard_message_codec.cc:173
kValueInt64
static constexpr int kValueInt64
Definition: fl_standard_message_codec.cc:19
read_int64_list_value
static FlValue * read_int64_list_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
Definition: fl_standard_message_codec.cc:273
read_float64_list_value
static FlValue * read_float64_list_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
Definition: fl_standard_message_codec.cc:321
kValueFalse
static constexpr int kValueFalse
Definition: fl_standard_message_codec.cc:17
fl_value_new_bool
G_MODULE_EXPORT FlValue * fl_value_new_bool(bool value)
Definition: fl_value.cc:255

References buffer, error, FL_MESSAGE_CODEC_ERROR, FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE, fl_value_new_bool(), fl_value_new_null(), fl_value_ref(), g_autoptr(), kValueFalse, kValueFloat32List, kValueFloat64, kValueFloat64List, kValueInt32, kValueInt32List, kValueInt64, kValueInt64List, kValueList, kValueMap, kValueNull, kValueString, kValueTrue, kValueUint8List, read_float32_list_value(), read_float64_list_value(), read_float64_value(), read_int32_list_value(), read_int32_value(), read_int64_list_value(), read_int64_value(), read_list_value(), read_map_value(), read_string_value(), read_uint8_list_value(), TRUE, type, and value.

Referenced by fl_standard_message_codec_class_init().

## ◆ fl_standard_message_codec_real_write_value()

static gboolean fl_standard_message_codec_real_write_value | ( | FlStandardMessageCodec * | self,
|  | GByteArray * | buffer,
|  | FlValue * | value,
|  | GError ** | error
| ) |  |
| static

Definition at line 444 of file fl_standard_message_codec.cc.

448 {
449 if (value == nullptr) {
450 write_uint8(buffer, kValueNull);
451 return TRUE;
452 }
453
454 switch (fl_value_get_type(value)) {
455 case FL_VALUE_TYPE_NULL:
456 write_uint8(buffer, kValueNull);
457 return TRUE;
458 case FL_VALUE_TYPE_BOOL:
459 if (fl_value_get_bool(value)) {
460 write_uint8(buffer, kValueTrue);
461 } else {
462 write_uint8(buffer, kValueFalse);
463 }
464 return TRUE;
465 case FL_VALUE_TYPE_INT: {
466 int64_t v = fl_value_get_int(value);
467 if (v >= INT32_MIN && v <= INT32_MAX) {
468 write_uint8(buffer, kValueInt32);
469 write_int32(buffer, v);
470 } else {
471 write_uint8(buffer, kValueInt64);
472 write_int64(buffer, v);
473 }
474 return TRUE;
475 }
476 case FL_VALUE_TYPE_FLOAT:
477 write_uint8(buffer, kValueFloat64);
478 write_align(buffer, 8);
479 write_float64(buffer, fl_value_get_float(value));
480 return TRUE;
481 case FL_VALUE_TYPE_STRING: {
482 write_uint8(buffer, kValueString);
483 const char* text = fl_value_get_string(value);
484 size_t length = strlen(text);
485 fl_standard_message_codec_write_size(self, buffer, length);
486 g_byte_array_append(buffer, reinterpret_cast<const uint8_t*>(text),
487 length);
488 return TRUE;
489 }
490 case FL_VALUE_TYPE_UINT8_LIST: {
491 write_uint8(buffer, kValueUint8List);
492 size_t length = fl_value_get_length(value);
493 fl_standard_message_codec_write_size(self, buffer, length);
494 g_byte_array_append(buffer, fl_value_get_uint8_list(value),
495 sizeof(uint8_t) * length);
496 return TRUE;
497 }
498 case FL_VALUE_TYPE_INT32_LIST: {
499 write_uint8(buffer, kValueInt32List);
500 size_t length = fl_value_get_length(value);
501 fl_standard_message_codec_write_size(self, buffer, length);
502 write_align(buffer, 4);
503 g_byte_array_append(
504 buffer,
505 reinterpret_cast<const uint8_t*>(fl_value_get_int32_list(value)),
506 sizeof(int32_t) * length);
507 return TRUE;
508 }
509 case FL_VALUE_TYPE_INT64_LIST: {
510 write_uint8(buffer, kValueInt64List);
511 size_t length = fl_value_get_length(value);
512 fl_standard_message_codec_write_size(self, buffer, length);
513 write_align(buffer, 8);
514 g_byte_array_append(
515 buffer,
516 reinterpret_cast<const uint8_t*>(fl_value_get_int64_list(value)),
517 sizeof(int64_t) * length);
518 return TRUE;
519 }
520 case FL_VALUE_TYPE_FLOAT32_LIST: {
521 write_uint8(buffer, kValueFloat32List);
522 size_t length = fl_value_get_length(value);
523 fl_standard_message_codec_write_size(self, buffer, length);
524 write_align(buffer, 4);
525 g_byte_array_append(
526 buffer,
527 reinterpret_cast<const uint8_t*>(fl_value_get_float32_list(value)),
528 sizeof(float) * length);
529 return TRUE;
530 }
531 case FL_VALUE_TYPE_FLOAT_LIST: {
532 write_uint8(buffer, kValueFloat64List);
533 size_t length = fl_value_get_length(value);
534 fl_standard_message_codec_write_size(self, buffer, length);
535 write_align(buffer, 8);
536 g_byte_array_append(
537 buffer,
538 reinterpret_cast<const uint8_t*>(fl_value_get_float_list(value)),
539 sizeof(double) * length);
540 return TRUE;
541 }
542 case FL_VALUE_TYPE_LIST:
543 write_uint8(buffer, kValueList);
544 fl_standard_message_codec_write_size(self, buffer,
545 fl_value_get_length(value));
546 for (size_t i = 0; i < fl_value_get_length(value); i++) {
547 if (!fl_standard_message_codec_write_value(
548 self, buffer, fl_value_get_list_value(value, i), error)) {
549 return FALSE;
550 }
551 }
552 return TRUE;
553 case FL_VALUE_TYPE_MAP:
554 write_uint8(buffer, kValueMap);
555 fl_standard_message_codec_write_size(self, buffer,
556 fl_value_get_length(value));
557 for (size_t i = 0; i < fl_value_get_length(value); i++) {
558 if (!fl_standard_message_codec_write_value(
559 self, buffer, fl_value_get_map_key(value, i), error) ||
560 !fl_standard_message_codec_write_value(
561 self, buffer, fl_value_get_map_value(value, i), error)) {
562 return FALSE;
563 }
564 }
565 return TRUE;
566 case FL_VALUE_TYPE_CUSTOM:
567 g_set_error(error, FL_MESSAGE_CODEC_ERROR,
568 FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE,
569 "Custom value not implemented");
570 return FALSE;
571 }
572
573 g_set_error(error, FL_MESSAGE_CODEC_ERROR,
574 FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE,
575 "Unexpected FlValue type %d", fl_value_get_type(value));
576 return FALSE;
577 }
i
int i
Definition: fl_socket_accessible.cc:18
fl_standard_message_codec_write_size
G_MODULE_EXPORT void fl_standard_message_codec_write_size(FlStandardMessageCodec *codec, GByteArray *buffer, uint32_t size)
Definition: fl_standard_message_codec.cc:642
write_align
static void write_align(GByteArray *buffer, guint align)
Definition: fl_standard_message_codec.cc:66
write_int64
static void write_int64(GByteArray *buffer, int64_t value)
Definition: fl_standard_message_codec.cc:55
write_float64
static void write_float64(GByteArray *buffer, double value)
Definition: fl_standard_message_codec.cc:60
write_int32
static void write_int32(GByteArray *buffer, int32_t value)
Definition: fl_standard_message_codec.cc:50
g_byte_array_append
g_byte_array_append(buffer, &type, sizeof(uint8_t))
length
size_t length
Definition: fl_standard_message_codec_test.cc:1115
fl_value_get_map_value
G_MODULE_EXPORT FlValue * fl_value_get_map_value(FlValue *self, size_t index)
Definition: fl_value.cc:792
fl_value_get_float_list
G_MODULE_EXPORT const double * fl_value_get_float_list(FlValue *self)
Definition: fl_value.cc:717
fl_value_get_list_value
G_MODULE_EXPORT FlValue * fl_value_get_list_value(FlValue *self, size_t index)
Definition: fl_value.cc:776
fl_value_get_uint8_list
G_MODULE_EXPORT const uint8_t * fl_value_get_uint8_list(FlValue *self)
Definition: fl_value.cc:689
fl_value_get_int
G_MODULE_EXPORT int64_t fl_value_get_int(FlValue *self)
Definition: fl_value.cc:668
fl_value_get_type
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
Definition: fl_value.cc:466
fl_value_get_float32_list
G_MODULE_EXPORT const float * fl_value_get_float32_list(FlValue *self)
Definition: fl_value.cc:710
fl_value_get_bool
G_MODULE_EXPORT bool fl_value_get_bool(FlValue *self)
Definition: fl_value.cc:661
fl_value_get_map_key
G_MODULE_EXPORT FlValue * fl_value_get_map_key(FlValue *self, size_t index)
Definition: fl_value.cc:784
fl_value_get_string
G_MODULE_EXPORT const gchar * fl_value_get_string(FlValue *self)
Definition: fl_value.cc:682
fl_value_get_int64_list
G_MODULE_EXPORT const int64_t * fl_value_get_int64_list(FlValue *self)
Definition: fl_value.cc:703
fl_value_get_float
G_MODULE_EXPORT double fl_value_get_float(FlValue *self)
Definition: fl_value.cc:675
fl_value_get_int32_list
G_MODULE_EXPORT const int32_t * fl_value_get_int32_list(FlValue *self)
Definition: fl_value.cc:696
fl_value_get_length
G_MODULE_EXPORT size_t fl_value_get_length(FlValue *self)
Definition: fl_value.cc:724
FL_VALUE_TYPE_STRING
@ FL_VALUE_TYPE_STRING
Definition: fl_value.h:68
FL_VALUE_TYPE_NULL
@ FL_VALUE_TYPE_NULL
Definition: fl_value.h:64
FL_VALUE_TYPE_INT
@ FL_VALUE_TYPE_INT
Definition: fl_value.h:66
FL_VALUE_TYPE_BOOL
@ FL_VALUE_TYPE_BOOL
Definition: fl_value.h:65
FL_VALUE_TYPE_FLOAT32_LIST
@ FL_VALUE_TYPE_FLOAT32_LIST
Definition: fl_value.h:75
FL_VALUE_TYPE_INT32_LIST
@ FL_VALUE_TYPE_INT32_LIST
Definition: fl_value.h:70
FL_VALUE_TYPE_UINT8_LIST
@ FL_VALUE_TYPE_UINT8_LIST
Definition: fl_value.h:69
FL_VALUE_TYPE_LIST
@ FL_VALUE_TYPE_LIST
Definition: fl_value.h:73
FL_VALUE_TYPE_MAP
@ FL_VALUE_TYPE_MAP
Definition: fl_value.h:74
FL_VALUE_TYPE_INT64_LIST
@ FL_VALUE_TYPE_INT64_LIST
Definition: fl_value.h:71
FL_VALUE_TYPE_FLOAT_LIST
@ FL_VALUE_TYPE_FLOAT_LIST
Definition: fl_value.h:72
FL_VALUE_TYPE_CUSTOM
@ FL_VALUE_TYPE_CUSTOM
Definition: fl_value.h:76
FL_VALUE_TYPE_FLOAT
@ FL_VALUE_TYPE_FLOAT
Definition: fl_value.h:67

References buffer, error, FL_MESSAGE_CODEC_ERROR, FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE, fl_standard_message_codec_write_size(), fl_standard_message_codec_write_value(), fl_value_get_bool(), fl_value_get_float(), fl_value_get_float32_list(), fl_value_get_float_list(), fl_value_get_int(), fl_value_get_int32_list(), fl_value_get_int64_list(), fl_value_get_length(), fl_value_get_list_value(), fl_value_get_map_key(), fl_value_get_map_value(), fl_value_get_string(), fl_value_get_type(), fl_value_get_uint8_list(), FL_VALUE_TYPE_BOOL, FL_VALUE_TYPE_CUSTOM, FL_VALUE_TYPE_FLOAT, FL_VALUE_TYPE_FLOAT32_LIST, FL_VALUE_TYPE_FLOAT_LIST, FL_VALUE_TYPE_INT, FL_VALUE_TYPE_INT32_LIST, FL_VALUE_TYPE_INT64_LIST, FL_VALUE_TYPE_LIST, FL_VALUE_TYPE_MAP, FL_VALUE_TYPE_NULL, FL_VALUE_TYPE_STRING, FL_VALUE_TYPE_UINT8_LIST, g_byte_array_append(), i, kValueFalse, kValueFloat32List, kValueFloat64, kValueFloat64List, kValueInt32, kValueInt32List, kValueInt64, kValueInt64List, kValueList, kValueMap, kValueNull, kValueString, kValueTrue, kValueUint8List, length, TRUE, value, write_align(), write_float64(), write_int32(), and write_int64().

Referenced by fl_standard_message_codec_class_init().

## ◆ fl_standard_message_codec_write_size()

G_MODULE_EXPORT void fl_standard_message_codec_write_size | ( | FlStandardMessageCodec * | codec,
|  | GByteArray * | buffer,
|  | uint32_t | size
| ) |  |

fl_standard_message_codec_write_size: @codec: an #FlStandardMessageCodec. @buffer: buffer to write into. @size: size value to write.

Writes a size field in Flutter Standard encoding.

Definition at line 642 of file fl_standard_message_codec.cc.

645 {
646 if (size < 254) {
647 write_uint8(buffer, size);
648 } else if (size <= 0xffff) {
649 write_uint8(buffer, 254);
650 write_uint16(buffer, size);
651 } else {
652 write_uint8(buffer, 255);
653 write_uint32(buffer, size);
654 }
655 }
write_uint32
static void write_uint32(GByteArray *buffer, uint32_t value)
Definition: fl_standard_message_codec.cc:45
write_uint16
static void write_uint16(GByteArray *buffer, uint16_t value)
Definition: fl_standard_message_codec.cc:40

References buffer, write_uint16(), and write_uint32().

Referenced by fl_standard_message_codec_real_write_value().

## ◆ fl_standard_message_codec_write_value()

G_MODULE_EXPORT gboolean fl_standard_message_codec_write_value | ( | FlStandardMessageCodec * | codec,
|  | GByteArray * | buffer,
|  | FlValue * | value,
|  | GError ** | error
| ) |  |

fl_standard_message_codec_write_value: @codec: an #FlStandardMessageCodec. @buffer: buffer to write into. @value: (allow-none): value to write. @error: (allow-none): #GError location to store the error occurring, or NULL.

Writes an FlValue in Flutter Standard encoding.

This method is intended for use by subclasses overriding FlStandardMessageCodec::write_value.

Returns: TRUE on success.

Definition at line 685 of file fl_standard_message_codec.cc.

689 {
690 return FL_STANDARD_MESSAGE_CODEC_GET_CLASS(self)->write_value(self, buffer,
691 value, error);
692 }

References buffer, error, and value.

Referenced by fl_standard_message_codec_encode_message(), fl_standard_message_codec_real_write_value(), fl_standard_method_codec_encode_error_envelope(), fl_standard_method_codec_encode_method_call(), and fl_standard_method_codec_encode_success_envelope().

## ◆ G_DEFINE_TYPE()

G_DEFINE_TYPE | ( | FlStandardMessageCodec | ,
|  | fl_standard_message_codec | ,
|  | fl_message_codec_get_type() |
| ) |  |

## ◆ get_data()

static const uint8_t* get_data | ( | GBytes * | buffer,
|  | size_t * | offset
| ) |  |
| static

Definition at line 104 of file fl_standard_message_codec.cc.

104 {
105 return static_cast<const uint8_t*>(g_bytes_get_data(buffer, nullptr)) +
106 *offset;
107 }

References buffer.

Referenced by read_float32_list_value(), read_float64_list_value(), read_float64_value(), read_int32_list_value(), read_int32_value(), read_int64_list_value(), read_int64_value(), read_string_value(), read_uint16(), read_uint32(), read_uint8(), and read_uint8_list_value().

## ◆ read_align()

static gboolean read_align | ( | GBytes * | buffer,
|  | size_t * | offset,
|  | size_t | align,
|  | GError ** | error
| ) |  |
| static

Definition at line 86 of file fl_standard_message_codec.cc.

89 {
90 if ((*offset) % align == 0) {
91 return TRUE;
92 }
93
94 size_t required = align - (*offset) % align;
95 if (!check_size(buffer, *offset, required, error)) {
96 return FALSE;
97 }
98
99 (*offset) += required;
100 return TRUE;
101 }
check_size
static gboolean check_size(GBytes *buffer, size_t offset, size_t required, GError **error)
Definition: fl_standard_message_codec.cc:73

References buffer, check_size(), error, and TRUE.

Referenced by read_float32_list_value(), read_float64_list_value(), read_float64_value(), read_int32_list_value(), and read_int64_list_value().

## ◆ read_float32_list_value()

static FlValue* read_float32_list_value | ( | FlStandardMessageCodec * | self,
|  | GBytes * | buffer,
|  | size_t * | offset,
|  | GError ** | error
| ) |  |
| static

Definition at line 297 of file fl_standard_message_codec.cc.

300 {
301 uint32_t length;
302 if (!fl_standard_message_codec_read_size(self, buffer, offset, &length,
303 error)) {
304 return nullptr;
305 }
306 if (!read_align(buffer, offset, 4, error)) {
307 return nullptr;
308 }
309 if (!check_size(buffer, *offset, sizeof(float) * length, error)) {
310 return nullptr;
311 }
312 FlValue* value = fl_value_new_float32_list(
313 reinterpret_cast<const float*>(get_data(buffer, offset)), length);
314 *offset += sizeof(float) * length;
315 return value;
316 }
fl_standard_message_codec_read_size
G_MODULE_EXPORT gboolean fl_standard_message_codec_read_size(FlStandardMessageCodec *codec, GBytes *buffer, size_t *offset, uint32_t *value, GError **error)
Definition: fl_standard_message_codec.cc:657
read_align
static gboolean read_align(GBytes *buffer, size_t *offset, size_t align, GError **error)
Definition: fl_standard_message_codec.cc:86
get_data
static const uint8_t * get_data(GBytes *buffer, size_t *offset)
Definition: fl_standard_message_codec.cc:104
fl_value_new_float32_list
G_MODULE_EXPORT FlValue * fl_value_new_float32_list(const float *data, size_t data_length)
Definition: fl_value.cc:329

References buffer, check_size(), error, fl_standard_message_codec_read_size(), fl_value_new_float32_list(), get_data(), length, read_align(), and value.

Referenced by fl_standard_message_codec_read_value_of_type().

## ◆ read_float64_list_value()

static FlValue* read_float64_list_value | ( | FlStandardMessageCodec * | self,
|  | GBytes * | buffer,
|  | size_t * | offset,
|  | GError ** | error
| ) |  |
| static

Definition at line 321 of file fl_standard_message_codec.cc.

324 {
325 uint32_t length;
326 if (!fl_standard_message_codec_read_size(self, buffer, offset, &length,
327 error)) {
328 return nullptr;
329 }
330 if (!read_align(buffer, offset, 8, error)) {
331 return nullptr;
332 }
333 if (!check_size(buffer, *offset, sizeof(double) * length, error)) {
334 return nullptr;
335 }
336 FlValue* value = fl_value_new_float_list(
337 reinterpret_cast<const double*>(get_data(buffer, offset)), length);
338 *offset += sizeof(double) * length;
339 return value;
340 }
fl_value_new_float_list
G_MODULE_EXPORT FlValue * fl_value_new_float_list(const double *data, size_t data_length)
Definition: fl_value.cc:339

References buffer, check_size(), error, fl_standard_message_codec_read_size(), fl_value_new_float_list(), get_data(), length, read_align(), and value.

Referenced by fl_standard_message_codec_read_value_of_type().

## ◆ read_float64_value()

static FlValue* read_float64_value | ( | GBytes * | buffer,
|  | size_t * | offset,
|  | GError ** | error
| ) |  |
| static

Definition at line 189 of file fl_standard_message_codec.cc.

191 {
192 if (!read_align(buffer, offset, 8, error)) {
193 return nullptr;
194 }
195 if (!check_size(buffer, *offset, sizeof(double), error)) {
196 return nullptr;
197 }
198
199 FlValue* value = fl_value_new_float(
200 reinterpret_cast<const double*>(get_data(buffer, offset))[0]);
201 *offset += sizeof(double);
202 return value;
203 }
fl_value_new_float
G_MODULE_EXPORT FlValue * fl_value_new_float(double value)
Definition: fl_value.cc:269

References buffer, check_size(), error, fl_value_new_float(), get_data(), read_align(), and value.

Referenced by fl_standard_message_codec_read_value_of_type().

## ◆ read_int32_list_value()

static FlValue* read_int32_list_value | ( | FlStandardMessageCodec * | self,
|  | GBytes * | buffer,
|  | size_t * | offset,
|  | GError ** | error
| ) |  |
| static

Definition at line 249 of file fl_standard_message_codec.cc.

252 {
253 uint32_t length;
254 if (!fl_standard_message_codec_read_size(self, buffer, offset, &length,
255 error)) {
256 return nullptr;
257 }
258 if (!read_align(buffer, offset, 4, error)) {
259 return nullptr;
260 }
261 if (!check_size(buffer, *offset, sizeof(int32_t) * length, error)) {
262 return nullptr;
263 }
264 FlValue* value = fl_value_new_int32_list(
265 reinterpret_cast<const int32_t*>(get_data(buffer, offset)), length);
266 *offset += sizeof(int32_t) * length;
267 return value;
268 }
fl_value_new_int32_list
G_MODULE_EXPORT FlValue * fl_value_new_int32_list(const int32_t *data, size_t data_length)
Definition: fl_value.cc:309

References buffer, check_size(), error, fl_standard_message_codec_read_size(), fl_value_new_int32_list(), get_data(), length, read_align(), and value.

Referenced by fl_standard_message_codec_read_value_of_type().

## ◆ read_int32_value()

static FlValue* read_int32_value | ( | GBytes * | buffer,
|  | size_t * | offset,
|  | GError ** | error
| ) |  |
| static

Definition at line 157 of file fl_standard_message_codec.cc.

159 {
160 if (!check_size(buffer, *offset, sizeof(int32_t), error)) {
161 return nullptr;
162 }
163
164 FlValue* value = fl_value_new_int(
165 reinterpret_cast<const int32_t*>(get_data(buffer, offset))[0]);
166 *offset += sizeof(int32_t);
167 return value;
168 }
fl_value_new_int
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
Definition: fl_value.cc:262

References buffer, check_size(), error, fl_value_new_int(), get_data(), and value.

Referenced by fl_standard_message_codec_read_value_of_type().

## ◆ read_int64_list_value()

static FlValue* read_int64_list_value | ( | FlStandardMessageCodec * | self,
|  | GBytes * | buffer,
|  | size_t * | offset,
|  | GError ** | error
| ) |  |
| static

Definition at line 273 of file fl_standard_message_codec.cc.

276 {
277 uint32_t length;
278 if (!fl_standard_message_codec_read_size(self, buffer, offset, &length,
279 error)) {
280 return nullptr;
281 }
282 if (!read_align(buffer, offset, 8, error)) {
283 return nullptr;
284 }
285 if (!check_size(buffer, *offset, sizeof(int64_t) * length, error)) {
286 return nullptr;
287 }
288 FlValue* value = fl_value_new_int64_list(
289 reinterpret_cast<const int64_t*>(get_data(buffer, offset)), length);
290 *offset += sizeof(int64_t) * length;
291 return value;
292 }
fl_value_new_int64_list
G_MODULE_EXPORT FlValue * fl_value_new_int64_list(const int64_t *data, size_t data_length)
Definition: fl_value.cc:319

References buffer, check_size(), error, fl_standard_message_codec_read_size(), fl_value_new_int64_list(), get_data(), length, read_align(), and value.

Referenced by fl_standard_message_codec_read_value_of_type().

## ◆ read_int64_value()

static FlValue* read_int64_value | ( | GBytes * | buffer,
|  | size_t * | offset,
|  | GError ** | error
| ) |  |
| static

Definition at line 173 of file fl_standard_message_codec.cc.

175 {
176 if (!check_size(buffer, *offset, sizeof(int64_t), error)) {
177 return nullptr;
178 }
179
180 FlValue* value = fl_value_new_int(
181 reinterpret_cast<const int64_t*>(get_data(buffer, offset))[0]);
182 *offset += sizeof(int64_t);
183 return value;
184 }

References buffer, check_size(), error, fl_value_new_int(), get_data(), and value.

Referenced by fl_standard_message_codec_read_value_of_type().

## ◆ read_list_value()

static FlValue* read_list_value | ( | FlStandardMessageCodec * | self,
|  | GBytes * | buffer,
|  | size_t * | offset,
|  | GError ** | error
| ) |  |
| static

Definition at line 345 of file fl_standard_message_codec.cc.

348 {
349 uint32_t length;
350 if (!fl_standard_message_codec_read_size(self, buffer, offset, &length,
351 error)) {
352 return nullptr;
353 }
354
355 g_autoptr(FlValue) list = fl_value_new_list();
356 for (size_t i = 0; i < length; i++) {
357 g_autoptr(FlValue) child =
358 fl_standard_message_codec_read_value(self, buffer, offset, error);
359 if (child == nullptr) {
360 return nullptr;
361 }
362 fl_value_append(list, child);
363 }
364
365 return fl_value_ref(list);
366 }
fl_value_append
G_MODULE_EXPORT void fl_value_append(FlValue *self, FlValue *value)
Definition: fl_value.cc:592
fl_value_new_list
G_MODULE_EXPORT FlValue * fl_value_new_list()
Definition: fl_value.cc:349

References buffer, error, fl_standard_message_codec_read_size(), fl_standard_message_codec_read_value(), fl_value_append(), fl_value_new_list(), fl_value_ref(), g_autoptr(), i, and length.

Referenced by fl_standard_message_codec_read_value_of_type().

## ◆ read_map_value()

static FlValue* read_map_value | ( | FlStandardMessageCodec * | self,
|  | GBytes * | buffer,
|  | size_t * | offset,
|  | GError ** | error
| ) |  |
| static

Definition at line 371 of file fl_standard_message_codec.cc.

374 {
375 uint32_t length;
376 if (!fl_standard_message_codec_read_size(self, buffer, offset, &length,
377 error)) {
378 return nullptr;
379 }
380
381 g_autoptr(FlValue) map = fl_value_new_map();
382 for (size_t i = 0; i < length; i++) {
383 g_autoptr(FlValue) key =
384 fl_standard_message_codec_read_value(self, buffer, offset, error);
385 if (key == nullptr) {
386 return nullptr;
387 }
388 g_autoptr(FlValue) value =
389 fl_standard_message_codec_read_value(self, buffer, offset, error);
390 if (value == nullptr) {
391 return nullptr;
392 }
393 fl_value_set(map, key, value);
394 }
395
396 return fl_value_ref(map);
397 }
fl_value_new_map
G_MODULE_EXPORT FlValue * fl_value_new_map()
Definition: fl_value.cc:366
fl_value_set
G_MODULE_EXPORT void fl_value_set(FlValue *self, FlValue *key, FlValue *value)
Definition: fl_value.cc:609

References buffer, error, fl_standard_message_codec_read_size(), fl_standard_message_codec_read_value(), fl_value_new_map(), fl_value_ref(), fl_value_set(), g_autoptr(), i, length, and value.

Referenced by fl_standard_message_codec_read_value_of_type().

## ◆ read_string_value()

static FlValue* read_string_value | ( | FlStandardMessageCodec * | self,
|  | GBytes * | buffer,
|  | size_t * | offset,
|  | GError ** | error
| ) |  |
| static

Definition at line 208 of file fl_standard_message_codec.cc.

211 {
212 uint32_t length;
213 if (!fl_standard_message_codec_read_size(self, buffer, offset, &length,
214 error)) {
215 return nullptr;
216 }
217 if (!check_size(buffer, *offset, length, error)) {
218 return nullptr;
219 }
220 FlValue* value = fl_value_new_string_sized(
221 reinterpret_cast<const gchar*>(get_data(buffer, offset)), length);
222 *offset += length;
223 return value;
224 }
fl_value_new_string_sized
G_MODULE_EXPORT FlValue * fl_value_new_string_sized(const gchar *value, size_t value_length)
Definition: fl_value.cc:283

References buffer, check_size(), error, fl_standard_message_codec_read_size(), fl_value_new_string_sized(), get_data(), length, and value.

Referenced by fl_standard_message_codec_read_value_of_type().

## ◆ read_uint16()

static gboolean read_uint16 | ( | GBytes * | buffer,
|  | size_t * | offset,
|  | uint16_t * | value,
|  | GError ** | error
| ) |  |
| static

Definition at line 126 of file fl_standard_message_codec.cc.

129 {
130 if (!check_size(buffer, *offset, sizeof(uint16_t), error)) {
131 return FALSE;
132 }
133
134 *value = reinterpret_cast<const uint16_t*>(get_data(buffer, offset))[0];
135 *offset += sizeof(uint16_t);
136 return TRUE;
137 }

References buffer, check_size(), error, get_data(), TRUE, and value.

Referenced by fl_standard_message_codec_read_size().

## ◆ read_uint32()

static gboolean read_uint32 | ( | GBytes * | buffer,
|  | size_t * | offset,
|  | uint32_t * | value,
|  | GError ** | error
| ) |  |
| static

Definition at line 141 of file fl_standard_message_codec.cc.

144 {
145 if (!check_size(buffer, *offset, sizeof(uint32_t), error)) {
146 return FALSE;
147 }
148
149 *value = reinterpret_cast<const uint32_t*>(get_data(buffer, offset))[0];
150 *offset += sizeof(uint32_t);
151 return TRUE;
152 }

References buffer, check_size(), error, get_data(), TRUE, and value.

Referenced by fl_standard_message_codec_read_size().

## ◆ read_uint8()

static gboolean read_uint8 | ( | GBytes * | buffer,
|  | size_t * | offset,
|  | uint8_t * | value,
|  | GError ** | error
| ) |  |
| static

Definition at line 111 of file fl_standard_message_codec.cc.

114 {
115 if (!check_size(buffer, *offset, sizeof(uint8_t), error)) {
116 return FALSE;
117 }
118
119 *value = get_data(buffer, offset)[0];
120 (*offset)++;
121 return TRUE;
122 }

References buffer, check_size(), error, get_data(), TRUE, and value.

Referenced by fl_standard_message_codec_read_size(), and fl_standard_message_codec_read_value().

## ◆ read_uint8_list_value()

static FlValue* read_uint8_list_value | ( | FlStandardMessageCodec * | self,
|  | GBytes * | buffer,
|  | size_t * | offset,
|  | GError ** | error
| ) |  |
| static

Definition at line 229 of file fl_standard_message_codec.cc.

232 {
233 uint32_t length;
234 if (!fl_standard_message_codec_read_size(self, buffer, offset, &length,
235 error)) {
236 return nullptr;
237 }
238 if (!check_size(buffer, *offset, sizeof(uint8_t) * length, error)) {
239 return nullptr;
240 }
241 FlValue* value = fl_value_new_uint8_list(get_data(buffer, offset), length);
242 *offset += length;
243 return value;
244 }
fl_value_new_uint8_list
G_MODULE_EXPORT FlValue * fl_value_new_uint8_list(const uint8_t *data, size_t data_length)
Definition: fl_value.cc:292

References buffer, check_size(), error, fl_standard_message_codec_read_size(), fl_value_new_uint8_list(), get_data(), length, and value.

Referenced by fl_standard_message_codec_read_value_of_type().

## ◆ write_align()

static void write_align | ( | GByteArray * | buffer,
|  | guint | align
| ) |  |
| static

Definition at line 66 of file fl_standard_message_codec.cc.

66 {
67 while (buffer->len % align != 0) {
68 write_uint8(buffer, 0);
69 }
70 }

References buffer.

Referenced by fl_standard_message_codec_real_write_value().

## ◆ write_float64()

static void write_float64 | ( | GByteArray * | buffer,
|  | double | value
| ) |  |
| static

Definition at line 60 of file fl_standard_message_codec.cc.

60 {
61 g_byte_array_append(buffer, reinterpret_cast<uint8_t*>(&value),
62 sizeof(double));
63 }

References buffer, g_byte_array_append(), and value.

Referenced by fl_standard_message_codec_real_write_value().

## ◆ write_int32()

static void write_int32 | ( | GByteArray * | buffer,
|  | int32_t | value
| ) |  |
| static

Definition at line 50 of file fl_standard_message_codec.cc.

50 {
51 g_byte_array_append(buffer, reinterpret_cast<uint8_t*>(&value),
52 sizeof(int32_t));
53 }

References buffer, g_byte_array_append(), and value.

Referenced by fl_standard_message_codec_real_write_value().

## ◆ write_int64()

static void write_int64 | ( | GByteArray * | buffer,
|  | int64_t | value
| ) |  |
| static

Definition at line 55 of file fl_standard_message_codec.cc.

55 {
56 g_byte_array_append(buffer, reinterpret_cast<uint8_t*>(&value),
57 sizeof(int64_t));
58 }

References buffer, g_byte_array_append(), and value.

Referenced by fl_standard_message_codec_real_write_value().

## ◆ write_uint16()

static void write_uint16 | ( | GByteArray * | buffer,
|  | uint16_t | value
| ) |  |
| static

Definition at line 40 of file fl_standard_message_codec.cc.

40 {
41 g_byte_array_append(buffer, reinterpret_cast<uint8_t*>(&value),
42 sizeof(uint16_t));
43 }

References buffer, g_byte_array_append(), and value.

Referenced by fl_standard_message_codec_write_size().

## ◆ write_uint32()

static void write_uint32 | ( | GByteArray * | buffer,
|  | uint32_t | value
| ) |  |
| static

Definition at line 45 of file fl_standard_message_codec.cc.

45 {
46 g_byte_array_append(buffer, reinterpret_cast<uint8_t*>(&value),
47 sizeof(uint32_t));
48 }

References buffer, g_byte_array_append(), and value.

Referenced by fl_standard_message_codec_write_size().

## Variable Documentation

## ◆ kValueFalse

constexpr int kValueFalse = 2
| static constexpr

Definition at line 17 of file fl_standard_message_codec.cc.

Referenced by fl_standard_message_codec_read_value_of_type(), and fl_standard_message_codec_real_write_value().

## ◆ kValueFloat32List

constexpr int kValueFloat32List = 14
| static constexpr

Definition at line 28 of file fl_standard_message_codec.cc.

Referenced by fl_standard_message_codec_read_value_of_type(), and fl_standard_message_codec_real_write_value().

## ◆ kValueFloat64

constexpr int kValueFloat64 = 6
| static constexpr

Definition at line 20 of file fl_standard_message_codec.cc.

Referenced by fl_standard_message_codec_read_value_of_type(), and fl_standard_message_codec_real_write_value().

## ◆ kValueFloat64List

constexpr int kValueFloat64List = 11
| static constexpr

Definition at line 25 of file fl_standard_message_codec.cc.

Referenced by fl_standard_message_codec_read_value_of_type(), and fl_standard_message_codec_real_write_value().

## ◆ kValueInt32

constexpr int kValueInt32 = 3
| static constexpr

Definition at line 18 of file fl_standard_message_codec.cc.

Referenced by fl_standard_message_codec_read_value_of_type(), and fl_standard_message_codec_real_write_value().

## ◆ kValueInt32List

constexpr int kValueInt32List = 9
| static constexpr

Definition at line 23 of file fl_standard_message_codec.cc.

Referenced by fl_standard_message_codec_read_value_of_type(), and fl_standard_message_codec_real_write_value().

## ◆ kValueInt64

constexpr int kValueInt64 = 4
| static constexpr

Definition at line 19 of file fl_standard_message_codec.cc.

Referenced by fl_standard_message_codec_read_value_of_type(), and fl_standard_message_codec_real_write_value().

## ◆ kValueInt64List

constexpr int kValueInt64List = 10
| static constexpr

Definition at line 24 of file fl_standard_message_codec.cc.

Referenced by fl_standard_message_codec_read_value_of_type(), and fl_standard_message_codec_real_write_value().

## ◆ kValueList

constexpr int kValueList = 12
| static constexpr

Definition at line 26 of file fl_standard_message_codec.cc.

Referenced by fl_standard_message_codec_read_value_of_type(), and fl_standard_message_codec_real_write_value().

## ◆ kValueMap

constexpr int kValueMap = 13
| static constexpr

Definition at line 27 of file fl_standard_message_codec.cc.

Referenced by fl_standard_message_codec_read_value_of_type(), and fl_standard_message_codec_real_write_value().

## ◆ kValueNull

constexpr int kValueNull = 0
| static constexpr

Definition at line 15 of file fl_standard_message_codec.cc.

Referenced by fl_standard_message_codec_read_value_of_type(), and fl_standard_message_codec_real_write_value().

## ◆ kValueString

constexpr int kValueString = 7
| static constexpr

Definition at line 21 of file fl_standard_message_codec.cc.

Referenced by fl_standard_message_codec_read_value_of_type(), and fl_standard_message_codec_real_write_value().

## ◆ kValueTrue

constexpr int kValueTrue = 1
| static constexpr

Definition at line 16 of file fl_standard_message_codec.cc.

Referenced by fl_standard_message_codec_read_value_of_type(), and fl_standard_message_codec_real_write_value().

## ◆ kValueUint8List

constexpr int kValueUint8List = 8
| static constexpr

Definition at line 22 of file fl_standard_message_codec.cc.

Referenced by fl_standard_message_codec_read_value_of_type(), and fl_standard_message_codec_real_write_value().

## ◆ value

uint8_t value

Initial value:
{
g_byte_array_append(buffer, &value, sizeof(uint8_t))

Definition at line 36 of file fl_standard_message_codec.cc.

Referenced by FlValueHandler::add(), build_list(), build_map(), flutter::CheckEncodeDecode(), flutter::CheckEncodeDecodeWithEncodePrefix(), corrected_modifier_physical_key(), flutter::AccessibilityBridge::CreateFlutterPlatformNodeDelegate(), decode_error_message(), decode_message(), flutter::JsonMethodCodec::DecodeAndProcessResponseEnvelopeInternal(), flutter::StandardMethodCodec::DecodeAndProcessResponseEnvelopeInternal(), define_system_cursor(), do_unref(), encode_bool(), encode_error_message(), encode_float(), encode_int(), encode_message(), encode_message_error(), encode_string(), fl_accessible_node_set_property(), fl_accessible_node_set_value(), fl_accessible_text_field_set_value(), fl_binary_codec_encode_message(), fl_engine_init(), fl_engine_set_property(), fl_gnome_settings_get_color_scheme(), fl_gnome_settings_set_property(), fl_json_message_codec_decode(), fl_json_message_codec_decode_message(), fl_json_message_codec_encode(), fl_json_method_codec_decode_method_call(), fl_json_method_codec_decode_response(), fl_key_embedder_responder_new(), fl_settings_portal_get_clock_format(), fl_settings_portal_get_color_scheme(), fl_settings_portal_get_enable_animations(), fl_settings_portal_get_high_contrast(), fl_settings_portal_get_text_scaling_factor(), fl_settings_portal_start(), fl_standard_message_codec_decode_message(), fl_standard_message_codec_read_size(), fl_standard_message_codec_read_value_of_type(), fl_standard_message_codec_real_write_value(), fl_standard_message_codec_write_value(), fl_string_codec_encode_message(), fl_test_codec_encode_message(), fl_text_input_channel_update_editing_state(), fl_text_input_channel_update_editing_state_with_deltas(), fl_value_append(), fl_value_append_take(), fl_value_destroy(), fl_value_lookup_string(), fl_value_new_bool(), fl_value_new_custom(), fl_value_new_float(), fl_value_new_int(), fl_value_new_list_from_strv(), fl_value_new_string(), fl_value_new_string_sized(), fl_value_set(), fl_value_set_string(), fl_value_set_string_take(), fl_value_set_take(), fl_value_to_string(), fl_view_accessible_handle_update_semantics(), float_to_string(), G_DECLARE_DERIVABLE_TYPE(), G_DEFINE_TYPE(), G_DEFINE_TYPE_WITH_CODE(), get_generated_id(), get_keyboard_state(), get_value(), hash_table_find_equal_value(), if(), int_to_string(), is_valid_size_argument(), parse_size_value(), parse_window_state_value(), perform_set_selection_action(), perform_set_text_action(), FlValueHandler::push(), read_float32_list_value(), read_float64_list_value(), read_float64_value(), read_int32_list_value(), read_int32_value(), read_int64_list_value(), read_int64_value(), read_map_value(), read_string_value(), read_uint16(), read_uint32(), read_uint8(), read_uint8_list_value(), flutter::ByteStreamReader::ReadDouble(), flutter::ByteStreamReader::ReadInt32(), flutter::ByteStreamReader::ReadInt64(), flutter::StandardCodecSerializer::ReadSize(), flutter::StandardCodecSerializer::ReadValueOfType(), reverse_lookup_hash_table(), send_lifecycle_state(), set_value(), settings_portal_changed_cb(), settings_portal_read(), synchronize_lock_states(), synchronize_pressed_states(), flutter::TEST(), TEST(), value_to_string(), write_float64(), write_int32(), write_int64(), write_uint16(), write_uint32(), flutter::ByteStreamWriter::WriteDouble(), flutter::ByteStreamWriter::WriteInt32(), flutter::ByteStreamWriter::WriteInt64(), flutter::StandardCodecSerializer::WriteSize(), and flutter::StandardCodecSerializer::WriteValue().