Skip to content

Update OpenGraph_SPI to OpenGraphCxx #142

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 6 commits into from
Aug 2, 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
15 changes: 6 additions & 9 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ if libraryEvolutionCondition {

let openGraphTarget = Target.target(
name: "OpenGraph",
dependencies: ["OpenGraph_SPI"],
dependencies: ["OpenGraphCxx"],
cSettings: sharedCSettings,
swiftSettings: sharedSwiftSettings
)
// FIXME: Merge into one target
// OpenGraph is a C++ & Swift mix target.
// The SwiftPM support for such usage is still in progress.
let openGraphSPITarget = Target.target(
name: "OpenGraph_SPI",
name: "OpenGraphCxx",
cSettings: sharedCSettings + [
.define("__COREFOUNDATION_FORSWIFTFOUNDATIONONLY__", to: "1", .when(platforms: .nonDarwinPlatforms)),
],
Expand All @@ -170,14 +170,11 @@ let openGraphTestTarget = Target.testTarget(
swiftSettings: sharedSwiftSettings
)
let openGraphSPITestTarget = Target.testTarget(
name: "OpenGraph_SPITests",
name: "OpenGraphCxxTests",
dependencies: [
"OpenGraph_SPI",
"OpenGraphCxx",
],
exclude: ["README.md"],
cSettings: sharedCSettings + [
.headerSearchPath("../../Sources/OpenGraph_SPI"),
],
swiftSettings: sharedSwiftSettings + [.interoperabilityMode(.Cxx)]
)
let openGraphShimsTestTarget = Target.testTarget(
Expand All @@ -204,8 +201,8 @@ let openGraphCompatibilityTestTarget = Target.testTarget(
let package = Package(
name: "OpenGraph",
products: [
.library(name: "OpenGraph", type: .dynamic, targets: ["OpenGraph", "OpenGraph_SPI"]),
.library(name: "OpenGraphShims", type: .dynamic, targets: ["OpenGraph", "OpenGraph_SPI", "OpenGraphShims"]),
.library(name: "OpenGraph", type: .dynamic, targets: ["OpenGraph", "OpenGraphCxx"]),
.library(name: "OpenGraphShims", type: .dynamic, targets: ["OpenGraph", "OpenGraphCxx", "OpenGraphShims"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-numerics", from: "1.0.2"),
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ The current suggested toolchain to build the project is Swift 6.1 / Xcode 16.3.

## Credits

OpenGraph_SPI's Data, Graph, Vector and more is modified based on [Compute](https://github.com/jcmosc/Compute)'s implementations.
OpenGraphCxx's Data, Graph, Vector and more is modified based on [Compute](https://github.com/jcmosc/Compute)'s implementations.

## License

Expand Down
4 changes: 2 additions & 2 deletions Scripts/gen_ag_interface_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ swift build -c release -Xswiftc -emit-module-interface -Xswiftc -enable-library-
cp .build/release/Modules/OpenGraph.swiftinterface ./template.swiftinterface

sed -i '' '1,4d' ./template.swiftinterface
sed -i '' 's/@_exported public import OpenGraph_SPI/@_exported public import AttributeGraph/g' ./template.swiftinterface
sed -i '' 's/OpenGraph_SPI\.//g' ./template.swiftinterface
sed -i '' 's/@_exported public import OpenGraphCxx/@_exported public import AttributeGraph/g' ./template.swiftinterface
sed -i '' 's/OpenGraphCxx\.//g' ./template.swiftinterface
sed -i '' 's/OpenGraph/AttributeGraph/g' ./template.swiftinterface
sed -i '' 's/OG/AG/g' ./template.swiftinterface

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Attribute/Attribute/AnyAttribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: API complete

public import OpenGraph_SPI
public import OpenGraphCxx

extension AnyAttribute {
public typealias Flags = OGAttributeTypeFlags
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Attribute/Attribute/Attribute.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public import OpenGraph_SPI
public import OpenGraphCxx

@frozen
@propertyWrapper
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Attribute/Body/AttributeBody.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: Complete

public import OpenGraph_SPI
public import OpenGraphCxx

public protocol _AttributeBody {
static func _destroySelf(_ pointer: UnsafeMutableRawPointer)
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Attribute/Rule/Rule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: Complete

public import OpenGraph_SPI
public import OpenGraphCxx

public protocol Rule: _AttributeBody {
associatedtype Value
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Attribute/Rule/StatefulRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: Complete

public import OpenGraph_SPI
public import OpenGraphCxx

public protocol StatefulRule: _AttributeBody {
associatedtype Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: Complete

public import OpenGraph_SPI
public import OpenGraphCxx

@frozen
public struct AnyRuleContext: Equatable {
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Attribute/RuleContext/RuleContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: Complete

public import OpenGraph_SPI
public import OpenGraphCxx

@frozen
public struct RuleContext<Value>: Equatable {
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Attribute/Weak/AnyWeakAttribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: Complete

public import OpenGraph_SPI
public import OpenGraphCxx

public typealias AnyWeakAttribute = OGWeakAttribute

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Attribute/Weak/WeakAttribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: Complete

public import OpenGraph_SPI
public import OpenGraphCxx

@frozen
@propertyWrapper
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Export.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@_exported public import OpenGraph_SPI
@_exported public import OpenGraphCxx

// Align the constant define behavior
#if OPENGRAPH_RELEASE_2024
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Graph/Graph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: WIP

public import OpenGraph_SPI
public import OpenGraphCxx

extension Graph {
public static func typeIndex(
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Graph/Subgraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: WIP

public import OpenGraph_SPI
public import OpenGraphCxx

extension Subgraph {
public func addObserver(_ observer: () -> Void) -> Int {
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Runtime/CompareValues.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: Complete

public import OpenGraph_SPI
public import OpenGraphCxx

@_silgen_name("OGCompareValues")
private func OGCompareValues(
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Runtime/Metadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for RELEASE_2021
// Status: WIP

public import OpenGraph_SPI
public import OpenGraphCxx
#if canImport(ObjectiveC)
public import Foundation
#endif
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Runtime/OGTypeApplyEnumData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//
//

// public import OpenGraph_SPI
// public import OpenGraphCxx

@discardableResult
public func withUnsafePointerToEnumCase<T>(
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Runtime/TupleType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Audited for iOS 18.0
// Status: WIP

public import OpenGraph_SPI
public import OpenGraphCxx

// MARK: TupleType

Expand Down
5 changes: 5 additions & 0 deletions Sources/OpenGraphCxx/Attribute/AttributeID.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//
// AttributeID.cpp
// OpenGraphCxx

#include <OpenGraphCxx/Attribute/AttributeID.hpp>
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
// Created by Kyle on 2024/2/17.
//

#include "OGAttributeType.h"
#include <OpenGraphC/OGAttributeType.h>
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
// Created by Kyle on 2024/2/16.
//

#include "OGAttribute.h"
#include "AttributeID.hpp"
#include "../Attribute/AttributeID.hpp"
#include "../Util/assert.hpp"
#include <OpenGraphC/OGAttribute.h>
#include <OpenGraphCxx/Attribute/AttributeID.hpp>
#include <OpenGraphCxx/Util/assert.hpp>
#include <optional>

const OGAttribute OGAttributeNil = OGAttribute(OG::AttributeID::Kind::Null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Kyle on 2024/2/27.
//

#include "OGWeakAttribute.h"
#include <OpenGraphC/OGWeakAttribute.h>

OGWeakAttribute OGCreateWeakAttribute(OGAttribute attribute) {
// TODO
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//
// OGCompareValues.cpp
// OpenGraph_SPI
// OpenGraphCxx

#include "OGComparison.h"
#include "OGComparisonPrivate.h"
#include <OpenGraphC/OGComparison.h>
#include <OpenGraphCxx/Comparison/OGComparisonPrivate.h>

const void *OGComparisonStateGetDestination(OGComparisonState state) {
return ((const OGComparisonStateStorage *)state)->destination;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
// Created by Kyle on 2024/3/6.
//

#include "ClosureFunction.hpp"
#include <OpenGraphCxx/Data/ClosureFunction.hpp>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//
// OGUniqueID.c
// OpenGraph_SPI
// OpenGraphCxx
//
// Audited for iOS 18.0
// Status: Complete

#include "OGUniqueID.h"
#include <OpenGraphC/OGUniqueID.h>
#include <stdatomic.h>

OGUniqueID OGMakeUniqueID(void) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
//
// table.cpp
// OpenGraph_SPI
// OpenGraphCxx
//
// Audited for iOS 18.0
// Status: WIP
// Modified from https://github.com/jcmosc/Compute/blob/0a6b21a4cdeb9bbdd95e7e914c4e18bed37a2456/Sources/ComputeCxx/Data/Table.cpp [MIT License]

#include <OpenGraphCxx/table.hpp>
#include "page.hpp"
#include "page_const.hpp"
#include "zone.hpp"
#include "../Util/assert.hpp"
#include <OpenGraphCxx/Data/table.hpp>
#include <OpenGraphCxx/Data/page.hpp>
#include <OpenGraphCxx/Data/page_const.hpp>
#include <OpenGraphCxx/Data/zone.hpp>
#include <OpenGraphCxx/Util/assert.hpp>
#include <sys/mman.h>
#include <dispatch/dispatch.h>
#if OG_TARGET_OS_DARWIN
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//
// zone.cpp
// OpenGraph_SPI
// OpenGraphCxx

#include "zone.hpp"
#include <OpenGraphCxx/table.hpp>
#include "page.hpp"
#include "../Util/assert.hpp"
#include <OpenGraphCxx/Data/zone.hpp>
#include <OpenGraphCxx/Data/table.hpp>
#include <OpenGraphCxx/Data/page.hpp>
#include <OpenGraphCxx/Util/assert.hpp>
#if OG_TARGET_OS_DARWIN
#include <malloc/malloc.h>
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Created by Kyle on 2024/2/17.
//

#include "OGDebugServer.h"
#include "og-debug-server.hpp"
#include <OpenGraphC/OGDebugServer.h>
#include <OpenGraphCxx/DebugServer/og-debug-server.hpp>

#if OG_TARGET_OS_DARWIN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
// Created by Kyle on 2024/1/11.
// Audited for 2021 Release

#include "og-debug-server.hpp"
#include <OpenGraphCxx/DebugServer/og-debug-server.hpp>
#if OG_TARGET_OS_DARWIN

#include "OGGraphDescription.h"
#include "../Util/log.hpp"
#include "../Util/assert.hpp"
#include "../Graph/Graph.hpp"
#include <OpenGraphC/OGGraphDescription.h>
#include <OpenGraphCxx/Util/log.hpp>
#include <OpenGraphCxx/Util/assert.hpp>
#include <OpenGraphCxx/Graph/Graph.hpp>

#include <iostream>
#include <sys/socket.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//
// Graph.cpp
// OpenGraph_SPI
// OpenGraphCxx

#include "Graph.hpp"
#include "Subgraph.hpp"
#include "OGGraphDescription.h"
#include <OpenGraphCxx/Graph/Graph.hpp>
#include <OpenGraphCxx/Graph/Subgraph.hpp>
#include <OpenGraphC/OGGraphDescription.h>

#if !OG_TARGET_OS_WASI
#include <dispatch/dispatch.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//
// Graph.mm
// OpenGraph_SPI
// OpenGraphCxx

#include "Graph.hpp"
#include "OGGraphDescription.h"
#include <OpenGraphCxx/Graph/Graph.hpp>
#include <OpenGraphC/OGGraphDescription.h>

#if OG_OBJC_FOUNDATION
#include <Foundation/Foundation.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
// Created by Kyle on 2024/2/16.
//

#include "Graph.hpp"
#include "OGGraph.h"
#include "../Util/assert.hpp"
#include <OpenGraphCxx/Graph/Graph.hpp>
#include <OpenGraphC/OGGraph.h>
#include <OpenGraphCxx/Util/assert.hpp>

OG::Graph::Context &OG::Graph::Context::from_cf(OGGraphRef storage) OG_NOEXCEPT {
if (storage->context.isInvalid()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//
// GraphDescription.cpp
// OpenGraph_SPI
// OpenGraphCxx

#include "OGGraphDescription.h"
#include "OGGraph.h"
#include "Graph.hpp"
#include "../Util/assert.hpp"
#include <OpenGraphC/OGGraphDescription.h>
#include <OpenGraphC/OGGraph.h>
#include <OpenGraphCxx/Graph/Graph.hpp>
#include <OpenGraphCxx/Util/assert.hpp>

CFTypeRef OGGraphDescription(OGGraphRef graph, CFDictionaryRef options) {
#if OG_OBJC_FOUNDATION
Expand Down
Loading