From 50cf4934716e1a1b328d77b4a0397ba4afa75477 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Thu, 18 Nov 2021 15:36:26 -0800 Subject: [PATCH 1/3] Add 'explicit' to darwin embedder constructors --- fml/platform/darwin/cf_utils.h | 3 +++ fml/platform/darwin/scoped_block.h | 1 + fml/platform/darwin/scoped_nsobject.h | 5 ++++- shell/platform/common/accessibility_bridge.h | 3 ++- shell/platform/common/text_editing_delta.h | 2 ++ .../platform/darwin/ios/framework/Source/vsync_waiter_ios.h | 2 +- shell/platform/darwin/ios/ios_switchable_gl_context.h | 2 +- .../darwin/macos/framework/Source/FlutterCompositor.h | 2 +- 8 files changed, 15 insertions(+), 5 deletions(-) diff --git a/fml/platform/darwin/cf_utils.h b/fml/platform/darwin/cf_utils.h index 0dc984ee89baf..0ad4e2a461be6 100644 --- a/fml/platform/darwin/cf_utils.h +++ b/fml/platform/darwin/cf_utils.h @@ -16,6 +16,7 @@ class CFRef { public: CFRef() : instance_(nullptr) {} + // NOLINTNEXTLINE(google-explicit-constructor) CFRef(T instance) : instance_(instance) {} CFRef(const CFRef& other) : instance_(other.instance_) { @@ -54,8 +55,10 @@ class CFRef { return instance; } + // NOLINTNEXTLINE(google-explicit-constructor) operator T() const { return instance_; } + // NOLINTNEXTLINE(google-explicit-constructor) operator bool() const { return instance_ != nullptr; } private: diff --git a/fml/platform/darwin/scoped_block.h b/fml/platform/darwin/scoped_block.h index d4a7e670517da..2608d1ef3149e 100644 --- a/fml/platform/darwin/scoped_block.h +++ b/fml/platform/darwin/scoped_block.h @@ -67,6 +67,7 @@ class ScopedBlock { bool operator!=(B that) const { return block_ != that; } + // NOLINTNEXTLINE(google-explicit-constructor) operator B() const { return block_; } B get() const { return block_; } diff --git a/fml/platform/darwin/scoped_nsobject.h b/fml/platform/darwin/scoped_nsobject.h index 34d966c8a3e8b..9f910e44f31ed 100644 --- a/fml/platform/darwin/scoped_nsobject.h +++ b/fml/platform/darwin/scoped_nsobject.h @@ -45,6 +45,7 @@ class scoped_nsprotocol { scoped_nsprotocol(const scoped_nsprotocol& that) : object_([that.object_ retain]) {} template + // NOLINTNEXTLINE(google-explicit-constructor) scoped_nsprotocol(const scoped_nsprotocol& that) : object_([that.get() retain]) {} ~scoped_nsprotocol() { [object_ release]; } @@ -66,7 +67,7 @@ class scoped_nsprotocol { bool operator==(NST that) const { return object_ == that; } bool operator!=(NST that) const { return object_ != that; } - operator NST() const { return object_; } + operator NST() const { return object_; } // NOLINT(google-explicit-constructor) NST get() const { return object_; } @@ -116,6 +117,7 @@ class scoped_nsobject : public scoped_nsprotocol { scoped_nsobject(const scoped_nsobject& that) : scoped_nsprotocol(that) {} template + // NOLINTNEXTLINE(google-explicit-constructor) scoped_nsobject(const scoped_nsobject& that) : scoped_nsprotocol(that) {} scoped_nsobject& operator=(const scoped_nsobject& that) { @@ -133,6 +135,7 @@ class scoped_nsobject : public scoped_nsprotocol { scoped_nsobject(const scoped_nsobject& that) : scoped_nsprotocol(that) {} template + // NOLINTNEXTLINE(google-explicit-constructor) scoped_nsobject(const scoped_nsobject& that) : scoped_nsprotocol(that) {} scoped_nsobject& operator=(const scoped_nsobject& that) { diff --git a/shell/platform/common/accessibility_bridge.h b/shell/platform/common/accessibility_bridge.h index 7a2b0a6c95d69..b9ef87719eb2a 100644 --- a/shell/platform/common/accessibility_bridge.h +++ b/shell/platform/common/accessibility_bridge.h @@ -106,7 +106,8 @@ class AccessibilityBridge /// @param[in] user_data A custom pointer to the data of your /// choice. This pointer can be retrieve later /// through GetUserData(). - AccessibilityBridge(std::unique_ptr delegate); + explicit AccessibilityBridge( + std::unique_ptr delegate); ~AccessibilityBridge(); //------------------------------------------------------------------------------ diff --git a/shell/platform/common/text_editing_delta.h b/shell/platform/common/text_editing_delta.h index 61c9875bc92e6..10fe0f96b6504 100644 --- a/shell/platform/common/text_editing_delta.h +++ b/shell/platform/common/text_editing_delta.h @@ -23,8 +23,10 @@ struct TextEditingDelta { TextRange range, const std::string& text); + // NOLINTNEXTLINE(google-explicit-constructor) TextEditingDelta(const std::u16string& text); + // NOLINTNEXTLINE(google-explicit-constructor) TextEditingDelta(const std::string& text); virtual ~TextEditingDelta() = default; diff --git a/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.h b/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.h index e4b0aedac2055..f20bb26ef47d4 100644 --- a/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.h +++ b/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.h @@ -40,7 +40,7 @@ namespace flutter { class VsyncWaiterIOS final : public VsyncWaiter { public: - VsyncWaiterIOS(flutter::TaskRunners task_runners); + explicit VsyncWaiterIOS(flutter::TaskRunners task_runners); ~VsyncWaiterIOS() override; diff --git a/shell/platform/darwin/ios/ios_switchable_gl_context.h b/shell/platform/darwin/ios/ios_switchable_gl_context.h index 24bceb3e60249..df84f78accd4a 100644 --- a/shell/platform/darwin/ios/ios_switchable_gl_context.h +++ b/shell/platform/darwin/ios/ios_switchable_gl_context.h @@ -26,7 +26,7 @@ namespace flutter { /// |GLContextSwitch| and should be destroyed when The |GLContectSwitch| destroys. class IOSSwitchableGLContext final : public SwitchableGLContext { public: - IOSSwitchableGLContext(EAGLContext* context); + explicit IOSSwitchableGLContext(EAGLContext* context); bool SetCurrent() override; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h index aca395edacf48..141e27509dd44 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h @@ -19,7 +19,7 @@ namespace flutter { // Platform views are not yet supported. class FlutterCompositor { public: - FlutterCompositor(FlutterViewController* view_controller); + explicit FlutterCompositor(FlutterViewController* view_controller); virtual ~FlutterCompositor() = default; From b44d33c81c1e2e2e26a76471e48f35c659c1ea68 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Thu, 18 Nov 2021 22:02:12 -0800 Subject: [PATCH 2/3] TextEditingDelta --- shell/platform/common/text_editing_delta.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/shell/platform/common/text_editing_delta.h b/shell/platform/common/text_editing_delta.h index 10fe0f96b6504..e66e891f7db18 100644 --- a/shell/platform/common/text_editing_delta.h +++ b/shell/platform/common/text_editing_delta.h @@ -23,11 +23,9 @@ struct TextEditingDelta { TextRange range, const std::string& text); - // NOLINTNEXTLINE(google-explicit-constructor) - TextEditingDelta(const std::u16string& text); + explicit TextEditingDelta(const std::u16string& text); - // NOLINTNEXTLINE(google-explicit-constructor) - TextEditingDelta(const std::string& text); + explicit TextEditingDelta(const std::string& text); virtual ~TextEditingDelta() = default; From 51f001bf4ea2401cfab32c86639fff8471760ddc Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Thu, 18 Nov 2021 22:06:38 -0800 Subject: [PATCH 3/3] bool --- fml/platform/darwin/cf_utils.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fml/platform/darwin/cf_utils.h b/fml/platform/darwin/cf_utils.h index 0ad4e2a461be6..02fd3229d7c66 100644 --- a/fml/platform/darwin/cf_utils.h +++ b/fml/platform/darwin/cf_utils.h @@ -58,8 +58,7 @@ class CFRef { // NOLINTNEXTLINE(google-explicit-constructor) operator T() const { return instance_; } - // NOLINTNEXTLINE(google-explicit-constructor) - operator bool() const { return instance_ != nullptr; } + explicit operator bool() const { return instance_ != nullptr; } private: T instance_;