Skip to content

Commit e7c2f89

Browse files
lorenteyshahmishal
authored andcommitted
[shims] Add AppKit overlay shims
(cherry picked from commit c8523e5) (cherry picked from commit 250f166)
1 parent 6695573 commit e7c2f89

File tree

3 files changed

+129
-0
lines changed

3 files changed

+129
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
//===--- AppKitOverlayShims.h ---===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===--------------------===//
12+
13+
#ifndef SWIFT_STDLIB_SHIMS_APPKIT_OVERLAY_H
14+
#define SWIFT_STDLIB_SHIMS_APPKIT_OVERLAY_H
15+
16+
#include <TargetConditionals.h>
17+
18+
#if !TARGET_OS_IPHONE
19+
20+
@import AppKit;
21+
22+
23+
//===--------------------===//
24+
// diffable data source //
25+
//===--------------------===//
26+
27+
#if __has_feature(nullability)
28+
#pragma clang assume_nonnull begin
29+
#endif
30+
31+
typedef NSCollectionViewItem * _Nullable(^NSDiffableDataSourceCollectionViewItemProvider)(NSCollectionView*, NSIndexPath *indexPath, id identifier) API_UNAVAILABLE(ios);
32+
typedef NSView<NSCollectionViewElement> * _Nullable(^NSDiffableDataSourceSupplementaryViewProvider)(NSCollectionView *, NSString *kind, NSIndexPath *indexPath) API_UNAVAILABLE(ios);
33+
34+
@class __NSDiffableDataSourceSnapshot;
35+
36+
API_AVAILABLE(macos(10.15)) API_UNAVAILABLE(ios)
37+
@interface __NSDiffableDataSource : NSObject
38+
39+
- (instancetype)initWithNSCollectionView:(NSCollectionView*)nsCollectionView
40+
itemProvider:(NSDiffableDataSourceCollectionViewItemProvider)itemProvider;
41+
42+
@property(nonatomic,weak,readonly,nullable) NSCollectionView *nsCollectionView;
43+
@property(nonatomic,nullable,copy) NSDiffableDataSourceSupplementaryViewProvider nsSupplementaryViewProvider;
44+
45+
- (NSString*)description;
46+
47+
- (instancetype)init NS_UNAVAILABLE;
48+
49+
@property(nonatomic,readonly) NSInteger numberOfItems;
50+
@property(nonatomic,readonly) NSInteger numberOfSections;
51+
@property(nonatomic,readonly) NSArray *sectionIdentifiers;
52+
@property(nonatomic,readonly) NSArray *itemIdentifiers;
53+
54+
- (NSInteger)numberOfItemsInSection:(id)sectionIdentifier;
55+
- (NSArray*)itemIdentifiersInSectionWithIdentifier:(id)sectionIdentifier;
56+
- (nullable id)sectionIdentifierForSectionContainingItemIdentifier:(id)identifier;
57+
58+
- (NSInteger)indexOfItemIdentifier:(id)itemIdentifier;
59+
- (NSInteger)indexOfSectionIdentifier:(id)sectionIdentifier;
60+
61+
- (void)appendItemsWithIdentifiers:(NSArray*)identifiers;
62+
- (void)appendItemsWithIdentifiers:(NSArray*)identifiers intoSectionWithIdentifier:(id _Nullable)sectionIdentifier;
63+
64+
- (void)insertItemsWithIdentifiers:(NSArray*)identifiers beforeItemWithIdentifier:(id)itemIdentifier;
65+
- (void)insertItemsWithIdentifiers:(NSArray*)identifiers afterItemWithIdentifier:(id)itemIdentifier;
66+
67+
- (void)deleteItemsWithIdentifiers:(NSArray*)identifiers;
68+
- (void)deleteAllItems;
69+
70+
- (void)moveItemWithIdentifier:(id)fromIdentifier beforeItemWithIdentifier:(id)toIdentifier;
71+
- (void)moveItemWithIdentifier:(id)fromIdentifier afterItemWithIdentifier:(id)toIdentifier;
72+
73+
- (void)reloadItemsWithIdentifiers:(NSArray*)identifiers;
74+
75+
- (void)appendSectionsWithIdentifiers:(NSArray*)sectionIdentifiers;
76+
77+
- (void)insertSectionsWithIdentifiers:(NSArray*)sectionIdentifiers beforeSectionWithIdentifier:(id)toSectionIdentifier;
78+
- (void)insertSectionsWithIdentifiers:(NSArray*)sectionIdentifiers afterSectionWithIdentifier:(id)toSectionIdentifier;
79+
80+
- (void)deleteSectionsWithIdentifiers:(NSArray*)sectionIdentifiers;
81+
82+
- (void)moveSectionWithIdentifier:(id)fromSectionIdentifier beforeSectionWithIdentifier:(id)toSectionIdentifier;
83+
- (void)moveSectionWithIdentifier:(id)fromSectionIdentifier afterSectionWithIdentifier:(id)toSectionIdentifier;
84+
85+
- (void)reloadSectionsWithIdentifiers:(NSArray*)sectionIdentifiers;
86+
87+
- (nullable id)itemIdentifierForIndexPath:(NSIndexPath*)indexPath;
88+
- (nullable NSIndexPath*)indexPathForItemIdentifier:(id)identifier;
89+
90+
- (__NSDiffableDataSourceSnapshot*)snapshot;
91+
- (__NSDiffableDataSourceSnapshot*)emptySnapshot;
92+
- (void)applyDifferencesFromSnapshot:(__NSDiffableDataSourceSnapshot*)snapshot;
93+
- (void)reloadFromSnapshot:(__NSDiffableDataSourceSnapshot*)snapshot;
94+
- (void)applyDifferencesFromSnapshot:(__NSDiffableDataSourceSnapshot *)snapshot animatingDifferences:(BOOL)animatingDifferences;
95+
- (void)applyDifferencesFromSnapshot:(__NSDiffableDataSourceSnapshot *)snapshot animatingDifferences:(BOOL)animatingDifferences completion:(void(^ _Nullable)(void))completion;
96+
97+
@property(nonatomic,copy) NSDiffableDataSourceCollectionViewItemProvider collectionViewItemProvider;
98+
99+
- (NSInteger)_numberOfSectionsForNSCollectionView:(NSCollectionView*)collectionView NS_SWIFT_NAME(_numberOfSectionsForNSCollectionView(_:));
100+
- (NSInteger)_numberOfItemsInSection:(NSInteger)section nsCollectionView:(NSCollectionView*)collectionView NS_SWIFT_NAME(_numberOfItemsInSection(_:nsCollectionView:));
101+
- (NSCollectionViewItem *)_itemAtIndexPath:(NSIndexPath*)indexPath nsCollectionView:(NSCollectionView*)collectionView NS_SWIFT_NAME(_itemAtIndexPath(_:nsCollectionView:));
102+
- (NSView *)_viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath nsCollectionView:(NSCollectionView *)collectionView NS_SWIFT_NAME(_viewForSupplementaryElementOfKind(_:atIndexPath:nsCollectionView:));
103+
104+
@end
105+
106+
107+
API_AVAILABLE(macos(10.15)) API_UNAVAILABLE(ios)
108+
@interface __NSDiffableDataSourceSnapshot : __NSDiffableDataSource<NSCopying>
109+
- (instancetype)init;
110+
@end
111+
112+
API_AVAILABLE(macos(10.15)) API_UNAVAILABLE(ios)
113+
@interface NSDiffableDataSourceSnapshot()
114+
@property(nonatomic,readonly) __NSDiffableDataSourceSnapshot *impl;
115+
- (instancetype)initWithDataSource:(__NSDiffableDataSource * _Nullable)dataSource;
116+
@end
117+
118+
#if __has_feature(nullability)
119+
#pragma clang assume_nonnull end
120+
#endif
121+
122+
#endif // !TARGET_OS_IPHONE
123+
124+
#endif // SWIFT_STDLIB_SHIMS_APPKIT_OVERLAY_H

stdlib/public/SwiftShims/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ set(sources
2626
OSOverlayShims.h
2727
ObjectiveCOverlayShims.h
2828
SafariServicesOverlayShims.h
29+
AppKitOverlayShims.h
2930
UIKitOverlayShims.h
3031
XCTestOverlayShims.h
3132
XPCOverlayShims.h

stdlib/public/SwiftShims/module.modulemap

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ module _SwiftSafariServicesOverlayShims {
4848
header "SafariServicesOverlayShims.h"
4949
}
5050

51+
module _SwiftAppKitOverlayShims {
52+
header "AppKitOverlayShims.h"
53+
}
54+
5155
module _SwiftUIKitOverlayShims {
5256
header "UIKitOverlayShims.h"
5357
}

0 commit comments

Comments
 (0)