Add missing full stops on the end of comments. (flutter/engine#18634)

This commit is contained in:
Robert Ancell
2020-06-03 06:21:46 +12:00
committed by GitHub
parent 6282eb8094
commit 43de315eee
19 changed files with 107 additions and 102 deletions

View File

@@ -9,19 +9,19 @@
struct _FlBasicMessageChannel {
GObject parent_instance;
// Messenger to communicate on
// Messenger to communicate on.
FlBinaryMessenger* messenger;
// TRUE if the channel has been closed
// TRUE if the channel has been closed.
gboolean channel_closed;
// Channel name
// Channel name.
gchar* name;
// Codec to en/decode messages
// Codec to en/decode messages.
FlMessageCodec* codec;
// Function called when a message is received
// Function called when a message is received.
FlBasicMessageChannelMessageHandler message_handler;
gpointer message_handler_data;
GDestroyNotify message_handler_destroy_notify;
@@ -33,7 +33,7 @@ struct _FlBasicMessageChannelResponseHandle {
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_DEFINE_TYPE(FlBasicMessageChannel, fl_basic_message_channel, G_TYPE_OBJECT)
@@ -73,7 +73,7 @@ fl_basic_message_channel_response_handle_new(
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,
const gchar* channel,
GBytes* message,
@@ -102,7 +102,7 @@ static void message_cb(FlBinaryMessenger* messenger,
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,
GAsyncResult* result,
gpointer user_data) {
@@ -110,13 +110,13 @@ static void message_response_cb(GObject* object,
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) {
g_autoptr(FlBasicMessageChannel) self = FL_BASIC_MESSAGE_CHANNEL(user_data);
self->channel_closed = TRUE;
// Disconnect handler
// Disconnect handler.
if (self->message_handler_destroy_notify != nullptr)
self->message_handler_destroy_notify(self->message_handler_data);
self->message_handler = nullptr;
@@ -180,7 +180,7 @@ G_MODULE_EXPORT void fl_basic_message_channel_set_message_handler(
GDestroyNotify destroy_notify) {
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 (handler != nullptr) {
g_warning(

View File

@@ -14,7 +14,7 @@ struct _FlBinaryCodec {
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,
FlValue* value,
GError** error) {
@@ -29,7 +29,7 @@ static GBytes* fl_binary_codec_encode_message(FlMessageCodec* codec,
fl_value_get_length(value));
}
// Implements FlMessageCodec::decode_message
// Implements FlMessageCodec::decode_message.
static FlValue* fl_binary_codec_decode_message(FlMessageCodec* codec,
GBytes* message,
GError** error) {

View File

@@ -18,7 +18,7 @@ struct _FlBinaryMessenger {
FlEngine* engine;
// PlatformMessageHandler keyed by channel name
// PlatformMessageHandler keyed by channel name.
GHashTable* platform_message_handlers;
};
@@ -27,7 +27,7 @@ G_DEFINE_TYPE(FlBinaryMessenger, fl_binary_messenger, G_TYPE_OBJECT)
struct _FlBinaryMessengerResponseHandle {
GObject parent_instance;
// Messenger sending response on
// Messenger sending response on.
FlBinaryMessenger* messenger;
// 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);
self->engine = nullptr;
// Disconnect any handlers
// Disconnect any 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(channel != nullptr);
// Don't set handlers if engine already gone
// Don't set handlers if engine already gone.
if (self->engine == nullptr) {
if (handler != nullptr) {
g_warning(

View File

@@ -12,13 +12,13 @@
static constexpr int kMicrosecondsPerNanosecond = 1000;
// Unique number associated with platform tasks
// Unique number associated with platform tasks.
static constexpr size_t kPlatformTaskRunnerIdentifier = 1;
struct _FlEngine {
GObject parent_instance;
// Thread the GLib main loop is running on
// Thread the GLib main loop is running on.
GThread* thread;
FlDartProject* project;
@@ -26,7 +26,7 @@ struct _FlEngine {
FlBinaryMessenger* binary_messenger;
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;
gpointer platform_message_handler_data;
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)
// 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 {
GSource parent;
FlEngine* self;
FlutterTask task;
} 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,
GSourceFunc callback,
gpointer user_data) {
@@ -58,7 +58,7 @@ static gboolean flutter_source_dispatch(GSource* source,
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 = {
nullptr, // prepare
nullptr, // check
@@ -68,7 +68,7 @@ static GSourceFuncs flutter_source_funcs = {
nullptr // Internal usage
};
// Flutter engine callbacks
// Flutter engine rendering callbacks.
static void* fl_engine_gl_proc_resolver(void* user_data, const char* name) {
FlEngine* self = static_cast<FlEngine*>(user_data);
@@ -107,11 +107,13 @@ static bool fl_engine_gl_present(void* user_data) {
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) {
FlEngine* self = static_cast<FlEngine*>(user_data);
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,
uint64_t target_time_nanos,
void* user_data) {
@@ -127,6 +129,7 @@ static void fl_engine_post_task(FlutterTask task,
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,
void* user_data) {
FlEngine* self = FL_ENGINE(user_data);
@@ -145,6 +148,8 @@ static void fl_engine_platform_message_cb(const FlutterPlatformMessage* message,
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,
size_t data_length,
void* user_data) {

View File

@@ -19,7 +19,7 @@ G_DEFINE_TYPE(FlJsonMessageCodec,
fl_json_message_codec,
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,
FlValue* value,
GError** error) {
@@ -111,7 +111,7 @@ static gboolean write_value(rapidjson::Writer<rapidjson::StringBuffer>& writer,
return TRUE;
}
// Handler to parse JSON using rapidjson in SAX mode
// Handler to parse JSON using rapidjson in SAX mode.
struct FlValueHandler {
GPtrArray* stack;
FlValue* key;
@@ -132,20 +132,20 @@ struct FlValueHandler {
g_error_free(error);
}
// Gets the current head of the stack
// Gets the current head of the stack.
FlValue* get_head() {
if (stack->len == 0)
return nullptr;
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)); }
// Pops the stack
// Pops the stack.
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) {
g_autoptr(FlValue) owned_value = value;
FlValue* head = get_head();
@@ -169,7 +169,7 @@ struct FlValueHandler {
return true;
}
// The following implements the rapidjson SAX API
// The following implements the rapidjson SAX API.
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 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)
return add(fl_value_new_int(i));
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,
FlValue* message,
GError** error) {
@@ -238,7 +238,7 @@ static GBytes* fl_json_message_codec_encode_message(FlMessageCodec* codec,
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,
GBytes* message,
GError** error) {

View File

@@ -151,7 +151,7 @@ TEST(FlJsonMessageCodecTest, DecodeIntMax) {
TEST(FlJsonMessageCodecTest, DecodeUintMax) {
// 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");
ASSERT_EQ(fl_value_get_type(value), FL_VALUE_TYPE_FLOAT);
EXPECT_EQ(fl_value_get_float(value), 1.8446744073709551615e+19);
@@ -159,7 +159,7 @@ TEST(FlJsonMessageCodecTest, DecodeUintMax) {
TEST(FlJsonMessageCodecTest, DecodeHugeNumber) {
// 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");
ASSERT_EQ(fl_value_get_type(value), FL_VALUE_TYPE_FLOAT);
EXPECT_EQ(fl_value_get_float(value), 1.84467440737095516150e+20);

View File

@@ -29,7 +29,7 @@ static void fl_json_method_codec_dispose(GObject* 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,
const gchar* name,
FlValue* args,
@@ -46,7 +46,7 @@ static GBytes* fl_json_method_codec_encode_method_call(FlMethodCodec* codec,
error);
}
// Implements FlMethodCodec::decode_method_call
// Implements FlMethodCodec::decode_method_call.
static gboolean fl_json_method_codec_decode_method_call(FlMethodCodec* codec,
GBytes* message,
gchar** name,
@@ -86,7 +86,7 @@ static gboolean fl_json_method_codec_decode_method_call(FlMethodCodec* codec,
return TRUE;
}
// Implements FlMethodCodec::encode_success_envelope
// Implements FlMethodCodec::encode_success_envelope.
static GBytes* fl_json_method_codec_encode_success_envelope(
FlMethodCodec* codec,
FlValue* result,
@@ -101,7 +101,7 @@ static GBytes* fl_json_method_codec_encode_success_envelope(
error);
}
// Implements FlMethodCodec::encode_error_envelope
// Implements FlMethodCodec::encode_error_envelope.
static GBytes* fl_json_method_codec_encode_error_envelope(
FlMethodCodec* codec,
const gchar* code,
@@ -122,7 +122,7 @@ static GBytes* fl_json_method_codec_encode_error_envelope(
error);
}
// Implements FlMethodCodec::decode_response
// Implements FlMethodCodec::decode_response.
static FlMethodResponse* fl_json_method_codec_decode_response(
FlMethodCodec* codec,
GBytes* message,

View File

@@ -8,7 +8,7 @@
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_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);
// 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;
if (message == nullptr) {
null_value = fl_value_new_null();

View File

@@ -8,14 +8,14 @@
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
// expected
// expected.
struct _FlTestCodec {
FlMessageCodec parent_instance;
};
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,
FlValue* value,
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,
GBytes* message,
GError** error) {

View File

@@ -11,13 +11,13 @@
struct _FlMethodCall {
GObject parent_instance;
// Name of method being called
// Name of method being called.
gchar* name;
// Arguments provided to method call
// Arguments provided to method call.
FlValue* args;
// Channel to respond on
// Channel to respond on.
FlMethodChannel* channel;
FlBinaryMessengerResponseHandle* response_handle;
};

View File

@@ -13,30 +13,30 @@
struct _FlMethodChannel {
GObject parent_instance;
// Messenger to communicate on
// Messenger to communicate on.
FlBinaryMessenger* messenger;
// TRUE if the channel has been closed
// TRUE if the channel has been closed.
gboolean channel_closed;
// Channel name
// Channel name.
gchar* name;
// Codec to en/decode messages
// Codec to en/decode messages.
FlMethodCodec* codec;
// Function called when a method call is received
// Function called when a method call is received.
FlMethodChannelMethodCallHandler method_call_handler;
gpointer method_call_handler_data;
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_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,
const gchar* channel,
GBytes* message,
@@ -61,7 +61,7 @@ static void message_cb(FlBinaryMessenger* messenger,
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,
GAsyncResult* result,
gpointer user_data) {
@@ -69,13 +69,13 @@ static void message_response_cb(GObject* object,
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) {
g_autoptr(FlMethodChannel) self = FL_METHOD_CHANNEL(user_data);
self->channel_closed = TRUE;
// Disconnect handler
// Disconnect handler.
if (self->method_call_handler_destroy_notify != nullptr)
self->method_call_handler_destroy_notify(self->method_call_handler_data);
self->method_call_handler = nullptr;
@@ -138,7 +138,7 @@ G_MODULE_EXPORT void fl_method_channel_set_method_call_handler(
GDestroyNotify destroy_notify) {
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 (handler != nullptr) {
g_warning(

View File

@@ -7,7 +7,7 @@
#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_DEFINE_TYPE(FlMethodCodec, fl_method_codec, G_TYPE_OBJECT)

View File

@@ -14,7 +14,7 @@ G_DECLARE_FINAL_TYPE(FlTestMethodCodec,
FlMethodCodec)
// Implement the FlMethodCodec API for the following tests to check it works as
// expected
// expected.
struct _FlTestMethodCodec {
FlMethodCodec parent_instance;
};
@@ -23,7 +23,7 @@ G_DEFINE_TYPE(FlTestMethodCodec,
fl_test_method_codec,
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) {
size_t data_length;
const gchar* data =
@@ -31,12 +31,12 @@ static gchar* message_to_text(GBytes* message) {
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) {
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,
const gchar* name,
FlValue* args,
@@ -58,7 +58,7 @@ static GBytes* fl_test_codec_encode_method_call(FlMethodCodec* codec,
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,
GBytes* message,
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,
FlValue* result,
GError** error) {
@@ -99,7 +99,7 @@ static GBytes* fl_test_codec_encode_success_envelope(FlMethodCodec* codec,
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,
const gchar* code,
const gchar* message,
@@ -131,7 +131,7 @@ static GBytes* fl_test_codec_encode_error_envelope(FlMethodCodec* codec,
return text_to_message(text);
}
// Implements FlMethodCodec::decode_response
// Implements FlMethodCodec::decode_response.
static FlMethodResponse* fl_test_codec_decode_response(FlMethodCodec* codec,
GBytes* message,
GError** error) {

View File

@@ -56,7 +56,7 @@ TEST(FlMethodResponseTest, NotImplemented) {
g_autoptr(FlMethodNotImplementedResponse) response =
fl_method_not_implemented_response_new();
// Trivial check to stop the compiler deciding that 'response' is an unused
// variable
// variable.
EXPECT_TRUE(FL_IS_METHOD_NOT_IMPLEMENTED_RESPONSE(response));
}

View File

@@ -121,7 +121,7 @@ gboolean fl_renderer_clear_current(FlRenderer* self, GError** error) {
}
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;
}

View File

@@ -10,9 +10,9 @@
#include <gmodule.h>
// 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 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);
}
// Implements FlMethodCodec::encode_method_code
// Implements FlMethodCodec::encode_method_call.
static GBytes* fl_standard_method_codec_encode_method_call(FlMethodCodec* codec,
const gchar* name,
FlValue* args,
@@ -53,7 +53,7 @@ static GBytes* fl_standard_method_codec_encode_method_call(FlMethodCodec* codec,
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(
FlMethodCodec* codec,
GBytes* message,
@@ -90,7 +90,7 @@ static gboolean fl_standard_method_codec_decode_method_call(
return TRUE;
}
// Implements FlMethodCodec::encode_success_envelope
// Implements FlMethodCodec::encode_success_envelope.
static GBytes* fl_standard_method_codec_encode_success_envelope(
FlMethodCodec* codec,
FlValue* result,
@@ -108,7 +108,7 @@ static GBytes* fl_standard_method_codec_encode_success_envelope(
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(
FlMethodCodec* codec,
const gchar* code,
@@ -137,7 +137,7 @@ static GBytes* fl_standard_method_codec_encode_error_envelope(
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(
FlMethodCodec* codec,
GBytes* message,
@@ -150,7 +150,7 @@ static FlMethodResponse* fl_standard_method_codec_decode_response(
return nullptr;
}
// First byte is response type
// First byte is response type.
const guint8* data =
static_cast<const guint8*>(g_bytes_get_data(message, nullptr));
guint8 type = data[0];

View File

@@ -14,7 +14,7 @@ struct _FlStringCodec {
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,
FlValue* value,
GError** error) {
@@ -29,7 +29,7 @@ static GBytes* fl_string_codec_encode_message(FlMessageCodec* codec,
return g_bytes_new(text, strlen(text));
}
// Implments FlMessageCodec::decode_message
// Implments FlMessageCodec::decode_message.
static FlValue* fl_string_codec_decode_message(FlMessageCodec* codec,
GBytes* message,
GError** error) {

View File

@@ -92,19 +92,19 @@ static ssize_t fl_value_lookup_index(FlValue* self, FlValue* key) {
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) {
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) {
g_string_append_printf(buffer, "%.16f", value);
// Strip trailing zeros
// Strip trailing zeros.
int zero_count = 0;
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] == '.') {
zero_count = zero_count == 0 ? 0 : zero_count - 1;
break;

View File

@@ -19,16 +19,16 @@ static constexpr int kMicrosecondsPerMillisecond = 1000;
struct _FlView {
GtkWidget parent_instance;
// Project being run
// Project being run.
FlDartProject* project;
// Rendering output
// Rendering output.
FlRendererX11* renderer;
// Engine running @project
// Engine running @project.
FlEngine* engine;
// Pointer button state recorded for sending status updates
// Pointer button state recorded for sending status updates.
int64_t button_state;
// 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;
FlutterPointerPhase phase;
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)
return FALSE;
self->button_state ^= button;
phase = old_button_state == 0 ? kDown : kMove;
} 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)
return FALSE;
self->button_state ^= button;
@@ -92,7 +92,7 @@ static gboolean fl_view_send_pointer_button_event(FlView* self,
return TRUE;
}
// Implements FlPluginRegistry::get_registrar_for_plugin
// Implements FlPluginRegistry::get_registrar_for_plugin.
static FlPluginRegistrar* fl_view_get_registrar_for_plugin(
FlPluginRegistry* registry,
const gchar* name) {
@@ -113,7 +113,7 @@ static void fl_view_constructed(GObject* object) {
self->renderer = fl_renderer_x11_new();
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);
self->key_event_plugin = fl_key_event_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);
}
// Implements GtkWidget::realize
// Implements GtkWidget::realize.
static void fl_view_realize(GtkWidget* 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);
}
// Implements GtkWidget::size-allocate
// Implements GtkWidget::size-allocate.
static void fl_view_size_allocate(GtkWidget* widget,
GtkAllocation* allocation) {
FlView* self = FL_VIEW(widget);
@@ -214,17 +214,17 @@ static void fl_view_size_allocate(GtkWidget* widget,
allocation->y, allocation->width,
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,
allocation->height, 1);
}
// Implements GtkWidget::button_press_event
// Implements GtkWidget::button_press_event.
static gboolean fl_view_button_press_event(GtkWidget* widget,
GdkEventButton* event) {
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 ||
event->type == GDK_TRIPLE_BUTTON_PRESS)
return FALSE;
@@ -232,7 +232,7 @@ static gboolean fl_view_button_press_event(GtkWidget* widget,
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,
GdkEventButton* event) {
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);
}
// Implements GtkWidget::motion_notify_event
// Implements GtkWidget::motion_notify_event.
static gboolean fl_view_motion_notify_event(GtkWidget* widget,
GdkEventMotion* event) {
FlView* self = FL_VIEW(widget);
@@ -256,7 +256,7 @@ static gboolean fl_view_motion_notify_event(GtkWidget* widget,
return TRUE;
}
// Implements GtkWidget::key_press_event
// Implements GtkWidget::key_press_event.
static gboolean fl_view_key_press_event(GtkWidget* widget, GdkEventKey* event) {
FlView* self = FL_VIEW(widget);
@@ -268,7 +268,7 @@ static gboolean fl_view_key_press_event(GtkWidget* widget, GdkEventKey* event) {
return TRUE;
}
// Implements GtkWidget::key_release_event
// Implements GtkWidget::key_release_event.
static gboolean fl_view_key_release_event(GtkWidget* widget,
GdkEventKey* event) {
FlView* self = FL_VIEW(widget);