From cd3de6d3ad25499bd1c96f7f5b99cc3452fdec34 Mon Sep 17 00:00:00 2001 From: Stefan Karschti Date: Fri, 19 Jan 2024 18:00:38 +0200 Subject: [PATCH] Fix Custom Drawable Layer usage of private headers (#2039) --- .../app/ExampleCustomDrawableStyleLayer.h | 7 +------ .../app/ExampleCustomDrawableStyleLayer.mm | 6 +----- .../darwin/src/MLNCustomDrawableStyleLayer.h | 11 ++++++++++- .../darwin/src/MLNCustomDrawableStyleLayer.mm | 18 ++++++------------ 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/platform/darwin/app/ExampleCustomDrawableStyleLayer.h b/platform/darwin/app/ExampleCustomDrawableStyleLayer.h index 2c5e558bc..4dfde0d9c 100644 --- a/platform/darwin/app/ExampleCustomDrawableStyleLayer.h +++ b/platform/darwin/app/ExampleCustomDrawableStyleLayer.h @@ -1,11 +1,6 @@ #import "Mapbox.h" -#import "MLNFoundation.h" -#import "MLNStyleValue.h" -#import "MLNStyleLayer.h" -#import "MLNGeometry.h" - -@interface ExampleCustomDrawableStyleLayer : MLNStyleLayer +@interface ExampleCustomDrawableStyleLayer : MLNCustomDrawableStyleLayer - (instancetype)initWithIdentifier:(NSString *)identifier; diff --git a/platform/darwin/app/ExampleCustomDrawableStyleLayer.mm b/platform/darwin/app/ExampleCustomDrawableStyleLayer.mm index a3756dce8..dce804d73 100644 --- a/platform/darwin/app/ExampleCustomDrawableStyleLayer.mm +++ b/platform/darwin/app/ExampleCustomDrawableStyleLayer.mm @@ -1,10 +1,6 @@ #import "ExampleCustomDrawableStyleLayer.h" #import "MLNStyleLayer.h" - -#import "MLNCustomDrawableStyleLayer_Private.h" -#import "MLNStyle_Private.h" -#import "MLNStyleLayer_Private.h" -#import "MLNGeometry_Private.h" +#import "MLNCustomDrawableStyleLayer.h" #include #include diff --git a/platform/darwin/src/MLNCustomDrawableStyleLayer.h b/platform/darwin/src/MLNCustomDrawableStyleLayer.h index 6c581b373..bd84e13ae 100644 --- a/platform/darwin/src/MLNCustomDrawableStyleLayer.h +++ b/platform/darwin/src/MLNCustomDrawableStyleLayer.h @@ -1,10 +1,19 @@ +#import + +#import "MLNFoundation.h" #import "MLNFoundation.h" #import "MLNStyleValue.h" #import "MLNStyleLayer.h" #import "MLNGeometry.h" +#ifdef __cplusplus +#include +#endif + @interface MLNCustomDrawableStyleLayer : MLNStyleLayer -- (instancetype)initWithIdentifier:(NSString *)identifier; +#ifdef __cplusplus +- (instancetype)initWithPendingLayer:(std::unique_ptr)pendingLayer; +#endif @end diff --git a/platform/darwin/src/MLNCustomDrawableStyleLayer.mm b/platform/darwin/src/MLNCustomDrawableStyleLayer.mm index be3698b13..b8ddaae46 100644 --- a/platform/darwin/src/MLNCustomDrawableStyleLayer.mm +++ b/platform/darwin/src/MLNCustomDrawableStyleLayer.mm @@ -14,18 +14,12 @@ @implementation MLNCustomDrawableStyleLayer -/// @note -/// Inherit MLNCustomDrawableStyleLayer class and override initWithIdentifier method to create and attach a valid CustomDrawableLayerHost instance -/// Example: -/// - (instancetype)initWithIdentifier:(NSString *)identifier { -/// auto layer = std::make_unique(identifier.UTF8String, -/// std::make_unique(self)); -/// return self = [super initWithPendingLayer:std::move(layer)]; -/// } -/// -- (instancetype)initWithIdentifier:(NSString *)identifier { - auto layer = std::make_unique(identifier.UTF8String, nullptr); - return self = [super initWithPendingLayer:std::move(layer)]; +- (instancetype)initWithRawLayer:(mbgl::style::Layer *)rawLayer { + return [super initWithRawLayer:rawLayer]; +} + +- (instancetype)initWithPendingLayer:(std::unique_ptr)pendingLayer { + return [super initWithPendingLayer:std::move(pendingLayer)]; } @end