Skip to content

Commit aa5298b

Browse files
authored
iOS/macOS: migrate darwin/common to ARC (flutter/engine#56155)
Migrates //flutter/shell/platform/darwin/common` targets to ARC. Most of these were already ARC compatible. This does add use of the `FLUTTER_ASSERT_ARC` define since that is defined in a public framework header, but this code has no dependency on the framework. This removes `flutter_cflags_objc` and `flutter_cflags_objcc` compile configs from `availability_version_check_unittests` since that target is pure C++ and contains no Objective-C code. No test changes since this there is no semantic change to the code. Issue: flutter#137801
1 parent d66f209 commit aa5298b

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

engine/src/flutter/shell/platform/darwin/common/BUILD.gn

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import("//flutter/testing/testing.gni")
99
import("framework_common.gni")
1010

1111
source_set("common") {
12-
cflags_objc = flutter_cflags_objc
13-
cflags_objcc = flutter_cflags_objcc
12+
cflags_objc = flutter_cflags_objc_arc
13+
cflags_objcc = flutter_cflags_objcc_arc
1414

1515
sources = [
1616
"buffer_conversions.h",
@@ -40,9 +40,6 @@ source_set("common") {
4040
# See: Upstream clang change: https://reviews.llvm.org/D150397
4141
# See: https://github.com/flutter/flutter/issues/133777
4242
source_set("availability_version_check") {
43-
cflags_objc = flutter_cflags_objc
44-
cflags_objcc = flutter_cflags_objcc
45-
4643
sources = [ "availability_version_check.cc" ]
4744

4845
deps = [ "//flutter/fml" ]

engine/src/flutter/shell/platform/darwin/common/buffer_conversions.mm

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@
77
#include "flutter/fml/macros.h"
88
#include "flutter/fml/platform/darwin/scoped_nsobject.h"
99

10+
static_assert(__has_feature(objc_arc), "ARC must be enabled.");
11+
1012
namespace flutter {
1113
namespace {
1214
class NSDataMapping : public fml::Mapping {
1315
public:
14-
explicit NSDataMapping(NSData* data) : data_([data retain]) {}
16+
explicit NSDataMapping(NSData* data) : data_(data) {}
1517

16-
size_t GetSize() const override { return [data_.get() length]; }
18+
size_t GetSize() const override { return data_.length; }
1719

18-
const uint8_t* GetMapping() const override {
19-
return static_cast<const uint8_t*>([data_.get() bytes]);
20-
}
20+
const uint8_t* GetMapping() const override { return static_cast<const uint8_t*>(data_.bytes); }
2121

2222
bool IsDontNeedSafe() const override { return false; }
2323

2424
private:
25-
fml::scoped_nsobject<NSData> data_;
25+
NSData* data_;
2626
FML_DISALLOW_COPY_AND_ASSIGN(NSDataMapping);
2727
};
2828
} // namespace

engine/src/flutter/shell/platform/darwin/common/command_line.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#import <Foundation/Foundation.h>
88

9+
static_assert(__has_feature(objc_arc), "ARC must be enabled.");
10+
911
namespace flutter {
1012

1113
fml::CommandLine CommandLineFromNSProcessInfo(NSProcessInfo* processInfoOrNil) {

0 commit comments

Comments
 (0)