Flutter Engine
fl_message_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_message_codec.h"
6 
7 #include <gmodule.h>
8 
9 G_DEFINE_QUARK(fl_message_codec_error_quark, fl_message_codec_error)
10 
11 // Added here to stop the compiler from optimising this function away.
12 G_MODULE_EXPORT GType fl_message_codec_get_type();
13 
14 G_DEFINE_TYPE(FlMessageCodec, fl_message_codec, G_TYPE_OBJECT)
15 
16 static void fl_message_codec_class_init(FlMessageCodecClass* klass) {}
17 
18 static void fl_message_codec_init(FlMessageCodec* self) {}
19 
20 G_MODULE_EXPORT GBytes* fl_message_codec_encode_message(FlMessageCodec* self,
21  FlValue* message,
22  GError** error) {
23  g_return_val_if_fail(FL_IS_MESSAGE_CODEC(self), nullptr);
24 
25  // If the user provided NULL, then make a temporary FlValue object for this to
26  // make it simpler for the subclasses.
27  g_autoptr(FlValue) null_value = nullptr;
28  if (message == nullptr) {
29  null_value = fl_value_new_null();
30  message = null_value;
31  }
32 
33  return FL_MESSAGE_CODEC_GET_CLASS(self)->encode_message(self, message, error);
34 }
35 
36 G_MODULE_EXPORT FlValue* fl_message_codec_decode_message(FlMessageCodec* self,
37  GBytes* message,
38  GError** error) {
39  g_return_val_if_fail(FL_IS_MESSAGE_CODEC(self), nullptr);
40  g_return_val_if_fail(message != nullptr, nullptr);
41 
42  return FL_MESSAGE_CODEC_GET_CLASS(self)->decode_message(self, message, error);
43 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
FlMethodResponse GError ** error
G_DEFINE_QUARK(fl_binary_messenger_codec_error_quark, fl_binary_messenger_codec_error) struct _FlBinaryMessenger
static void fl_message_codec_class_init(FlMessageCodecClass *klass)
static void fl_message_codec_init(FlMessageCodec *self)
G_MODULE_EXPORT GType fl_message_codec_get_type()
GQuark fl_message_codec_error_quark(void) G_GNUC_CONST
G_MODULE_EXPORT GBytes * fl_message_codec_encode_message(FlMessageCodec *self, FlValue *message, GError **error)
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 FlValue * fl_message_codec_decode_message(FlMessageCodec *self, GBytes *message, GError **error)
G_MODULE_EXPORT FlValue * fl_value_new_null()
Definition: fl_value.cc:222