Skip to content

Commit

Permalink
Yet more compliance with .clang_tidy, stragglers edition. (flutter#…
Browse files Browse the repository at this point in the history
  • Loading branch information
matanlurey authored Nov 21, 2023
1 parent a8e9b8d commit 7cf9d90
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 24 deletions.
2 changes: 1 addition & 1 deletion impeller/renderer/testing/mocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class MockRenderPass : public RenderPass {
class MockCommandBuffer : public CommandBuffer {
public:
explicit MockCommandBuffer(std::weak_ptr<const Context> context)
: CommandBuffer(context) {}
: CommandBuffer(std::move(context)) {}
MOCK_METHOD(bool, IsValid, (), (const, override));
MOCK_METHOD(void, SetLabel, (const std::string& label), (const, override));
MOCK_METHOD(std::shared_ptr<BlitPass>, OnCreateBlitPass, (), (override));
Expand Down
2 changes: 2 additions & 0 deletions shell/platform/linux/fl_engine_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ G_BEGIN_DECLS
*/

typedef enum {
// NOLINTBEGIN(readability-identifier-naming)
FL_ENGINE_ERROR_FAILED,
// NOLINTEND(readability-identifier-naming)
} FlEngineError;

GQuark fl_engine_error_quark(void) G_GNUC_CONST;
Expand Down
2 changes: 2 additions & 0 deletions shell/platform/linux/fl_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ G_BEGIN_DECLS
*/

typedef enum {
// NOLINTBEGIN(readability-identifier-naming)
FL_RENDERER_ERROR_FAILED,
// NOLINTEND(readability-identifier-naming)
} FlRendererError;

GQuark fl_renderer_error_quark(void) G_GNUC_CONST;
Expand Down
4 changes: 4 additions & 0 deletions shell/platform/linux/fl_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ G_DECLARE_INTERFACE(FlSettings, fl_settings, FL, SETTINGS, GObject)
* Available clock formats.
*/
typedef enum {
// NOLINTBEGIN(readability-identifier-naming)
FL_CLOCK_FORMAT_12H,
FL_CLOCK_FORMAT_24H,
// NOLINTEND(readability-identifier-naming)
} FlClockFormat;

/**
Expand All @@ -31,8 +33,10 @@ typedef enum {
* Available color schemes.
*/
typedef enum {
// NOLINTBEGIN(readability-identifier-naming)
FL_COLOR_SCHEME_LIGHT,
FL_COLOR_SCHEME_DARK,
// NOLINTEND(readability-identifier-naming)
} FlColorScheme;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ G_BEGIN_DECLS
#define FL_JSON_MESSAGE_CODEC_ERROR fl_json_message_codec_error_quark()

typedef enum {
// NOLINTBEGIN(readability-identifier-naming)
FL_JSON_MESSAGE_CODEC_ERROR_INVALID_UTF8,
FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON,
FL_JSON_MESSAGE_CODEC_ERROR_INVALID_OBJECT_KEY_TYPE,
// NOLINTEND(readability-identifier-naming)
} FlJsonMessageCodecError;

GQuark fl_json_message_codec_error_quark(void) G_GNUC_CONST;
Expand Down
2 changes: 2 additions & 0 deletions shell/platform/linux/public/flutter_linux/fl_message_codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ G_BEGIN_DECLS
#define FL_MESSAGE_CODEC_ERROR fl_message_codec_error_quark()

typedef enum {
// NOLINTBEGIN(readability-identifier-naming)
FL_MESSAGE_CODEC_ERROR_FAILED,
FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA,
FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA,
FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE,
// NOLINTEND(readability-identifier-naming)
} FlMessageCodecError;

GQuark fl_message_codec_error_quark(void) G_GNUC_CONST;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ G_BEGIN_DECLS
#define FL_METHOD_RESPONSE_ERROR fl_method_response_error_quark()

typedef enum {
// NOLINTBEGIN(readability-identifier-naming)
FL_METHOD_RESPONSE_ERROR_FAILED,
FL_METHOD_RESPONSE_ERROR_REMOTE_ERROR,
FL_METHOD_RESPONSE_ERROR_NOT_IMPLEMENTED,
// NOLINTEND(readability-identifier-naming)
} FlMethodResponseError;

GQuark fl_method_response_error_quark(void) G_GNUC_CONST;
Expand Down
16 changes: 8 additions & 8 deletions shell/platform/linux/testing/mock_binary_messenger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,26 @@ MockBinaryMessenger::operator FlBinaryMessenger*() {
}

bool MockBinaryMessenger::HasMessageHandler(const gchar* channel) const {
return message_handlers.at(channel) != nullptr;
return message_handlers_.at(channel) != nullptr;
}

void MockBinaryMessenger::SetMessageHandler(
const gchar* channel,
FlBinaryMessengerMessageHandler handler,
gpointer user_data) {
message_handlers[channel] = handler;
user_datas[channel] = user_data;
message_handlers_[channel] = handler;
user_datas_[channel] = user_data;
}

void MockBinaryMessenger::ReceiveMessage(const gchar* channel,
GBytes* message) {
FlBinaryMessengerMessageHandler handler = message_handlers[channel];
if (response_handles[channel] == nullptr) {
response_handles[channel] = FL_BINARY_MESSENGER_RESPONSE_HANDLE(
FlBinaryMessengerMessageHandler handler = message_handlers_[channel];
if (response_handles_[channel] == nullptr) {
response_handles_[channel] = FL_BINARY_MESSENGER_RESPONSE_HANDLE(
fl_mock_binary_messenger_response_handle_new());
}
handler(instance_, channel, message, response_handles[channel],
user_datas[channel]);
handler(instance_, channel, message, response_handles_[channel],
user_datas_[channel]);
}

static void fl_mock_binary_messenger_iface_init(
Expand Down
10 changes: 7 additions & 3 deletions shell/platform/linux/testing/mock_binary_messenger.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ class MockBinaryMessenger {
MockBinaryMessenger();
~MockBinaryMessenger();

// This was an existing use of operator overloading. It's against our style
// guide but enabling clang tidy on header files is a higher priority than
// fixing this.
// NOLINTNEXTLINE(google-explicit-constructor)
operator FlBinaryMessenger*();

MOCK_METHOD(void,
Expand Down Expand Up @@ -75,10 +79,10 @@ class MockBinaryMessenger {
private:
FlBinaryMessenger* instance_ = nullptr;
std::unordered_map<std::string, FlBinaryMessengerMessageHandler>
message_handlers;
message_handlers_;
std::unordered_map<std::string, FlBinaryMessengerResponseHandle*>
response_handles;
std::unordered_map<std::string, gpointer> user_datas;
response_handles_;
std::unordered_map<std::string, gpointer> user_datas_;
};

} // namespace testing
Expand Down
4 changes: 4 additions & 0 deletions shell/platform/linux/testing/mock_im_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class MockIMContext {
public:
~MockIMContext();

// This was an existing use of operator overloading. It's against our style
// guide but enabling clang tidy on header files is a higher priority than
// fixing this.
// NOLINTNEXTLINE(google-explicit-constructor)
operator GtkIMContext*();

MOCK_METHOD(void,
Expand Down
4 changes: 4 additions & 0 deletions shell/platform/linux/testing/mock_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class MockSettings {
MockSettings();
~MockSettings();

// This was an existing use of operator overloading. It's against our style
// guide but enabling clang tidy on header files is a higher priority than
// fixing this.
// NOLINTNEXTLINE(google-explicit-constructor)
operator FlSettings*();

MOCK_METHOD(FlClockFormat,
Expand Down
22 changes: 11 additions & 11 deletions vulkan/vulkan_application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ VulkanApplication::VulkanApplication(
uint32_t application_version,
uint32_t api_version,
bool enable_validation_layers)
: vk(p_vk),
: vk_(p_vk),
api_version_(api_version),
valid_(false),
enable_validation_layers_(enable_validation_layers) {
// Check if we want to enable debugging.
std::vector<VkExtensionProperties> supported_extensions =
GetSupportedInstanceExtensions(vk);
GetSupportedInstanceExtensions(vk_);
bool enable_instance_debugging =
enable_validation_layers_ &&
ExtensionSupported(supported_extensions,
Expand Down Expand Up @@ -59,7 +59,7 @@ VulkanApplication::VulkanApplication(
// Configure layers.

const std::vector<std::string> enabled_layers =
InstanceLayersToEnable(vk, enable_validation_layers_);
InstanceLayersToEnable(vk_, enable_validation_layers_);

const char* layers[enabled_layers.size()];

Expand Down Expand Up @@ -94,26 +94,26 @@ VulkanApplication::VulkanApplication(

VkInstance instance = VK_NULL_HANDLE;

if (VK_CALL_LOG_ERROR(vk.CreateInstance(&create_info, nullptr, &instance)) !=
if (VK_CALL_LOG_ERROR(vk_.CreateInstance(&create_info, nullptr, &instance)) !=
VK_SUCCESS) {
FML_DLOG(INFO) << "Could not create application instance.";
return;
}

// Now that we have an instance, set up instance proc table entries.
if (!vk.SetupInstanceProcAddresses(VulkanHandle<VkInstance>(instance))) {
if (!vk_.SetupInstanceProcAddresses(VulkanHandle<VkInstance>(instance))) {
FML_DLOG(INFO) << "Could not set up instance proc addresses.";
return;
}

instance_ = VulkanHandle<VkInstance>{instance, [this](VkInstance i) {
FML_DLOG(INFO)
<< "Destroying Vulkan instance";
vk.DestroyInstance(i, nullptr);
vk_.DestroyInstance(i, nullptr);
}};

if (enable_instance_debugging) {
auto debug_report = std::make_unique<VulkanDebugReport>(vk, instance_);
auto debug_report = std::make_unique<VulkanDebugReport>(vk_, instance_);
if (!debug_report->IsValid()) {
FML_DLOG(INFO) << "Vulkan debugging was enabled but could not be set up "
"for this instance.";
Expand Down Expand Up @@ -150,8 +150,8 @@ std::vector<VkPhysicalDevice> VulkanApplication::GetPhysicalDevices() const {
}

uint32_t device_count = 0;
if (VK_CALL_LOG_ERROR(vk.EnumeratePhysicalDevices(instance_, &device_count,
nullptr)) != VK_SUCCESS) {
if (VK_CALL_LOG_ERROR(vk_.EnumeratePhysicalDevices(instance_, &device_count,
nullptr)) != VK_SUCCESS) {
FML_DLOG(INFO) << "Could not enumerate physical device.";
return {};
}
Expand All @@ -166,7 +166,7 @@ std::vector<VkPhysicalDevice> VulkanApplication::GetPhysicalDevices() const {

physical_devices.resize(device_count);

if (VK_CALL_LOG_ERROR(vk.EnumeratePhysicalDevices(
if (VK_CALL_LOG_ERROR(vk_.EnumeratePhysicalDevices(
instance_, &device_count, physical_devices.data())) != VK_SUCCESS) {
FML_DLOG(INFO) << "Could not enumerate physical device.";
return {};
Expand All @@ -179,7 +179,7 @@ std::unique_ptr<VulkanDevice>
VulkanApplication::AcquireFirstCompatibleLogicalDevice() const {
for (auto device_handle : GetPhysicalDevices()) {
auto logical_device = std::make_unique<VulkanDevice>(
vk, VulkanHandle<VkPhysicalDevice>(device_handle),
vk_, VulkanHandle<VkPhysicalDevice>(device_handle),
enable_validation_layers_);
if (logical_device->IsValid()) {
return logical_device;
Expand Down
2 changes: 1 addition & 1 deletion vulkan/vulkan_application.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class VulkanApplication {
std::unique_ptr<VulkanDevice> AcquireFirstCompatibleLogicalDevice() const;

private:
VulkanProcTable& vk;
VulkanProcTable& vk_;
VulkanHandle<VkInstance> instance_;
uint32_t api_version_;
std::unique_ptr<VulkanDebugReport> debug_report_;
Expand Down

0 comments on commit 7cf9d90

Please sign in to comment.