Flutter Engine
 
Loading...
Searching...
No Matches
fl_method_codec.cc File Reference

Go to the source code of this file.

Functions

static void fl_method_codec_class_init (FlMethodCodecClass *klass)
 
static void fl_method_codec_init (FlMethodCodec *self)
 
GBytes * fl_method_codec_encode_method_call (FlMethodCodec *self, const gchar *name, FlValue *args, GError **error)
 
gboolean fl_method_codec_decode_method_call (FlMethodCodec *self, GBytes *message, gchar **name, FlValue **args, GError **error)
 
GBytes * fl_method_codec_encode_success_envelope (FlMethodCodec *self, FlValue *result, GError **error)
 
GBytes * fl_method_codec_encode_error_envelope (FlMethodCodec *self, const gchar *code, const gchar *message, FlValue *details, GError **error)
 
GBytes * fl_method_codec_encode_response (FlMethodCodec *self, FlMethodResponse *response, GError **error)
 
FlMethodResponse * fl_method_codec_decode_response (FlMethodCodec *self, GBytes *message, GError **error)
 

Function Documentation

◆ fl_method_codec_class_init()

static void fl_method_codec_class_init ( FlMethodCodecClass *  klass)
static

Definition at line 12 of file fl_method_codec.cc.

12{}

◆ fl_method_codec_decode_method_call()

gboolean fl_method_codec_decode_method_call ( FlMethodCodec *  self,
GBytes *  message,
gchar **  name,
FlValue **  args,
GError **  error 
)

Definition at line 27 of file fl_method_codec.cc.

31 {
32 g_return_val_if_fail(FL_IS_METHOD_CODEC(self), FALSE);
33 g_return_val_if_fail(message != nullptr, FALSE);
34 g_return_val_if_fail(name != nullptr, FALSE);
35 g_return_val_if_fail(args != nullptr, FALSE);
36
37 return FL_METHOD_CODEC_GET_CLASS(self)->decode_method_call(self, message,
38 name, args, error);
39}
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
G_BEGIN_DECLS GBytes * message
const uint8_t uint32_t uint32_t GError ** error
const char * name
Definition fuchsia.cc:49

References args, error, message, name, and self.

Referenced by decode_error_method_call(), decode_error_method_call(), decode_method_call(), decode_method_call(), fl_mock_binary_messenger_send_on_channel(), message_cb(), message_cb(), TEST(), and test_method_codec_decode_method_call().

◆ fl_method_codec_decode_response()

FlMethodResponse * fl_method_codec_decode_response ( FlMethodCodec *  self,
GBytes *  message,
GError **  error 
)

Definition at line 88 of file fl_method_codec.cc.

90 {
91 g_return_val_if_fail(FL_IS_METHOD_CODEC(self), nullptr);
92 g_return_val_if_fail(message != nullptr, nullptr);
93
94 if (g_bytes_get_size(message) == 0) {
95 return FL_METHOD_RESPONSE(fl_method_not_implemented_response_new());
96 }
97
98 return FL_METHOD_CODEC_GET_CLASS(self)->decode_response(self, message, error);
99}
G_MODULE_EXPORT FlMethodNotImplementedResponse * fl_method_not_implemented_response_new()

References error, fl_method_not_implemented_response_new(), message, and self.

Referenced by decode_error_response(), decode_error_response(), decode_response_with_error(), decode_response_with_error(), decode_response_with_success(), decode_response_with_success(), finish_method(), fl_method_channel_invoke_method_finish(), fl_mock_binary_messenger_send_on_channel(), invoke_method_cb(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and test_method_codec_decode_response().

◆ fl_method_codec_encode_error_envelope()

GBytes * fl_method_codec_encode_error_envelope ( FlMethodCodec *  self,
const gchar *  code,
const gchar *  message,
FlValue details,
GError **  error 
)

Definition at line 50 of file fl_method_codec.cc.

54 {
55 g_return_val_if_fail(FL_IS_METHOD_CODEC(self), nullptr);
56 g_return_val_if_fail(code != nullptr, nullptr);
57
58 return FL_METHOD_CODEC_GET_CLASS(self)->encode_error_envelope(
59 self, code, message, details, error);
60}

References error, message, and self.

Referenced by encode_error_envelope(), encode_error_envelope(), fl_event_channel_send_error(), fl_method_codec_encode_response(), message_cb(), TEST(), TEST(), TEST(), and TEST().

◆ fl_method_codec_encode_method_call()

GBytes * fl_method_codec_encode_method_call ( FlMethodCodec *  self,
const gchar *  name,
FlValue args,
GError **  error 
)

Definition at line 16 of file fl_method_codec.cc.

19 {
20 g_return_val_if_fail(FL_IS_METHOD_CODEC(self), nullptr);
21 g_return_val_if_fail(name != nullptr, nullptr);
22
23 return FL_METHOD_CODEC_GET_CLASS(self)->encode_method_call(self, name, args,
24 error);
25}

References args, error, name, and self.

Referenced by encode_method_call(), encode_method_call(), fl_method_channel_invoke_method(), fl_mock_binary_messenger_invoke_method(), resize_channel(), set_warns_on_channel_overflow(), TEST(), TEST(), TEST(), TEST(), and test_method_codec_encode_method_call().

◆ fl_method_codec_encode_response()

GBytes * fl_method_codec_encode_response ( FlMethodCodec *  self,
FlMethodResponse *  response,
GError **  error 
)

Definition at line 62 of file fl_method_codec.cc.

64 {
65 g_return_val_if_fail(FL_IS_METHOD_CODEC(self), nullptr);
66 g_return_val_if_fail(FL_IS_METHOD_SUCCESS_RESPONSE(response) ||
67 FL_IS_METHOD_ERROR_RESPONSE(response) ||
68 FL_IS_METHOD_NOT_IMPLEMENTED_RESPONSE(response),
69 nullptr);
70
71 if (FL_IS_METHOD_SUCCESS_RESPONSE(response)) {
72 FlMethodSuccessResponse* r = FL_METHOD_SUCCESS_RESPONSE(response);
75 } else if (FL_IS_METHOD_ERROR_RESPONSE(response)) {
76 FlMethodErrorResponse* r = FL_METHOD_ERROR_RESPONSE(response);
81 } else if (FL_IS_METHOD_NOT_IMPLEMENTED_RESPONSE(response)) {
82 return g_bytes_new(nullptr, 0);
83 } else {
84 g_assert_not_reached();
85 }
86}
GBytes * fl_method_codec_encode_success_envelope(FlMethodCodec *self, FlValue *result, GError **error)
GBytes * fl_method_codec_encode_error_envelope(FlMethodCodec *self, const gchar *code, const gchar *message, FlValue *details, GError **error)
G_MODULE_EXPORT FlValue * fl_method_success_response_get_result(FlMethodSuccessResponse *self)
G_MODULE_EXPORT const gchar * fl_method_error_response_get_message(FlMethodErrorResponse *self)
G_MODULE_EXPORT FlValue * fl_method_error_response_get_details(FlMethodErrorResponse *self)
G_MODULE_EXPORT const gchar * fl_method_error_response_get_code(FlMethodErrorResponse *self)

References error, fl_method_codec_encode_error_envelope(), fl_method_codec_encode_success_envelope(), fl_method_error_response_get_code(), fl_method_error_response_get_details(), fl_method_error_response_get_message(), fl_method_success_response_get_result(), and self.

Referenced by fl_method_channel_respond(), fl_mock_binary_messenger_method_channel_respond(), and fl_mock_binary_messenger_send_on_channel().

◆ fl_method_codec_encode_success_envelope()

GBytes * fl_method_codec_encode_success_envelope ( FlMethodCodec *  codec,
FlValue result,
GError **  error 
)

fl_method_codec_encode_success_envelope: @codec: an #FlMethodCodec.

Returns
: (allow-none): method result, or NULL. @error: (allow-none): #GError location to store the error occurring, or NULL.

Encodes a successful response to a method call.

Returns: (transfer full): a binary encoding of this response or NULL if not able to encode.

Definition at line 41 of file fl_method_codec.cc.

43 {
44 g_return_val_if_fail(FL_IS_METHOD_CODEC(self), nullptr);
45
46 return FL_METHOD_CODEC_GET_CLASS(self)->encode_success_envelope(self, result,
47 error);
48}

References error, and self.

Referenced by encode_success_envelope(), encode_success_envelope(), fl_event_channel_send(), fl_method_codec_encode_response(), message_cb(), TEST(), TEST(), TEST(), and TEST().

◆ fl_method_codec_init()

static void fl_method_codec_init ( FlMethodCodec *  self)
static

Definition at line 14 of file fl_method_codec.cc.

14{}