Skip to content

Add IMPLICIT_BRIDGING for autorelease #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Sources/OpenGraph/Runtime/Metadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extension Metadata: Swift.Hashable, Swift.CustomStringConvertible {
@inline(__always)
public var description: String {
#if canImport(ObjectiveC)
__OGTypeDescription(self).takeUnretainedValue() as NSString as String
__OGTypeDescription(self) as NSString as String
#else
fatalError("Unimplemented")
#endif
Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenGraphShims/Graph+Debug.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extension Graph {
guard let description = Graph.description(nil, options: options) else {
return nil
}
guard let dictionary = description.takeUnretainedValue() as? NSDictionary else {
guard let dictionary = description as? NSDictionary else {
return nil
}
return dictionary as? [String: Any]
Expand All @@ -30,7 +30,7 @@ extension Graph {
else {
return nil
}
return description.takeUnretainedValue() as? String
return description as? String
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph_SPI/Graph/GraphDescription.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#if OG_OBJC_FOUNDATION
#include <Foundation/Foundation.h>
CFStringRef OGDescriptionFormat = CFSTR("format");
const CFStringRef OGDescriptionFormat = CFSTR("format");

CFTypeRef OG::Graph::description(const Graph * _Nullable graph, NSDictionary* dic) {
// TODO
Expand Down
4 changes: 4 additions & 0 deletions Sources/OpenGraph_SPI/include/OGComparison.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

OG_ASSUME_NONNULL_BEGIN

OG_IMPLICIT_BRIDGING_ENABLED

OG_EXTERN_C_BEGIN

typedef struct OGFieldRange {
Expand Down Expand Up @@ -98,6 +100,8 @@ void OGOverrideComparisonForTypeDescriptor(void *descriptor, OGComparisonMode mo

OG_EXTERN_C_END

OG_IMPLICIT_BRIDGING_DISABLED

OG_ASSUME_NONNULL_END

#endif /* OGComparison_h */
4 changes: 4 additions & 0 deletions Sources/OpenGraph_SPI/include/OGDebugServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

OG_ASSUME_NONNULL_BEGIN

OG_IMPLICIT_BRIDGING_ENABLED

typedef struct OGDebugServerStorage OGDebugServerStorage;

typedef const OGDebugServerStorage *OGDebugServer OG_SWIFT_STRUCT;
Expand All @@ -28,6 +30,8 @@ OG_EXPORT
void OGDebugServerRun(int timeout) OG_SWIFT_NAME(OGDebugServer.run(timeout:));
OG_EXTERN_C_END

OG_IMPLICIT_BRIDGING_DISABLED

OG_ASSUME_NONNULL_END

#endif
Expand Down
4 changes: 4 additions & 0 deletions Sources/OpenGraph_SPI/include/OGGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ typedef uint32_t OGAttribute OG_SWIFT_STRUCT OG_SWIFT_NAME(AnyAttribute);

OG_ASSUME_NONNULL_BEGIN

OG_IMPLICIT_BRIDGING_ENABLED

// MARK: - Exported C functions

OG_EXTERN_C_BEGIN
Expand Down Expand Up @@ -118,6 +120,8 @@ bool OGGraphAnyInputsChanged(const OGAttribute *inputs, size_t count);

OG_EXTERN_C_END

OG_IMPLICIT_BRIDGING_DISABLED

OG_ASSUME_NONNULL_END

#endif /* OGGraph_h */
4 changes: 4 additions & 0 deletions Sources/OpenGraph_SPI/include/OGGraphContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

OG_ASSUME_NONNULL_BEGIN

OG_IMPLICIT_BRIDGING_ENABLED

OG_EXTERN_C_BEGIN

OG_EXPORT
Expand All @@ -20,6 +22,8 @@ OGGraphRef OGGraphContextGetGraph(OGGraphContextRef context) OG_SWIFT_NAME(gette

OG_EXTERN_C_END

OG_IMPLICIT_BRIDGING_DISABLED

OG_ASSUME_NONNULL_END

#endif /* OGGraphContext_h */
14 changes: 11 additions & 3 deletions Sources/OpenGraph_SPI/include/OGGraphDescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,21 @@

OG_ASSUME_NONNULL_BEGIN

#if OG_OBJC_FOUNDATION
OG_IMPLICIT_BRIDGING_ENABLED

OG_EXTERN_C_BEGIN

#if OG_OBJC_FOUNDATION

OG_EXPORT
CFStringRef OGDescriptionFormat OG_SWIFT_NAME(OGGraphRef.descriptionFormat);
OG_EXTERN_C_END
const CFStringRef OGDescriptionFormat OG_SWIFT_NAME(OGGraphRef.descriptionFormat);

#endif

OG_EXTERN_C_END

OG_IMPLICIT_BRIDGING_DISABLED

OG_ASSUME_NONNULL_END

#endif /* OGGraphDescription_h */
4 changes: 4 additions & 0 deletions Sources/OpenGraph_SPI/include/OGGraphTracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ typedef OG_OPTIONS(uint32_t, OGGraphTraceFlags) {

OG_ASSUME_NONNULL_BEGIN

OG_IMPLICIT_BRIDGING_ENABLED

OG_EXTERN_C_BEGIN

OG_EXPORT
Expand All @@ -32,6 +34,8 @@ void OGGraphStopTracing(_Nullable OGGraphRef graph) OG_SWIFT_NAME(OGGraphRef.sto

OG_EXTERN_C_END

OG_IMPLICIT_BRIDGING_DISABLED

OG_ASSUME_NONNULL_END

#endif /* OGGraphTracing_hpp */
4 changes: 4 additions & 0 deletions Sources/OpenGraph_SPI/include/OGSubgraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

OG_ASSUME_NONNULL_BEGIN

OG_IMPLICIT_BRIDGING_ENABLED

// MARK: - Exported C functions

OG_EXTERN_C_BEGIN
Expand Down Expand Up @@ -109,6 +111,8 @@ void OGSubgraphEndTreeElement(OGAttribute attribute);

OG_EXTERN_C_END

OG_IMPLICIT_BRIDGING_DISABLED

OG_ASSUME_NONNULL_END

#endif /* OGSubgraph_h */
4 changes: 4 additions & 0 deletions Sources/OpenGraph_SPI/include/OGTupleType.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

OG_ASSUME_NONNULL_BEGIN

OG_IMPLICIT_BRIDGING_ENABLED

typedef const OGSwiftMetadata *OGTupleType OG_SWIFT_STRUCT OG_SWIFT_NAME(TupleType);

typedef OG_CLOSED_ENUM(uint32_t, OGTupleCopyOptions) {
Expand Down Expand Up @@ -84,6 +86,8 @@ void OGTupleWithBuffer(OGTupleType tuple_type, size_t count, const void (* funct

OG_EXTERN_C_END

OG_IMPLICIT_BRIDGING_DISABLED

OG_ASSUME_NONNULL_END

#endif /* OGTupleType_h */
4 changes: 4 additions & 0 deletions Sources/OpenGraph_SPI/include/OGTypeID.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

OG_ASSUME_NONNULL_BEGIN

OG_IMPLICIT_BRIDGING_ENABLED

typedef struct OG_SWIFT_NAME(_Metadata) OGSwiftMetadata {
} OGSwiftMetadata;

Expand Down Expand Up @@ -114,6 +116,8 @@ char const* _Nullable OGTypeNominalDescriptorName(OGTypeID typeID) OG_SWIFT_NAME

OG_EXTERN_C_END

OG_IMPLICIT_BRIDGING_DISABLED

OG_ASSUME_NONNULL_END

#endif /* OGTypeID_h */
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import Testing

#if canImport(Darwin)

@Suite(.enabled(if: compatibilityTestEnabled))
final class AnyWeakAttributeTests: AttributeTestBase {
@Test
func basic() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import Testing

// *** Program crashed: Bad pointer dereference at 0x00000007eff1c01b ***
#if canImport(Darwin)
@Suite(.enabled(if: compatibilityTestEnabled))
final class WeakAttributeTests: AttributeTestBase {
@Test
func initTest() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//
// DebugServerTests.swift
//
//
//
// OpenGraphCompatibilityTests

#if canImport(Darwin)
import CoreFoundation
Expand All @@ -22,12 +20,11 @@ struct DebugServerTests {
// Or we can disable SIP on the target darwinOS and run `sudo sysctl kern.osvariant_status=xx` to workaround
@Test(
.disabled(if: compatibilityTestEnabled, "Skip on AG due to internal_diagnostics check"),
.disabled(if: !compatibilityTestEnabled, "Skip on OG due to OGReference crash on CLI test")
)
func testMode1() throws {
_ = try #require(OGDebugServer.start(mode: 1))
let url = try #require(OGDebugServer.copyURL())
let urlString = (url.takeRetainedValue() as URL).absoluteString
let urlString = (url as URL).absoluteString
#expect(urlString.hasPrefix("graph://"))
OGDebugServer.run(timeout: 1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Testing
struct GraphDescriptionTests {
@Test
func format() {
#expect(Graph.descriptionFormat.takeUnretainedValue() as String == "format")
#expect(Graph.descriptionFormat as String == "format")
}
}
#endif
4 changes: 2 additions & 2 deletions Tests/OpenGraphCompatibilityTests/Graph/GraphTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct GraphTests {
@Test(.disabled(if: !compatibilityTestEnabled, "Not implemented on OG"))
func graphDescriptionDict() throws {
let description = try #require(Graph.description(nil, options: ["format": "graph/dict"] as NSDictionary))
let dic = description.takeUnretainedValue() as! Dictionary<String, AnyHashable>
let dic = description as! Dictionary<String, AnyHashable>
#expect(dic["version"] as? UInt32 == 2)
#expect((dic["graphs"] as? NSArray)?.count == 0)
}
Expand All @@ -53,7 +53,7 @@ struct GraphTests {
#expect(Graph.description(nil, options: options) == nil)
let graph = Graph()
let description = try #require(Graph.description(graph, options: options))
let dotGraph = description.takeUnretainedValue() as! String
let dotGraph = description as! String
let expectedEmptyDotGraph = #"""
digraph {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import Testing

@Suite(.enabled(if: compatibilityTestEnabled))
struct SubgraphTests {
@Test
func shouldRecordTree() {
Expand Down