Flutter Engine
 
Loading...
Searching...
No Matches
fl_standard_message_codec.h File Reference
#include <gmodule.h>
#include "fl_message_codec.h"

Go to the source code of this file.

Functions

G_BEGIN_DECLS G_MODULE_EXPORT G_DECLARE_DERIVABLE_TYPE (FlStandardMessageCodec, fl_standard_message_codec, FL, STANDARD_MESSAGE_CODEC, FlMessageCodec) struct _FlStandardMessageCodecClass
 
FlStandardMessageCodec * fl_standard_message_codec_new ()
 
void fl_standard_message_codec_write_size (FlStandardMessageCodec *codec, GByteArray *buffer, uint32_t size)
 
gboolean fl_standard_message_codec_read_size (FlStandardMessageCodec *codec, GBytes *buffer, size_t *offset, uint32_t *value, GError **error)
 
gboolean fl_standard_message_codec_write_value (FlStandardMessageCodec *codec, GByteArray *buffer, FlValue *value, GError **error)
 
FlValuefl_standard_message_codec_read_value (FlStandardMessageCodec *codec, GBytes *buffer, size_t *offset, GError **error)
 

Function Documentation

◆ fl_standard_message_codec_new()

◆ fl_standard_message_codec_read_size()

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 658 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}
return TRUE
const uint8_t uint32_t uint32_t GError ** error
static gboolean read_uint32(GBytes *buffer, size_t *offset, uint32_t *value, GError **error)
uint8_t value
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)

References 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()

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}
GLenum type

References error, read_uint8(), self, 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_write_size()

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}
static void write_uint32(GByteArray *buffer, uint32_t value)
static void write_uint16(GByteArray *buffer, uint16_t value)

References write_uint16(), and write_uint32().

Referenced by fl_standard_message_codec_real_write_value().

◆ fl_standard_message_codec_write_value()

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 686 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 error, self, 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_DECLARE_DERIVABLE_TYPE()

G_BEGIN_DECLS G_MODULE_EXPORT G_DECLARE_DERIVABLE_TYPE ( FlStandardMessageCodec  ,
fl_standard_message_codec  ,
FL  ,
STANDARD_MESSAGE_CODEC  ,
FlMessageCodec   
)

FlStandardMessageCodec:

#FlStandardMessageCodec is an #FlMessageCodec that implements the Flutter standard message encoding. This codec encodes and decodes FlValue of type FL_VALUE_TYPE_NULL, FL_VALUE_TYPE_BOOL, FL_VALUE_TYPE_INT, FL_VALUE_TYPE_FLOAT, FL_VALUE_TYPE_STRING, FL_VALUE_TYPE_UINT8_LIST, FL_VALUE_TYPE_INT32_LIST, FL_VALUE_TYPE_INT64_LIST, FL_VALUE_TYPE_FLOAT_LIST, FL_VALUE_TYPE_LIST, and FL_VALUE_TYPE_MAP.

If other values types are required to be supported create a new subclass that overrides write_value and read_value_of_type.

#FlStandardMessageCodec matches the StandardCodec class in the Flutter services library.

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

Virtual method to write an FlValue in Flutter Standard encoding.

If a codec needs to support custom FlValue objects it must override this method to encode those values. For non-custom values the parent method should be called.

Returns: TRUE on success.

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

Virtual method to read an FlValue in Flutter Standard encoding.

If a codec needs to support custom FlValue objects it must override this method to decode those values. For non-custom values the parent method should be called.

Returns: an FlValue or NULL on error.

Definition at line 19 of file fl_standard_message_codec.h.

42 {
43 FlMessageCodecClass parent_class;
44
45 /**
46 * FlStandardMessageCodec::write_value:
47 * @codec: an #FlStandardMessageCodec.
48 * @buffer: a buffer to write into.
49 * @value: (allow-none): value to write.
50 * @error: (allow-none): #GError location to store the error occurring, or
51 * %NULL.
52 *
53 * Virtual method to write an #FlValue in Flutter Standard encoding.
54 *
55 * If a codec needs to support custom #FlValue objects it must override this
56 * method to encode those values. For non-custom values the parent method
57 * should be called.
58 *
59 * Returns: %TRUE on success.
60 */
61 gboolean (*write_value)(FlStandardMessageCodec* codec,
62 GByteArray* buffer,
64 GError** error);
65
66 /**
67 * FlStandardMessageCodec::read_value_of_type:
68 * @codec: an #FlStandardMessageCodec.
69 * @buffer: buffer to read from.
70 * @offset: (inout): read position in @buffer.
71 * @type: the type of the value.
72 * @error: (allow-none): #GError location to store the error occurring, or
73 * %NULL.
74 *
75 * Virtual method to read an #FlValue in Flutter Standard encoding.
76 *
77 * If a codec needs to support custom #FlValue objects it must override this
78 * method to decode those values. For non-custom values the parent method
79 * should be called.
80 *
81 * Returns: an #FlValue or %NULL on error.
82 */
83 FlValue* (*read_value_of_type)(FlStandardMessageCodec* codec,
84 GBytes* buffer,
85 size_t* offset,
86 int type,
87 GError** error);
88};
int32_t value
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition fl_value.h:42
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 disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set profile Make the profiler discard new samples once the profiler sample buffer is full When this flag is not the profiler sample buffer is used as a ring buffer
Definition switch_defs.h:98

References error, type, and value.