Flutter Engine
The Flutter Engine
fl_binary_codec.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_codec.h"
6
7#include <gmodule.h>
8
9G_DEFINE_QUARK(fl_binary_codec_error_quark, fl_binary_codec_error)
10
12 FlMessageCodec parent_instance;
13};
14
15G_DEFINE_TYPE(FlBinaryCodec, fl_binary_codec, fl_message_codec_get_type())
16
17// Implements FlMessageCodec::encode_message.
18static GBytes* fl_binary_codec_encode_message(FlMessageCodec* codec,
20 GError** error) {
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}
31
32// Implements FlMessageCodec::decode_message.
33static FlValue* fl_binary_codec_decode_message(FlMessageCodec* codec,
34 GBytes* message,
35 GError** error) {
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}
41
42static void fl_binary_codec_class_init(FlBinaryCodecClass* klass) {
43 FL_MESSAGE_CODEC_CLASS(klass)->encode_message =
45 FL_MESSAGE_CODEC_CLASS(klass)->decode_message =
47}
48
49static void fl_binary_codec_init(FlBinaryCodec* self) {}
50
51G_MODULE_EXPORT FlBinaryCodec* fl_binary_codec_new() {
52 return static_cast<FlBinaryCodec*>(
53 g_object_new(fl_binary_codec_get_type(), nullptr));
54}
G_DEFINE_TYPE(FlBasicMessageChannelResponseHandle, fl_basic_message_channel_response_handle, G_TYPE_OBJECT) static void fl_basic_message_channel_response_handle_dispose(GObject *object)
G_MODULE_EXPORT FlBinaryCodec * fl_binary_codec_new()
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)
static void fl_binary_codec_init(FlBinaryCodec *self)
static void fl_binary_codec_class_init(FlBinaryCodecClass *klass)
G_DEFINE_QUARK(fl_binary_messenger_codec_error_quark, fl_binary_messenger_codec_error) G_DECLARE_FINAL_TYPE(FlBinaryMessengerImpl
@ FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE
#define FL_MESSAGE_CODEC_ERROR
const uint8_t uint32_t uint32_t GError ** error
uint8_t value
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
Definition: fl_value.cc:466
G_MODULE_EXPORT const uint8_t * fl_value_get_uint8_list(FlValue *self)
Definition: fl_value.cc:689
G_MODULE_EXPORT FlValue * fl_value_new_uint8_list(const uint8_t *data, size_t data_length)
Definition: fl_value.cc:292
G_MODULE_EXPORT size_t fl_value_get_length(FlValue *self)
Definition: fl_value.cc:724
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42
@ FL_VALUE_TYPE_UINT8_LIST
Definition: fl_value.h:70
Win32Message message
FlMessageCodec parent_instance
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63