From bef76e554ea91878483cfdfec4d2aabf724d48e7 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Fri, 26 Apr 2024 08:28:11 -0700 Subject: [PATCH] Fix function type cast warnings for macOS embedder callbacks (flutter/engine#52377) The latest version of Clang is reporting warnings from the -Wcast-function-type-mismatch check when a function taking a __strong pointer parameter is converted to a void* parameter. --- .../darwin/macos/framework/Source/FlutterEngine.mm | 3 ++- .../darwin/macos/framework/Source/FlutterRenderer.mm | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index b7dd26aedf4..2670c0faf0b 100644 --- a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -399,7 +399,8 @@ constexpr char kTextPlainFormat[] = "text/plain"; // Callbacks provided to the engine. See the called methods for documentation. #pragma mark - Static methods provided to engine configuration -static void OnPlatformMessage(const FlutterPlatformMessage* message, FlutterEngine* engine) { +static void OnPlatformMessage(const FlutterPlatformMessage* message, void* user_data) { + FlutterEngine* engine = (__bridge FlutterEngine*)user_data; [engine engineCallbackOnPlatformMessage:message]; } diff --git a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderer.mm b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderer.mm index 815336227f3..8e5adde74af 100644 --- a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderer.mm +++ b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderer.mm @@ -12,22 +12,22 @@ #pragma mark - Static callbacks that require the engine. -static FlutterMetalTexture OnGetNextDrawable(FlutterEngine* engine, - const FlutterFrameInfo* frameInfo) { +static FlutterMetalTexture OnGetNextDrawable(void* user_data, const FlutterFrameInfo* frameInfo) { NSCAssert(NO, @"The renderer config should not be used to get the next drawable."); return FlutterMetalTexture{}; } -static bool OnPresentDrawable(FlutterEngine* engine, const FlutterMetalTexture* texture) { +static bool OnPresentDrawable(void* user_data, const FlutterMetalTexture* texture) { NSCAssert(NO, @"The renderer config should not be used to present drawable."); return false; } -static bool OnAcquireExternalTexture(FlutterEngine* engine, +static bool OnAcquireExternalTexture(void* user_data, int64_t textureIdentifier, size_t width, size_t height, FlutterMetalExternalTexture* metalTexture) { + FlutterEngine* engine = (__bridge FlutterEngine*)user_data; return [engine.renderer populateTextureWithIdentifier:textureIdentifier metalTexture:metalTexture]; }