Flutter Engine
The Flutter Engine
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 FlValueread_int32_value (GBytes *buffer, size_t *offset, GError **error)
 
static FlValueread_int64_value (GBytes *buffer, size_t *offset, GError **error)
 
static FlValueread_float64_value (GBytes *buffer, size_t *offset, GError **error)
 
static FlValueread_string_value (FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
 
static FlValueread_uint8_list_value (FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
 
static FlValueread_int32_list_value (FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
 
static FlValueread_int64_list_value (FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
 
static FlValueread_float32_list_value (FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
 
static FlValueread_float64_list_value (FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
 
static FlValueread_list_value (FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
 
static FlValueread_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 FlValuefl_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 FlValuefl_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 FlValuefl_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}
@ FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA
#define FL_MESSAGE_CODEC_ERROR
const uint8_t uint32_t uint32_t GError ** error
return FALSE
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 vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
SeparatedVector2 offset

◆ 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 =
629 FL_MESSAGE_CODEC_CLASS(klass)->decode_message =
632 klass->read_value_of_type = fl_standard_message_codec_read_value_of_type;
633}
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 GBytes * fl_standard_message_codec_encode_message(FlMessageCodec *codec, FlValue *message, GError **error)
static FlValue * fl_standard_message_codec_read_value_of_type(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, int type, GError **error)

◆ 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 =
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,
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}
@ FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA
G_MODULE_EXPORT FlValue * fl_standard_message_codec_read_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
uint8_t value
G_MODULE_EXPORT FlValue * fl_value_ref(FlValue *self)
Definition: fl_value.cc:394
G_MODULE_EXPORT FlValue * fl_value_new_null()
Definition: fl_value.cc:251
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42
Win32Message message

◆ 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();
408 return nullptr;
409 }
410 return g_byte_array_free_to_bytes(
411 static_cast<GByteArray*>(g_steal_pointer(&buffer)));
412}
G_MODULE_EXPORT gboolean fl_standard_message_codec_write_value(FlStandardMessageCodec *self, GByteArray *buffer, FlValue *value, GError **error)

◆ 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}

◆ 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) {
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}
static gboolean read_uint32(GBytes *buffer, size_t *offset, uint32_t *value, GError **error)
static gboolean read_uint16(GBytes *buffer, size_t *offset, uint16_t *value, GError **error)
static gboolean read_uint8(GBytes *buffer, size_t *offset, uint8_t *value, GError **error)

◆ 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(
706}
GLenum type

◆ 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) {
595 } else if (type == kValueInt64) {
597 } else if (type == kValueFloat64) {
599 } else if (type == kValueString) {
601 } else if (type == kValueUint8List) {
603 } else if (type == kValueInt32List) {
605 } else if (type == kValueInt64List) {
607 } else if (type == kValueFloat32List) {
609 } else if (type == kValueFloat64List) {
611 } else if (type == kValueList) {
613 } else if (type == kValueMap) {
615 } else {
616 g_set_error(error, FL_MESSAGE_CODEC_ERROR,
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
static FlValue * read_int64_list_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
static FlValue * read_int32_value(GBytes *buffer, size_t *offset, GError **error)
static constexpr int kValueNull
static constexpr int kValueString
static FlValue * read_float64_value(GBytes *buffer, size_t *offset, GError **error)
static constexpr int kValueTrue
static FlValue * read_float32_list_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
static constexpr int kValueInt64List
static FlValue * read_int64_value(GBytes *buffer, size_t *offset, GError **error)
static constexpr int kValueFloat64List
static constexpr int kValueFloat32List
static constexpr int kValueUint8List
static constexpr int kValueInt32
static constexpr int kValueList
static constexpr int kValueFloat64
static constexpr int kValueMap
static FlValue * read_string_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
static constexpr int kValueInt32List
static FlValue * read_uint8_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 constexpr int kValueInt64
static FlValue * read_map_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
static constexpr int kValueFalse
static FlValue * read_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)
G_MODULE_EXPORT FlValue * fl_value_new_bool(bool value)
Definition: fl_value.cc:255

◆ 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)) {
456 write_uint8(buffer, kValueNull);
457 return TRUE;
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);
470 } else {
471 write_uint8(buffer, kValueInt64);
473 }
474 return TRUE;
475 }
477 write_uint8(buffer, kValueFloat64);
480 return TRUE;
482 write_uint8(buffer, kValueString);
483 const char* text = fl_value_get_string(value);
484 size_t length = strlen(text);
486 g_byte_array_append(buffer, reinterpret_cast<const uint8_t*>(text),
487 length);
488 return TRUE;
489 }
491 write_uint8(buffer, kValueUint8List);
495 sizeof(uint8_t) * length);
496 return TRUE;
497 }
499 write_uint8(buffer, kValueInt32List);
504 buffer,
505 reinterpret_cast<const uint8_t*>(fl_value_get_int32_list(value)),
506 sizeof(int32_t) * length);
507 return TRUE;
508 }
510 write_uint8(buffer, kValueInt64List);
515 buffer,
516 reinterpret_cast<const uint8_t*>(fl_value_get_int64_list(value)),
517 sizeof(int64_t) * length);
518 return TRUE;
519 }
521 write_uint8(buffer, kValueFloat32List);
526 buffer,
527 reinterpret_cast<const uint8_t*>(fl_value_get_float32_list(value)),
528 sizeof(float) * length);
529 return TRUE;
530 }
532 write_uint8(buffer, kValueFloat64List);
537 buffer,
538 reinterpret_cast<const uint8_t*>(fl_value_get_float_list(value)),
539 sizeof(double) * length);
540 return TRUE;
541 }
543 write_uint8(buffer, kValueList);
546 for (size_t i = 0; i < fl_value_get_length(value); i++) {
549 return FALSE;
550 }
551 }
552 return TRUE;
554 write_uint8(buffer, kValueMap);
557 for (size_t i = 0; i < fl_value_get_length(value); i++) {
562 return FALSE;
563 }
564 }
565 return TRUE;
567 g_set_error(error, FL_MESSAGE_CODEC_ERROR,
569 "Custom value not implemented");
570 return FALSE;
571 }
572
573 g_set_error(error, FL_MESSAGE_CODEC_ERROR,
575 "Unexpected FlValue type %d", fl_value_get_type(value));
576 return FALSE;
577}
G_MODULE_EXPORT void fl_standard_message_codec_write_size(FlStandardMessageCodec *codec, GByteArray *buffer, uint32_t size)
static void write_align(GByteArray *buffer, guint align)
static void write_int64(GByteArray *buffer, int64_t value)
static void write_float64(GByteArray *buffer, double value)
static void write_int32(GByteArray *buffer, int32_t value)
g_byte_array_append(buffer, &type, sizeof(uint8_t))
G_MODULE_EXPORT const double * fl_value_get_float_list(FlValue *self)
Definition: fl_value.cc:717
G_MODULE_EXPORT int64_t fl_value_get_int(FlValue *self)
Definition: fl_value.cc:668
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
Definition: fl_value.cc:466
G_MODULE_EXPORT FlValue * fl_value_get_map_key(FlValue *self, size_t index)
Definition: fl_value.cc:784
G_MODULE_EXPORT const gchar * fl_value_get_string(FlValue *self)
Definition: fl_value.cc:682
G_MODULE_EXPORT const uint8_t * fl_value_get_uint8_list(FlValue *self)
Definition: fl_value.cc:689
G_MODULE_EXPORT FlValue * fl_value_get_list_value(FlValue *self, size_t index)
Definition: fl_value.cc:776
G_MODULE_EXPORT bool fl_value_get_bool(FlValue *self)
Definition: fl_value.cc:661
G_MODULE_EXPORT const float * fl_value_get_float32_list(FlValue *self)
Definition: fl_value.cc:710
G_MODULE_EXPORT FlValue * fl_value_get_map_value(FlValue *self, size_t index)
Definition: fl_value.cc:792
G_MODULE_EXPORT double fl_value_get_float(FlValue *self)
Definition: fl_value.cc:675
G_MODULE_EXPORT size_t fl_value_get_length(FlValue *self)
Definition: fl_value.cc:724
G_MODULE_EXPORT const int32_t * fl_value_get_int32_list(FlValue *self)
Definition: fl_value.cc:696
G_MODULE_EXPORT const int64_t * fl_value_get_int64_list(FlValue *self)
Definition: fl_value.cc:703
@ FL_VALUE_TYPE_STRING
Definition: fl_value.h:69
@ FL_VALUE_TYPE_NULL
Definition: fl_value.h:65
@ FL_VALUE_TYPE_INT
Definition: fl_value.h:67
@ FL_VALUE_TYPE_BOOL
Definition: fl_value.h:66
@ FL_VALUE_TYPE_FLOAT32_LIST
Definition: fl_value.h:76
@ FL_VALUE_TYPE_INT32_LIST
Definition: fl_value.h:71
@ FL_VALUE_TYPE_UINT8_LIST
Definition: fl_value.h:70
@ FL_VALUE_TYPE_LIST
Definition: fl_value.h:74
@ FL_VALUE_TYPE_MAP
Definition: fl_value.h:75
@ FL_VALUE_TYPE_INT64_LIST
Definition: fl_value.h:72
@ FL_VALUE_TYPE_FLOAT_LIST
Definition: fl_value.h:73
@ FL_VALUE_TYPE_CUSTOM
Definition: fl_value.h:77
@ FL_VALUE_TYPE_FLOAT
Definition: fl_value.h:68
size_t length
std::u16string text

◆ 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);
651 } else {
652 write_uint8(buffer, 255);
654 }
655}
static void write_uint32(GByteArray *buffer, uint32_t value)
static void write_uint16(GByteArray *buffer, uint16_t value)
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
Definition: switches.h:259

◆ 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}

◆ 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}

◆ 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}
static gboolean check_size(GBytes *buffer, size_t offset, size_t required, GError **error)

◆ 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;
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 }
313 reinterpret_cast<const float*>(get_data(buffer, offset)), length);
314 *offset += sizeof(float) * length;
315 return value;
316}
G_MODULE_EXPORT gboolean fl_standard_message_codec_read_size(FlStandardMessageCodec *codec, GBytes *buffer, size_t *offset, uint32_t *value, 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)
G_MODULE_EXPORT FlValue * fl_value_new_float32_list(const float *data, size_t data_length)
Definition: fl_value.cc:329

◆ 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;
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 }
337 reinterpret_cast<const double*>(get_data(buffer, offset)), length);
338 *offset += sizeof(double) * length;
339 return value;
340}
G_MODULE_EXPORT FlValue * fl_value_new_float_list(const double *data, size_t data_length)
Definition: fl_value.cc:339

◆ 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
200 reinterpret_cast<const double*>(get_data(buffer, offset))[0]);
201 *offset += sizeof(double);
202 return value;
203}
G_MODULE_EXPORT FlValue * fl_value_new_float(double value)
Definition: fl_value.cc:269

◆ 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;
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 }
265 reinterpret_cast<const int32_t*>(get_data(buffer, offset)), length);
266 *offset += sizeof(int32_t) * length;
267 return value;
268}
G_MODULE_EXPORT FlValue * fl_value_new_int32_list(const int32_t *data, size_t data_length)
Definition: fl_value.cc:309

◆ 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
165 reinterpret_cast<const int32_t*>(get_data(buffer, offset))[0]);
166 *offset += sizeof(int32_t);
167 return value;
168}
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
Definition: fl_value.cc:262

◆ 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;
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 }
289 reinterpret_cast<const int64_t*>(get_data(buffer, offset)), length);
290 *offset += sizeof(int64_t) * length;
291 return value;
292}
G_MODULE_EXPORT FlValue * fl_value_new_int64_list(const int64_t *data, size_t data_length)
Definition: fl_value.cc:319

◆ 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
181 reinterpret_cast<const int64_t*>(get_data(buffer, offset))[0]);
182 *offset += sizeof(int64_t);
183 return value;
184}

◆ 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;
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 =
359 if (child == nullptr) {
360 return nullptr;
361 }
362 fl_value_append(list, child);
363 }
364
365 return fl_value_ref(list);
366}
G_MODULE_EXPORT void fl_value_append(FlValue *self, FlValue *value)
Definition: fl_value.cc:592
G_MODULE_EXPORT FlValue * fl_value_new_list()
Definition: fl_value.cc:349

◆ 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;
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 =
385 if (key == nullptr) {
386 return nullptr;
387 }
388 g_autoptr(FlValue) value =
390 if (value == nullptr) {
391 return nullptr;
392 }
394 }
395
396 return fl_value_ref(map);
397}
G_MODULE_EXPORT FlValue * fl_value_new_map()
Definition: fl_value.cc:366
G_MODULE_EXPORT void fl_value_set(FlValue *self, FlValue *key, FlValue *value)
Definition: fl_value.cc:609
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
Definition: SkVx.h:680

◆ 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;
214 error)) {
215 return nullptr;
216 }
217 if (!check_size(buffer, *offset, length, error)) {
218 return nullptr;
219 }
221 reinterpret_cast<const gchar*>(get_data(buffer, offset)), length);
222 *offset += length;
223 return value;
224}
G_MODULE_EXPORT FlValue * fl_value_new_string_sized(const gchar *value, size_t value_length)
Definition: fl_value.cc:283

◆ 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}

◆ 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}

◆ 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}

◆ 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;
235 error)) {
236 return nullptr;
237 }
238 if (!check_size(buffer, *offset, sizeof(uint8_t) * length, error)) {
239 return nullptr;
240 }
242 *offset += length;
243 return value;
244}
G_MODULE_EXPORT FlValue * fl_value_new_uint8_list(const uint8_t *data, size_t data_length)
Definition: fl_value.cc:292

◆ 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}

◆ 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}

◆ 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}

◆ 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}

◆ 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}

◆ 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}

Variable Documentation

◆ kValueFalse

constexpr int kValueFalse = 2
staticconstexpr

Definition at line 17 of file fl_standard_message_codec.cc.

◆ kValueFloat32List

constexpr int kValueFloat32List = 14
staticconstexpr

Definition at line 28 of file fl_standard_message_codec.cc.

◆ kValueFloat64

constexpr int kValueFloat64 = 6
staticconstexpr

Definition at line 20 of file fl_standard_message_codec.cc.

◆ kValueFloat64List

constexpr int kValueFloat64List = 11
staticconstexpr

Definition at line 25 of file fl_standard_message_codec.cc.

◆ kValueInt32

constexpr int kValueInt32 = 3
staticconstexpr

Definition at line 18 of file fl_standard_message_codec.cc.

◆ kValueInt32List

constexpr int kValueInt32List = 9
staticconstexpr

Definition at line 23 of file fl_standard_message_codec.cc.

◆ kValueInt64

constexpr int kValueInt64 = 4
staticconstexpr

Definition at line 19 of file fl_standard_message_codec.cc.

◆ kValueInt64List

constexpr int kValueInt64List = 10
staticconstexpr

Definition at line 24 of file fl_standard_message_codec.cc.

◆ kValueList

constexpr int kValueList = 12
staticconstexpr

Definition at line 26 of file fl_standard_message_codec.cc.

◆ kValueMap

constexpr int kValueMap = 13
staticconstexpr

Definition at line 27 of file fl_standard_message_codec.cc.

◆ kValueNull

constexpr int kValueNull = 0
staticconstexpr

Definition at line 15 of file fl_standard_message_codec.cc.

◆ kValueString

constexpr int kValueString = 7
staticconstexpr

Definition at line 21 of file fl_standard_message_codec.cc.

◆ kValueTrue

constexpr int kValueTrue = 1
staticconstexpr

Definition at line 16 of file fl_standard_message_codec.cc.

◆ kValueUint8List

constexpr int kValueUint8List = 8
staticconstexpr

Definition at line 22 of file fl_standard_message_codec.cc.

◆ 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.