From aa5298b270379f347acf14f87252e296e88191ae Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Mon, 28 Oct 2024 12:34:59 -0700 Subject: [PATCH] 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: https://github.com/flutter/flutter/issues/137801 --- .../flutter/shell/platform/darwin/common/BUILD.gn | 7 ++----- .../platform/darwin/common/buffer_conversions.mm | 12 ++++++------ .../shell/platform/darwin/common/command_line.mm | 2 ++ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/common/BUILD.gn b/engine/src/flutter/shell/platform/darwin/common/BUILD.gn index 3d509700e0..58638a5bc0 100644 --- a/engine/src/flutter/shell/platform/darwin/common/BUILD.gn +++ b/engine/src/flutter/shell/platform/darwin/common/BUILD.gn @@ -9,8 +9,8 @@ import("//flutter/testing/testing.gni") import("framework_common.gni") source_set("common") { - cflags_objc = flutter_cflags_objc - cflags_objcc = flutter_cflags_objcc + cflags_objc = flutter_cflags_objc_arc + cflags_objcc = flutter_cflags_objcc_arc sources = [ "buffer_conversions.h", @@ -40,9 +40,6 @@ source_set("common") { # See: Upstream clang change: https://reviews.llvm.org/D150397 # See: https://github.com/flutter/flutter/issues/133777 source_set("availability_version_check") { - cflags_objc = flutter_cflags_objc - cflags_objcc = flutter_cflags_objcc - sources = [ "availability_version_check.cc" ] deps = [ "//flutter/fml" ] diff --git a/engine/src/flutter/shell/platform/darwin/common/buffer_conversions.mm b/engine/src/flutter/shell/platform/darwin/common/buffer_conversions.mm index 1aa07df265..749f35a956 100644 --- a/engine/src/flutter/shell/platform/darwin/common/buffer_conversions.mm +++ b/engine/src/flutter/shell/platform/darwin/common/buffer_conversions.mm @@ -7,22 +7,22 @@ #include "flutter/fml/macros.h" #include "flutter/fml/platform/darwin/scoped_nsobject.h" +static_assert(__has_feature(objc_arc), "ARC must be enabled."); + namespace flutter { namespace { class NSDataMapping : public fml::Mapping { public: - explicit NSDataMapping(NSData* data) : data_([data retain]) {} + explicit NSDataMapping(NSData* data) : data_(data) {} - size_t GetSize() const override { return [data_.get() length]; } + size_t GetSize() const override { return data_.length; } - const uint8_t* GetMapping() const override { - return static_cast([data_.get() bytes]); - } + const uint8_t* GetMapping() const override { return static_cast(data_.bytes); } bool IsDontNeedSafe() const override { return false; } private: - fml::scoped_nsobject data_; + NSData* data_; FML_DISALLOW_COPY_AND_ASSIGN(NSDataMapping); }; } // namespace diff --git a/engine/src/flutter/shell/platform/darwin/common/command_line.mm b/engine/src/flutter/shell/platform/darwin/common/command_line.mm index d9f42e634f..47c8ef2b8e 100644 --- a/engine/src/flutter/shell/platform/darwin/common/command_line.mm +++ b/engine/src/flutter/shell/platform/darwin/common/command_line.mm @@ -6,6 +6,8 @@ #import +static_assert(__has_feature(objc_arc), "ARC must be enabled."); + namespace flutter { fml::CommandLine CommandLineFromNSProcessInfo(NSProcessInfo* processInfoOrNil) {