Flutter Engine
fl_binary_codec.cc File Reference
#include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_codec.h"
#include <gmodule.h>

Go to the source code of this file.

Classes

struct  _FlBinaryCodec
 

Functions

static GBytes * fl_binary_codec_encode_message (FlMessageCodec *codec, FlValue *value, GError **error)
 
static FlValuefl_binary_codec_decode_message (FlMessageCodec *codec, GBytes *message, GError **error)
 
static void fl_binary_codec_class_init (FlBinaryCodecClass *klass)
 
static void fl_binary_codec_init (FlBinaryCodec *self)
 
G_MODULE_EXPORT FlBinaryCodec * fl_binary_codec_new ()
 

Function Documentation

◆ fl_binary_codec_class_init()

static void fl_binary_codec_class_init ( FlBinaryCodecClass *  klass)
static

Definition at line 42 of file fl_binary_codec.cc.

References fl_binary_codec_decode_message(), and fl_binary_codec_encode_message().

42  {
43  FL_MESSAGE_CODEC_CLASS(klass)->encode_message =
45  FL_MESSAGE_CODEC_CLASS(klass)->decode_message =
47 }
static GBytes * fl_binary_codec_encode_message(FlMessageCodec *codec, FlValue *value, GError **error)
static FlValue * fl_binary_codec_decode_message(FlMessageCodec *codec, GBytes *message, GError **error)

◆ fl_binary_codec_decode_message()

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

Definition at line 33 of file fl_binary_codec.cc.

References fl_value_new_uint8_list().

Referenced by fl_binary_codec_class_init().

35  {
36  gsize data_length;
37  const uint8_t* data =
38  static_cast<const uint8_t*>(g_bytes_get_data(message, &data_length));
39  return fl_value_new_uint8_list(data, data_length);
40 }
G_MODULE_EXPORT FlValue * fl_value_new_uint8_list(const uint8_t *data, size_t data_length)
Definition: fl_value.cc:263

◆ fl_binary_codec_encode_message()

static GBytes* fl_binary_codec_encode_message ( FlMessageCodec *  codec,
FlValue value,
GError **  error 
)
static

Definition at line 18 of file fl_binary_codec.cc.

References FL_MESSAGE_CODEC_ERROR, FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE, fl_value_get_length(), fl_value_get_type(), fl_value_get_uint8_list(), and FL_VALUE_TYPE_UINT8_LIST.

Referenced by fl_binary_codec_class_init().

20  {
22  g_set_error(error, FL_MESSAGE_CODEC_ERROR,
24  "Only uint8[] values supported");
25  return nullptr;
26  }
27 
28  return g_bytes_new(fl_value_get_uint8_list(value),
30 }
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
Definition: fl_value.cc:395
FlMethodResponse GError ** error
#define FL_MESSAGE_CODEC_ERROR
G_MODULE_EXPORT const uint8_t * fl_value_get_uint8_list(FlValue *self)
Definition: fl_value.cc:603
uint8_t value
G_MODULE_EXPORT size_t fl_value_get_length(FlValue *self)
Definition: fl_value.cc:631

◆ fl_binary_codec_init()

static void fl_binary_codec_init ( FlBinaryCodec *  self)
static

Definition at line 49 of file fl_binary_codec.cc.

49 {}

◆ fl_binary_codec_new()

G_MODULE_EXPORT FlBinaryCodec* fl_binary_codec_new ( )

Definition at line 51 of file fl_binary_codec.cc.

Referenced by decode_message(), encode_message(), encode_message_error(), and TEST().

51  {
52  return static_cast<FlBinaryCodec*>(
53  g_object_new(fl_binary_codec_get_type(), nullptr));
54 }