 |
Flutter Linux Embedder
|
|
Go to the documentation of this file.
36 fl_standard_message_codec,
37 fl_message_codec_get_type())
42 g_byte_array_append(
buffer, &
value,
sizeof(uint8_t));
46 g_byte_array_append(
buffer,
reinterpret_cast<uint8_t*
>(&
value),
51 g_byte_array_append(
buffer,
reinterpret_cast<uint8_t*
>(&
value),
56 g_byte_array_append(
buffer,
reinterpret_cast<uint8_t*
>(&
value),
61 g_byte_array_append(
buffer,
reinterpret_cast<uint8_t*
>(&
value),
66 g_byte_array_append(
buffer,
reinterpret_cast<uint8_t*
>(&
value),
72 while (
buffer->len % align != 0) {
82 if (offset + required > g_bytes_get_size(
buffer)) {
95 if ((*offset) % align == 0) {
99 size_t required = align - (*offset) % align;
104 (*offset) += required;
110 return static_cast<const uint8_t*
>(g_bytes_get_data(
buffer,
nullptr)) +
140 *offset +=
sizeof(uint16_t);
155 *offset +=
sizeof(uint32_t);
171 *offset +=
sizeof(int32_t);
187 *offset +=
sizeof(int64_t);
206 *offset +=
sizeof(double);
226 reinterpret_cast<const gchar*
>(
get_data(
buffer, offset)), length);
270 reinterpret_cast<const int32_t*
>(
get_data(
buffer, offset)), length);
271 *offset +=
sizeof(int32_t) * length;
294 reinterpret_cast<const int64_t*
>(
get_data(
buffer, offset)), length);
295 *offset +=
sizeof(int64_t) * length;
318 reinterpret_cast<const float*
>(
get_data(
buffer, offset)), length);
319 *offset +=
sizeof(float) * length;
342 reinterpret_cast<const double*
>(
get_data(
buffer, offset)), length);
343 *offset +=
sizeof(double) * length;
361 for (
size_t i = 0; i < length; i++) {
364 if (child ==
nullptr) {
387 for (
size_t i = 0; i < length; i++) {
390 if (key ==
nullptr) {
395 if (
value ==
nullptr) {
408 FlStandardMessageCodec*
self =
409 reinterpret_cast<FlStandardMessageCodec*
>(codec);
411 g_autoptr(GByteArray)
buffer = g_byte_array_new();
415 return g_byte_array_free_to_bytes(
416 static_cast<GByteArray*
>(g_steal_pointer(&
buffer)));
423 if (g_bytes_get_size(message) == 0) {
427 FlStandardMessageCodec*
self =
428 reinterpret_cast<FlStandardMessageCodec*
>(codec);
433 if (
value ==
nullptr) {
437 if (offset != g_bytes_get_size(message)) {
440 "Unused %zi bytes after standard message",
441 g_bytes_get_size(message) - offset);
449 FlStandardMessageCodecClass* klass) {
450 FL_MESSAGE_CODEC_CLASS(klass)->encode_message =
452 FL_MESSAGE_CODEC_CLASS(klass)->decode_message =
459 return static_cast<FlStandardMessageCodec*
>(
460 g_object_new(fl_standard_message_codec_get_type(),
nullptr));
467 write_uint8(
buffer, size);
468 }
else if (size <= 0xffff) {
491 }
else if (value8 == 254) {
508 if (
value ==
nullptr) {
526 if (v >= INT32_MIN && v <= INT32_MAX) {
543 size_t length = strlen(text);
545 g_byte_array_append(
buffer,
reinterpret_cast<const uint8_t*
>(text),
554 sizeof(uint8_t) * length);
565 sizeof(int32_t) * length);
576 sizeof(int64_t) * length);
587 sizeof(
float) * length);
598 sizeof(
double) * length);
674 "Unexpected standard codec type %02x", type);
G_DEFINE_TYPE(FlStandardMessageCodec, fl_standard_message_codec, fl_message_codec_get_type()) static void write_uint8(GByteArray *buffer
static FlValue * read_list_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
static gboolean read_uint16(GBytes *buffer, size_t *offset, uint16_t *value, GError **error)
static constexpr int kValueList
const G_MODULE_EXPORT int32_t * fl_value_get_int32_list(FlValue *self)
@ FL_VALUE_TYPE_UINT8_LIST
G_MODULE_EXPORT FlValue * fl_value_new_string_sized(const gchar *value, size_t value_length)
FlValue * fl_standard_message_codec_read_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
G_MODULE_EXPORT FlStandardMessageCodec * fl_standard_message_codec_new()
static constexpr int kValueUint8List
static GBytes * fl_standard_message_codec_encode_message(FlMessageCodec *codec, FlValue *message, GError **error)
static FlValue * read_int32_value(GBytes *buffer, size_t *offset, GError **error)
static constexpr int kValueNull
static constexpr int kValueInt64List
G_MODULE_EXPORT FlValue * fl_value_new_list()
G_MODULE_EXPORT FlValue * fl_value_new_float32_list(const float *data, size_t data_length)
const G_MODULE_EXPORT double * fl_value_get_float_list(FlValue *self)
static constexpr int kValueInt32List
static constexpr int kValueInt64
G_MODULE_EXPORT FlValue * fl_value_new_bool(bool value)
@ FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA
typedefG_BEGIN_DECLS struct _FlValue FlValue
static constexpr int kValueInt32
static constexpr int kValueFloat64List
static void write_float64(GByteArray *buffer, double value)
static constexpr int kValueTrue
G_MODULE_EXPORT FlValue * fl_value_new_null()
static FlValue * read_string_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
G_MODULE_EXPORT bool fl_value_get_bool(FlValue *self)
const G_MODULE_EXPORT uint8_t * fl_value_get_uint8_list(FlValue *self)
G_MODULE_EXPORT void fl_value_set(FlValue *self, FlValue *key, FlValue *value)
static void write_int64(GByteArray *buffer, int64_t value)
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
const G_MODULE_EXPORT gchar * fl_value_get_string(FlValue *self)
static FlValue * read_float64_value(GBytes *buffer, size_t *offset, GError **error)
const G_MODULE_EXPORT float * fl_value_get_float32_list(FlValue *self)
static FlValue * read_map_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
static gboolean read_align(GBytes *buffer, size_t *offset, size_t align, GError **error)
static FlValue * read_int32_list_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
G_MODULE_EXPORT int64_t fl_value_get_int(FlValue *self)
static void write_int32(GByteArray *buffer, int32_t value)
static FlValue * read_uint8_list_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
void fl_standard_message_codec_write_size(FlStandardMessageCodec *codec, GByteArray *buffer, uint32_t size)
G_MODULE_EXPORT FlValue * fl_value_ref(FlValue *self)
G_MODULE_EXPORT FlValue * fl_value_new_map()
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
static void write_uint16(GByteArray *buffer, uint16_t value)
G_MODULE_EXPORT FlValue * fl_value_get_list_value(FlValue *self, size_t index)
static FlValue * read_int64_value(GBytes *buffer, size_t *offset, GError **error)
@ FL_VALUE_TYPE_FLOAT32_LIST
gboolean fl_standard_message_codec_read_size(FlStandardMessageCodec *codec, GBytes *buffer, size_t *offset, uint32_t *value, GError **error)
static FlValue * read_float32_list_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
G_MODULE_EXPORT FlValue * fl_value_new_float_list(const double *data, size_t data_length)
static constexpr int kValueFalse
static FlValue * fl_standard_message_codec_decode_message(FlMessageCodec *codec, GBytes *message, GError **error)
static gboolean check_size(GBytes *buffer, size_t offset, size_t required, GError **error)
G_MODULE_EXPORT FlValue * fl_value_new_int32_list(const int32_t *data, size_t data_length)
G_MODULE_EXPORT double fl_value_get_float(FlValue *self)
G_MODULE_EXPORT size_t fl_value_get_length(FlValue *self)
@ FL_VALUE_TYPE_INT64_LIST
static constexpr int kValueFloat64
G_MODULE_EXPORT FlValue * fl_value_new_int64_list(const int64_t *data, size_t data_length)
static const uint8_t * get_data(GBytes *buffer, size_t *offset)
static void fl_standard_message_codec_class_init(FlStandardMessageCodecClass *klass)
@ FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA
const uint8_t uint32_t uint32_t GError ** error
static constexpr int kValueMap
@ FL_VALUE_TYPE_FLOAT_LIST
static void fl_standard_message_codec_init(FlStandardMessageCodec *self)
static gboolean read_uint32(GBytes *buffer, size_t *offset, uint32_t *value, GError **error)
G_MODULE_EXPORT FlValue * fl_value_new_uint8_list(const uint8_t *data, size_t data_length)
G_MODULE_EXPORT void fl_value_append(FlValue *self, FlValue *value)
static const uint8_t buffer[]
static constexpr int kValueFloat32List
static constexpr int kValueString
@ FL_VALUE_TYPE_INT32_LIST
static void write_align(GByteArray *buffer, guint align)
@ FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE
G_MODULE_EXPORT FlValue * fl_value_new_float(double value)
static FlValue * read_float64_list_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
G_MODULE_EXPORT FlValue * fl_value_get_map_key(FlValue *self, size_t index)
static gboolean read_uint8(GBytes *buffer, size_t *offset, uint8_t *value, GError **error)
static void write_uint32(GByteArray *buffer, uint32_t value)
const G_MODULE_EXPORT int64_t * fl_value_get_int64_list(FlValue *self)
gboolean fl_standard_message_codec_write_value(FlStandardMessageCodec *self, GByteArray *buffer, FlValue *value, GError **error)
G_MODULE_EXPORT FlValue * fl_value_get_map_value(FlValue *self, size_t index)
static FlValue * read_int64_list_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
FlMessageCodec parent_instance
#define FL_MESSAGE_CODEC_ERROR