PromiseKit/Sources/AnyPromise+Private.h
Max Howell 1339ca0695 Rewrite AnyPromise to use composition
Our existing hack broke the new Xcode build system (see #724).

Also, CocoaPods 1.4 didn’t like it.

So I had to rewrite with composition instead adding additional methods via an objc category.

The cause of the issue was that the framework required that the -Swift.h file be generated before the objc portions were built (since the objc extended the swift portion), and neither build system guarantees this.

All tests pass. However it is not as efficient as before. Could use some optimizations.
2018-02-12 15:27:50 -05:00

33 lines
1021 B
Objective-C

@import Foundation.NSError;
@import Foundation.NSPointerArray;
#if TARGET_OS_IPHONE
#define NSPointerArrayMake(N) ({ \
NSPointerArray *aa = [NSPointerArray strongObjectsPointerArray]; \
aa.count = N; \
aa; \
})
#else
static inline NSPointerArray * __nonnull NSPointerArrayMake(NSUInteger count) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
NSPointerArray *aa = [[NSPointerArray class] respondsToSelector:@selector(strongObjectsPointerArray)]
? [NSPointerArray strongObjectsPointerArray]
: [NSPointerArray pointerArrayWithStrongObjects];
#pragma clang diagnostic pop
aa.count = count;
return aa;
}
#endif
#define IsError(o) [o isKindOfClass:[NSError class]]
#define IsPromise(o) [o isKindOfClass:[AnyPromise class]]
#import "AnyPromise.h"
@class PMKArray;
@interface AnyPromise ()
- (void)__pipe:(void(^ __nonnull)(__nullable id))block NS_REFINED_FOR_SWIFT;
@end