//===--- NSSwiftXXXBase.mm.gyb - Cocoa bases for Swift container buffers --===// // // This source file is part of the Swift.org open source project // // Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// // // This file defines: // // NSSwiftArrayBase, NSSwiftDictionaryBase, and eventually, // NSSwiftStringBase // // To optimize bridging between Swift containers and their Cocoa // counterparts, we derive Swift containers' buffers from the // corresponding Cocoa classes; that way we can just hand a buffer off // to Cocoa when it holds bridged types. // //===----------------------------------------------------------------------===// #import #include #include #if __has_include() #include #endif #include "swift/Runtime/HeapObject.h" #include "swift/Runtime/Metadata.h" #include "swift/Runtime/ObjCBridge.h" #include "llvm/ADT/DenseMap.h" #include "Private.h" #include #include #include #include "../shims/shims.h" // Redeclare these just we check them. extern "C" id _objc_rootAutorelease(id); using namespace swift; % for Class in ('Array','Dictionary'): @interface NSSwift${Class}Base : NS${Class} { SWIFT_HEAPOBJECT_NON_OBJC_MEMBERS; } @end @implementation NSSwift${Class}Base + (void)load { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" class_setSuperclass( objc_getClass("NSSwift${Class}"), [NSSwift${Class}Base class]); #pragma clang diagnostic pop } - (id)retain { auto SELF = reinterpret_cast(self); swift_retain(SELF); return self; } - (oneway void)release { auto SELF = reinterpret_cast(self); swift_release(SELF); } - (id)autorelease { return _objc_rootAutorelease(self); } #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wobjc-missing-super-calls" - (void)dealloc { auto SELF = reinterpret_cast(self); swift_deallocObject(SELF, 0); } #pragma clang diagnostic pop - (bool) __usesNativeSwiftReferenceCounting { return true; } @end % end