Skip to content

Commit e17c6c9

Browse files
authored
Merge branch 'OpenSwiftUIProject:main' into patch-2
2 parents cf40826 + 6aceaa1 commit e17c6c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+306
-127
lines changed

.codecov.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
codecov:
2-
require_ci_to_pass: no
2+
require_ci_to_pass: yes
33
coverage:
44
status:
55
project:
66
default:
77
target: auto
88
threshold: 5
9+
patch: off
10+
# default:
11+
# target: auto
12+
# threshold: 5
913
ignore:
10-
- Tests
14+
- Tests

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ let openGraphSPITarget = Target.target(
147147
name: "OpenGraph_SPI",
148148
cSettings: sharedCSettings + [
149149
.define("__COREFOUNDATION_FORSWIFTFOUNDATIONONLY__", to: "1", .when(platforms: .nonDarwinPlatforms)),
150+
],
151+
linkerSettings: [
152+
.linkedLibrary("z"),
150153
]
151154
)
152155
let openGraphShimsTarget = Target.target(

Sources/OpenGraph/Graph/Graph.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,33 @@ extension Graph {
7171
@inlinable
7272
public static func setOutputValue<Value>(_ value: UnsafePointer<Value>)
7373
}
74+
75+
#if canImport(Darwin)
76+
import Foundation
77+
#endif
78+
79+
extension Graph {
80+
public func archiveJSON(name: String?) {
81+
#if canImport(Darwin)
82+
let options: NSDictionary = [
83+
Graph.descriptionFormat: "graph/dict",
84+
Graph.descriptionIncludeValues: true,
85+
]
86+
guard let description = Graph.description(self, options: options) as? [String: Any] else {
87+
return
88+
}
89+
var name = name ?? "graph"
90+
name.append(".ag-json")
91+
let path = (NSTemporaryDirectory() as NSString).appendingPathComponent(name)
92+
guard let data = try? JSONSerialization.data(withJSONObject: description, options: []) else {
93+
return
94+
}
95+
let url = URL(fileURLWithPath: path)
96+
do {
97+
try data.write(to: url, options: [])
98+
print("Wrote graph data to \"\(path)\".")
99+
} catch {
100+
}
101+
#endif
102+
}
103+
}

Sources/OpenGraph/Runtime/Metadata.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ extension Metadata: Swift.Hashable, Swift.CustomStringConvertible {
4040
@inline(__always)
4141
public var description: String {
4242
#if canImport(ObjectiveC)
43-
__OGTypeDescription(self).takeUnretainedValue() as NSString as String
43+
__OGTypeDescription(self) as NSString as String
4444
#else
4545
fatalError("Unimplemented")
4646
#endif

Sources/OpenGraphShims/Graph+Debug.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ import Foundation
99
@_spi(Debug)
1010
extension Graph {
1111
public var dict: [String: Any]? {
12-
let options = ["format": "graph/dict"] as NSDictionary
12+
let options = [
13+
Graph.descriptionFormat: Graph.descriptionFormatDictionary
14+
] as NSDictionary
1315
guard let description = Graph.description(nil, options: options) else {
1416
return nil
1517
}
16-
guard let dictionary = description.takeUnretainedValue() as? NSDictionary else {
18+
guard let dictionary = description as? NSDictionary else {
1719
return nil
1820
}
1921
return dictionary as? [String: Any]
@@ -25,12 +27,14 @@ extension Graph {
2527
// color:
2628
// - red: is_changed
2729
public var dot: String? {
28-
let options = ["format": "graph/dot"] as NSDictionary
30+
let options = [
31+
Graph.descriptionFormat: Graph.descriptionFormatDot
32+
] as NSDictionary
2933
guard let description = Graph.description(self, options: options)
3034
else {
3135
return nil
3236
}
33-
return description.takeUnretainedValue() as? String
37+
return description as? String
3438
}
3539
}
3640

Sources/OpenGraph_SPI/Attribute/AttributeID.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class AttributeID final {
2222
enum class Kind: uint8_t {
2323
Direct = 0x0,
2424
Indirect = 0x1,
25-
Nil = 0x2,
25+
Null = 0x2,
2626
};
2727
private:
2828
uint32_t _rawValue;
@@ -59,8 +59,8 @@ class AttributeID final {
5959
}
6060

6161
OG_INLINE OG_CONSTEXPR
62-
const bool isNil() const OG_NOEXCEPT {
63-
return getKind() == Kind::Nil;
62+
const bool isNull() const OG_NOEXCEPT {
63+
return getKind() == Kind::Null;
6464
}
6565

6666
OG_INLINE OG_CONSTEXPR

Sources/OpenGraph_SPI/Attribute/OGAttribute.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "../Util/assert.hpp"
1212
#include <optional>
1313

14-
const OGAttribute OGAttributeNil = OGAttribute(OG::AttributeID::Kind::Nil);
14+
const OGAttribute OGAttributeNil = OGAttribute(OG::AttributeID::Kind::Null);
1515

1616
OGAttribute OGGraphGetCurrentAttribute() {
1717
// TODO

Sources/OpenGraph_SPI/Debug/og-debug-server.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202
NSString *command = dic[@"command"];
203203
if ([command isEqual:@"graph/description"]) {
204204
NSMutableDictionary *mutableDic = [NSMutableDictionary dictionaryWithDictionary:dic];
205-
mutableDic[(__bridge NSString *)OGDescriptionFormat] = @"graph/dict";
205+
mutableDic[(__bridge NSString *)OGDescriptionFormat] = (__bridge NSString *)OGDescriptionFormatDictionary;
206206
CFTypeRef description = OG::Graph::description(nullptr, mutableDic);
207207
if (description) {
208208
NSData *descriptionData = [NSJSONSerialization dataWithJSONObject:(__bridge id)description options:0 error:NULL];

Sources/OpenGraph_SPI/Graph/Graph.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
//
22
// Graph.cpp
3-
//
4-
//
5-
// Created by Kyle on 2024/1/18.
6-
//
3+
// OpenGraph_SPI
74

85
#include "Graph.hpp"
96
#include "Subgraph.hpp"
7+
#include "OGGraphDescription.h"
108

119
#if !OG_TARGET_OS_WASI
1210
#include <dispatch/dispatch.h>
1311
#endif
12+
1413
#include <pthread.h>
1514

1615
pthread_key_t OG::Graph::_current_update_key;
1716

1817
OG::Graph::Graph() OG_NOEXCEPT {
1918
// TODO
20-
19+
2120
// libdispatch is not supported on WASI
2221
// Tracked via https://github.com/swiftwasm/swift/issues/5565
2322
#if !OG_TARGET_OS_WASI
@@ -27,7 +26,7 @@ OG::Graph::Graph() OG_NOEXCEPT {
2726
OG::Subgraph::make_current_subgraph_key();
2827
});
2928
#endif
30-
29+
3130
// TODO
3231
}
3332

@@ -48,10 +47,6 @@ void OG::Graph::stop_profiling() OG_NOEXCEPT {
4847
// TODO
4948
}
5049

51-
void OG::Graph::write_to_file(const Graph * _Nullable, const char * _Nullable) OG_NOEXCEPT {
52-
// TODO
53-
}
54-
5550
const bool OG::Graph::thread_is_updating() const OG_NOEXCEPT {
5651
void *current = pthread_getspecific(current_key());
5752
if (!current) {

0 commit comments

Comments
 (0)