[lint] Merge impeller .clang-tidy into main config (flutter/engine#33692)

Merges most (but not all) of the impeller .clang-tidy rules into the
main .clang-tidy config. Merges:

readability-identifier-naming.PrivateMemberSuffix (_)
readability-identifier-naming.EnumConstantPrefix (k)
modernize-use-default-member-init.UseAssignment
Does not merge:

readability-identifier-naming.PublicMethodCase (CamelCase)
readability-identifier-naming.PrivateMethodCase (CamelCase)
These last two are not merged due to the non-trivial number of existing
field accessors that use field_name() methods to directly return
field_name_. While these are permitted by the C++ style guide, we may
want to move to a single, simple rule and name everything in CamelCase.
These can be enabled in a followup patch.

No new tests added, since this change is style-only.
This commit is contained in:
Chris Bracken 2022-06-21 19:52:42 +01:00 committed by GitHub
parent ba49690c20
commit 53a9648da9
31 changed files with 170 additions and 172 deletions

View File

@ -2,6 +2,7 @@
Checks: "google-*,\
clang-analyzer-*,\
clang-diagnostic-*,\
modernize-use-default-member-init,\
readability-identifier-naming,\
-google-objc-global-variable-declaration,\
-google-objc-avoid-throwing-exception,\
@ -22,5 +23,15 @@ google-objc-*,\
google-explicit-constructor"
CheckOptions:
- key: readability-identifier-naming.GlobalConstantPrefix
value: k
- key: modernize-use-default-member-init.UseAssignment
value: true
- key: readability-identifier-naming.EnumConstantCase
value: 'CamelCase'
- key: readability-identifier-naming.EnumConstantPrefix
value: 'k'
- key: readability-identifier-naming.GlobalConstantPrefix
value: 'k'
- key: readability-identifier-naming.PrivateMemberCase
value: 'lower_case'
- key: readability-identifier-naming.PrivateMemberSuffix
value: '_'

View File

@ -397,7 +397,6 @@ FILE: ../../../flutter/fml/unique_fd.cc
FILE: ../../../flutter/fml/unique_fd.h
FILE: ../../../flutter/fml/unique_object.h
FILE: ../../../flutter/fml/wakeable.h
FILE: ../../../flutter/impeller/.clang-tidy
FILE: ../../../flutter/impeller/aiks/aiks_context.cc
FILE: ../../../flutter/impeller/aiks/aiks_context.h
FILE: ../../../flutter/impeller/aiks/aiks_playground.cc

View File

@ -1360,15 +1360,15 @@ TEST(DisplayList, DisplayListBlenderRefHandling) {
class BlenderRefTester : public virtual AttributeRefTester {
public:
void setRefToPaint(SkPaint& paint) const override {
paint.setBlender(blender);
paint.setBlender(blender_);
}
void setRefToDisplayList(DisplayListBuilder& builder) const override {
builder.setBlender(blender);
builder.setBlender(blender_);
}
bool ref_is_unique() const override { return blender->unique(); }
bool ref_is_unique() const override { return blender_->unique(); }
private:
sk_sp<SkBlender> blender =
sk_sp<SkBlender> blender_ =
SkBlenders::Arithmetic(0.25, 0.25, 0.25, 0.25, true);
};

View File

@ -17,8 +17,7 @@ SurfaceFrame::SurfaceFrame(sk_sp<SkSurface> surface,
const SubmitCallback& submit_callback,
std::unique_ptr<GLContextResult> context_result,
bool display_list_fallback)
: submitted_(false),
surface_(surface),
: surface_(surface),
framebuffer_info_(std::move(framebuffer_info)),
submit_callback_(submit_callback),
context_result_(std::move(context_result)) {

View File

@ -51,8 +51,7 @@ Mapping::Mapping() = default;
Mapping::~Mapping() = default;
FileMapping::FileMapping(const fml::UniqueFD& handle,
std::initializer_list<Protection> protection)
: size_(0), mapping_(nullptr) {
std::initializer_list<Protection> protection) {
if (!handle.is_valid()) {
return;
}

View File

@ -15,44 +15,44 @@ namespace fml {
class PlatformSemaphore {
public:
explicit PlatformSemaphore(uint32_t count)
: _sem(dispatch_semaphore_create(count)), _initial(count) {}
: sem_(dispatch_semaphore_create(count)), initial_(count) {}
~PlatformSemaphore() {
for (uint32_t i = 0; i < _initial; ++i) {
for (uint32_t i = 0; i < initial_; ++i) {
Signal();
}
if (_sem != nullptr) {
dispatch_release(reinterpret_cast<dispatch_object_t>(_sem));
_sem = nullptr;
if (sem_ != nullptr) {
dispatch_release(reinterpret_cast<dispatch_object_t>(sem_));
sem_ = nullptr;
}
}
bool IsValid() const { return _sem != nullptr; }
bool IsValid() const { return sem_ != nullptr; }
bool Wait() {
if (_sem == nullptr) {
if (sem_ == nullptr) {
return false;
}
return dispatch_semaphore_wait(_sem, DISPATCH_TIME_FOREVER) == 0;
return dispatch_semaphore_wait(sem_, DISPATCH_TIME_FOREVER) == 0;
}
bool TryWait() {
if (_sem == nullptr) {
if (sem_ == nullptr) {
return false;
}
return dispatch_semaphore_wait(_sem, DISPATCH_TIME_NOW) == 0;
return dispatch_semaphore_wait(sem_, DISPATCH_TIME_NOW) == 0;
}
void Signal() {
if (_sem != nullptr) {
dispatch_semaphore_signal(_sem);
if (sem_ != nullptr) {
dispatch_semaphore_signal(sem_);
}
}
private:
dispatch_semaphore_t _sem;
const uint32_t _initial;
dispatch_semaphore_t sem_;
const uint32_t initial_;
FML_DISALLOW_COPY_AND_ASSIGN(PlatformSemaphore);
};

View File

@ -1,30 +0,0 @@
---
Checks: 'clang-diagnostic-*,\
clang-analyzer-*,\
google-*,\
readability-identifier-naming,\
-google-explicit-constructor,\
modernize-use-default-member-init'
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
CheckOptions:
- key: readability-identifier-naming.PrivateMemberCase
value: 'lower_case'
- key: readability-identifier-naming.EnumConstantCase
value: 'CamelCase'
- key: readability-identifier-naming.EnumConstantPrefix
value: 'k'
- key: readability-identifier-naming.PrivateMemberSuffix
value: '_'
- key: readability-identifier-naming.PublicMethodCase
value: 'CamelCase'
- key: readability-identifier-naming.PrivateMethodCase
value: 'CamelCase'
- key: cppcoreguidelines-prefer-member-initializer.UseAssignment
value: true
- key: modernize-use-default-member-init.UseAssignment
value: true
...

View File

@ -17,7 +17,7 @@
namespace impeller {
struct ArchiveDatabase::Handle {
Handle(const std::string& filename) {
explicit Handle(const std::string& filename) {
if (::sqlite3_initialize() != SQLITE_OK) {
VALIDATION_LOG << "Could not initialize sqlite.";
return;

View File

@ -18,7 +18,7 @@ static int64_t LastSample = 0;
class Sample : public Archivable {
public:
Sample(uint64_t count = 42) : some_data_(count) {}
explicit Sample(uint64_t count = 42) : some_data_(count) {}
Sample(Sample&&) = default;

View File

@ -44,7 +44,7 @@ TEST(ThreadTest, CanCreateRWMutex) {
f.mtx.UnlockWriter();
// int b = f.a; <--- Static analysis error.
f.mtx.LockReader();
int b = f.a;
int b = f.a; // NOLINT(clang-analyzer-deadcode.DeadStores)
FML_ALLOW_UNUSED_LOCAL(b);
f.mtx.UnlockReader();
}
@ -61,7 +61,7 @@ TEST(ThreadTest, CanCreateRWMutexLock) {
// int b = f.a; <--- Static analysis error.
{
auto read_lock = ReaderLock(f.mtx);
int b = f.a;
int b = f.a; // NOLINT(clang-analyzer-deadcode.DeadStores)
FML_ALLOW_UNUSED_LOCAL(b);
}

View File

@ -42,7 +42,7 @@ BlobLibrary::BlobLibrary(std::shared_ptr<fml::Mapping> mapping)
{
const size_t read_size = sizeof(Blob) * header.blob_count;
::memcpy(blobs.data(), mapping_->GetMapping() + offset, read_size);
offset += read_size;
offset += read_size; // NOLINT(clang-analyzer-deadcode.DeadStores)
}
// Read the blobs.

View File

@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// FLUTTER_NOLINT: https://github.com/flutter/flutter/issues/105732
#include "impeller/compiler/reflector.h"
#include <atomic>

View File

@ -38,7 +38,8 @@ TEST_P(EntityTest, CanCreateEntity) {
class TestPassDelegate final : public EntityPassDelegate {
public:
TestPassDelegate(std::optional<Rect> coverage) : coverage_(coverage) {}
explicit TestPassDelegate(std::optional<Rect> coverage)
: coverage_(coverage) {}
// |EntityPassDelegate|
~TestPassDelegate() override = default;

View File

@ -130,7 +130,7 @@ struct CubicPathComponent {
struct ContourComponent {
Point destination;
bool is_closed;
bool is_closed = false;
ContourComponent() {}

View File

@ -90,7 +90,7 @@ struct TexImage2DData {
GLenum type = GL_NONE;
std::shared_ptr<const fml::Mapping> data;
TexImage2DData(PixelFormat pixel_format) {
explicit TexImage2DData(PixelFormat pixel_format) {
switch (pixel_format) {
case PixelFormat::kA8UNormInt:
internal_format = GL_ALPHA;

View File

@ -8,6 +8,9 @@
namespace impeller {
namespace {
// NOLINTBEGIN(readability-identifier-naming)
// TODO(dnfield): remove this declaration when we no longer need to build on
// machines with lower SDK versions than 11.0.
#if !defined(MAC_OS_VERSION_11_0) || \
@ -21,6 +24,8 @@ typedef NS_ENUM(NSInteger, MTLCommandEncoderErrorState) {
} API_AVAILABLE(macos(11.0), ios(14.0));
#endif
// NOLINTEND(readability-identifier-naming)
API_AVAILABLE(ios(14.0), macos(11.0))
NSString* MTLCommandEncoderErrorStateToString(
MTLCommandEncoderErrorState state) {
@ -39,6 +44,8 @@ NSString* MTLCommandEncoderErrorStateToString(
return @"unknown";
}
// NOLINTBEGIN(readability-identifier-naming)
// TODO(dnfield): This can be removed when all bots have been sufficiently
// upgraded for MAC_OS_VERSION_12_0.
#if !defined(MAC_OS_VERSION_12_0) || \
@ -47,6 +54,8 @@ constexpr int MTLCommandBufferErrorAccessRevoked = 4;
constexpr int MTLCommandBufferErrorStackOverflow = 12;
#endif
// NOLINTEND(readability-identifier-naming)
static NSString* MTLCommandBufferErrorToString(MTLCommandBufferError code) {
switch (code) {
case MTLCommandBufferErrorNone:

View File

@ -186,7 +186,8 @@ bool RenderPassMTL::EncodeCommands(
/// absent.
///
struct PassBindingsCache {
PassBindingsCache(id<MTLRenderCommandEncoder> encoder) : encoder_(encoder) {}
explicit PassBindingsCache(id<MTLRenderCommandEncoder> encoder)
: encoder_(encoder) {}
PassBindingsCache(const PassBindingsCache&) = delete;

View File

@ -64,7 +64,7 @@ constexpr float kInvertColors[20] = {
// clang-format on
// Must be kept in sync with the MaskFilter private constants in painting.dart.
enum MaskFilterType { Null, Blur };
enum MaskFilterType { kNull, kBlur };
Paint::Paint(Dart_Handle paint_objects, Dart_Handle paint_data)
: paint_objects_(paint_objects), paint_data_(paint_data) {}
@ -169,9 +169,9 @@ const SkPaint* Paint::paint(SkPaint& paint) const {
}
switch (uint_data[kMaskFilterIndex]) {
case Null:
case kNull:
break;
case Blur:
case kBlur:
SkBlurStyle blur_style =
static_cast<SkBlurStyle>(uint_data[kMaskFilterBlurStyleIndex]);
double sigma = float_data[kMaskFilterSigmaIndex];
@ -300,10 +300,10 @@ bool Paint::sync_to(DisplayListBuilder* builder,
if (flags.applies_mask_filter()) {
switch (uint_data[kMaskFilterIndex]) {
case Null:
case kNull:
builder->setMaskFilter(nullptr);
break;
case Blur:
case kBlur:
SkBlurStyle blur_style =
static_cast<SkBlurStyle>(uint_data[kMaskFilterBlurStyleIndex]);
double sigma = float_data[kMaskFilterSigmaIndex];

View File

@ -42,7 +42,7 @@ constexpr std::string_view kFileUriPrefix = "file://";
class DartErrorString {
public:
DartErrorString() : str_(nullptr) {}
DartErrorString() {}
~DartErrorString() {
if (str_) {
::free(str_);
@ -54,7 +54,7 @@ class DartErrorString {
private:
FML_DISALLOW_COPY_AND_ASSIGN(DartErrorString);
char* str_;
char* str_ = nullptr;
};
} // anonymous namespace

View File

@ -81,7 +81,7 @@ class FlutterEventTracer : public SkEventTracer {
FlutterEventTracer(bool enabled,
const std::optional<std::vector<std::string>>& allowlist)
: enabled_(enabled ? kYes : kNo), shaders_category_flag_(nullptr) {
: enabled_(enabled ? kYes : kNo) {
if (allowlist.has_value()) {
allowlist_.emplace();
for (const std::string& category : *allowlist) {
@ -311,7 +311,7 @@ class FlutterEventTracer : public SkEventTracer {
std::mutex flag_map_mutex_;
std::map<const char*, uint8_t> category_flag_map_;
std::map<const uint8_t*, const char*> reverse_flag_map_;
const uint8_t* shaders_category_flag_;
const uint8_t* shaders_category_flag_ = nullptr;
FML_DISALLOW_COPY_AND_ASSIGN(FlutterEventTracer);
};

View File

@ -73,7 +73,7 @@ GPUSurfaceGLSkia::GPUSurfaceGLSkia(sk_sp<GrDirectContext> gr_context,
bool render_to_surface)
: delegate_(delegate),
context_(gr_context),
context_owner_(false),
render_to_surface_(render_to_surface),
weak_factory_(this) {
auto context_switch = delegate_->GLContextMakeCurrent();

View File

@ -20,28 +20,35 @@ namespace {
// framework code expects certain values, and has additional values (like the
// sided modifier values below), we translate the iOS values to the framework
// values, and add a mask for all the possible values.
typedef NS_OPTIONS(NSInteger, KeyboardModifier) {
KeyboardModifierAlphaShift = 0x10000,
KeyboardModifierShift = 0x20000,
KeyboardModifierLeftShift = 0x02,
KeyboardModifierRightShift = 0x04,
KeyboardModifierControl = 0x40000,
KeyboardModifierLeftControl = 0x01,
KeyboardModifierRightControl = 0x2000,
KeyboardModifierOption = 0x80000,
KeyboardModifierLeftOption = 0x20,
KeyboardModifierRightOption = 0x40,
KeyboardModifierCommand = 0x100000,
KeyboardModifierLeftCommand = 0x08,
KeyboardModifierRightCommand = 0x10,
KeyboardModifierNumericPad = 0x200000,
KeyboardModifierMask = KeyboardModifierAlphaShift | KeyboardModifierShift |
KeyboardModifierLeftShift | KeyboardModifierRightShift |
KeyboardModifierControl | KeyboardModifierLeftControl |
KeyboardModifierRightControl | KeyboardModifierOption |
KeyboardModifierLeftOption | KeyboardModifierRightOption |
KeyboardModifierCommand | KeyboardModifierLeftCommand |
KeyboardModifierRightCommand | KeyboardModifierNumericPad,
typedef NS_OPTIONS(NSInteger, kKeyboardModifier) {
kKeyboardModifierAlphaShift = 0x10000,
kKeyboardModifierShift = 0x20000,
kKeyboardModifierLeftShift = 0x02,
kKeyboardModifierRightShift = 0x04,
kKeyboardModifierControl = 0x40000,
kKeyboardModifierLeftControl = 0x01,
kKeyboardModifierRightControl = 0x2000,
kKeyboardModifierOption = 0x80000,
kKeyboardModifierLeftOption = 0x20,
kKeyboardModifierRightOption = 0x40,
kKeyboardModifierCommand = 0x100000,
kKeyboardModifierLeftCommand = 0x08,
kKeyboardModifierRightCommand = 0x10,
kKeyboardModifierNumericPad = 0x200000,
kKeyboardModifierMask = kKeyboardModifierAlphaShift | //
kKeyboardModifierShift | //
kKeyboardModifierLeftShift | //
kKeyboardModifierRightShift | //
kKeyboardModifierControl | //
kKeyboardModifierLeftControl | //
kKeyboardModifierRightControl | //
kKeyboardModifierOption | //
kKeyboardModifierLeftOption | //
kKeyboardModifierRightOption | //
kKeyboardModifierCommand | //
kKeyboardModifierLeftCommand | //
kKeyboardModifierRightCommand | //
kKeyboardModifierNumericPad,
};
/**
@ -83,7 +90,7 @@ static NSString* getEventCharacters(NSString* characters, UIKeyboardHIDUsage key
- (NSInteger)adjustModifiers:(nonnull FlutterUIPressProxy*)press API_AVAILABLE(ios(13.4));
- (void)updatePressedModifiers:(nonnull FlutterUIPressProxy*)press API_AVAILABLE(ios(13.4));
@property(nonatomic) KeyboardModifier pressedModifiers;
@property(nonatomic) kKeyboardModifier pressedModifiers;
@end
@implementation FlutterChannelKeyResponder
@ -174,7 +181,7 @@ static NSString* getEventCharacters(NSString* characters, UIKeyboardHIDUsage key
break;
}
void (^update)(KeyboardModifier, bool) = ^(KeyboardModifier mod, bool isOn) {
void (^update)(kKeyboardModifier, bool) = ^(kKeyboardModifier mod, bool isOn) {
if (isOn) {
_pressedModifiers |= mod;
} else {
@ -183,48 +190,48 @@ static NSString* getEventCharacters(NSString* characters, UIKeyboardHIDUsage key
};
switch (press.key.keyCode) {
case UIKeyboardHIDUsageKeyboardCapsLock:
update(KeyboardModifierAlphaShift, isKeyDown);
update(kKeyboardModifierAlphaShift, isKeyDown);
break;
case UIKeyboardHIDUsageKeypadNumLock:
update(KeyboardModifierNumericPad, isKeyDown);
update(kKeyboardModifierNumericPad, isKeyDown);
break;
case UIKeyboardHIDUsageKeyboardLeftShift:
update(KeyboardModifierLeftShift, isKeyDown);
update(kKeyboardModifierLeftShift, isKeyDown);
break;
case UIKeyboardHIDUsageKeyboardRightShift:
update(KeyboardModifierRightShift, isKeyDown);
update(kKeyboardModifierRightShift, isKeyDown);
break;
case UIKeyboardHIDUsageKeyboardLeftControl:
update(KeyboardModifierLeftControl, isKeyDown);
update(kKeyboardModifierLeftControl, isKeyDown);
break;
case UIKeyboardHIDUsageKeyboardRightControl:
update(KeyboardModifierRightControl, isKeyDown);
update(kKeyboardModifierRightControl, isKeyDown);
break;
case UIKeyboardHIDUsageKeyboardLeftAlt:
update(KeyboardModifierLeftOption, isKeyDown);
update(kKeyboardModifierLeftOption, isKeyDown);
break;
case UIKeyboardHIDUsageKeyboardRightAlt:
update(KeyboardModifierRightOption, isKeyDown);
update(kKeyboardModifierRightOption, isKeyDown);
break;
case UIKeyboardHIDUsageKeyboardLeftGUI:
update(KeyboardModifierLeftCommand, isKeyDown);
update(kKeyboardModifierLeftCommand, isKeyDown);
break;
case UIKeyboardHIDUsageKeyboardRightGUI:
update(KeyboardModifierRightCommand, isKeyDown);
update(kKeyboardModifierRightCommand, isKeyDown);
break;
default:
// If we didn't update any of the modifiers above, we're done.
return;
}
// Update the non-sided modifier flags to match the content of the sided ones.
update(KeyboardModifierShift,
_pressedModifiers & (KeyboardModifierRightShift | KeyboardModifierLeftShift));
update(KeyboardModifierControl,
_pressedModifiers & (KeyboardModifierRightControl | KeyboardModifierLeftControl));
update(KeyboardModifierOption,
_pressedModifiers & (KeyboardModifierRightOption | KeyboardModifierLeftOption));
update(KeyboardModifierCommand,
_pressedModifiers & (KeyboardModifierRightCommand | KeyboardModifierLeftCommand));
update(kKeyboardModifierShift,
_pressedModifiers & (kKeyboardModifierRightShift | kKeyboardModifierLeftShift));
update(kKeyboardModifierControl,
_pressedModifiers & (kKeyboardModifierRightControl | kKeyboardModifierLeftControl));
update(kKeyboardModifierOption,
_pressedModifiers & (kKeyboardModifierRightOption | kKeyboardModifierLeftOption));
update(kKeyboardModifierCommand,
_pressedModifiers & (kKeyboardModifierRightCommand | kKeyboardModifierLeftCommand));
}
// Because iOS differs from macOS in that the modifier flags still contain the
@ -239,7 +246,7 @@ static NSString* getEventCharacters(NSString* characters, UIKeyboardHIDUsage key
[self updatePressedModifiers:press];
// Replace the supplied modifier flags with our computed ones.
return _pressedModifiers | (press.key.modifierFlags & ~KeyboardModifierMask);
return _pressedModifiers | (press.key.modifierFlags & ~kKeyboardModifierMask);
}
@end

View File

@ -345,30 +345,30 @@ static NSString* AutofillIdFromDictionary(NSDictionary* dictionary) {
// The text input plugin then tries to determine which kind of autofill the text
// field needs. If the AutofillGroup the text field belongs to contains an
// autofillable text field that's password related, this text 's autofill type
// will be FlutterAutofillTypePassword. If autofill is disabled for a text field,
// then its type will be FlutterAutofillTypeNone. Otherwise the text field will
// have an autofill type of FlutterAutofillTypeRegular.
// will be kFlutterAutofillTypePassword. If autofill is disabled for a text field,
// then its type will be kFlutterAutofillTypeNone. Otherwise the text field will
// have an autofill type of kFlutterAutofillTypeRegular.
//
// The text input plugin creates a new UIView for every FlutterAutofillTypeNone
// The text input plugin creates a new UIView for every kFlutterAutofillTypeNone
// text field. The UIView instance is never reused for other flutter text fields
// since the software keyboard often uses the identity of a UIView to distinguish
// different views and provides the same predictive text suggestions or restore
// the composing region if a UIView is reused for a different flutter text field.
//
// The text input plugin creates a new "autofill context" if the text field has
// the type of FlutterAutofillTypePassword, to represent the AutofillGroup of
// the type of kFlutterAutofillTypePassword, to represent the AutofillGroup of
// the text field, and creates one FlutterTextInputView for every text field in
// the AutofillGroup.
//
// The text input plugin will try to reuse a UIView if a flutter text field's
// type is FlutterAutofillTypeRegular, and has the same autofill id.
// type is kFlutterAutofillTypeRegular, and has the same autofill id.
typedef NS_ENUM(NSInteger, FlutterAutofillType) {
// The field does not have autofillable content. Additionally if
// the field is currently in the autofill context, it will be
// removed from the context without triggering autofill save.
FlutterAutofillTypeNone,
FlutterAutofillTypeRegular,
FlutterAutofillTypePassword,
kFlutterAutofillTypeNone,
kFlutterAutofillTypeRegular,
kFlutterAutofillTypePassword,
};
static BOOL IsFieldPasswordRelated(NSDictionary* configuration) {
@ -405,22 +405,22 @@ static BOOL IsFieldPasswordRelated(NSDictionary* configuration) {
static FlutterAutofillType AutofillTypeOf(NSDictionary* configuration) {
for (NSDictionary* field in configuration[kAssociatedAutofillFields]) {
if (IsFieldPasswordRelated(field)) {
return FlutterAutofillTypePassword;
return kFlutterAutofillTypePassword;
}
}
if (IsFieldPasswordRelated(configuration)) {
return FlutterAutofillTypePassword;
return kFlutterAutofillTypePassword;
}
if (@available(iOS 10.0, *)) {
NSDictionary* autofill = configuration[kAutofillProperties];
UITextContentType contentType = ToUITextContentType(autofill[kAutofillHints]);
return !autofill || [contentType isEqualToString:@""] ? FlutterAutofillTypeNone
: FlutterAutofillTypeRegular;
return !autofill || [contentType isEqualToString:@""] ? kFlutterAutofillTypeNone
: kFlutterAutofillTypeRegular;
}
return FlutterAutofillTypeNone;
return kFlutterAutofillTypeNone;
}
static BOOL IsApproximatelyEqual(float x, float y, float delta) {
@ -2218,17 +2218,17 @@ static BOOL IsSelectionRectCloserToPoint(CGPoint point,
// Update the current active view.
switch (AutofillTypeOf(configuration)) {
case FlutterAutofillTypeNone:
case kFlutterAutofillTypeNone:
self.activeView = [self createInputViewWith:configuration];
break;
case FlutterAutofillTypeRegular:
case kFlutterAutofillTypeRegular:
// If the group does not involve password autofill, only install the
// input view that's being focused.
self.activeView = [self updateAndShowAutofillViews:nil
focusedField:configuration
isPasswordRelated:NO];
break;
case FlutterAutofillTypePassword:
case kFlutterAutofillTypePassword:
self.activeView = [self updateAndShowAutofillViews:configuration[kAssociatedAutofillFields]
focusedField:configuration
isPasswordRelated:YES];
@ -2266,7 +2266,7 @@ static BOOL IsSelectionRectCloserToPoint(CGPoint point,
for (NSDictionary* field in configuration[kAssociatedAutofillFields]) {
NSString* autofillId = AutofillIdFromDictionary(field);
if (autofillId && AutofillTypeOf(field) == FlutterAutofillTypeNone) {
if (autofillId && AutofillTypeOf(field) == kFlutterAutofillTypeNone) {
[_autofillContext removeObjectForKey:autofillId];
}
}
@ -2291,7 +2291,7 @@ static BOOL IsSelectionRectCloserToPoint(CGPoint point,
NSString* autofillId = AutofillIdFromDictionary(field);
NSAssert(autofillId, @"autofillId must not be null for field: %@", field);
BOOL hasHints = AutofillTypeOf(field) != FlutterAutofillTypeNone;
BOOL hasHints = AutofillTypeOf(field) != kFlutterAutofillTypeNone;
BOOL isFocused = [focusedId isEqualToString:autofillId];
if (isFocused) {

View File

@ -57,8 +57,8 @@ static NSString* const kTransformKey = @"transform";
* or at the beginning of the next (downstream).
*/
typedef NS_ENUM(NSUInteger, FlutterTextAffinity) {
FlutterTextAffinityUpstream,
FlutterTextAffinityDownstream
kFlutterTextAffinityUpstream,
kFlutterTextAffinityDownstream
};
/*
@ -267,7 +267,7 @@ static flutter::TextRange RangeFromBaseExtent(NSNumber* base,
_enableDeltaModel = [config[kEnableDeltaModel] boolValue];
NSDictionary* inputTypeInfo = config[kTextInputType];
_inputType = inputTypeInfo[kTextInputTypeName];
self.textAffinity = FlutterTextAffinityUpstream;
self.textAffinity = kFlutterTextAffinityUpstream;
_activeModel = std::make_unique<flutter::TextInputModel>();
}
@ -361,8 +361,8 @@ static flutter::TextRange RangeFromBaseExtent(NSNumber* base,
NSString* selectionAffinity = state[kSelectionAffinityKey];
if (selectionAffinity != nil) {
_textAffinity = [selectionAffinity isEqualToString:kTextAffinityUpstream]
? FlutterTextAffinityUpstream
: FlutterTextAffinityDownstream;
? kFlutterTextAffinityUpstream
: kFlutterTextAffinityDownstream;
}
NSString* text = state[kTextKey];
@ -464,8 +464,8 @@ static flutter::TextRange RangeFromBaseExtent(NSNumber* base,
}
- (NSString*)textAffinityString {
return (self.textAffinity == FlutterTextAffinityUpstream) ? kTextAffinityUpstream
: kTextAffinityDownstream;
return (self.textAffinity == kFlutterTextAffinityUpstream) ? kTextAffinityUpstream
: kTextAffinityDownstream;
}
- (BOOL)isComposing {

View File

@ -22,7 +22,7 @@ struct _FlGnomeSettings {
GSettings* interface_settings;
};
enum { PROP_0, PROP_INTERFACE_SETTINGS, PROP_LAST };
enum { kProp0, kPropInterfaceSettings, kPropLast };
static void fl_gnome_settings_iface_init(FlSettingsInterface* iface);
@ -98,7 +98,7 @@ static void fl_gnome_settings_set_property(GObject* object,
GParamSpec* pspec) {
FlGnomeSettings* self = FL_GNOME_SETTINGS(object);
switch (prop_id) {
case PROP_INTERFACE_SETTINGS:
case kPropInterfaceSettings:
fl_gnome_settings_set_interface_settings(
self, G_SETTINGS(g_value_get_object(value)));
break;
@ -122,7 +122,7 @@ static void fl_gnome_settings_class_init(FlGnomeSettingsClass* klass) {
object_class->set_property = fl_gnome_settings_set_property;
g_object_class_install_property(
object_class, PROP_INTERFACE_SETTINGS,
object_class, kPropInterfaceSettings,
g_param_spec_object(
kInterfaceSettings, kInterfaceSettings, kDesktopInterfaceSchema,
g_settings_get_type(),

View File

@ -9,11 +9,11 @@
G_DEFINE_INTERFACE(FlSettings, fl_settings, G_TYPE_OBJECT)
enum {
SIGNAL_CHANGED,
SIGNAL_LAST_SIGNAL,
kSignalChanged,
kSignalLastSignal,
};
static guint signals[SIGNAL_LAST_SIGNAL];
static guint signals[kSignalLastSignal];
static void fl_settings_default_init(FlSettingsInterface* iface) {
/**
@ -22,7 +22,7 @@ static void fl_settings_default_init(FlSettingsInterface* iface) {
*
* This signal is emitted after the settings have been changed.
*/
signals[SIGNAL_CHANGED] =
signals[kSignalChanged] =
g_signal_new("changed", G_TYPE_FROM_INTERFACE(iface), G_SIGNAL_RUN_LAST,
0, NULL, NULL, NULL, G_TYPE_NONE, 0);
}
@ -41,7 +41,7 @@ gdouble fl_settings_get_text_scaling_factor(FlSettings* self) {
void fl_settings_emit_changed(FlSettings* self) {
g_return_if_fail(FL_IS_SETTINGS(self));
g_signal_emit(self, signals[SIGNAL_CHANGED], 0);
g_signal_emit(self, signals[kSignalChanged], 0);
}
FlSettings* fl_settings_new() {

View File

@ -51,7 +51,7 @@ static const FlSetting kAllSettings[] = {
static constexpr char kClockFormat12Hour[] = "12h";
static constexpr char kGtkThemeDarkSuffix[] = "-dark";
typedef enum { DEFAULT, PREFER_DARK, PREFER_LIGHT } ColorScheme;
typedef enum { kDefault, kPreferDark, kPreferLight } ColorScheme;
struct _FlSettingsPortal {
GObject parent_instance;
@ -172,7 +172,7 @@ static FlColorScheme fl_settings_portal_get_color_scheme(FlSettings* settings) {
g_autoptr(GVariant) value = nullptr;
if (get_value(self, &kColorScheme, &value)) {
if (g_variant_get_uint32(value) == PREFER_DARK) {
if (g_variant_get_uint32(value) == kPreferDark) {
color_scheme = FL_COLOR_SCHEME_DARK;
}
} else if (get_value(self, &kGtkTheme, &value)) {

View File

@ -50,11 +50,11 @@ static constexpr char kNoneInputType[] = "TextInputType.none";
static constexpr int64_t kClientIdUnset = -1;
typedef enum {
FL_TEXT_INPUT_TYPE_TEXT,
kFlTextInputTypeText,
// Send newline when multi-line and enter is pressed.
FL_TEXT_INPUT_TYPE_MULTILINE,
kFlTextInputTypeMultiline,
// The input method is not shown at all.
FL_TEXT_INPUT_TYPE_NONE,
kFlTextInputTypeNone,
} FlTextInputType;
struct FlTextInputPluginPrivate {
@ -373,7 +373,7 @@ static FlMethodResponse* set_client(FlTextInputPlugin* self, FlValue* args) {
priv->enable_delta_model = enable_delta_model;
// Reset the input type, then set only if appropriate.
priv->input_type = FL_TEXT_INPUT_TYPE_TEXT;
priv->input_type = kFlTextInputTypeText;
FlValue* input_type_value =
fl_value_lookup_string(config_value, kTextInputTypeKey);
if (fl_value_get_type(input_type_value) == FL_VALUE_TYPE_MAP) {
@ -382,9 +382,9 @@ static FlMethodResponse* set_client(FlTextInputPlugin* self, FlValue* args) {
if (fl_value_get_type(input_type_name) == FL_VALUE_TYPE_STRING) {
const gchar* input_type = fl_value_get_string(input_type_name);
if (g_strcmp0(input_type, kMultilineInputType) == 0) {
priv->input_type = FL_TEXT_INPUT_TYPE_MULTILINE;
priv->input_type = kFlTextInputTypeMultiline;
} else if (g_strcmp0(input_type, kNoneInputType) == 0) {
priv->input_type = FL_TEXT_INPUT_TYPE_NONE;
priv->input_type = kFlTextInputTypeNone;
}
}
}
@ -405,7 +405,7 @@ static FlMethodResponse* hide(FlTextInputPlugin* self) {
static FlMethodResponse* show(FlTextInputPlugin* self) {
FlTextInputPluginPrivate* priv = static_cast<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
if (priv->input_type == FL_TEXT_INPUT_TYPE_NONE) {
if (priv->input_type == kFlTextInputTypeNone) {
return hide(self);
}
@ -630,7 +630,7 @@ static gboolean fl_text_input_plugin_filter_keypress_default(
case GDK_KEY_Return:
case GDK_KEY_KP_Enter:
case GDK_KEY_ISO_Enter:
if (priv->input_type == FL_TEXT_INPUT_TYPE_MULTILINE) {
if (priv->input_type == kFlTextInputTypeMultiline) {
priv->text_model->AddCodePoint('\n');
text = "\n";
changed = TRUE;
@ -686,7 +686,7 @@ static void fl_text_input_plugin_init(FlTextInputPlugin* self) {
fl_text_input_plugin_get_instance_private(self));
priv->client_id = kClientIdUnset;
priv->input_type = FL_TEXT_INPUT_TYPE_TEXT;
priv->input_type = kFlTextInputTypeText;
priv->text_model = new flutter::TextInputModel();
}

View File

@ -70,7 +70,7 @@ typedef struct _FlViewChild {
GdkRectangle geometry;
} FlViewChild;
enum { PROP_FLUTTER_PROJECT = 1, PROP_LAST };
enum { kPropFlutterProject = 1, kPropLast };
static void fl_view_plugin_registry_iface_init(
FlPluginRegistryInterface* iface);
@ -531,7 +531,7 @@ static void fl_view_set_property(GObject* object,
FlView* self = FL_VIEW(object);
switch (prop_id) {
case PROP_FLUTTER_PROJECT:
case kPropFlutterProject:
g_set_object(&self->project,
static_cast<FlDartProject*>(g_value_get_object(value)));
break;
@ -548,7 +548,7 @@ static void fl_view_get_property(GObject* object,
FlView* self = FL_VIEW(object);
switch (prop_id) {
case PROP_FLUTTER_PROJECT:
case kPropFlutterProject:
g_value_set_object(value, self->project);
break;
default:
@ -876,7 +876,7 @@ static void fl_view_class_init(FlViewClass* klass) {
container_class->get_child_property = fl_view_get_child_property;
g_object_class_install_property(
G_OBJECT_CLASS(klass), PROP_FLUTTER_PROJECT,
G_OBJECT_CLASS(klass), kPropFlutterProject,
g_param_spec_object(
"flutter-project", "flutter-project", "Flutter project in use",
fl_dart_project_get_type(),

View File

@ -15,7 +15,7 @@ struct _FlViewAccessible {
GHashTable* semantics_nodes_by_id;
};
enum { PROP_0, PROP_ENGINE, PROP_LAST };
enum { kProp0, kPropEngine, kPropLast };
G_DEFINE_TYPE(FlViewAccessible,
fl_view_accessible,
@ -85,7 +85,7 @@ static void fl_view_accessible_set_property(GObject* object,
GParamSpec* pspec) {
FlViewAccessible* self = FL_VIEW_ACCESSIBLE(object);
switch (prop_id) {
case PROP_ENGINE:
case kPropEngine:
init_engine(self, FL_ENGINE(g_value_get_object(value)));
break;
default:
@ -115,7 +115,7 @@ static void fl_view_accessible_class_init(FlViewAccessibleClass* klass) {
G_OBJECT_CLASS(klass)->set_property = fl_view_accessible_set_property;
g_object_class_install_property(
G_OBJECT_CLASS(klass), PROP_ENGINE,
G_OBJECT_CLASS(klass), kPropEngine,
g_param_spec_object(
"engine", "engine", "Flutter engine", fl_engine_get_type(),
static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |

View File

@ -155,9 +155,9 @@ class ScriptCompletionTaskObserver {
return;
}
if (!has_terminated) {
if (!has_terminated_) {
// Only try to terminate the loop once.
has_terminated = true;
has_terminated_ = true;
fml::TaskRunner::RunNowOrPostTask(main_task_runner_, []() {
fml::MessageLoop::GetCurrent().Terminate();
});
@ -169,7 +169,7 @@ class ScriptCompletionTaskObserver {
fml::RefPtr<fml::TaskRunner> main_task_runner_;
bool run_forever_ = false;
std::optional<DartErrorCode> last_error_;
bool has_terminated = false;
bool has_terminated_ = false;
FML_DISALLOW_COPY_AND_ASSIGN(ScriptCompletionTaskObserver);
};