Skip to content

Commit f2b16a1

Browse files
authored
Add OGGraphGetWeakValue (#87)
* Add OGGraphGetWeakValue * Fix OPENGRAPH_COMPATIBILITY_TEST default value * Update WeakAttribute.value implementation
1 parent f459df4 commit f2b16a1

File tree

9 files changed

+37
-3
lines changed

9 files changed

+37
-3
lines changed

AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGWeakAttribute.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ AG_EXPORT
2828
AG_REFINED_FOR_SWIFT
2929
AGAttribute AGWeakAttributeGetAttribute(AGWeakAttribute weakAttribute);
3030

31+
AG_EXPORT
32+
AG_REFINED_FOR_SWIFT
33+
AGValue AGGraphGetWeakValue(AGWeakAttribute weakAttribute, AGValueOptions options, AGTypeID type);
34+
3135
AG_EXTERN_C_END
3236

3337
AG_ASSUME_NONNULL_END

AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGWeakAttribute.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ AG_EXPORT
2828
AG_REFINED_FOR_SWIFT
2929
AGAttribute AGWeakAttributeGetAttribute(AGWeakAttribute weakAttribute);
3030

31+
AG_EXPORT
32+
AG_REFINED_FOR_SWIFT
33+
AGValue AGGraphGetWeakValue(AGWeakAttribute weakAttribute, AGValueOptions options, AGTypeID type);
34+
3135
AG_EXTERN_C_END
3236

3337
AG_ASSUME_NONNULL_END

AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGWeakAttribute.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ AG_EXPORT
2828
AG_REFINED_FOR_SWIFT
2929
AGAttribute AGWeakAttributeGetAttribute(AGWeakAttribute weakAttribute);
3030

31+
AG_EXPORT
32+
AG_REFINED_FOR_SWIFT
33+
AGValue AGGraphGetWeakValue(AGWeakAttribute weakAttribute, AGValueOptions options, AGTypeID type);
34+
3135
AG_EXTERN_C_END
3236

3337
AG_ASSUME_NONNULL_END

AG/Sources/Headers/AGWeakAttribute.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ AG_EXPORT
2828
AG_REFINED_FOR_SWIFT
2929
AGAttribute AGWeakAttributeGetAttribute(AGWeakAttribute weakAttribute);
3030

31+
AG_EXPORT
32+
AG_REFINED_FOR_SWIFT
33+
AGValue AGGraphGetWeakValue(AGWeakAttribute weakAttribute, AGValueOptions options, AGTypeID type);
34+
3135
AG_EXTERN_C_END
3236

3337
AG_ASSUME_NONNULL_END

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ if attributeGraphCondition {
169169
openGraphShimsTarget.dependencies.append("OpenGraph")
170170
}
171171

172-
let compatibilityTestCondition = envEnable("OPENGRAPH_COMPATIBILITY_TEST", default: true)
172+
let compatibilityTestCondition = envEnable("OPENGRAPH_COMPATIBILITY_TEST")
173173
if compatibilityTestCondition && attributeGraphCondition {
174174
openGraphCompatibilityTestTarget.dependencies.append("AttributeGraph")
175175
var swiftSettings: [SwiftSetting] = (openGraphCompatibilityTestTarget.swiftSettings ?? [])

Plugins/UpdateModule/UpdateModuleCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct UpdateModuleCommand: CommandPlugin {
1212
func performCommand(context: PackagePlugin.PluginContext, arguments: [String]) async throws {
1313
#if compiler(>=6.0) // Skip build on WASI 5.10
1414
let process = Process()
15-
process.executableURL = try context.tool(named: "zsh").url
15+
process.executableURL = try context.tool(named: "bash").url
1616
process.arguments = ["AG/update.sh"]
1717
try process.run()
1818
process.waitUntilExit()

Sources/OpenGraph/Attribute/Weak/WeakAttribute.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ public struct WeakAttribute<Value> {
4949
}
5050

5151
public var value: Value? {
52-
attribute?.value
52+
OGGraphGetWeakValue(base, type: Value.self)
53+
.value
54+
// TO BE CONFIRMED
55+
.assumingMemoryBound(to: Value?.self)
56+
.pointee
5357
}
5458

5559
public func changedValue(options: OGValueOptions = []) -> (value: Value, changed: Bool)? {
@@ -62,3 +66,8 @@ extension WeakAttribute: Hashable {}
6266
extension WeakAttribute: CustomStringConvertible {
6367
public var description: String { base.description }
6468
}
69+
70+
@_silgen_name("OGGraphGetWeakValue")
71+
@inline(__always)
72+
@inlinable
73+
func OGGraphGetWeakValue<Value>(_ attribute: AnyWeakAttribute, options: OGValueOptions = [], type: Value.Type = Value.self) -> OGValue

Sources/OpenGraph_SPI/Attribute/OGWeakAttribute.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ OGAttribute OGWeakAttributeGetAttribute(OGWeakAttribute weakAttribute) {
1616
// TODO
1717
return OGAttributeNil;
1818
}
19+
20+
OGValue OGGraphGetWeakValue(OGWeakAttribute weakAttribute, OGValueOptions options, OGTypeID type) {
21+
// TODO
22+
return {nullptr, false};
23+
}

Sources/OpenGraph_SPI/Attribute/OGWeakAttribute.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ OG_EXPORT
2828
OG_REFINED_FOR_SWIFT
2929
OGAttribute OGWeakAttributeGetAttribute(OGWeakAttribute weakAttribute);
3030

31+
OG_EXPORT
32+
OG_REFINED_FOR_SWIFT
33+
OGValue OGGraphGetWeakValue(OGWeakAttribute weakAttribute, OGValueOptions options, OGTypeID type);
34+
3135
OG_EXTERN_C_END
3236

3337
OG_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)