Skip to content

Commit 4edf5cf

Browse files
committed
Fix AGWeakAttribute link issue
1 parent 16cd4d8 commit 4edf5cf

File tree

4 files changed

+3
-30
lines changed

4 files changed

+3
-30
lines changed

Sources/OpenAttributeGraph/Attribute/Weak/AnyWeakAttribute.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,19 @@
77

88
public import OpenAttributeGraphCxx
99

10-
// FIXME: For some unknown reason, AnyWeakAttribute and WeakAttribute's symbol can't be linked.
11-
1210
extension AnyWeakAttribute {
13-
@_alwaysEmitIntoClient
1411
public init(_ attribute: AnyAttribute?) {
1512
self = __OAGCreateWeakAttribute(attribute ?? .nil)
1613
}
1714

18-
@_alwaysEmitIntoClient
1915
public init<Value>(_ weakAttribute: WeakAttribute<Value>) {
2016
self = weakAttribute.base
2117
}
2218

23-
@_alwaysEmitIntoClient
2419
public func unsafeCast<Value>(to _: Value.Type) -> WeakAttribute<Value> {
2520
WeakAttribute(base: self)
2621
}
2722

28-
@_alwaysEmitIntoClient
2923
public var attribute: AnyAttribute? {
3024
get {
3125
let attribute = __OAGWeakAttributeGetAttribute(self)
@@ -38,21 +32,14 @@ extension AnyWeakAttribute {
3832
}
3933

4034
extension AnyWeakAttribute: Swift.Hashable {
41-
@_alwaysEmitIntoClient
4235
public static func == (lhs: AnyWeakAttribute, rhs: AnyWeakAttribute) -> Bool {
4336
lhs._details.identifier == rhs._details.identifier && lhs._details.seed == rhs._details.seed
4437
}
4538

46-
@_alwaysEmitIntoClient
4739
public func hash(into hasher: inout Hasher) {
4840
hasher.combine(_details.identifier)
4941
hasher.combine(_details.seed)
5042
}
51-
52-
@_alwaysEmitIntoClient
53-
public var hashValue: Int {
54-
_hashValue(for: self)
55-
}
5643
}
5744

5845
extension AnyWeakAttribute: Swift.CustomStringConvertible {

Sources/OpenAttributeGraph/Attribute/Weak/WeakAttribute.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,65 +7,52 @@
77

88
public import OpenAttributeGraphCxx
99

10-
// FIXME: For some unknown reason, AnyWeakAttribute and WeakAttribute's symbol can't be linked.
11-
1210
@frozen
1311
@propertyWrapper
1412
@dynamicMemberLookup
1513
public struct WeakAttribute<Value> {
16-
@usableFromInline
1714
var base: AnyWeakAttribute
1815

19-
@_alwaysEmitIntoClient
2016
public init(base: AnyWeakAttribute) {
2117
self.base = base
2218
}
2319

24-
@_alwaysEmitIntoClient
2520
public init() {
2621
base = AnyWeakAttribute(_details: .init(identifier: .init(rawValue: 0), seed: 0))
2722
}
2823

29-
@_alwaysEmitIntoClient
3024
public init(_ attribute: Attribute<Value>) {
3125
base = AnyWeakAttribute(attribute.identifier)
3226
}
3327

34-
@_alwaysEmitIntoClient
3528
public init(_ attribute: Attribute<Value>?) {
3629
base = AnyWeakAttribute(attribute?.identifier)
3730
}
3831

39-
@_alwaysEmitIntoClient
4032
public var wrappedValue: Value? {
4133
OAGGraphGetWeakValue(base, type: Value.self)
4234
.value?
4335
.assumingMemoryBound(to: Value.self)
4436
.pointee
4537
}
4638

47-
@_alwaysEmitIntoClient
4839
public var projectedValue: Attribute<Value>?{
4940
get { attribute }
5041
set { attribute = newValue }
5142
_modify { yield &attribute }
5243
}
5344

54-
@_alwaysEmitIntoClient
5545
public subscript<Member>(dynamicMember keyPath: KeyPath<Value, Member>) -> Attribute<Member>? {
5646
attribute?[keyPath: keyPath]
5747
}
5848

59-
@_alwaysEmitIntoClient
6049
public var attribute: Attribute<Value>? {
6150
get { base.attribute?.unsafeCast(to: Value.self) }
6251
set { base.attribute = newValue?.identifier }
6352
}
6453

65-
@_alwaysEmitIntoClient
6654
public var value: Value? { wrappedValue }
6755

68-
@_alwaysEmitIntoClient
6956
public func changedValue(options: OAGValueOptions) -> (value: Value, changed: Bool)? {
7057
let value = OAGGraphGetWeakValue(base, options: options, type: Value.self)
7158
guard let ptr = value.value else {
@@ -85,5 +72,4 @@ extension WeakAttribute: CustomStringConvertible {
8572
}
8673

8774
@_silgen_name("OAGGraphGetWeakValue")
88-
@_alwaysEmitIntoClient
8975
private func OAGGraphGetWeakValue<Value>(_ attribute: AnyWeakAttribute, options: OAGValueOptions = [], type: Value.Type = Value.self) -> OAGWeakValue

Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGWeakAttribute.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
OAG_ASSUME_NONNULL_BEGIN
1313

14-
typedef struct OAG_SWIFT_NAME(AnyWeakAttribute) OAGWeakAttribute {
14+
typedef OAG_SWIFT_STRUCT struct {
1515
struct {
1616
OAGAttribute identifier;
1717
uint32_t seed;
1818
} _details;
19-
} OAGWeakAttribute;
19+
} OAGWeakAttribute OAG_SWIFT_NAME(AnyWeakAttribute);
2020

2121
OAG_EXTERN_C_BEGIN
2222

Tests/OpenAttributeGraphCompatibilityTests/Attribute/Weak/AnyWeakAttributeCompatibilityTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct AnyWeakAttributeCompatibilityTests {
3737
@Test
3838
func dict() {
3939
let w1 = AnyWeakAttribute(nil)
40-
let w2 = AnyWeakAttribute(WeakAttribute<Void>(nil))
40+
let w2 = AnyWeakAttribute(Attribute(value: 0).identifier)
4141
let dict: [AnyWeakAttribute: Int] = [
4242
w1: 1,
4343
w2: 2,

0 commit comments

Comments
 (0)