Add missing full stops on the end of comments. (flutter/engine#18634)
This commit is contained in:
@@ -9,19 +9,19 @@
|
|||||||
struct _FlBasicMessageChannel {
|
struct _FlBasicMessageChannel {
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
|
|
||||||
// Messenger to communicate on
|
// Messenger to communicate on.
|
||||||
FlBinaryMessenger* messenger;
|
FlBinaryMessenger* messenger;
|
||||||
|
|
||||||
// TRUE if the channel has been closed
|
// TRUE if the channel has been closed.
|
||||||
gboolean channel_closed;
|
gboolean channel_closed;
|
||||||
|
|
||||||
// Channel name
|
// Channel name.
|
||||||
gchar* name;
|
gchar* name;
|
||||||
|
|
||||||
// Codec to en/decode messages
|
// Codec to en/decode messages.
|
||||||
FlMessageCodec* codec;
|
FlMessageCodec* codec;
|
||||||
|
|
||||||
// Function called when a message is received
|
// Function called when a message is received.
|
||||||
FlBasicMessageChannelMessageHandler message_handler;
|
FlBasicMessageChannelMessageHandler message_handler;
|
||||||
gpointer message_handler_data;
|
gpointer message_handler_data;
|
||||||
GDestroyNotify message_handler_destroy_notify;
|
GDestroyNotify message_handler_destroy_notify;
|
||||||
@@ -33,7 +33,7 @@ struct _FlBasicMessageChannelResponseHandle {
|
|||||||
FlBinaryMessengerResponseHandle* response_handle;
|
FlBinaryMessengerResponseHandle* response_handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Added here to stop the compiler from optimising this function away
|
// Added here to stop the compiler from optimising this function away.
|
||||||
G_MODULE_EXPORT GType fl_basic_message_channel_get_type();
|
G_MODULE_EXPORT GType fl_basic_message_channel_get_type();
|
||||||
|
|
||||||
G_DEFINE_TYPE(FlBasicMessageChannel, fl_basic_message_channel, G_TYPE_OBJECT)
|
G_DEFINE_TYPE(FlBasicMessageChannel, fl_basic_message_channel, G_TYPE_OBJECT)
|
||||||
@@ -73,7 +73,7 @@ fl_basic_message_channel_response_handle_new(
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when a binary message is received on this channel
|
// Called when a binary message is received on this channel.
|
||||||
static void message_cb(FlBinaryMessenger* messenger,
|
static void message_cb(FlBinaryMessenger* messenger,
|
||||||
const gchar* channel,
|
const gchar* channel,
|
||||||
GBytes* message,
|
GBytes* message,
|
||||||
@@ -102,7 +102,7 @@ static void message_cb(FlBinaryMessenger* messenger,
|
|||||||
self->message_handler_data);
|
self->message_handler_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when a response is received to a sent message
|
// Called when a response is received to a sent message.
|
||||||
static void message_response_cb(GObject* object,
|
static void message_response_cb(GObject* object,
|
||||||
GAsyncResult* result,
|
GAsyncResult* result,
|
||||||
gpointer user_data) {
|
gpointer user_data) {
|
||||||
@@ -110,13 +110,13 @@ static void message_response_cb(GObject* object,
|
|||||||
g_task_return_pointer(task, result, g_object_unref);
|
g_task_return_pointer(task, result, g_object_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the channel handler is closed
|
// Called when the channel handler is closed.
|
||||||
static void channel_closed_cb(gpointer user_data) {
|
static void channel_closed_cb(gpointer user_data) {
|
||||||
g_autoptr(FlBasicMessageChannel) self = FL_BASIC_MESSAGE_CHANNEL(user_data);
|
g_autoptr(FlBasicMessageChannel) self = FL_BASIC_MESSAGE_CHANNEL(user_data);
|
||||||
|
|
||||||
self->channel_closed = TRUE;
|
self->channel_closed = TRUE;
|
||||||
|
|
||||||
// Disconnect handler
|
// Disconnect handler.
|
||||||
if (self->message_handler_destroy_notify != nullptr)
|
if (self->message_handler_destroy_notify != nullptr)
|
||||||
self->message_handler_destroy_notify(self->message_handler_data);
|
self->message_handler_destroy_notify(self->message_handler_data);
|
||||||
self->message_handler = nullptr;
|
self->message_handler = nullptr;
|
||||||
@@ -180,7 +180,7 @@ G_MODULE_EXPORT void fl_basic_message_channel_set_message_handler(
|
|||||||
GDestroyNotify destroy_notify) {
|
GDestroyNotify destroy_notify) {
|
||||||
g_return_if_fail(FL_IS_BASIC_MESSAGE_CHANNEL(self));
|
g_return_if_fail(FL_IS_BASIC_MESSAGE_CHANNEL(self));
|
||||||
|
|
||||||
// Don't set handler if channel closed
|
// Don't set handler if channel closed.
|
||||||
if (self->channel_closed) {
|
if (self->channel_closed) {
|
||||||
if (handler != nullptr) {
|
if (handler != nullptr) {
|
||||||
g_warning(
|
g_warning(
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ struct _FlBinaryCodec {
|
|||||||
|
|
||||||
G_DEFINE_TYPE(FlBinaryCodec, fl_binary_codec, fl_message_codec_get_type())
|
G_DEFINE_TYPE(FlBinaryCodec, fl_binary_codec, fl_message_codec_get_type())
|
||||||
|
|
||||||
// Implements FlMessageCodec::encode_message
|
// Implements FlMessageCodec::encode_message.
|
||||||
static GBytes* fl_binary_codec_encode_message(FlMessageCodec* codec,
|
static GBytes* fl_binary_codec_encode_message(FlMessageCodec* codec,
|
||||||
FlValue* value,
|
FlValue* value,
|
||||||
GError** error) {
|
GError** error) {
|
||||||
@@ -29,7 +29,7 @@ static GBytes* fl_binary_codec_encode_message(FlMessageCodec* codec,
|
|||||||
fl_value_get_length(value));
|
fl_value_get_length(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FlMessageCodec::decode_message
|
// Implements FlMessageCodec::decode_message.
|
||||||
static FlValue* fl_binary_codec_decode_message(FlMessageCodec* codec,
|
static FlValue* fl_binary_codec_decode_message(FlMessageCodec* codec,
|
||||||
GBytes* message,
|
GBytes* message,
|
||||||
GError** error) {
|
GError** error) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ struct _FlBinaryMessenger {
|
|||||||
|
|
||||||
FlEngine* engine;
|
FlEngine* engine;
|
||||||
|
|
||||||
// PlatformMessageHandler keyed by channel name
|
// PlatformMessageHandler keyed by channel name.
|
||||||
GHashTable* platform_message_handlers;
|
GHashTable* platform_message_handlers;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ G_DEFINE_TYPE(FlBinaryMessenger, fl_binary_messenger, G_TYPE_OBJECT)
|
|||||||
struct _FlBinaryMessengerResponseHandle {
|
struct _FlBinaryMessengerResponseHandle {
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
|
|
||||||
// Messenger sending response on
|
// Messenger sending response on.
|
||||||
FlBinaryMessenger* messenger;
|
FlBinaryMessenger* messenger;
|
||||||
|
|
||||||
// Handle to send the response with. This is cleared to nullptr when it is
|
// Handle to send the response with. This is cleared to nullptr when it is
|
||||||
@@ -102,7 +102,7 @@ static void engine_weak_notify_cb(gpointer user_data, GObject* object) {
|
|||||||
FlBinaryMessenger* self = FL_BINARY_MESSENGER(user_data);
|
FlBinaryMessenger* self = FL_BINARY_MESSENGER(user_data);
|
||||||
self->engine = nullptr;
|
self->engine = nullptr;
|
||||||
|
|
||||||
// Disconnect any handlers
|
// Disconnect any handlers.
|
||||||
g_hash_table_remove_all(self->platform_message_handlers);
|
g_hash_table_remove_all(self->platform_message_handlers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@ G_MODULE_EXPORT void fl_binary_messenger_set_message_handler_on_channel(
|
|||||||
g_return_if_fail(FL_IS_BINARY_MESSENGER(self));
|
g_return_if_fail(FL_IS_BINARY_MESSENGER(self));
|
||||||
g_return_if_fail(channel != nullptr);
|
g_return_if_fail(channel != nullptr);
|
||||||
|
|
||||||
// Don't set handlers if engine already gone
|
// Don't set handlers if engine already gone.
|
||||||
if (self->engine == nullptr) {
|
if (self->engine == nullptr) {
|
||||||
if (handler != nullptr) {
|
if (handler != nullptr) {
|
||||||
g_warning(
|
g_warning(
|
||||||
|
|||||||
@@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
static constexpr int kMicrosecondsPerNanosecond = 1000;
|
static constexpr int kMicrosecondsPerNanosecond = 1000;
|
||||||
|
|
||||||
// Unique number associated with platform tasks
|
// Unique number associated with platform tasks.
|
||||||
static constexpr size_t kPlatformTaskRunnerIdentifier = 1;
|
static constexpr size_t kPlatformTaskRunnerIdentifier = 1;
|
||||||
|
|
||||||
struct _FlEngine {
|
struct _FlEngine {
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
|
|
||||||
// Thread the GLib main loop is running on
|
// Thread the GLib main loop is running on.
|
||||||
GThread* thread;
|
GThread* thread;
|
||||||
|
|
||||||
FlDartProject* project;
|
FlDartProject* project;
|
||||||
@@ -26,7 +26,7 @@ struct _FlEngine {
|
|||||||
FlBinaryMessenger* binary_messenger;
|
FlBinaryMessenger* binary_messenger;
|
||||||
FLUTTER_API_SYMBOL(FlutterEngine) engine;
|
FLUTTER_API_SYMBOL(FlutterEngine) engine;
|
||||||
|
|
||||||
// Function to call when a platform message is received
|
// Function to call when a platform message is received.
|
||||||
FlEnginePlatformMessageHandler platform_message_handler;
|
FlEnginePlatformMessageHandler platform_message_handler;
|
||||||
gpointer platform_message_handler_data;
|
gpointer platform_message_handler_data;
|
||||||
GDestroyNotify platform_message_handler_destroy_notify;
|
GDestroyNotify platform_message_handler_destroy_notify;
|
||||||
@@ -36,14 +36,14 @@ G_DEFINE_QUARK(fl_engine_error_quark, fl_engine_error)
|
|||||||
|
|
||||||
G_DEFINE_TYPE(FlEngine, fl_engine, G_TYPE_OBJECT)
|
G_DEFINE_TYPE(FlEngine, fl_engine, G_TYPE_OBJECT)
|
||||||
|
|
||||||
// Subclass of GSource that integrates Flutter tasks into the GLib main loop
|
// Subclass of GSource that integrates Flutter tasks into the GLib main loop.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GSource parent;
|
GSource parent;
|
||||||
FlEngine* self;
|
FlEngine* self;
|
||||||
FlutterTask task;
|
FlutterTask task;
|
||||||
} FlutterSource;
|
} FlutterSource;
|
||||||
|
|
||||||
// Callback to run a Flutter task in the GLib main loop
|
// Callback to run a Flutter task in the GLib main loop.
|
||||||
static gboolean flutter_source_dispatch(GSource* source,
|
static gboolean flutter_source_dispatch(GSource* source,
|
||||||
GSourceFunc callback,
|
GSourceFunc callback,
|
||||||
gpointer user_data) {
|
gpointer user_data) {
|
||||||
@@ -58,7 +58,7 @@ static gboolean flutter_source_dispatch(GSource* source,
|
|||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Table of functions for Flutter GLib main loop integration
|
// Table of functions for Flutter GLib main loop integration.
|
||||||
static GSourceFuncs flutter_source_funcs = {
|
static GSourceFuncs flutter_source_funcs = {
|
||||||
nullptr, // prepare
|
nullptr, // prepare
|
||||||
nullptr, // check
|
nullptr, // check
|
||||||
@@ -68,7 +68,7 @@ static GSourceFuncs flutter_source_funcs = {
|
|||||||
nullptr // Internal usage
|
nullptr // Internal usage
|
||||||
};
|
};
|
||||||
|
|
||||||
// Flutter engine callbacks
|
// Flutter engine rendering callbacks.
|
||||||
|
|
||||||
static void* fl_engine_gl_proc_resolver(void* user_data, const char* name) {
|
static void* fl_engine_gl_proc_resolver(void* user_data, const char* name) {
|
||||||
FlEngine* self = static_cast<FlEngine*>(user_data);
|
FlEngine* self = static_cast<FlEngine*>(user_data);
|
||||||
@@ -107,11 +107,13 @@ static bool fl_engine_gl_present(void* user_data) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Called by the engine to determine if it is on the GTK thread.
|
||||||
static bool fl_engine_runs_task_on_current_thread(void* user_data) {
|
static bool fl_engine_runs_task_on_current_thread(void* user_data) {
|
||||||
FlEngine* self = static_cast<FlEngine*>(user_data);
|
FlEngine* self = static_cast<FlEngine*>(user_data);
|
||||||
return self->thread == g_thread_self();
|
return self->thread == g_thread_self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Called when the engine has a task to perform in the GTK thread.
|
||||||
static void fl_engine_post_task(FlutterTask task,
|
static void fl_engine_post_task(FlutterTask task,
|
||||||
uint64_t target_time_nanos,
|
uint64_t target_time_nanos,
|
||||||
void* user_data) {
|
void* user_data) {
|
||||||
@@ -127,6 +129,7 @@ static void fl_engine_post_task(FlutterTask task,
|
|||||||
g_source_attach(source, nullptr);
|
g_source_attach(source, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Called when a platform message is received from the engine.
|
||||||
static void fl_engine_platform_message_cb(const FlutterPlatformMessage* message,
|
static void fl_engine_platform_message_cb(const FlutterPlatformMessage* message,
|
||||||
void* user_data) {
|
void* user_data) {
|
||||||
FlEngine* self = FL_ENGINE(user_data);
|
FlEngine* self = FL_ENGINE(user_data);
|
||||||
@@ -145,6 +148,8 @@ static void fl_engine_platform_message_cb(const FlutterPlatformMessage* message,
|
|||||||
nullptr, nullptr);
|
nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Called when a response to a sent platform message is received from the
|
||||||
|
// engine.
|
||||||
static void fl_engine_platform_message_response_cb(const uint8_t* data,
|
static void fl_engine_platform_message_response_cb(const uint8_t* data,
|
||||||
size_t data_length,
|
size_t data_length,
|
||||||
void* user_data) {
|
void* user_data) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ G_DEFINE_TYPE(FlJsonMessageCodec,
|
|||||||
fl_json_message_codec,
|
fl_json_message_codec,
|
||||||
fl_message_codec_get_type())
|
fl_message_codec_get_type())
|
||||||
|
|
||||||
// Recursively writes #FlValue objects using rapidjson
|
// Recursively writes #FlValue objects using rapidjson.
|
||||||
static gboolean write_value(rapidjson::Writer<rapidjson::StringBuffer>& writer,
|
static gboolean write_value(rapidjson::Writer<rapidjson::StringBuffer>& writer,
|
||||||
FlValue* value,
|
FlValue* value,
|
||||||
GError** error) {
|
GError** error) {
|
||||||
@@ -111,7 +111,7 @@ static gboolean write_value(rapidjson::Writer<rapidjson::StringBuffer>& writer,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handler to parse JSON using rapidjson in SAX mode
|
// Handler to parse JSON using rapidjson in SAX mode.
|
||||||
struct FlValueHandler {
|
struct FlValueHandler {
|
||||||
GPtrArray* stack;
|
GPtrArray* stack;
|
||||||
FlValue* key;
|
FlValue* key;
|
||||||
@@ -132,20 +132,20 @@ struct FlValueHandler {
|
|||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the current head of the stack
|
// Gets the current head of the stack.
|
||||||
FlValue* get_head() {
|
FlValue* get_head() {
|
||||||
if (stack->len == 0)
|
if (stack->len == 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return static_cast<FlValue*>(g_ptr_array_index(stack, stack->len - 1));
|
return static_cast<FlValue*>(g_ptr_array_index(stack, stack->len - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pushes a value onto the stack
|
// Pushes a value onto the stack.
|
||||||
void push(FlValue* value) { g_ptr_array_add(stack, fl_value_ref(value)); }
|
void push(FlValue* value) { g_ptr_array_add(stack, fl_value_ref(value)); }
|
||||||
|
|
||||||
// Pops the stack
|
// Pops the stack.
|
||||||
void pop() { g_ptr_array_remove_index(stack, stack->len - 1); }
|
void pop() { g_ptr_array_remove_index(stack, stack->len - 1); }
|
||||||
|
|
||||||
// Adds a new value to the stack
|
// Adds a new value to the stack.
|
||||||
bool add(FlValue* value) {
|
bool add(FlValue* value) {
|
||||||
g_autoptr(FlValue) owned_value = value;
|
g_autoptr(FlValue) owned_value = value;
|
||||||
FlValue* head = get_head();
|
FlValue* head = get_head();
|
||||||
@@ -169,7 +169,7 @@ struct FlValueHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The following implements the rapidjson SAX API
|
// The following implements the rapidjson SAX API.
|
||||||
|
|
||||||
bool Null() { return add(fl_value_new_null()); }
|
bool Null() { return add(fl_value_new_null()); }
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ struct FlValueHandler {
|
|||||||
bool Int64(int64_t i) { return add(fl_value_new_int(i)); }
|
bool Int64(int64_t i) { return add(fl_value_new_int(i)); }
|
||||||
|
|
||||||
bool Uint64(uint64_t i) {
|
bool Uint64(uint64_t i) {
|
||||||
// For some reason (bug in rapidjson?) this is not returned in Int64
|
// For some reason (bug in rapidjson?) this is not returned in Int64.
|
||||||
if (i == G_MAXINT64)
|
if (i == G_MAXINT64)
|
||||||
return add(fl_value_new_int(i));
|
return add(fl_value_new_int(i));
|
||||||
else
|
else
|
||||||
@@ -224,7 +224,7 @@ struct FlValueHandler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Implements FlMessageCodec:encode_message
|
// Implements FlMessageCodec:encode_message.
|
||||||
static GBytes* fl_json_message_codec_encode_message(FlMessageCodec* codec,
|
static GBytes* fl_json_message_codec_encode_message(FlMessageCodec* codec,
|
||||||
FlValue* message,
|
FlValue* message,
|
||||||
GError** error) {
|
GError** error) {
|
||||||
@@ -238,7 +238,7 @@ static GBytes* fl_json_message_codec_encode_message(FlMessageCodec* codec,
|
|||||||
return g_bytes_new(text, strlen(text));
|
return g_bytes_new(text, strlen(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FlMessageCodec:decode_message
|
// Implements FlMessageCodec:decode_message.
|
||||||
static FlValue* fl_json_message_codec_decode_message(FlMessageCodec* codec,
|
static FlValue* fl_json_message_codec_decode_message(FlMessageCodec* codec,
|
||||||
GBytes* message,
|
GBytes* message,
|
||||||
GError** error) {
|
GError** error) {
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ TEST(FlJsonMessageCodecTest, DecodeIntMax) {
|
|||||||
|
|
||||||
TEST(FlJsonMessageCodecTest, DecodeUintMax) {
|
TEST(FlJsonMessageCodecTest, DecodeUintMax) {
|
||||||
// This is bigger than an signed 64 bit integer, so we expect it to be
|
// This is bigger than an signed 64 bit integer, so we expect it to be
|
||||||
// represented as a double
|
// represented as a double.
|
||||||
g_autoptr(FlValue) value = decode_message("18446744073709551615");
|
g_autoptr(FlValue) value = decode_message("18446744073709551615");
|
||||||
ASSERT_EQ(fl_value_get_type(value), FL_VALUE_TYPE_FLOAT);
|
ASSERT_EQ(fl_value_get_type(value), FL_VALUE_TYPE_FLOAT);
|
||||||
EXPECT_EQ(fl_value_get_float(value), 1.8446744073709551615e+19);
|
EXPECT_EQ(fl_value_get_float(value), 1.8446744073709551615e+19);
|
||||||
@@ -159,7 +159,7 @@ TEST(FlJsonMessageCodecTest, DecodeUintMax) {
|
|||||||
|
|
||||||
TEST(FlJsonMessageCodecTest, DecodeHugeNumber) {
|
TEST(FlJsonMessageCodecTest, DecodeHugeNumber) {
|
||||||
// This is bigger than an unsigned 64 bit integer, so we expect it to be
|
// This is bigger than an unsigned 64 bit integer, so we expect it to be
|
||||||
// represented as a double
|
// represented as a double.
|
||||||
g_autoptr(FlValue) value = decode_message("184467440737095516150");
|
g_autoptr(FlValue) value = decode_message("184467440737095516150");
|
||||||
ASSERT_EQ(fl_value_get_type(value), FL_VALUE_TYPE_FLOAT);
|
ASSERT_EQ(fl_value_get_type(value), FL_VALUE_TYPE_FLOAT);
|
||||||
EXPECT_EQ(fl_value_get_float(value), 1.84467440737095516150e+20);
|
EXPECT_EQ(fl_value_get_float(value), 1.84467440737095516150e+20);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ static void fl_json_method_codec_dispose(GObject* object) {
|
|||||||
G_OBJECT_CLASS(fl_json_method_codec_parent_class)->dispose(object);
|
G_OBJECT_CLASS(fl_json_method_codec_parent_class)->dispose(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FlMethodCodec::encode_method_call
|
// Implements FlMethodCodec::encode_method_call.
|
||||||
static GBytes* fl_json_method_codec_encode_method_call(FlMethodCodec* codec,
|
static GBytes* fl_json_method_codec_encode_method_call(FlMethodCodec* codec,
|
||||||
const gchar* name,
|
const gchar* name,
|
||||||
FlValue* args,
|
FlValue* args,
|
||||||
@@ -46,7 +46,7 @@ static GBytes* fl_json_method_codec_encode_method_call(FlMethodCodec* codec,
|
|||||||
error);
|
error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FlMethodCodec::decode_method_call
|
// Implements FlMethodCodec::decode_method_call.
|
||||||
static gboolean fl_json_method_codec_decode_method_call(FlMethodCodec* codec,
|
static gboolean fl_json_method_codec_decode_method_call(FlMethodCodec* codec,
|
||||||
GBytes* message,
|
GBytes* message,
|
||||||
gchar** name,
|
gchar** name,
|
||||||
@@ -86,7 +86,7 @@ static gboolean fl_json_method_codec_decode_method_call(FlMethodCodec* codec,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FlMethodCodec::encode_success_envelope
|
// Implements FlMethodCodec::encode_success_envelope.
|
||||||
static GBytes* fl_json_method_codec_encode_success_envelope(
|
static GBytes* fl_json_method_codec_encode_success_envelope(
|
||||||
FlMethodCodec* codec,
|
FlMethodCodec* codec,
|
||||||
FlValue* result,
|
FlValue* result,
|
||||||
@@ -101,7 +101,7 @@ static GBytes* fl_json_method_codec_encode_success_envelope(
|
|||||||
error);
|
error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FlMethodCodec::encode_error_envelope
|
// Implements FlMethodCodec::encode_error_envelope.
|
||||||
static GBytes* fl_json_method_codec_encode_error_envelope(
|
static GBytes* fl_json_method_codec_encode_error_envelope(
|
||||||
FlMethodCodec* codec,
|
FlMethodCodec* codec,
|
||||||
const gchar* code,
|
const gchar* code,
|
||||||
@@ -122,7 +122,7 @@ static GBytes* fl_json_method_codec_encode_error_envelope(
|
|||||||
error);
|
error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FlMethodCodec::decode_response
|
// Implements FlMethodCodec::decode_response.
|
||||||
static FlMethodResponse* fl_json_method_codec_decode_response(
|
static FlMethodResponse* fl_json_method_codec_decode_response(
|
||||||
FlMethodCodec* codec,
|
FlMethodCodec* codec,
|
||||||
GBytes* message,
|
GBytes* message,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
G_DEFINE_QUARK(fl_message_codec_error_quark, fl_message_codec_error)
|
G_DEFINE_QUARK(fl_message_codec_error_quark, fl_message_codec_error)
|
||||||
|
|
||||||
// Added here to stop the compiler from optimising this function away
|
// Added here to stop the compiler from optimising this function away.
|
||||||
G_MODULE_EXPORT GType fl_message_codec_get_type();
|
G_MODULE_EXPORT GType fl_message_codec_get_type();
|
||||||
|
|
||||||
G_DEFINE_TYPE(FlMessageCodec, fl_message_codec, G_TYPE_OBJECT)
|
G_DEFINE_TYPE(FlMessageCodec, fl_message_codec, G_TYPE_OBJECT)
|
||||||
@@ -23,7 +23,7 @@ G_MODULE_EXPORT GBytes* fl_message_codec_encode_message(FlMessageCodec* self,
|
|||||||
g_return_val_if_fail(FL_IS_MESSAGE_CODEC(self), nullptr);
|
g_return_val_if_fail(FL_IS_MESSAGE_CODEC(self), nullptr);
|
||||||
|
|
||||||
// If the user provided NULL, then make a temporary FlValue object for this to
|
// If the user provided NULL, then make a temporary FlValue object for this to
|
||||||
// make it simpler for the subclasses
|
// make it simpler for the subclasses.
|
||||||
g_autoptr(FlValue) null_value = nullptr;
|
g_autoptr(FlValue) null_value = nullptr;
|
||||||
if (message == nullptr) {
|
if (message == nullptr) {
|
||||||
null_value = fl_value_new_null();
|
null_value = fl_value_new_null();
|
||||||
|
|||||||
@@ -8,14 +8,14 @@
|
|||||||
G_DECLARE_FINAL_TYPE(FlTestCodec, fl_test_codec, FL, TEST_CODEC, FlMessageCodec)
|
G_DECLARE_FINAL_TYPE(FlTestCodec, fl_test_codec, FL, TEST_CODEC, FlMessageCodec)
|
||||||
|
|
||||||
// Implement the FlMessageCodec API for the following tests to check it works as
|
// Implement the FlMessageCodec API for the following tests to check it works as
|
||||||
// expected
|
// expected.
|
||||||
struct _FlTestCodec {
|
struct _FlTestCodec {
|
||||||
FlMessageCodec parent_instance;
|
FlMessageCodec parent_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE(FlTestCodec, fl_test_codec, fl_message_codec_get_type())
|
G_DEFINE_TYPE(FlTestCodec, fl_test_codec, fl_message_codec_get_type())
|
||||||
|
|
||||||
// Implements FlMessageCodec::encode_message
|
// Implements FlMessageCodec::encode_message.
|
||||||
static GBytes* fl_test_codec_encode_message(FlMessageCodec* codec,
|
static GBytes* fl_test_codec_encode_message(FlMessageCodec* codec,
|
||||||
FlValue* value,
|
FlValue* value,
|
||||||
GError** error) {
|
GError** error) {
|
||||||
@@ -31,7 +31,7 @@ static GBytes* fl_test_codec_encode_message(FlMessageCodec* codec,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FlMessageCodec::decode_message
|
// Implements FlMessageCodec::decode_message.
|
||||||
static FlValue* fl_test_codec_decode_message(FlMessageCodec* codec,
|
static FlValue* fl_test_codec_decode_message(FlMessageCodec* codec,
|
||||||
GBytes* message,
|
GBytes* message,
|
||||||
GError** error) {
|
GError** error) {
|
||||||
|
|||||||
@@ -11,13 +11,13 @@
|
|||||||
struct _FlMethodCall {
|
struct _FlMethodCall {
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
|
|
||||||
// Name of method being called
|
// Name of method being called.
|
||||||
gchar* name;
|
gchar* name;
|
||||||
|
|
||||||
// Arguments provided to method call
|
// Arguments provided to method call.
|
||||||
FlValue* args;
|
FlValue* args;
|
||||||
|
|
||||||
// Channel to respond on
|
// Channel to respond on.
|
||||||
FlMethodChannel* channel;
|
FlMethodChannel* channel;
|
||||||
FlBinaryMessengerResponseHandle* response_handle;
|
FlBinaryMessengerResponseHandle* response_handle;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,30 +13,30 @@
|
|||||||
struct _FlMethodChannel {
|
struct _FlMethodChannel {
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
|
|
||||||
// Messenger to communicate on
|
// Messenger to communicate on.
|
||||||
FlBinaryMessenger* messenger;
|
FlBinaryMessenger* messenger;
|
||||||
|
|
||||||
// TRUE if the channel has been closed
|
// TRUE if the channel has been closed.
|
||||||
gboolean channel_closed;
|
gboolean channel_closed;
|
||||||
|
|
||||||
// Channel name
|
// Channel name.
|
||||||
gchar* name;
|
gchar* name;
|
||||||
|
|
||||||
// Codec to en/decode messages
|
// Codec to en/decode messages.
|
||||||
FlMethodCodec* codec;
|
FlMethodCodec* codec;
|
||||||
|
|
||||||
// Function called when a method call is received
|
// Function called when a method call is received.
|
||||||
FlMethodChannelMethodCallHandler method_call_handler;
|
FlMethodChannelMethodCallHandler method_call_handler;
|
||||||
gpointer method_call_handler_data;
|
gpointer method_call_handler_data;
|
||||||
GDestroyNotify method_call_handler_destroy_notify;
|
GDestroyNotify method_call_handler_destroy_notify;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Added here to stop the compiler from optimising this function away
|
// Added here to stop the compiler from optimising this function away.
|
||||||
G_MODULE_EXPORT GType fl_method_channel_get_type();
|
G_MODULE_EXPORT GType fl_method_channel_get_type();
|
||||||
|
|
||||||
G_DEFINE_TYPE(FlMethodChannel, fl_method_channel, G_TYPE_OBJECT)
|
G_DEFINE_TYPE(FlMethodChannel, fl_method_channel, G_TYPE_OBJECT)
|
||||||
|
|
||||||
// Called when a binary message is received on this channel
|
// Called when a binary message is received on this channel.
|
||||||
static void message_cb(FlBinaryMessenger* messenger,
|
static void message_cb(FlBinaryMessenger* messenger,
|
||||||
const gchar* channel,
|
const gchar* channel,
|
||||||
GBytes* message,
|
GBytes* message,
|
||||||
@@ -61,7 +61,7 @@ static void message_cb(FlBinaryMessenger* messenger,
|
|||||||
self->method_call_handler(self, method_call, self->method_call_handler_data);
|
self->method_call_handler(self, method_call, self->method_call_handler_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when a response is received to a sent message
|
// Called when a response is received to a sent message.
|
||||||
static void message_response_cb(GObject* object,
|
static void message_response_cb(GObject* object,
|
||||||
GAsyncResult* result,
|
GAsyncResult* result,
|
||||||
gpointer user_data) {
|
gpointer user_data) {
|
||||||
@@ -69,13 +69,13 @@ static void message_response_cb(GObject* object,
|
|||||||
g_task_return_pointer(task, result, g_object_unref);
|
g_task_return_pointer(task, result, g_object_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the channel handler is closed
|
// Called when the channel handler is closed.
|
||||||
static void channel_closed_cb(gpointer user_data) {
|
static void channel_closed_cb(gpointer user_data) {
|
||||||
g_autoptr(FlMethodChannel) self = FL_METHOD_CHANNEL(user_data);
|
g_autoptr(FlMethodChannel) self = FL_METHOD_CHANNEL(user_data);
|
||||||
|
|
||||||
self->channel_closed = TRUE;
|
self->channel_closed = TRUE;
|
||||||
|
|
||||||
// Disconnect handler
|
// Disconnect handler.
|
||||||
if (self->method_call_handler_destroy_notify != nullptr)
|
if (self->method_call_handler_destroy_notify != nullptr)
|
||||||
self->method_call_handler_destroy_notify(self->method_call_handler_data);
|
self->method_call_handler_destroy_notify(self->method_call_handler_data);
|
||||||
self->method_call_handler = nullptr;
|
self->method_call_handler = nullptr;
|
||||||
@@ -138,7 +138,7 @@ G_MODULE_EXPORT void fl_method_channel_set_method_call_handler(
|
|||||||
GDestroyNotify destroy_notify) {
|
GDestroyNotify destroy_notify) {
|
||||||
g_return_if_fail(FL_IS_METHOD_CHANNEL(self));
|
g_return_if_fail(FL_IS_METHOD_CHANNEL(self));
|
||||||
|
|
||||||
// Don't set handler if channel closed
|
// Don't set handler if channel closed.
|
||||||
if (self->channel_closed) {
|
if (self->channel_closed) {
|
||||||
if (handler != nullptr) {
|
if (handler != nullptr) {
|
||||||
g_warning(
|
g_warning(
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include <gmodule.h>
|
#include <gmodule.h>
|
||||||
|
|
||||||
// Added here to stop the compiler from optimising this function away
|
// Added here to stop the compiler from optimising this function away.
|
||||||
G_MODULE_EXPORT GType fl_method_codec_get_type();
|
G_MODULE_EXPORT GType fl_method_codec_get_type();
|
||||||
|
|
||||||
G_DEFINE_TYPE(FlMethodCodec, fl_method_codec, G_TYPE_OBJECT)
|
G_DEFINE_TYPE(FlMethodCodec, fl_method_codec, G_TYPE_OBJECT)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ G_DECLARE_FINAL_TYPE(FlTestMethodCodec,
|
|||||||
FlMethodCodec)
|
FlMethodCodec)
|
||||||
|
|
||||||
// Implement the FlMethodCodec API for the following tests to check it works as
|
// Implement the FlMethodCodec API for the following tests to check it works as
|
||||||
// expected
|
// expected.
|
||||||
struct _FlTestMethodCodec {
|
struct _FlTestMethodCodec {
|
||||||
FlMethodCodec parent_instance;
|
FlMethodCodec parent_instance;
|
||||||
};
|
};
|
||||||
@@ -23,7 +23,7 @@ G_DEFINE_TYPE(FlTestMethodCodec,
|
|||||||
fl_test_method_codec,
|
fl_test_method_codec,
|
||||||
fl_method_codec_get_type())
|
fl_method_codec_get_type())
|
||||||
|
|
||||||
// Helper function to convert binary data to text
|
// Helper function to convert binary data to text.
|
||||||
static gchar* message_to_text(GBytes* message) {
|
static gchar* message_to_text(GBytes* message) {
|
||||||
size_t data_length;
|
size_t data_length;
|
||||||
const gchar* data =
|
const gchar* data =
|
||||||
@@ -31,12 +31,12 @@ static gchar* message_to_text(GBytes* message) {
|
|||||||
return g_strndup(data, data_length);
|
return g_strndup(data, data_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to convert text to binary data
|
// Helper function to convert text to binary data.
|
||||||
static GBytes* text_to_message(const gchar* text) {
|
static GBytes* text_to_message(const gchar* text) {
|
||||||
return g_bytes_new(text, strlen(text));
|
return g_bytes_new(text, strlen(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FlMethodCodec::encode_method_call
|
// Implements FlMethodCodec::encode_method_call.
|
||||||
static GBytes* fl_test_codec_encode_method_call(FlMethodCodec* codec,
|
static GBytes* fl_test_codec_encode_method_call(FlMethodCodec* codec,
|
||||||
const gchar* name,
|
const gchar* name,
|
||||||
FlValue* args,
|
FlValue* args,
|
||||||
@@ -58,7 +58,7 @@ static GBytes* fl_test_codec_encode_method_call(FlMethodCodec* codec,
|
|||||||
return text_to_message(text);
|
return text_to_message(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FlMethodCodec::decode_method_call
|
// Implements FlMethodCodec::decode_method_call.
|
||||||
static gboolean fl_test_codec_decode_method_call(FlMethodCodec* codec,
|
static gboolean fl_test_codec_decode_method_call(FlMethodCodec* codec,
|
||||||
GBytes* message,
|
GBytes* message,
|
||||||
gchar** name,
|
gchar** name,
|
||||||
@@ -79,7 +79,7 @@ static gboolean fl_test_codec_decode_method_call(FlMethodCodec* codec,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FlMethodCodec::encode_success_envelope
|
// Implements FlMethodCodec::encode_success_envelope.
|
||||||
static GBytes* fl_test_codec_encode_success_envelope(FlMethodCodec* codec,
|
static GBytes* fl_test_codec_encode_success_envelope(FlMethodCodec* codec,
|
||||||
FlValue* result,
|
FlValue* result,
|
||||||
GError** error) {
|
GError** error) {
|
||||||
@@ -99,7 +99,7 @@ static GBytes* fl_test_codec_encode_success_envelope(FlMethodCodec* codec,
|
|||||||
return text_to_message(text);
|
return text_to_message(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FlMethodCodec::encode_error_envelope
|
// Implements FlMethodCodec::encode_error_envelope.
|
||||||
static GBytes* fl_test_codec_encode_error_envelope(FlMethodCodec* codec,
|
static GBytes* fl_test_codec_encode_error_envelope(FlMethodCodec* codec,
|
||||||
const gchar* code,
|
const gchar* code,
|
||||||
const gchar* message,
|
const gchar* message,
|
||||||
@@ -131,7 +131,7 @@ static GBytes* fl_test_codec_encode_error_envelope(FlMethodCodec* codec,
|
|||||||
return text_to_message(text);
|
return text_to_message(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FlMethodCodec::decode_response
|
// Implements FlMethodCodec::decode_response.
|
||||||
static FlMethodResponse* fl_test_codec_decode_response(FlMethodCodec* codec,
|
static FlMethodResponse* fl_test_codec_decode_response(FlMethodCodec* codec,
|
||||||
GBytes* message,
|
GBytes* message,
|
||||||
GError** error) {
|
GError** error) {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ TEST(FlMethodResponseTest, NotImplemented) {
|
|||||||
g_autoptr(FlMethodNotImplementedResponse) response =
|
g_autoptr(FlMethodNotImplementedResponse) response =
|
||||||
fl_method_not_implemented_response_new();
|
fl_method_not_implemented_response_new();
|
||||||
// Trivial check to stop the compiler deciding that 'response' is an unused
|
// Trivial check to stop the compiler deciding that 'response' is an unused
|
||||||
// variable
|
// variable.
|
||||||
EXPECT_TRUE(FL_IS_METHOD_NOT_IMPLEMENTED_RESPONSE(response));
|
EXPECT_TRUE(FL_IS_METHOD_NOT_IMPLEMENTED_RESPONSE(response));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ gboolean fl_renderer_clear_current(FlRenderer* self, GError** error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
guint32 fl_renderer_get_fbo(FlRenderer* self) {
|
guint32 fl_renderer_get_fbo(FlRenderer* self) {
|
||||||
// There is only one frame buffer object - always return that
|
// There is only one frame buffer object - always return that.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,9 @@
|
|||||||
#include <gmodule.h>
|
#include <gmodule.h>
|
||||||
|
|
||||||
// See lib/src/services/message_codecs.dart in Flutter source for description of
|
// See lib/src/services/message_codecs.dart in Flutter source for description of
|
||||||
// encoding
|
// encoding.
|
||||||
|
|
||||||
// Envelope codes
|
// Envelope codes.
|
||||||
static constexpr guint8 kEnvelopeTypeSuccess = 0;
|
static constexpr guint8 kEnvelopeTypeSuccess = 0;
|
||||||
static constexpr guint8 kEnvelopeTypeError = 1;
|
static constexpr guint8 kEnvelopeTypeError = 1;
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ static void fl_standard_method_codec_dispose(GObject* object) {
|
|||||||
G_OBJECT_CLASS(fl_standard_method_codec_parent_class)->dispose(object);
|
G_OBJECT_CLASS(fl_standard_method_codec_parent_class)->dispose(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FlMethodCodec::encode_method_code
|
// Implements FlMethodCodec::encode_method_call.
|
||||||
static GBytes* fl_standard_method_codec_encode_method_call(FlMethodCodec* codec,
|
static GBytes* fl_standard_method_codec_encode_method_call(FlMethodCodec* codec,
|
||||||
const gchar* name,
|
const gchar* name,
|
||||||
FlValue* args,
|
FlValue* args,
|
||||||
@@ -53,7 +53,7 @@ static GBytes* fl_standard_method_codec_encode_method_call(FlMethodCodec* codec,
|
|||||||
static_cast<GByteArray*>(g_steal_pointer(&buffer)));
|
static_cast<GByteArray*>(g_steal_pointer(&buffer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FlMethodCodec::decode_method_code
|
// Implements FlMethodCodec::decode_method_call.
|
||||||
static gboolean fl_standard_method_codec_decode_method_call(
|
static gboolean fl_standard_method_codec_decode_method_call(
|
||||||
FlMethodCodec* codec,
|
FlMethodCodec* codec,
|
||||||
GBytes* message,
|
GBytes* message,
|
||||||
@@ -90,7 +90,7 @@ static gboolean fl_standard_method_codec_decode_method_call(
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FlMethodCodec::encode_success_envelope
|
// Implements FlMethodCodec::encode_success_envelope.
|
||||||
static GBytes* fl_standard_method_codec_encode_success_envelope(
|
static GBytes* fl_standard_method_codec_encode_success_envelope(
|
||||||
FlMethodCodec* codec,
|
FlMethodCodec* codec,
|
||||||
FlValue* result,
|
FlValue* result,
|
||||||
@@ -108,7 +108,7 @@ static GBytes* fl_standard_method_codec_encode_success_envelope(
|
|||||||
static_cast<GByteArray*>(g_steal_pointer(&buffer)));
|
static_cast<GByteArray*>(g_steal_pointer(&buffer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FlMethodCodec::encode_error_envelope
|
// Implements FlMethodCodec::encode_error_envelope.
|
||||||
static GBytes* fl_standard_method_codec_encode_error_envelope(
|
static GBytes* fl_standard_method_codec_encode_error_envelope(
|
||||||
FlMethodCodec* codec,
|
FlMethodCodec* codec,
|
||||||
const gchar* code,
|
const gchar* code,
|
||||||
@@ -137,7 +137,7 @@ static GBytes* fl_standard_method_codec_encode_error_envelope(
|
|||||||
static_cast<GByteArray*>(g_steal_pointer(&buffer)));
|
static_cast<GByteArray*>(g_steal_pointer(&buffer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FlMethodCodec::encode_decode_reponse
|
// Implements FlMethodCodec::encode_decode_reponse.
|
||||||
static FlMethodResponse* fl_standard_method_codec_decode_response(
|
static FlMethodResponse* fl_standard_method_codec_decode_response(
|
||||||
FlMethodCodec* codec,
|
FlMethodCodec* codec,
|
||||||
GBytes* message,
|
GBytes* message,
|
||||||
@@ -150,7 +150,7 @@ static FlMethodResponse* fl_standard_method_codec_decode_response(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// First byte is response type
|
// First byte is response type.
|
||||||
const guint8* data =
|
const guint8* data =
|
||||||
static_cast<const guint8*>(g_bytes_get_data(message, nullptr));
|
static_cast<const guint8*>(g_bytes_get_data(message, nullptr));
|
||||||
guint8 type = data[0];
|
guint8 type = data[0];
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ struct _FlStringCodec {
|
|||||||
|
|
||||||
G_DEFINE_TYPE(FlStringCodec, fl_string_codec, fl_message_codec_get_type())
|
G_DEFINE_TYPE(FlStringCodec, fl_string_codec, fl_message_codec_get_type())
|
||||||
|
|
||||||
// Implments FlMessageCodec::encode_message
|
// Implments FlMessageCodec::encode_message.
|
||||||
static GBytes* fl_string_codec_encode_message(FlMessageCodec* codec,
|
static GBytes* fl_string_codec_encode_message(FlMessageCodec* codec,
|
||||||
FlValue* value,
|
FlValue* value,
|
||||||
GError** error) {
|
GError** error) {
|
||||||
@@ -29,7 +29,7 @@ static GBytes* fl_string_codec_encode_message(FlMessageCodec* codec,
|
|||||||
return g_bytes_new(text, strlen(text));
|
return g_bytes_new(text, strlen(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implments FlMessageCodec::decode_message
|
// Implments FlMessageCodec::decode_message.
|
||||||
static FlValue* fl_string_codec_decode_message(FlMessageCodec* codec,
|
static FlValue* fl_string_codec_decode_message(FlMessageCodec* codec,
|
||||||
GBytes* message,
|
GBytes* message,
|
||||||
GError** error) {
|
GError** error) {
|
||||||
|
|||||||
@@ -92,19 +92,19 @@ static ssize_t fl_value_lookup_index(FlValue* self, FlValue* key) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Converts an integer to a string and adds it to the buffer
|
// Converts an integer to a string and adds it to the buffer.
|
||||||
static void int_to_string(int64_t value, GString* buffer) {
|
static void int_to_string(int64_t value, GString* buffer) {
|
||||||
g_string_append_printf(buffer, "%" G_GINT64_FORMAT, value);
|
g_string_append_printf(buffer, "%" G_GINT64_FORMAT, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Converts a floating point number to a string and adds it to the buffer
|
// Converts a floating point number to a string and adds it to the buffer.
|
||||||
static void float_to_string(double value, GString* buffer) {
|
static void float_to_string(double value, GString* buffer) {
|
||||||
g_string_append_printf(buffer, "%.16f", value);
|
g_string_append_printf(buffer, "%.16f", value);
|
||||||
|
|
||||||
// Strip trailing zeros
|
// Strip trailing zeros.
|
||||||
int zero_count = 0;
|
int zero_count = 0;
|
||||||
for (int i = buffer->len - 1; i >= 0; i--) {
|
for (int i = buffer->len - 1; i >= 0; i--) {
|
||||||
// Leave one zero after a decimal point
|
// Leave one zero after a decimal point.
|
||||||
if (buffer->str[i] == '.') {
|
if (buffer->str[i] == '.') {
|
||||||
zero_count = zero_count == 0 ? 0 : zero_count - 1;
|
zero_count = zero_count == 0 ? 0 : zero_count - 1;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -19,16 +19,16 @@ static constexpr int kMicrosecondsPerMillisecond = 1000;
|
|||||||
struct _FlView {
|
struct _FlView {
|
||||||
GtkWidget parent_instance;
|
GtkWidget parent_instance;
|
||||||
|
|
||||||
// Project being run
|
// Project being run.
|
||||||
FlDartProject* project;
|
FlDartProject* project;
|
||||||
|
|
||||||
// Rendering output
|
// Rendering output.
|
||||||
FlRendererX11* renderer;
|
FlRendererX11* renderer;
|
||||||
|
|
||||||
// Engine running @project
|
// Engine running @project.
|
||||||
FlEngine* engine;
|
FlEngine* engine;
|
||||||
|
|
||||||
// Pointer button state recorded for sending status updates
|
// Pointer button state recorded for sending status updates.
|
||||||
int64_t button_state;
|
int64_t button_state;
|
||||||
|
|
||||||
// Flutter system channel handlers.
|
// Flutter system channel handlers.
|
||||||
@@ -68,14 +68,14 @@ static gboolean fl_view_send_pointer_button_event(FlView* self,
|
|||||||
int old_button_state = self->button_state;
|
int old_button_state = self->button_state;
|
||||||
FlutterPointerPhase phase;
|
FlutterPointerPhase phase;
|
||||||
if (event->type == GDK_BUTTON_PRESS) {
|
if (event->type == GDK_BUTTON_PRESS) {
|
||||||
// Drop the event if Flutter already thinks the button is down
|
// Drop the event if Flutter already thinks the button is down.
|
||||||
if ((self->button_state & button) != 0)
|
if ((self->button_state & button) != 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
self->button_state ^= button;
|
self->button_state ^= button;
|
||||||
|
|
||||||
phase = old_button_state == 0 ? kDown : kMove;
|
phase = old_button_state == 0 ? kDown : kMove;
|
||||||
} else if (event->type == GDK_BUTTON_RELEASE) {
|
} else if (event->type == GDK_BUTTON_RELEASE) {
|
||||||
// Drop the event if Flutter already thinks the button is up
|
// Drop the event if Flutter already thinks the button is up.
|
||||||
if ((self->button_state & button) == 0)
|
if ((self->button_state & button) == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
self->button_state ^= button;
|
self->button_state ^= button;
|
||||||
@@ -92,7 +92,7 @@ static gboolean fl_view_send_pointer_button_event(FlView* self,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements FlPluginRegistry::get_registrar_for_plugin
|
// Implements FlPluginRegistry::get_registrar_for_plugin.
|
||||||
static FlPluginRegistrar* fl_view_get_registrar_for_plugin(
|
static FlPluginRegistrar* fl_view_get_registrar_for_plugin(
|
||||||
FlPluginRegistry* registry,
|
FlPluginRegistry* registry,
|
||||||
const gchar* name) {
|
const gchar* name) {
|
||||||
@@ -113,7 +113,7 @@ static void fl_view_constructed(GObject* object) {
|
|||||||
self->renderer = fl_renderer_x11_new();
|
self->renderer = fl_renderer_x11_new();
|
||||||
self->engine = fl_engine_new(self->project, FL_RENDERER(self->renderer));
|
self->engine = fl_engine_new(self->project, FL_RENDERER(self->renderer));
|
||||||
|
|
||||||
// Create system channel handlers
|
// Create system channel handlers.
|
||||||
FlBinaryMessenger* messenger = fl_engine_get_binary_messenger(self->engine);
|
FlBinaryMessenger* messenger = fl_engine_get_binary_messenger(self->engine);
|
||||||
self->key_event_plugin = fl_key_event_plugin_new(messenger);
|
self->key_event_plugin = fl_key_event_plugin_new(messenger);
|
||||||
self->text_input_plugin = fl_text_input_plugin_new(messenger);
|
self->text_input_plugin = fl_text_input_plugin_new(messenger);
|
||||||
@@ -164,7 +164,7 @@ static void fl_view_dispose(GObject* object) {
|
|||||||
G_OBJECT_CLASS(fl_view_parent_class)->dispose(object);
|
G_OBJECT_CLASS(fl_view_parent_class)->dispose(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements GtkWidget::realize
|
// Implements GtkWidget::realize.
|
||||||
static void fl_view_realize(GtkWidget* widget) {
|
static void fl_view_realize(GtkWidget* widget) {
|
||||||
FlView* self = FL_VIEW(widget);
|
FlView* self = FL_VIEW(widget);
|
||||||
|
|
||||||
@@ -202,7 +202,7 @@ static void fl_view_realize(GtkWidget* widget) {
|
|||||||
g_warning("Failed to start Flutter engine: %s", error->message);
|
g_warning("Failed to start Flutter engine: %s", error->message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements GtkWidget::size-allocate
|
// Implements GtkWidget::size-allocate.
|
||||||
static void fl_view_size_allocate(GtkWidget* widget,
|
static void fl_view_size_allocate(GtkWidget* widget,
|
||||||
GtkAllocation* allocation) {
|
GtkAllocation* allocation) {
|
||||||
FlView* self = FL_VIEW(widget);
|
FlView* self = FL_VIEW(widget);
|
||||||
@@ -214,17 +214,17 @@ static void fl_view_size_allocate(GtkWidget* widget,
|
|||||||
allocation->y, allocation->width,
|
allocation->y, allocation->width,
|
||||||
allocation->height);
|
allocation->height);
|
||||||
|
|
||||||
// TODO(robert-ancell): This pixel ratio won't work on hidpi displays
|
// TODO(robert-ancell): This pixel ratio won't work on hidpi displays.
|
||||||
fl_engine_send_window_metrics_event(self->engine, allocation->width,
|
fl_engine_send_window_metrics_event(self->engine, allocation->width,
|
||||||
allocation->height, 1);
|
allocation->height, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements GtkWidget::button_press_event
|
// Implements GtkWidget::button_press_event.
|
||||||
static gboolean fl_view_button_press_event(GtkWidget* widget,
|
static gboolean fl_view_button_press_event(GtkWidget* widget,
|
||||||
GdkEventButton* event) {
|
GdkEventButton* event) {
|
||||||
FlView* self = FL_VIEW(widget);
|
FlView* self = FL_VIEW(widget);
|
||||||
|
|
||||||
// Flutter doesn't handle double and triple click events
|
// Flutter doesn't handle double and triple click events.
|
||||||
if (event->type == GDK_DOUBLE_BUTTON_PRESS ||
|
if (event->type == GDK_DOUBLE_BUTTON_PRESS ||
|
||||||
event->type == GDK_TRIPLE_BUTTON_PRESS)
|
event->type == GDK_TRIPLE_BUTTON_PRESS)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -232,7 +232,7 @@ static gboolean fl_view_button_press_event(GtkWidget* widget,
|
|||||||
return fl_view_send_pointer_button_event(self, event);
|
return fl_view_send_pointer_button_event(self, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements GtkWidget::button_release_event
|
// Implements GtkWidget::button_release_event.
|
||||||
static gboolean fl_view_button_release_event(GtkWidget* widget,
|
static gboolean fl_view_button_release_event(GtkWidget* widget,
|
||||||
GdkEventButton* event) {
|
GdkEventButton* event) {
|
||||||
FlView* self = FL_VIEW(widget);
|
FlView* self = FL_VIEW(widget);
|
||||||
@@ -240,7 +240,7 @@ static gboolean fl_view_button_release_event(GtkWidget* widget,
|
|||||||
return fl_view_send_pointer_button_event(self, event);
|
return fl_view_send_pointer_button_event(self, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements GtkWidget::motion_notify_event
|
// Implements GtkWidget::motion_notify_event.
|
||||||
static gboolean fl_view_motion_notify_event(GtkWidget* widget,
|
static gboolean fl_view_motion_notify_event(GtkWidget* widget,
|
||||||
GdkEventMotion* event) {
|
GdkEventMotion* event) {
|
||||||
FlView* self = FL_VIEW(widget);
|
FlView* self = FL_VIEW(widget);
|
||||||
@@ -256,7 +256,7 @@ static gboolean fl_view_motion_notify_event(GtkWidget* widget,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements GtkWidget::key_press_event
|
// Implements GtkWidget::key_press_event.
|
||||||
static gboolean fl_view_key_press_event(GtkWidget* widget, GdkEventKey* event) {
|
static gboolean fl_view_key_press_event(GtkWidget* widget, GdkEventKey* event) {
|
||||||
FlView* self = FL_VIEW(widget);
|
FlView* self = FL_VIEW(widget);
|
||||||
|
|
||||||
@@ -268,7 +268,7 @@ static gboolean fl_view_key_press_event(GtkWidget* widget, GdkEventKey* event) {
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements GtkWidget::key_release_event
|
// Implements GtkWidget::key_release_event.
|
||||||
static gboolean fl_view_key_release_event(GtkWidget* widget,
|
static gboolean fl_view_key_release_event(GtkWidget* widget,
|
||||||
GdkEventKey* event) {
|
GdkEventKey* event) {
|
||||||
FlView* self = FL_VIEW(widget);
|
FlView* self = FL_VIEW(widget);
|
||||||
|
|||||||
Reference in New Issue
Block a user