Skip to content

Commit cb8da29

Browse files
authored
Update OGComparisionMode (#10)
* Update OGComparisionMode to fix __C issue * Add compareValues and update test
1 parent ef985c1 commit cb8da29

File tree

30 files changed

+460
-46
lines changed

30 files changed

+460
-46
lines changed

Package.swift

+39-8
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let openSwiftUITarget = Target.target(
2020
],
2121
swiftSettings: [
2222
.enableExperimentalFeature("AccessLevelOnImport"),
23-
.define("OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS")
23+
.define("OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS"),
2424
],
2525
linkerSettings: [
2626
.unsafeFlags(
@@ -80,17 +80,42 @@ let package = Package(
8080
]
8181
)
8282

83+
// FIXME: The binary of AG for macOS is copied from dyld shared cache and it will cause a link error when running. Use iOS Simulator to run this target as a temporary workaround
84+
let graphCompatibilityTest = ProcessInfo.processInfo.environment["OPENGRAPH_COMPATIBILITY_TEST"] != nil
85+
let openGraphCompatibilityTestTarget = Target.testTarget(
86+
name: "OpenGraphCompatibilityTests",
87+
dependencies: [
88+
graphCompatibilityTest ? "AttributeGraph" : "OpenGraph",
89+
],
90+
exclude: ["README.md"],
91+
swiftSettings: graphCompatibilityTest ? [
92+
.define("OPENGRAPH_COMPATIBILITY_TEST")
93+
] : []
94+
)
95+
package.targets.append(openGraphCompatibilityTestTarget)
96+
8397
let useAG = ProcessInfo.processInfo.environment["OPENSWIFTUI_USE_AG"] != nil
8498
if useAG {
99+
if !graphCompatibilityTest {
100+
let targets: [Target] = [
101+
// FIXME: Merge into one target
102+
// OpenGraph is a C++ & Swift mix target.
103+
// The SwiftPM support for such usage is still in progress.
104+
.target(
105+
name: "_OpenGraph",
106+
dependencies: [.product(name: "OpenFoundation", package: "OpenFoundation")],
107+
cSettings: [clangEnumFixSetting]
108+
),
109+
.target(
110+
name: "OpenGraph",
111+
dependencies: ["_OpenGraph"],
112+
cSettings: [clangEnumFixSetting]
113+
),
114+
]
115+
package.targets.append(contentsOf: targets)
116+
}
85117
let targets: [Target] = [
86118
.binaryTarget(name: "AttributeGraph", path: "Sources/AttributeGraph.xcframework"),
87-
// FIXME: The binary of AG for macOS is copied from dyld shared cache and it will cause a link error when running. Use iOS Simulator to run this target as a temporary workaround
88-
.testTarget(
89-
name: "AttributeGraphTests",
90-
dependencies: [
91-
"AttributeGraph",
92-
]
93-
),
94119
]
95120
package.targets.append(contentsOf: targets)
96121
openSwiftUITarget.dependencies.append(
@@ -100,6 +125,12 @@ if useAG {
100125
swiftSettings.append(.define("OPENSWIFTUI_USE_AG"))
101126
openSwiftUITarget.swiftSettings = swiftSettings
102127
} else {
128+
if graphCompatibilityTest {
129+
let targets: [Target] = [
130+
.binaryTarget(name: "AttributeGraph", path: "Sources/AttributeGraph.xcframework"),
131+
]
132+
package.targets.append(contentsOf: targets)
133+
}
103134
package.products.append(
104135
.library(name: "OpenGraph", targets: ["OpenGraph", "_OpenGraph"])
105136
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// AGCompareValues.h
3+
//
4+
//
5+
// Created by Kyle on 2023/10/9.
6+
//
7+
8+
#ifndef AGCompareValues_h
9+
#define AGCompareValues_h
10+
11+
#include <CoreFoundation/CoreFoundation.h>
12+
#include "AGComparisonMode.h"
13+
#include <stdbool.h>
14+
15+
CF_EXTERN_C_BEGIN
16+
CF_EXPORT
17+
bool AGCompareValues(const void *lhs, const void *rhs, const AGComparisonMode comparisonMode, const void *type);
18+
CF_EXTERN_C_END
19+
20+
#endif /* AGCompareValues_h */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// AGComparisonMode.hpp
3+
//
4+
//
5+
// Created by Kyle on 2023/12/20.
6+
//
7+
8+
#ifndef AGComparisonMode_h
9+
#define AGComparisonMode_h
10+
11+
#include <CoreFoundation/CoreFoundation.h>
12+
13+
typedef CF_OPTIONS(uint32_t, AGComparisonMode) {
14+
AGComparisonMode_0 = 0,
15+
AGComparisonMode_1 = 1 << 0,
16+
AGComparisonMode_2 = 1 << 1,
17+
AGComparisonMode_3 = AGComparisonMode_1 | AGComparisonMode_2,
18+
};
19+
20+
#endif /* AGComparisonMode_h */
21+
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//
2-
// AGMakeUniqueID.hpp
2+
// AGUniqueID.h
33
//
44
//
55
// Created by Kyle on 2023/10/9.
66
//
77

8-
#ifndef AGMakeUniqueID_hpp
9-
#define AGMakeUniqueID_hpp
8+
#ifndef AGUniqueID_h
9+
#define AGUniqueID_h
1010

1111
#include <CoreFoundation/CoreFoundation.h>
1212
typedef long long AGUniqueID;
@@ -16,4 +16,4 @@ CF_EXPORT
1616
AGUniqueID AGMakeUniqueID(void);
1717
CF_EXTERN_C_END
1818

19-
#endif /* AGMakeUniqueID_hpp */
19+
#endif /* AGUniqueID_h */

Sources/AttributeGraph.xcframework/ios-arm64_x86_64-simulator/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
#import "AGAttribute.h"
1414
#import "AGUniqueID.h"
15+
#import "AGComparisonMode.h"
16+
#import "AGCompareValues.h"
1517

1618
FOUNDATION_EXPORT double AGAttributeVersionNumber;
1719
FOUNDATION_EXPORT const unsigned char AGAttributeVersionString[];

Sources/AttributeGraph.xcframework/ios-arm64_x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios-simulator.swiftinterface

+3
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ public protocol _AttributeBody {
4343
static func _destroySelf(_ value: Swift.UnsafeMutableRawPointer)
4444
static var _hasDestroySelf: Swift.Bool { get }
4545
static func _updateDefault(_ value: Swift.UnsafeMutableRawPointer)
46+
static var comparisonMode: AGComparisonMode { get }
4647
}
4748
extension AttributeGraph._AttributeBody {
4849
public static func _destroySelf(_ value: Swift.UnsafeMutableRawPointer)
4950
public static var _hasDestroySelf: Swift.Bool {
5051
get
5152
}
5253
public static func _updateDefault(_ value: Swift.UnsafeMutableRawPointer)
54+
public static var comparisonMode: AGComparisonMode { get }
5355
}
5456
public protocol Rule : AttributeGraph._AttributeBody {
5557
associatedtype Value
@@ -61,3 +63,4 @@ extension AttributeGraph.Rule {
6163
get
6264
}
6365
}
66+
public func compareValues<A>(_ lhs: A, _ rhs: A, mode: AGComparisonMode = ._3) -> Swift.Bool

Sources/AttributeGraph.xcframework/ios-arm64_x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-ios-simulator.swiftinterface

+3
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ public protocol _AttributeBody {
4343
static func _destroySelf(_ value: Swift.UnsafeMutableRawPointer)
4444
static var _hasDestroySelf: Swift.Bool { get }
4545
static func _updateDefault(_ value: Swift.UnsafeMutableRawPointer)
46+
static var comparisonMode: AGComparisonMode { get }
4647
}
4748
extension AttributeGraph._AttributeBody {
4849
public static func _destroySelf(_ value: Swift.UnsafeMutableRawPointer)
4950
public static var _hasDestroySelf: Swift.Bool {
5051
get
5152
}
5253
public static func _updateDefault(_ value: Swift.UnsafeMutableRawPointer)
54+
public static var comparisonMode: AGComparisonMode { get }
5355
}
5456
public protocol Rule : AttributeGraph._AttributeBody {
5557
associatedtype Value
@@ -61,3 +63,4 @@ extension AttributeGraph.Rule {
6163
get
6264
}
6365
}
66+
public func compareValues<A>(_ lhs: A, _ rhs: A, mode: AGComparisonMode = ._3) -> Swift.Bool
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// AGCompareValues.h
3+
//
4+
//
5+
// Created by Kyle on 2023/10/9.
6+
//
7+
8+
#ifndef AGCompareValues_h
9+
#define AGCompareValues_h
10+
11+
#include <CoreFoundation/CoreFoundation.h>
12+
#include "AGComparisonMode.h"
13+
#include <stdbool.h>
14+
15+
CF_EXTERN_C_BEGIN
16+
CF_EXPORT
17+
bool AGCompareValues(const void *lhs, const void *rhs, const AGComparisonMode comparisonMode, const void *type);
18+
CF_EXTERN_C_END
19+
20+
#endif /* AGCompareValues_h */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// AGComparisonMode.hpp
3+
//
4+
//
5+
// Created by Kyle on 2023/12/20.
6+
//
7+
8+
#ifndef AGComparisonMode_h
9+
#define AGComparisonMode_h
10+
11+
#include <CoreFoundation/CoreFoundation.h>
12+
13+
typedef CF_OPTIONS(uint32_t, AGComparisonMode) {
14+
AGComparisonMode_0 = 0,
15+
AGComparisonMode_1 = 1 << 0,
16+
AGComparisonMode_2 = 1 << 1,
17+
AGComparisonMode_3 = AGComparisonMode_1 | AGComparisonMode_2,
18+
};
19+
20+
#endif /* AGComparisonMode_h */
21+
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//
2-
// AGMakeUniqueID.hpp
2+
// AGUniqueID.h
33
//
44
//
55
// Created by Kyle on 2023/10/9.
66
//
77

8-
#ifndef AGMakeUniqueID_hpp
9-
#define AGMakeUniqueID_hpp
8+
#ifndef AGUniqueID_h
9+
#define AGUniqueID_h
1010

1111
#include <CoreFoundation/CoreFoundation.h>
1212
typedef long long AGUniqueID;
@@ -16,4 +16,4 @@ CF_EXPORT
1616
AGUniqueID AGMakeUniqueID(void);
1717
CF_EXTERN_C_END
1818

19-
#endif /* AGMakeUniqueID_hpp */
19+
#endif /* AGUniqueID_h */

Sources/AttributeGraph.xcframework/ios-arm64e/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
#import "AGAttribute.h"
1414
#import "AGUniqueID.h"
15+
#import "AGComparisonMode.h"
16+
#import "AGCompareValues.h"
1517

1618
FOUNDATION_EXPORT double AGAttributeVersionNumber;
1719
FOUNDATION_EXPORT const unsigned char AGAttributeVersionString[];

Sources/AttributeGraph.xcframework/ios-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-ios.swiftinterface

+3
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ public protocol _AttributeBody {
4343
static func _destroySelf(_ value: Swift.UnsafeMutableRawPointer)
4444
static var _hasDestroySelf: Swift.Bool { get }
4545
static func _updateDefault(_ value: Swift.UnsafeMutableRawPointer)
46+
static var comparisonMode: AGComparisonMode { get }
4647
}
4748
extension AttributeGraph._AttributeBody {
4849
public static func _destroySelf(_ value: Swift.UnsafeMutableRawPointer)
4950
public static var _hasDestroySelf: Swift.Bool {
5051
get
5152
}
5253
public static func _updateDefault(_ value: Swift.UnsafeMutableRawPointer)
54+
public static var comparisonMode: AGComparisonMode { get }
5355
}
5456
public protocol Rule : AttributeGraph._AttributeBody {
5557
associatedtype Value
@@ -61,3 +63,4 @@ extension AttributeGraph.Rule {
6163
get
6264
}
6365
}
66+
public func compareValues<A>(_ lhs: A, _ rhs: A, mode: AGComparisonMode = ._3) -> Swift.Bool
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// AGCompareValues.h
3+
//
4+
//
5+
// Created by Kyle on 2023/10/9.
6+
//
7+
8+
#ifndef AGCompareValues_h
9+
#define AGCompareValues_h
10+
11+
#include <CoreFoundation/CoreFoundation.h>
12+
#include "AGComparisonMode.h"
13+
#include <stdbool.h>
14+
15+
CF_EXTERN_C_BEGIN
16+
CF_EXPORT
17+
bool AGCompareValues(const void *lhs, const void *rhs, const AGComparisonMode comparisonMode, const void *type);
18+
CF_EXTERN_C_END
19+
20+
#endif /* AGCompareValues_h */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// AGComparisonMode.hpp
3+
//
4+
//
5+
// Created by Kyle on 2023/12/20.
6+
//
7+
8+
#ifndef AGComparisonMode_h
9+
#define AGComparisonMode_h
10+
11+
#include <CoreFoundation/CoreFoundation.h>
12+
13+
typedef CF_OPTIONS(uint32_t, AGComparisonMode) {
14+
AGComparisonMode_0 = 0,
15+
AGComparisonMode_1 = 1 << 0,
16+
AGComparisonMode_2 = 1 << 1,
17+
AGComparisonMode_3 = AGComparisonMode_1 | AGComparisonMode_2,
18+
};
19+
20+
#endif /* AGComparisonMode_h */
21+
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//
2-
// AGMakeUniqueID.hpp
2+
// AGUniqueID.h
33
//
44
//
55
// Created by Kyle on 2023/10/9.
66
//
77

8-
#ifndef AGMakeUniqueID_hpp
9-
#define AGMakeUniqueID_hpp
8+
#ifndef AGUniqueID_h
9+
#define AGUniqueID_h
1010

1111
#include <CoreFoundation/CoreFoundation.h>
1212
typedef long long AGUniqueID;
@@ -16,4 +16,4 @@ CF_EXPORT
1616
AGUniqueID AGMakeUniqueID(void);
1717
CF_EXTERN_C_END
1818

19-
#endif /* AGMakeUniqueID_hpp */
19+
#endif /* AGUniqueID_h */

Sources/AttributeGraph.xcframework/macos-arm64e/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
#import "AGAttribute.h"
1414
#import "AGUniqueID.h"
15+
#import "AGComparisonMode.h"
16+
#import "AGCompareValues.h"
1517

1618
FOUNDATION_EXPORT double AGAttributeVersionNumber;
1719
FOUNDATION_EXPORT const unsigned char AGAttributeVersionString[];

Sources/AttributeGraph.xcframework/macos-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-macos.swiftinterface

+3
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ public protocol _AttributeBody {
4343
static func _destroySelf(_ value: Swift.UnsafeMutableRawPointer)
4444
static var _hasDestroySelf: Swift.Bool { get }
4545
static func _updateDefault(_ value: Swift.UnsafeMutableRawPointer)
46+
static var comparisonMode: AGComparisonMode { get }
4647
}
4748
extension AttributeGraph._AttributeBody {
4849
public static func _destroySelf(_ value: Swift.UnsafeMutableRawPointer)
4950
public static var _hasDestroySelf: Swift.Bool {
5051
get
5152
}
5253
public static func _updateDefault(_ value: Swift.UnsafeMutableRawPointer)
54+
public static var comparisonMode: AGComparisonMode { get }
5355
}
5456
public protocol Rule : AttributeGraph._AttributeBody {
5557
associatedtype Value
@@ -61,3 +63,4 @@ extension AttributeGraph.Rule {
6163
get
6264
}
6365
}
66+
public func compareValues<A>(_ lhs: A, _ rhs: A, mode: AGComparisonMode = ._3) -> Swift.Bool

Sources/OpenGraph/TODO/OGComparisonMode.swift

-6
This file was deleted.

0 commit comments

Comments
 (0)