mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Runtime: Add ObjC weak referencing support to SwiftObject.
We were missing -_tryRetain, -_isDeallocating, -allowsWeakReference and -retainWeakReference implementations on SwiftObject, so forming an ObjC weak reference to a pure Swift object always failed and produced a nil reference. Fixes rdar://problem/18637774. Swift SVN r22710
This commit is contained in:
@@ -32,11 +32,6 @@
|
||||
|
||||
using namespace swift;
|
||||
|
||||
namespace swift {
|
||||
extern "C" HeapObject *swift_tryRetain(HeapObject *object);
|
||||
};
|
||||
|
||||
|
||||
HeapObject *
|
||||
swift::swift_allocObject(HeapMetadata const *metadata,
|
||||
size_t requiredSize,
|
||||
@@ -331,6 +326,17 @@ static HeapObject *_swift_tryRetain_(HeapObject *object) {
|
||||
}
|
||||
auto swift::_swift_tryRetain = _swift_tryRetain_;
|
||||
|
||||
bool swift::swift_isDeallocating(HeapObject *object) {
|
||||
return _swift_isDeallocating(object);
|
||||
}
|
||||
static bool _swift_isDeallocating_(HeapObject *object) {
|
||||
if (!object) return false;
|
||||
uint32_t count
|
||||
= reinterpret_cast<std::atomic<uint32_t>*>(&object->refCount)->load();
|
||||
return count & RC_DEALLOCATING_BIT;
|
||||
}
|
||||
auto swift::_swift_isDeallocating = _swift_isDeallocating_;
|
||||
|
||||
#endif
|
||||
|
||||
void swift::swift_retainUnowned(HeapObject *object) {
|
||||
|
||||
Reference in New Issue
Block a user