diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 86f7aa8a..9dcda007 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -1,12 +1,12 @@ -# OpenGraph Copilot Instructions +# OpenAttributeGraph Copilot Instructions -This file contains coding guidelines and conventions for AI assistants working on the OpenGraph project. +This file contains coding guidelines and conventions for AI assistants working on the OpenAttributeGraph project. ## Quick Reference ### Key Principles - Use `swift-testing` framework with `#expect` macro (not XCTest) -- Follow OpenGraph C++ and Swift interop patterns +- Follow OpenAttributeGraph C++ and Swift interop patterns - Trim trailing whitespaces automatically - Use 4-space indentation consistently @@ -23,7 +23,7 @@ This file contains coding guidelines and conventions for AI assistants working o ```swift import Testing -struct OpenGraphTests { +struct OpenAttributeGraphTests { @Test func functionality() { let value = SomeType() @@ -100,19 +100,19 @@ struct OpenGraphTests { ## C++ Coding Style -### OpenGraphCxx Guidelines +### OpenAttributeGraphCxx Guidelines -- Follow existing OpenGraph C++ patterns and conventions -- Use `OG_INLINE` and `OG_CONSTEXPR` macros for inline and constexpr functions -- Use `OG_NOEXCEPT` for exception specifications -- Maintain compatibility with existing OpenGraph APIs +- Follow existing OpenAttributeGraph C++ patterns and conventions +- Use `OAG_INLINE` and `OAG_CONSTEXPR` macros for inline and constexpr functions +- Use `OAG_NOEXCEPT` for exception specifications +- Maintain compatibility with existing OpenAttributeGraph APIs - Use proper header guards with project-specific naming ### Memory Management - Use RAII principles for resource management - Prefer smart pointers and custom deleters for automatic cleanup -- Use `ptr` template for OpenGraph-specific pointer management +- Use `ptr` template for OpenAttributeGraph-specific pointer management - Implement proper validation and assertion mechanisms ### Template Usage @@ -120,20 +120,20 @@ struct OpenGraphTests { ```cpp template class ptr { - // Implementation following OpenGraph patterns + // Implementation following OpenAttributeGraph patterns }; ``` ## Architecture Patterns -### OpenGraph Compatibility -- Maintain API compatibility with existing OpenGraph functionality +### OpenAttributeGraph Compatibility +- Maintain API compatibility with existing OpenAttributeGraph functionality - Use similar naming conventions and parameter patterns -- Implement protocols and extensions that mirror OpenGraph's design +- Implement protocols and extensions that mirror OpenAttributeGraph's design ### Module Organization - Keep related functionality in appropriate modules -- Use clear module boundaries between OpenGraphCxx and Swift layers +- Use clear module boundaries between OpenAttributeGraphCxx and Swift layers - Avoid circular dependencies between modules ### C++/Swift Interop @@ -163,7 +163,7 @@ func someFunction(value: String) throws -> Int { ## Performance Considerations -- Optimize memory allocation patterns using OpenGraph's table/page system +- Optimize memory allocation patterns using OpenAttributeGraph's table/page system - Use lazy initialization for expensive computations - Consider memory management and avoid retain cycles - Optimize for common use cases while maintaining flexibility @@ -179,7 +179,7 @@ func someFunction(value: String) throws -> Int { ### C++ Files - Use proper header inclusion guards -- Include OpenGraph base headers first +- Include OpenAttributeGraph base headers first - Follow dependency order in include statements - Use forward declarations when possible @@ -193,16 +193,16 @@ func someFunction(value: String) throws -> Int { ## Memory and Data Management -### OpenGraph Patterns +### OpenAttributeGraph Patterns - Use `data::table` for memory region management - Implement proper page allocation and deallocation - Use `ptr` for type-safe offset-based pointers -- Follow OpenGraph's zone-based memory organization +- Follow OpenAttributeGraph's zone-based memory organization ### Validation and Assertions - Use `assert_valid` methods for pointer validation - Implement proper precondition checking -- Use OpenGraph's assertion macros consistently +- Use OpenAttributeGraph's assertion macros consistently - Handle edge cases gracefully --- diff --git a/.github/workflows/compatibility_tests.yml b/.github/workflows/compatibility_tests.yml index 384d057a..5358363d 100644 --- a/.github/workflows/compatibility_tests.yml +++ b/.github/workflows/compatibility_tests.yml @@ -17,11 +17,11 @@ jobs: xcode-version: "16.4" # Swift 6.1.2 runs-on: ${{ matrix.os }} env: - OPENGRAPH_WERROR: 1 - OPENGRAPH_ATTRIBUTEGRAPH: 1 - OPENGRAPH_COMPATIBILITY_TEST: 1 - OPENGRAPH_USE_LOCAL_DEPS: 1 - OPENGRAPH_TARGET_RELEASE: 2024 + OPENATTRIBUTEGRAPH_WERROR: 1 + OPENATTRIBUTEGRAPH_ATTRIBUTEGRAPH: 1 + OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST: 1 + OPENATTRIBUTEGRAPH_USE_LOCAL_DEPS: 1 + OPENATTRIBUTEGRAPH_TARGET_RELEASE: 2024 DARWIN_PRIVATE_FRAMEWORKS_TARGET_RELEASE: 2024 GH_TOKEN: ${{ github.token }} steps: @@ -42,7 +42,7 @@ jobs: - name: Run tests against Apple's AttributeGraph on macOS via Xcode run: | xcodebuild test \ - -scheme OpenGraph-Package \ + -scheme OpenAttributeGraph-Package \ -sdk macosx \ -destination "platform=macOS" \ -skipPackagePluginValidation \ diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 469004e1..78e419a9 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -20,11 +20,11 @@ jobs: ios-simulator-name: "iPhone 16 Pro" runs-on: ${{ matrix.os }} env: - OPENGRAPH_WERROR: 1 - OPENGRAPH_ATTRIBUTEGRAPH: 0 - OPENGRAPH_COMPATIBILITY_TEST: 0 - OPENGRAPH_USE_LOCAL_DEPS: 1 - OPENGRAPH_TARGET_RELEASE: 2024 + OPENATTRIBUTEGRAPH_WERROR: 1 + OPENATTRIBUTEGRAPH_ATTRIBUTEGRAPH: 0 + OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST: 0 + OPENATTRIBUTEGRAPH_USE_LOCAL_DEPS: 1 + OPENATTRIBUTEGRAPH_TARGET_RELEASE: 2024 DARWIN_PRIVATE_FRAMEWORKS_TARGET_RELEASE: 2024 GH_TOKEN: ${{ github.token }} steps: @@ -41,7 +41,7 @@ jobs: - name: Build in debug mode on iOS run: | xcodebuild build \ - -scheme OpenGraph-Package \ + -scheme OpenAttributeGraph-Package \ -configuration Debug \ -destination "platform=iOS Simulator,OS=${{ matrix.ios-version }},name=${{ matrix.ios-simulator-name }}" \ -derivedDataPath .build-debug \ @@ -51,7 +51,7 @@ jobs: - name: Build and run tests in debug mode with coverage on iOS Simulator run: | xcodebuild test \ - -scheme OpenGraph-Package \ + -scheme OpenAttributeGraph-Package \ -configuration Debug \ -destination "platform=iOS Simulator,OS=${{ matrix.ios-version }},name=${{ matrix.ios-simulator-name }}" \ -enableCodeCoverage=YES \ diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index d0965742..622a905c 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -16,11 +16,11 @@ jobs: xcode-version: ["16.4"] # Swift 6.1.2 runs-on: ${{ matrix.os }} env: - OPENGRAPH_WERROR: 1 - OPENGRAPH_ATTRIBUTEGRAPH: 0 - OPENGRAPH_COMPATIBILITY_TEST: 0 - OPENGRAPH_USE_LOCAL_DEPS: 1 - OPENGRAPH_TARGET_RELEASE: 2024 + OPENATTRIBUTEGRAPH_WERROR: 1 + OPENATTRIBUTEGRAPH_ATTRIBUTEGRAPH: 0 + OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST: 0 + OPENATTRIBUTEGRAPH_USE_LOCAL_DEPS: 1 + OPENATTRIBUTEGRAPH_TARGET_RELEASE: 2024 DARWIN_PRIVATE_FRAMEWORKS_TARGET_RELEASE: 2024 GH_TOKEN: ${{ github.token }} steps: @@ -42,7 +42,7 @@ jobs: --build-path .build-test-debug xcrun llvm-cov show \ -instr-profile=.build-test-debug/debug/codecov/default.profdata \ - .build-test-debug/debug/OpenGraphPackageTests.xctest/Contents/MacOS/OpenGraphPackageTests \ + .build-test-debug/debug/OpenAttributeGraphPackageTests.xctest/Contents/MacOS/OpenAttributeGraphPackageTests \ > coverage.txt - name: Build and run tests in release mode run: | diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 8ba54b26..d6b3ec14 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -15,9 +15,9 @@ jobs: swift_version: ["6.1.2"] runs-on: ubuntu-22.04 env: - OPENGRAPH_WERROR: 1 - OPENGRAPH_ATTRIBUTEGRAPH: 0 - OPENGRAPH_COMPATIBILITY_TEST: 0 + OPENATTRIBUTEGRAPH_WERROR: 1 + OPENATTRIBUTEGRAPH_ATTRIBUTEGRAPH: 0 + OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST: 0 container: swift:${{ matrix.swift_version }}-jammy steps: - uses: actions/checkout@v4 @@ -32,7 +32,7 @@ jobs: --build-path .build-test-debug llvm-cov show \ -instr-profile=.build-test-debug/debug/codecov/default.profdata \ - .build-test-debug/debug/OpenGraphPackageTests.xctest \ + .build-test-debug/debug/OpenAttributeGraphPackageTests.xctest \ > coverage.txt - name: Building and running tests in release mode run: | diff --git a/.spi.yml b/.spi.yml index d9e0a5fb..5793db38 100644 --- a/.spi.yml +++ b/.spi.yml @@ -2,4 +2,4 @@ version: 1 builder: configs: - swift_version: 6.0 - documentation_targets: [OpenGraph] + documentation_targets: [OpenAttributeGraph] diff --git a/CREDITS.md b/CREDITS.md index ff1205bb..0555b323 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -6,7 +6,7 @@ This project uses third-party libraries and code. Their licenses and acknowledge ## Compute -OpenGraphCxx's Data, Graph, Vector and more is modified based on [Compute](https://github.com/jcmosc/Compute)'s implementations. +OpenAttributeGraphCxx's Data, Graph, Vector and more is modified based on [Compute](https://github.com/jcmosc/Compute)'s implementations. Compute is licensed as follows: diff --git a/Package.swift b/Package.swift index 285d7fe4..0953d6fd 100644 --- a/Package.swift +++ b/Package.swift @@ -33,7 +33,7 @@ let isSPIBuild = envEnable("SPI_BUILD") // MARK: - Env and Config let isXcodeEnv = Context.environment["__CFBundleIdentifier"] == "com.apple.dt.Xcode" -let development = envEnable("OPENGRAPH_DEVELOPMENT", default: false) +let development = envEnable("OPENATTRIBUTEGRAPH_DEVELOPMENT", default: false) let swiftBinPath = Context.environment["_"] ?? "/usr/bin/swift" let swiftBinURL = URL(fileURLWithPath: swiftBinPath) @@ -51,22 +51,22 @@ var sharedSwiftSettings: [SwiftSetting] = [ .swiftLanguageMode(.v5), ] -// MARK: [env] OPENGRAPH_SWIFT_TOOLCHAIN_PATH +// MARK: [env] OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_PATH // Modified from: https://github.com/swiftlang/swift/blob/main/SwiftCompilerSources/Package.swift // // Create a couple of symlinks to an existing Ninja build: // // ```shell -// cd $OPENGRAPH_SWIFT_TOOLCHAIN_PATH +// cd $OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_PATH // mkdir -p build/Default // ln -s build//llvm- build/Default/llvm // ln -s build//swift- build/Default/swift // ``` // -// where <$OPENGRAPH_SWIFT_TOOLCHAIN_PATH> is the parent directory of the swift repository. +// where <$OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_PATH> is the parent directory of the swift repository. -let swiftToolchainPath = Context.environment["OPENGRAPH_SWIFT_TOOLCHAIN_PATH"] ?? (development ? "/Volumes/BuildMachine/swift-project" : "") +let swiftToolchainPath = Context.environment["OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_PATH"] ?? (development ? "/Volumes/BuildMachine/swift-project" : "") if !swiftToolchainPath.isEmpty { sharedCSettings.append( .unsafeFlags( @@ -88,64 +88,64 @@ if !swiftToolchainPath.isEmpty { ) } -// MARK: [env] OPENGRAPH_SWIFT_TOOLCHAIN_VERSION +// MARK: [env] OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_VERSION -let swiftToolchainVersion = Context.environment["OPENGRAPH_SWIFT_TOOLCHAIN_VERSION"] ?? (development ? "6.0.2" : "") +let swiftToolchainVersion = Context.environment["OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_VERSION"] ?? (development ? "6.0.2" : "") if !swiftToolchainVersion.isEmpty { sharedCSettings.append( - .define("OPENGRAPH_SWIFT_TOOLCHAIN_VERSION", to: swiftToolchainVersion) + .define("OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_VERSION", to: swiftToolchainVersion) ) } -// MARK: - [env] OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED +// MARK: - [env] OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED -let swiftToolchainSupported = envEnable("OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED", default: !swiftToolchainVersion.isEmpty) +let swiftToolchainSupported = envEnable("OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED", default: !swiftToolchainVersion.isEmpty) if swiftToolchainSupported { - sharedCSettings.append(.define("OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED")) - sharedSwiftSettings.append(.define("OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED")) + sharedCSettings.append(.define("OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED")) + sharedSwiftSettings.append(.define("OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED")) } -// MARK: - [env] OPENGRAPH_TARGET_RELEASE +// MARK: - [env] OPENATTRIBUTEGRAPH_TARGET_RELEASE -let releaseVersion = Context.environment["OPENGRAPH_TARGET_RELEASE"].flatMap { Int($0) } ?? 2024 -//sharedCSettings.append(.define("OPENGRAPH_RELEASE", to: "\(releaseVersion)")) -sharedSwiftSettings.append(.define("OPENGRAPH_RELEASE_\(releaseVersion)")) +let releaseVersion = Context.environment["OPENATTRIBUTEGRAPH_TARGET_RELEASE"].flatMap { Int($0) } ?? 2024 +//sharedCSettings.append(.define("OPENATTRIBUTEGRAPH_RELEASE", to: "\(releaseVersion)")) +sharedSwiftSettings.append(.define("OPENATTRIBUTEGRAPH_RELEASE_\(releaseVersion)")) if releaseVersion >= 2021 { for year in 2021 ... releaseVersion { - sharedSwiftSettings.append(.define("OPENGRAPH_SUPPORT_\(year)_API")) + sharedSwiftSettings.append(.define("OPENATTRIBUTEGRAPH_SUPPORT_\(year)_API")) } } -// MARK: - [env] OPENGRAPH_WERROR +// MARK: - [env] OPENATTRIBUTEGRAPH_WERROR -let warningsAsErrorsCondition = envEnable("OPENGRAPH_WERROR", default: isXcodeEnv && development) +let warningsAsErrorsCondition = envEnable("OPENATTRIBUTEGRAPH_WERROR", default: isXcodeEnv && development) if warningsAsErrorsCondition { sharedSwiftSettings.append(.unsafeFlags(["-warnings-as-errors"])) } -// MARK: - [env] OPENGRAPH_LIBRARY_EVOLUTION +// MARK: - [env] OPENATTRIBUTEGRAPH_LIBRARY_EVOLUTION -let libraryEvolutionCondition = envEnable("OPENGRAPH_LIBRARY_EVOLUTION", default: buildForDarwinPlatform) +let libraryEvolutionCondition = envEnable("OPENATTRIBUTEGRAPH_LIBRARY_EVOLUTION", default: buildForDarwinPlatform) if libraryEvolutionCondition { // NOTE: -enable-library-evolution will cause module verify failure for `swift build`. - // Either set OPENGRAPH_LIBRARY_EVOLUTION=0 or add `-Xswiftc -no-verify-emitted-module-interface` after `swift build` + // Either set OPENATTRIBUTEGRAPH_LIBRARY_EVOLUTION=0 or add `-Xswiftc -no-verify-emitted-module-interface` after `swift build` sharedSwiftSettings.append(.unsafeFlags(["-enable-library-evolution", "-no-verify-emitted-module-interface"])) } // MARK: - Targets let openGraphTarget = Target.target( - name: "OpenGraph", - dependencies: ["OpenGraphCxx"], + name: "OpenAttributeGraph", + dependencies: ["OpenAttributeGraphCxx"], cSettings: sharedCSettings, swiftSettings: sharedSwiftSettings ) // FIXME: Merge into one target -// OpenGraph is a C++ & Swift mix target. +// OpenAttributeGraph is a C++ & Swift mix target. // The SwiftPM support for such usage is still in progress. let openGraphSPITarget = Target.target( - name: "OpenGraphCxx", + name: "OpenAttributeGraphCxx", cSettings: sharedCSettings + [ .define("__COREFOUNDATION_FORSWIFTFOUNDATIONONLY__", to: "1", .when(platforms: .nonDarwinPlatforms)), ], @@ -154,7 +154,7 @@ let openGraphSPITarget = Target.target( ] ) let openGraphShimsTarget = Target.target( - name: "OpenGraphShims", + name: "OpenAttributeGraphShims", cSettings: sharedCSettings, swiftSettings: sharedSwiftSettings ) @@ -162,33 +162,33 @@ let openGraphShimsTarget = Target.target( // MARK: - Test Targets let openGraphTestsTarget = Target.testTarget( - name: "OpenGraphTests", + name: "OpenAttributeGraphTests", dependencies: [ - "OpenGraph", + "OpenAttributeGraph", ], exclude: ["README.md"], cSettings: sharedCSettings, swiftSettings: sharedSwiftSettings ) let openGraphCxxTestsTarget = Target.testTarget( - name: "OpenGraphCxxTests", + name: "OpenAttributeGraphCxxTests", dependencies: [ - "OpenGraphCxx", + "OpenAttributeGraphCxx", ], exclude: ["README.md"], swiftSettings: sharedSwiftSettings + [.interoperabilityMode(.Cxx)] ) let openGraphShimsTestsTarget = Target.testTarget( - name: "OpenGraphShimsTests", + name: "OpenAttributeGraphShimsTests", dependencies: [ - "OpenGraphShims", + "OpenAttributeGraphShims", ], exclude: ["README.md"], cSettings: sharedCSettings, swiftSettings: sharedSwiftSettings ) let openGraphCompatibilityTestsTarget = Target.testTarget( - name: "OpenGraphCompatibilityTests", + name: "OpenAttributeGraphCompatibilityTests", dependencies: [ .product(name: "Numerics", package: "swift-numerics"), ], @@ -200,10 +200,10 @@ let openGraphCompatibilityTestsTarget = Target.testTarget( // MARK: - Package let package = Package( - name: "OpenGraph", + name: "OpenAttributeGraph", products: [ - .library(name: "OpenGraph", type: .dynamic, targets: ["OpenGraph", "OpenGraphCxx"]), - .library(name: "OpenGraphShims", type: .dynamic, targets: ["OpenGraph", "OpenGraphCxx", "OpenGraphShims"]), + .library(name: "OpenAttributeGraph", type: .dynamic, targets: ["OpenAttributeGraph", "OpenAttributeGraphCxx"]), + .library(name: "OpenAttributeGraphShims", type: .dynamic, targets: ["OpenAttributeGraph", "OpenAttributeGraphCxx", "OpenAttributeGraphShims"]), ], dependencies: [ .package(url: "https://github.com/apple/swift-numerics", from: "1.0.2"), @@ -227,7 +227,7 @@ extension Target { .product(name: "AttributeGraph", package: "DarwinPrivateFrameworks") ) var swiftSettings = swiftSettings ?? [] - swiftSettings.append(.define("OPENGRAPH_ATTRIBUTEGRAPH")) + swiftSettings.append(.define("OPENATTRIBUTEGRAPH_ATTRIBUTEGRAPH")) self.swiftSettings = swiftSettings } @@ -236,14 +236,14 @@ extension Target { .product(name: "AttributeGraph", package: "DarwinPrivateFrameworks") ) var swiftSettings = swiftSettings ?? [] - swiftSettings.append(.define("OPENGRAPH_COMPATIBILITY_TEST")) + swiftSettings.append(.define("OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST")) self.swiftSettings = swiftSettings } } -let useLocalDeps = envEnable("OPENGRAPH_USE_LOCAL_DEPS") +let useLocalDeps = envEnable("OPENATTRIBUTEGRAPH_USE_LOCAL_DEPS") -let attributeGraphCondition = envEnable("OPENGRAPH_ATTRIBUTEGRAPH", default: buildForDarwinPlatform && !isSPIBuild) +let attributeGraphCondition = envEnable("OPENATTRIBUTEGRAPH_ATTRIBUTEGRAPH", default: buildForDarwinPlatform && !isSPIBuild) if attributeGraphCondition { let privateFrameworkRepo: Package.Dependency @@ -262,15 +262,15 @@ if attributeGraphCondition { default: nil } } else { - openGraphShimsTarget.dependencies.append("OpenGraph") + openGraphShimsTarget.dependencies.append("OpenAttributeGraph") package.platforms = [.iOS(.v13), .macOS(.v10_15), .macCatalyst(.v13), .tvOS(.v13), .watchOS(.v5)] } -let compatibilityTestCondition = envEnable("OPENGRAPH_COMPATIBILITY_TEST") +let compatibilityTestCondition = envEnable("OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST") if compatibilityTestCondition && attributeGraphCondition { openGraphCompatibilityTestsTarget.addCompatibilitySettings() } else { - openGraphCompatibilityTestsTarget.dependencies.append("OpenGraph") + openGraphCompatibilityTestsTarget.dependencies.append("OpenAttributeGraph") } extension [Platform] { diff --git a/README.md b/README.md index c97285aa..a49e0184 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# OpenGraph +# OpenAttributeGraph -[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FOpenSwiftUIProject%2FOpenGraph%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/OpenSwiftUIProject/OpenGraph) +[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FOpenSwiftUIProject%2FOpenAttributeGraph%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/OpenSwiftUIProject/OpenAttributeGraph) -[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FOpenSwiftUIProject%2FOpenGraph%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/OpenSwiftUIProject/OpenGraph) +[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FOpenSwiftUIProject%2FOpenAttributeGraph%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/OpenSwiftUIProject/OpenAttributeGraph) -[![codecov](https://codecov.io/gh/OpenSwiftUIProject/OpenGraph/graph/badge.svg?token=W1KDSUMWJW)](https://codecov.io/gh/OpenSwiftUIProject/OpenGraph) +[![codecov](https://codecov.io/gh/OpenSwiftUIProject/OpenAttributeGraph/graph/badge.svg?token=W1KDSUMWJW)](https://codecov.io/gh/OpenSwiftUIProject/OpenAttributeGraph) -OpenGraph is an open source implementation of Apple's Private framework - AttributeGraph +OpenAttributeGraph is an open source implementation of Apple's Private framework - AttributeGraph AttributeGraph is a high performance computing engine written in C++ and Swift. @@ -14,13 +14,13 @@ And it powers the underlying computing and diffing of SwiftUI. | **CI Status** | |---| -|[![Compatibility tests](https://github.com/OpenSwiftUIProject/OpenGraph/actions/workflows/compatibility_tests.yml/badge.svg)](https://github.com/OpenSwiftUIProject/OpenGraph/actions/workflows/compatibility_tests.yml)| -|[![macOS](https://github.com/OpenSwiftUIProject/OpenGraph/actions/workflows/macos.yml/badge.svg)](https://github.com/OpenSwiftUIProject/OpenGraph/actions/workflows/macos.yml)| -|[![iOS](https://github.com/OpenSwiftUIProject/OpenGraph/actions/workflows/ios.yml/badge.svg)](https://github.com/OpenSwiftUIProject/OpenGraph/actions/workflows/ios.yml)| -|[![Ubuntu](https://github.com/OpenSwiftUIProject/OpenGraph/actions/workflows/ubuntu.yml/badge.svg)](https://github.com/OpenSwiftUIProject/OpenGraph/actions/workflows/ubuntu.yml)| +|[![Compatibility tests](https://github.com/OpenSwiftUIProject/OpenAttributeGraph/actions/workflows/compatibility_tests.yml/badge.svg)](https://github.com/OpenSwiftUIProject/OpenAttributeGraph/actions/workflows/compatibility_tests.yml)| +|[![macOS](https://github.com/OpenSwiftUIProject/OpenAttributeGraph/actions/workflows/macos.yml/badge.svg)](https://github.com/OpenSwiftUIProject/OpenAttributeGraph/actions/workflows/macos.yml)| +|[![iOS](https://github.com/OpenSwiftUIProject/OpenAttributeGraph/actions/workflows/ios.yml/badge.svg)](https://github.com/OpenSwiftUIProject/OpenAttributeGraph/actions/workflows/ios.yml)| +|[![Ubuntu](https://github.com/OpenSwiftUIProject/OpenAttributeGraph/actions/workflows/ubuntu.yml/badge.svg)](https://github.com/OpenSwiftUIProject/OpenAttributeGraph/actions/workflows/ubuntu.yml)| The project is for the following purposes: -- Add OG support for non-Apple platform (eg. Linux, WASI and Windows) +- Add OAG support for non-Apple platform (eg. Linux, WASI and Windows) - Diagnose and debug AG issues on Apple platform Currently, this project is in early development. @@ -29,21 +29,21 @@ Currently, this project is in early development. ### Via Swift Package Manager -Add OpenGraph as a dependency in your `Package.swift`: +Add OpenAttributeGraph as a dependency in your `Package.swift`: ```swift dependencies: [ - .package(url: "https://github.com/OpenSwiftUIProject/OpenGraph.git", from: "0.2.0") + .package(url: "https://github.com/OpenSwiftUIProject/OpenAttributeGraph.git", from: "0.2.0") ] ``` > [!NOTE] -> - You may need to configure the Swift toolchain header for proper integration of OpenGraph -> - By default, OpenGraphShims will use the private AttributeGraph as its implementation on Apple platforms +> - You may need to configure the Swift toolchain header for proper integration of OpenAttributeGraph +> - By default, OpenAttributeGraphShims will use the private AttributeGraph as its implementation on Apple platforms ### Via Prebuilt XCFramework -For a simpler setup, you can use the prebuilt XCFramework available on the [releases page](https://github.com/OpenSwiftUIProject/OpenGraph/releases). +For a simpler setup, you can use the prebuilt XCFramework available on the [releases page](https://github.com/OpenSwiftUIProject/OpenAttributeGraph/releases). ## Build diff --git a/Scripts/build.sh b/Scripts/build.sh index a12a29d5..2a714df8 100755 --- a/Scripts/build.sh +++ b/Scripts/build.sh @@ -5,8 +5,8 @@ filepath() { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" } -OPENGRAPH_ROOT="$(dirname $(dirname $(filepath $0)))" +OPENATTRIBUTEGRAPH_ROOT="$(dirname $(dirname $(filepath $0)))" -cd $OPENGRAPH_ROOT +cd $OPENATTRIBUTEGRAPH_ROOT swift build diff --git a/Scripts/build_swiftinterface.sh b/Scripts/build_swiftinterface.sh index 0fe8dfd5..44110209 100755 --- a/Scripts/build_swiftinterface.sh +++ b/Scripts/build_swiftinterface.sh @@ -5,8 +5,8 @@ filepath() { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" } -OPENGRAPH_ROOT="$(dirname $(dirname $(filepath $0)))" +OPENATTRIBUTEGRAPH_ROOT="$(dirname $(dirname $(filepath $0)))" -cd $OPENGRAPH_ROOT +cd $OPENATTRIBUTEGRAPH_ROOT swift build -Xswiftc -emit-module-interface -Xswiftc -enable-library-evolution -Xswiftc -no-verify-emitted-module-interface diff --git a/Scripts/build_xcframework.sh b/Scripts/build_xcframework.sh index 07d72f71..344a7071 100755 --- a/Scripts/build_xcframework.sh +++ b/Scripts/build_xcframework.sh @@ -14,8 +14,8 @@ XCODEBUILD_DERIVED_DATA_PATH="$XCODEBUILD_BUILD_DIR/DerivedData" # Copy and modify modulemap mkdir -p "$PROJECT_BUILD_DIR" cat > "$PROJECT_BUILD_DIR/module.modulemap" << 'EOF' -framework module OpenGraph { - umbrella header "OpenGraph-umbrella.h" +framework module OpenAttributeGraph { + umbrella header "OpenAttributeGraph-umbrella.h" export * module * { export * } } @@ -75,10 +75,10 @@ build_framework() { cp -r \ "$XCODEBUILD_DERIVED_DATA_PATH/Build/Intermediates.noindex/ArchiveIntermediates/$scheme/BuildProductsPath/Release/$scheme.swiftmodule" \ "$FRAMEWORK_MODULES_PATH/$scheme.swiftmodule" - # Replace OpenGraphCxx with OpenGraph in swiftinterface files - find "$FRAMEWORK_MODULES_PATH/$scheme.swiftmodule" -name "*.swiftinterface" -exec sed -i '' 's/OpenGraphCxx/OpenGraph/g' {} \; + # Replace OpenAttributeGraphCxx with OpenAttributeGraph in swiftinterface files + find "$FRAMEWORK_MODULES_PATH/$scheme.swiftmodule" -name "*.swiftinterface" -exec sed -i '' 's/OpenAttributeGraphCxx/OpenAttributeGraph/g' {} \; cp -r \ - "$PROJECT_ROOT/Sources/OpenGraphCxx/include/OpenGraph"/* \ + "$PROJECT_ROOT/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph"/* \ "$FRAMEWORK_HEADERS_PATH/" 2>/dev/null || true cp "$PROJECT_BUILD_DIR/module.modulemap" \ "$FRAMEWORK_MODULES_PATH/module.modulemap" 2>/dev/null || true @@ -94,10 +94,10 @@ build_framework() { cp -r \ "$XCODEBUILD_DERIVED_DATA_PATH/Build/Intermediates.noindex/ArchiveIntermediates/$scheme/BuildProductsPath/Release-$sdk/$scheme.swiftmodule" \ "$FRAMEWORK_MODULES_PATH/$scheme.swiftmodule" - # Replace OpenGraphCxx with OpenGraph in swiftinterface files - find "$FRAMEWORK_MODULES_PATH/$scheme.swiftmodule" -name "*.swiftinterface" -exec sed -i '' 's/OpenGraphCxx/OpenGraph/g' {} \; + # Replace OpenAttributeGraphCxx with OpenAttributeGraph in swiftinterface files + find "$FRAMEWORK_MODULES_PATH/$scheme.swiftmodule" -name "*.swiftinterface" -exec sed -i '' 's/OpenAttributeGraphCxx/OpenAttributeGraph/g' {} \; cp -r \ - "$PROJECT_ROOT/Sources/OpenGraphCxx/include/OpenGraph"/* \ + "$PROJECT_ROOT/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph"/* \ "$FRAMEWORK_HEADERS_PATH/" 2>/dev/null || true cp "$PROJECT_BUILD_DIR/module.modulemap" \ "$FRAMEWORK_MODULES_PATH/module.modulemap" 2>/dev/null || true diff --git a/Scripts/bump_ag_pr.sh b/Scripts/bump_ag_pr.sh index 970f9b43..3ca7a151 100755 --- a/Scripts/bump_ag_pr.sh +++ b/Scripts/bump_ag_pr.sh @@ -11,8 +11,8 @@ filepath() { TARGET_BRANCH="${1:-main}" SCRIPT_ROOT="$(dirname $(dirname $(filepath $0)))" -OG_REPO_DIR="$SCRIPT_ROOT/.og_repo" -OPENGRAPH_ROOT="$OG_REPO_DIR" +OAG_REPO_DIR="$SCRIPT_ROOT/.og_repo" +OPENATTRIBUTEGRAPH_ROOT="$OAG_REPO_DIR" AG_REPO_DIR="$SCRIPT_ROOT/.ag_repo" echo "Starting DarwinPrivateFrameworks bump PR workflow..." @@ -24,10 +24,10 @@ cleanup() { echo "Cleaning up temporary repository..." rm -rf "$AG_REPO_DIR" fi - if [[ -d "$OG_REPO_DIR" ]]; then + if [[ -d "$OAG_REPO_DIR" ]]; then echo "Cleaning up git worktree..." cd "$SCRIPT_ROOT" - git worktree remove --force "$OG_REPO_DIR" 2>/dev/null || true + git worktree remove --force "$OAG_REPO_DIR" 2>/dev/null || true fi } @@ -38,11 +38,11 @@ cd "$SCRIPT_ROOT" # Step 1: Setup git worktree for target branch echo "Setting up git worktree for branch: $TARGET_BRANCH" -if [[ -d "$OG_REPO_DIR" ]]; then - git worktree remove --force "$OG_REPO_DIR" 2>/dev/null || true +if [[ -d "$OAG_REPO_DIR" ]]; then + git worktree remove --force "$OAG_REPO_DIR" 2>/dev/null || true fi -git worktree add "$OG_REPO_DIR" "$TARGET_BRANCH" +git worktree add "$OAG_REPO_DIR" "$TARGET_BRANCH" # Step 2: Clone DarwinPrivateFrameworks repository echo "Cloning DarwinPrivateFrameworks repository..." @@ -59,7 +59,7 @@ git checkout -b "update-ag-$TARGET_BRANCH" # Step 4: Generate AG template echo "Generating AG template..." -cd "$OPENGRAPH_ROOT" +cd "$OPENATTRIBUTEGRAPH_ROOT" ./Scripts/gen_ag_template.sh # Step 5: Update DarwinPrivateFrameworks with generated content @@ -86,11 +86,11 @@ git add . if git diff --staged --quiet; then echo "No changes to commit" else - git commit -m "feat(ag): Update AttributeGraph from OpenGraph $TARGET_BRANCH + git commit -m "feat(ag): Update AttributeGraph from OpenAttributeGraph $TARGET_BRANCH -- Updated headers from OpenGraph sources +- Updated headers from OpenAttributeGraph sources - Updated Swift interface template -- Generated from OpenGraph branch: $TARGET_BRANCH" +- Generated from OpenAttributeGraph branch: $TARGET_BRANCH" fi # Step 7: Update xcframeworks @@ -110,16 +110,16 @@ echo "Pushing branch and creating PR..." git push origin "update-ag-$TARGET_BRANCH" # Create PR -PR_TITLE="Update AttributeGraph from OpenGraph $TARGET_BRANCH" -PR_BODY="Automated update of AttributeGraph framework from OpenGraph. +PR_TITLE="Update AttributeGraph from OpenAttributeGraph $TARGET_BRANCH" +PR_BODY="Automated update of AttributeGraph framework from OpenAttributeGraph. **Changes:** -- Updated headers from OpenGraph sources +- Updated headers from OpenAttributeGraph sources - Updated Swift interface template - Updated xcframework binaries **Source Branch:** $TARGET_BRANCH -**Generated by:** OpenGraph bump script" +**Generated by:** OpenAttributeGraph bump script" gh pr create \ --title "$PR_TITLE" \ diff --git a/Scripts/demangle.sh b/Scripts/demangle.sh index 90ca5f96..03a4c823 100755 --- a/Scripts/demangle.sh +++ b/Scripts/demangle.sh @@ -6,7 +6,7 @@ filepath() { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" } -OG_ROOT="$(dirname $(dirname $(filepath $0)))" +OAG_ROOT="$(dirname $(dirname $(filepath $0)))" # Get the language and input file path from the arguments language=${1:-"swift"} diff --git a/Scripts/gen_ag_template.sh b/Scripts/gen_ag_template.sh index f9cc77a0..d7dff4ac 100755 --- a/Scripts/gen_ag_template.sh +++ b/Scripts/gen_ag_template.sh @@ -6,17 +6,17 @@ filepath() { } gen_interface() { - swift build -c release -Xswiftc -emit-module-interface -Xswiftc -enable-library-evolution -Xswiftc -no-verify-emitted-module-interface -Xswiftc -package-name -Xswiftc OpenGraph -Xswiftc -Osize + swift build -c release -Xswiftc -emit-module-interface -Xswiftc -enable-library-evolution -Xswiftc -no-verify-emitted-module-interface -Xswiftc -package-name -Xswiftc OpenAttributeGraph -Xswiftc -Osize mkdir -p .ag_template - cp .build/release/Modules/OpenGraph.swiftinterface .ag_template/template.swiftinterface + cp .build/release/Modules/OpenAttributeGraph.swiftinterface .ag_template/template.swiftinterface sed -i '' '1,4d' .ag_template/template.swiftinterface - sed -i '' 's/@_exported public import OpenGraphCxx/@_exported public import AttributeGraph/g' .ag_template/template.swiftinterface - sed -i '' 's/OpenGraphCxx\.//g' .ag_template/template.swiftinterface - sed -i '' 's/OpenGraph/AttributeGraph/g' .ag_template/template.swiftinterface - sed -i '' 's/OPENGRAPH/ATTRIBUTEGRAPH/g' .ag_template/template.swiftinterface - sed -i '' 's/OG/AG/g' .ag_template/template.swiftinterface + sed -i '' 's/@_exported public import OpenAttributeGraphCxx/@_exported public import AttributeGraph/g' .ag_template/template.swiftinterface + sed -i '' 's/OpenAttributeGraphCxx\.//g' .ag_template/template.swiftinterface + sed -i '' 's/OpenAttributeGraph/AttributeGraph/g' .ag_template/template.swiftinterface + sed -i '' 's/OPENATTRIBUTEGRAPH/ATTRIBUTEGRAPH/g' .ag_template/template.swiftinterface + sed -i '' 's/OAG/AG/g' .ag_template/template.swiftinterface echo "Generated template.swiftinterface successfully" } @@ -24,33 +24,33 @@ gen_interface() { gen_header() { mkdir -p .ag_template/Headers - cp -r Sources/OpenGraphCxx/include/OpenGraph/* .ag_template/Headers/ + cp -r Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/* .ag_template/Headers/ - # Rename files from OGxx to AGxx and OpenGraphxx to AttributeGraphxx - find .ag_template/Headers -name "OG*" -type f | while read file; do - new_name=$(echo "$file" | sed 's/OG/AG/g') + # Rename files from OAGxx to AGxx and OpenAttributeGraphxx to AttributeGraphxx + find .ag_template/Headers -name "OAG*" -type f | while read file; do + new_name=$(echo "$file" | sed 's/OAG/AG/g') mv "$file" "$new_name" done - find .ag_template/Headers -name "OpenGraph*" -type f | while read file; do - new_name=$(echo "$file" | sed 's/OpenGraph/AttributeGraph/g') + find .ag_template/Headers -name "OpenAttributeGraph*" -type f | while read file; do + new_name=$(echo "$file" | sed 's/OpenAttributeGraph/AttributeGraph/g') mv "$file" "$new_name" done # Update content in all header files find .ag_template/Headers -name "*.h" -type f | while read file; do - sed -i '' 's/OpenGraphCxx/AttributeGraph/g' "$file" - sed -i '' 's/OpenGraph/AttributeGraph/g' "$file" - sed -i '' 's/OPENGRAPH/ATTRIBUTEGRAPH/g' "$file" - sed -i '' 's/OG/AG/g' "$file" + sed -i '' 's/OpenAttributeGraphCxx/AttributeGraph/g' "$file" + sed -i '' 's/OpenAttributeGraph/AttributeGraph/g' "$file" + sed -i '' 's/OPENATTRIBUTEGRAPH/ATTRIBUTEGRAPH/g' "$file" + sed -i '' 's/OAG/AG/g' "$file" done echo "Generated template headers successfully" } -OPENGRAPH_ROOT="$(dirname $(dirname $(filepath $0)))" +OPENATTRIBUTEGRAPH_ROOT="$(dirname $(dirname $(filepath $0)))" -cd $OPENGRAPH_ROOT +cd $OPENATTRIBUTEGRAPH_ROOT gen_interface gen_header diff --git a/Sources/OpenGraph/Attribute/Attribute/AnyAttribute.swift b/Sources/OpenAttributeGraph/Attribute/Attribute/AnyAttribute.swift similarity index 85% rename from Sources/OpenGraph/Attribute/Attribute/AnyAttribute.swift rename to Sources/OpenAttributeGraph/Attribute/Attribute/AnyAttribute.swift index 08f73f3c..2a25ee91 100644 --- a/Sources/OpenGraph/Attribute/Attribute/AnyAttribute.swift +++ b/Sources/OpenAttributeGraph/Attribute/Attribute/AnyAttribute.swift @@ -1,14 +1,14 @@ // // AnyAttribute.swift -// OpenGraph +// OpenAttributeGraph // // Audited for RELEASE_2021 // Status: API complete -public import OpenGraphCxx +public import OpenAttributeGraphCxx -@_silgen_name("OGGraphMutateAttribute") -private func OGGraphMutateAttribute( +@_silgen_name("OAGGraphMutateAttribute") +private func OAGGraphMutateAttribute( _ attribute: AnyAttribute, type: Metadata, invalidating: Bool, @@ -25,7 +25,7 @@ extension AnyAttribute { } public static var current: AnyAttribute? { - let current = __OGGraphGetCurrentAttribute() + let current = __OAGGraphGetCurrentAttribute() return current == .nil ? nil : current } @@ -37,11 +37,11 @@ extension AnyAttribute { flags = flags.subtracting(mask).union(newFlags.intersection(mask)) } - public func addInput(_ attribute: AnyAttribute, options: OGInputOptions = [], token: Int) { - __OGGraphAddInput(self, attribute, options, token) + public func addInput(_ attribute: AnyAttribute, options: OAGInputOptions = [], token: Int) { + __OAGGraphAddInput(self, attribute, options, token) } - public func addInput(_ attribute: Attribute, options: OGInputOptions = [], token: Int) { + public func addInput(_ attribute: Attribute, options: OAGInputOptions = [], token: Int) { addInput(attribute.identifier, options: options, token: token) } @@ -52,7 +52,7 @@ extension AnyAttribute { } public func mutateBody(as type: Value.Type, invalidating: Bool, _ body: (inout Value) -> Void) { - OGGraphMutateAttribute( + OAGGraphMutateAttribute( self, type: Metadata(type), invalidating: invalidating diff --git a/Sources/OpenGraph/Attribute/Attribute/Attribute.swift b/Sources/OpenAttributeGraph/Attribute/Attribute/Attribute.swift similarity index 83% rename from Sources/OpenGraph/Attribute/Attribute/Attribute.swift rename to Sources/OpenAttributeGraph/Attribute/Attribute/Attribute.swift index 103d19c1..b097ffc3 100644 --- a/Sources/OpenGraph/Attribute/Attribute/Attribute.swift +++ b/Sources/OpenAttributeGraph/Attribute/Attribute/Attribute.swift @@ -1,4 +1,4 @@ -public import OpenGraphCxx +public import OpenAttributeGraphCxx @frozen @propertyWrapper @@ -43,7 +43,7 @@ public struct Attribute { #if os(WASI) // This is a compiler issue and SwiftWasm toolchain enable the assertation // See https://github.com/swiftwasm/swift/issues/5569 - fatalError("Swift 5.9.1 Compiler issue - type mismatch of Unmanaged and OGGraphContext") + fatalError("Swift 5.9.1 Compiler issue - type mismatch of Unmanaged and OAGGraphContext") #else guard let context = Subgraph.currentGraphContext else { fatalError("attempting to create attribute with no subgraph: \(Value.self)") @@ -55,7 +55,7 @@ public struct Attribute { flags: flags, update: update ) - identifier = OGGraphCreateAttribute(index: index, body: body, value: value) + identifier = OAGGraphCreateAttribute(index: index, body: body, value: value) #endif } @@ -63,7 +63,7 @@ public struct Attribute { public var wrappedValue: Value { unsafeAddress { - OGGraphGetValue(identifier, type: Value.self) + OAGGraphGetValue(identifier, type: Value.self) .value .assumingMemoryBound(to: Value.self) } @@ -145,7 +145,7 @@ public struct Attribute { public var value: Value { unsafeAddress { - OGGraphGetValue(identifier, type: Value.self) + OAGGraphGetValue(identifier, type: Value.self) .value .assumingMemoryBound(to: Value.self) } @@ -154,16 +154,16 @@ public struct Attribute { public var valueState: ValueState { identifier.valueState } - public func valueAndFlags(options: OGValueOptions = []) -> (value: Value, flags: OGChangedValueFlags) { - let value = OGGraphGetValue(identifier, options: options, type: Value.self) + public func valueAndFlags(options: OAGValueOptions = []) -> (value: Value, flags: OAGChangedValueFlags) { + let value = OAGGraphGetValue(identifier, options: options, type: Value.self) return ( value.value.assumingMemoryBound(to: Value.self).pointee, value.flags ) } - public func changedValue(options: OGValueOptions = []) -> (value: Value, changed: Bool) { - let value = OGGraphGetValue(identifier, options: options, type: Value.self) + public func changedValue(options: OAGValueOptions = []) -> (value: Value, changed: Bool) { + let value = OAGGraphGetValue(identifier, options: options, type: Value.self) return ( value.value.assumingMemoryBound(to: Value.self).pointee, value.flags.contains(.changed) @@ -172,7 +172,7 @@ public struct Attribute { public func setValue(_ value: Value) -> Bool { withUnsafePointer(to: value) { valuePointer in - OGGraphSetValue(identifier, valuePointer: valuePointer) + OAGGraphSetValue(identifier, valuePointer: valuePointer) } } @@ -184,11 +184,11 @@ public struct Attribute { // MARK: - Input - public func addInput(_ attribute: AnyAttribute, options: OGInputOptions = [], token: Int) { + public func addInput(_ attribute: AnyAttribute, options: OAGInputOptions = [], token: Int) { identifier.addInput(attribute, options: options, token: token) } - public func addInput(_ attribute: Attribute, options: OGInputOptions = [], token: Int) { + public func addInput(_ attribute: Attribute, options: OAGInputOptions = [], token: Int) { identifier.addInput(attribute, options: options, token: token) } @@ -230,17 +230,17 @@ extension Attribute { } } -@_silgen_name("OGGraphCreateAttribute") +@_silgen_name("OAGGraphCreateAttribute") @inline(__always) @inlinable -func OGGraphCreateAttribute(index: Int, body: UnsafeRawPointer, value: UnsafeRawPointer?) -> AnyAttribute +func OAGGraphCreateAttribute(index: Int, body: UnsafeRawPointer, value: UnsafeRawPointer?) -> AnyAttribute -@_silgen_name("OGGraphGetValue") +@_silgen_name("OAGGraphGetValue") @inline(__always) @inlinable -func OGGraphGetValue(_ attribute: AnyAttribute, options: OGValueOptions = [], type: Value.Type = Value.self) -> OGValue +func OAGGraphGetValue(_ attribute: AnyAttribute, options: OAGValueOptions = [], type: Value.Type = Value.self) -> OAGValue -@_silgen_name("OGGraphSetValue") +@_silgen_name("OAGGraphSetValue") @inline(__always) @inlinable -func OGGraphSetValue(_ attribute: AnyAttribute, valuePointer: UnsafePointer) -> Bool +func OAGGraphSetValue(_ attribute: AnyAttribute, valuePointer: UnsafePointer) -> Bool diff --git a/Sources/OpenGraph/Attribute/Attribute/External.swift b/Sources/OpenAttributeGraph/Attribute/Attribute/External.swift similarity index 96% rename from Sources/OpenGraph/Attribute/Attribute/External.swift rename to Sources/OpenAttributeGraph/Attribute/Attribute/External.swift index d90411e4..e21295a9 100644 --- a/Sources/OpenGraph/Attribute/Attribute/External.swift +++ b/Sources/OpenAttributeGraph/Attribute/Attribute/External.swift @@ -1,6 +1,6 @@ // // External.swift -// OpenGraph +// OpenAttributeGraph // // Audited for RELEASE_2021 // Status: Complete diff --git a/Sources/OpenGraph/Attribute/Attribute/PointerOffset.swift b/Sources/OpenAttributeGraph/Attribute/Attribute/PointerOffset.swift similarity index 97% rename from Sources/OpenGraph/Attribute/Attribute/PointerOffset.swift rename to Sources/OpenAttributeGraph/Attribute/Attribute/PointerOffset.swift index 84db3cd8..b0187102 100644 --- a/Sources/OpenGraph/Attribute/Attribute/PointerOffset.swift +++ b/Sources/OpenAttributeGraph/Attribute/Attribute/PointerOffset.swift @@ -1,6 +1,6 @@ // // PointerOffset.swift -// OpenGraph +// OpenAttributeGraph // // Audited for RELEASE_2021 // Status: Complete @@ -22,7 +22,7 @@ extension PointerOffset { extension PointerOffset { public static func invalidScenePointer() -> UnsafeMutablePointer { - #if OPENGRAPH_RELEASE_2024 + #if OPENATTRIBUTEGRAPH_RELEASE_2024 UnsafeMutablePointer(bitPattern: 0x1)! #else UnsafeMutablePointer(bitPattern: MemoryLayout.stride)! diff --git a/Sources/OpenGraph/Attribute/Body/AttributeBody.swift b/Sources/OpenAttributeGraph/Attribute/Body/AttributeBody.swift similarity index 94% rename from Sources/OpenGraph/Attribute/Body/AttributeBody.swift rename to Sources/OpenAttributeGraph/Attribute/Body/AttributeBody.swift index c3ce2139..774b02c3 100644 --- a/Sources/OpenGraph/Attribute/Body/AttributeBody.swift +++ b/Sources/OpenAttributeGraph/Attribute/Body/AttributeBody.swift @@ -1,11 +1,11 @@ // // _AttributeBody.swift -// OpenGraph +// OpenAttributeGraph // // Audited for RELEASE_2021 // Status: Complete -public import OpenGraphCxx +public import OpenAttributeGraphCxx public protocol _AttributeBody { static func _destroySelf(_ pointer: UnsafeMutableRawPointer) diff --git a/Sources/OpenGraph/Attribute/Body/AttributeBodyVisitor.swift b/Sources/OpenAttributeGraph/Attribute/Body/AttributeBodyVisitor.swift similarity index 87% rename from Sources/OpenGraph/Attribute/Body/AttributeBodyVisitor.swift rename to Sources/OpenAttributeGraph/Attribute/Body/AttributeBodyVisitor.swift index dfa4fc98..d85fbf42 100644 --- a/Sources/OpenGraph/Attribute/Body/AttributeBodyVisitor.swift +++ b/Sources/OpenAttributeGraph/Attribute/Body/AttributeBodyVisitor.swift @@ -1,6 +1,6 @@ // // AttributeBodyVisitor.swift -// OpenGraph +// OpenAttributeGraph // // Status: WIP diff --git a/Sources/OpenGraph/Attribute/Body/ObservedAttribute.swift b/Sources/OpenAttributeGraph/Attribute/Body/ObservedAttribute.swift similarity index 94% rename from Sources/OpenGraph/Attribute/Body/ObservedAttribute.swift rename to Sources/OpenAttributeGraph/Attribute/Body/ObservedAttribute.swift index 9ee62ff1..7b573ca5 100644 --- a/Sources/OpenGraph/Attribute/Body/ObservedAttribute.swift +++ b/Sources/OpenAttributeGraph/Attribute/Body/ObservedAttribute.swift @@ -1,6 +1,6 @@ // // ObservedAttribute.swift -// OpenGraph +// OpenAttributeGraph // // Audited for RELEASE_2021 // Status: Complete diff --git a/Sources/OpenGraph/Attribute/Indirect/IndirectAttribute.swift b/Sources/OpenAttributeGraph/Attribute/Indirect/IndirectAttribute.swift similarity index 93% rename from Sources/OpenGraph/Attribute/Indirect/IndirectAttribute.swift rename to Sources/OpenAttributeGraph/Attribute/Indirect/IndirectAttribute.swift index d18c1405..ceb3ba6d 100644 --- a/Sources/OpenGraph/Attribute/Indirect/IndirectAttribute.swift +++ b/Sources/OpenAttributeGraph/Attribute/Indirect/IndirectAttribute.swift @@ -1,6 +1,6 @@ // // IndirectAttribute.swift -// OpenGraph +// OpenAttributeGraph // // Audited for RELEASE_2021 // Status: Complete @@ -34,7 +34,7 @@ public struct IndirectAttribute { nonmutating _modify { yield &Attribute(identifier: identifier).value } } - public func changedValue(options: OGValueOptions = []) -> (value: Value, changed: Bool) { + public func changedValue(options: OAGValueOptions = []) -> (value: Value, changed: Bool) { Attribute(identifier: identifier).changedValue(options: options) } diff --git a/Sources/OpenGraph/Attribute/Optional/AnyOptionalAttribute.swift b/Sources/OpenAttributeGraph/Attribute/Optional/AnyOptionalAttribute.swift similarity index 89% rename from Sources/OpenGraph/Attribute/Optional/AnyOptionalAttribute.swift rename to Sources/OpenAttributeGraph/Attribute/Optional/AnyOptionalAttribute.swift index 1d04d7d4..20d80ce5 100644 --- a/Sources/OpenGraph/Attribute/Optional/AnyOptionalAttribute.swift +++ b/Sources/OpenAttributeGraph/Attribute/Optional/AnyOptionalAttribute.swift @@ -1,6 +1,6 @@ // // AnyOptionalAttribute.swift -// OpenGraph +// OpenAttributeGraph // // Audited for RELEASE_2021 // Status: Complete @@ -22,7 +22,7 @@ public struct AnyOptionalAttribute { } init(_ weakAttribute: AnyWeakAttribute) { - identifier = __OGWeakAttributeGetAttribute(weakAttribute) + identifier = __OAGWeakAttributeGetAttribute(weakAttribute) } public init(_ attribute: OptionalAttribute) { @@ -30,7 +30,7 @@ public struct AnyOptionalAttribute { } public static var current: AnyOptionalAttribute { - AnyOptionalAttribute(__OGGraphGetCurrentAttribute()) + AnyOptionalAttribute(__OAGGraphGetCurrentAttribute()) } public var attribute: AnyAttribute? { diff --git a/Sources/OpenGraph/Attribute/Optional/OptionalAttribute.swift b/Sources/OpenAttributeGraph/Attribute/Optional/OptionalAttribute.swift similarity index 93% rename from Sources/OpenGraph/Attribute/Optional/OptionalAttribute.swift rename to Sources/OpenAttributeGraph/Attribute/Optional/OptionalAttribute.swift index a4a1ebe5..9722b8ca 100644 --- a/Sources/OpenGraph/Attribute/Optional/OptionalAttribute.swift +++ b/Sources/OpenAttributeGraph/Attribute/Optional/OptionalAttribute.swift @@ -1,6 +1,6 @@ // // OptionalAttribute.swift -// OpenGraph +// OpenAttributeGraph // // Audited for RELEASE_2021 // Status: Complete @@ -38,7 +38,7 @@ public struct OptionalAttribute { public var value: Value? { attribute?.value } - public func changedValue(options: OGValueOptions = []) -> (value: Value, changed: Bool)? { + public func changedValue(options: OAGValueOptions = []) -> (value: Value, changed: Bool)? { attribute?.changedValue(options: options) } diff --git a/Sources/OpenGraph/Attribute/Rule/Focus.swift b/Sources/OpenAttributeGraph/Attribute/Rule/Focus.swift similarity index 96% rename from Sources/OpenGraph/Attribute/Rule/Focus.swift rename to Sources/OpenAttributeGraph/Attribute/Rule/Focus.swift index af66b5ac..dd23ab5a 100644 --- a/Sources/OpenGraph/Attribute/Rule/Focus.swift +++ b/Sources/OpenAttributeGraph/Attribute/Rule/Focus.swift @@ -1,6 +1,6 @@ // // Focus.swift -// OpenGraph +// OpenAttributeGraph // // Audited for RELEASE_2021 // Status: Complete diff --git a/Sources/OpenGraph/Attribute/Rule/Map.swift b/Sources/OpenAttributeGraph/Attribute/Rule/Map.swift similarity index 95% rename from Sources/OpenGraph/Attribute/Rule/Map.swift rename to Sources/OpenAttributeGraph/Attribute/Rule/Map.swift index 72ad75fe..d598343d 100644 --- a/Sources/OpenGraph/Attribute/Rule/Map.swift +++ b/Sources/OpenAttributeGraph/Attribute/Rule/Map.swift @@ -1,6 +1,6 @@ // // Map.swift -// OpenGraph +// OpenAttributeGraph // // Audited for RELEASE_2021 // Status: Complete diff --git a/Sources/OpenGraph/Attribute/Rule/Rule.swift b/Sources/OpenAttributeGraph/Attribute/Rule/Rule.swift similarity index 82% rename from Sources/OpenGraph/Attribute/Rule/Rule.swift rename to Sources/OpenAttributeGraph/Attribute/Rule/Rule.swift index 6f9df86f..4e661ee1 100644 --- a/Sources/OpenGraph/Attribute/Rule/Rule.swift +++ b/Sources/OpenAttributeGraph/Attribute/Rule/Rule.swift @@ -1,11 +1,11 @@ // // _AttributeBody.swift -// OpenGraph +// OpenAttributeGraph // // Audited for RELEASE_2021 // Status: Complete -public import OpenGraphCxx +public import OpenAttributeGraphCxx public protocol Rule: _AttributeBody { associatedtype Value @@ -54,7 +54,7 @@ extension Rule { extension Rule where Self: Hashable { public func cachedValue( - options: OGCachedValueOptions = [], + options: OAGCachedValueOptions = [], owner: AnyAttribute? ) -> Value { withUnsafePointer(to: self) { pointer in @@ -69,25 +69,25 @@ extension Rule where Self: Hashable { } public func cachedValueIfExists( - options: OGCachedValueOptions = [], + options: OAGCachedValueOptions = [], owner: AnyAttribute? ) -> Value? { withUnsafePointer(to: self) { bodyPointer in - let value = __OGGraphReadCachedAttributeIfExists(hashValue, Metadata(Self.self), bodyPointer, Metadata(Value.self), options, owner ?? .nil, false) + let value = __OAGGraphReadCachedAttributeIfExists(hashValue, Metadata(Self.self), bodyPointer, Metadata(Value.self), options, owner ?? .nil, false) guard let value else { return nil } return value.assumingMemoryBound(to: Value.self).pointee } } public static func _cachedValue( - options: OGCachedValueOptions = [], + options: OAGCachedValueOptions = [], owner: AnyAttribute?, hashValue: Int, bodyPtr: UnsafeRawPointer, update: AttributeUpdateBlock ) -> UnsafePointer { // TODO: pass closure here - __OGGraphReadCachedAttribute(hashValue, Metadata(Self.self), bodyPtr, Metadata(Value.self), options, owner ?? .nil, false) + __OAGGraphReadCachedAttribute(hashValue, Metadata(Self.self), bodyPtr, Metadata(Value.self), options, owner ?? .nil, false) .assumingMemoryBound(to: Value.self) } } diff --git a/Sources/OpenGraph/Attribute/Rule/StatefulRule.swift b/Sources/OpenAttributeGraph/Attribute/Rule/StatefulRule.swift similarity index 95% rename from Sources/OpenGraph/Attribute/Rule/StatefulRule.swift rename to Sources/OpenAttributeGraph/Attribute/Rule/StatefulRule.swift index 0812eba2..be1894d4 100644 --- a/Sources/OpenGraph/Attribute/Rule/StatefulRule.swift +++ b/Sources/OpenAttributeGraph/Attribute/Rule/StatefulRule.swift @@ -1,11 +1,11 @@ // // StatefulRule.swift -// OpenGraph +// OpenAttributeGraph // // Audited for RELEASE_2021 // Status: Complete -public import OpenGraphCxx +public import OpenAttributeGraphCxx public protocol StatefulRule: _AttributeBody { associatedtype Value diff --git a/Sources/OpenGraph/Attribute/RuleContext/AnyRuleContext.swift b/Sources/OpenAttributeGraph/Attribute/RuleContext/AnyRuleContext.swift similarity index 68% rename from Sources/OpenGraph/Attribute/RuleContext/AnyRuleContext.swift rename to Sources/OpenAttributeGraph/Attribute/RuleContext/AnyRuleContext.swift index 1158852a..fa533c2b 100644 --- a/Sources/OpenGraph/Attribute/RuleContext/AnyRuleContext.swift +++ b/Sources/OpenAttributeGraph/Attribute/RuleContext/AnyRuleContext.swift @@ -1,11 +1,11 @@ // // AnyRuleContext.swift -// OpenGraph +// OpenAttributeGraph // // Audited for RELEASE_2021 // Status: Complete -public import OpenGraphCxx +public import OpenAttributeGraphCxx @frozen public struct AnyRuleContext: Equatable { @@ -21,7 +21,7 @@ public struct AnyRuleContext: Equatable { public subscript(attribute: Attribute) -> V { unsafeAddress { - OGGraphGetInputValue(self.attribute, input: attribute.identifier, type: V.self) + OAGGraphGetInputValue(self.attribute, input: attribute.identifier, type: V.self) .value .assumingMemoryBound(to: V.self) } @@ -29,7 +29,7 @@ public struct AnyRuleContext: Equatable { public subscript(weakAttribute: WeakAttribute) -> V? { weakAttribute.attribute.map { attribute in - OGGraphGetInputValue(self.attribute, input: attribute.identifier, type: V.self) + OAGGraphGetInputValue(self.attribute, input: attribute.identifier, type: V.self) .value .assumingMemoryBound(to: V.self) .pointee @@ -38,23 +38,23 @@ public struct AnyRuleContext: Equatable { public subscript(optionalAttribute: OptionalAttribute) -> V? { optionalAttribute.attribute.map { attribute in - OGGraphGetInputValue(self.attribute, input: attribute.identifier, type: V.self) + OAGGraphGetInputValue(self.attribute, input: attribute.identifier, type: V.self) .value .assumingMemoryBound(to: V.self) .pointee } } - public func valueAndFlags(of input: Attribute, options: OGValueOptions = []) -> (value: V, flags: OGChangedValueFlags) { - let value = OGGraphGetInputValue(attribute, input: input.identifier, options: options, type: V.self) + public func valueAndFlags(of input: Attribute, options: OAGValueOptions = []) -> (value: V, flags: OAGChangedValueFlags) { + let value = OAGGraphGetInputValue(attribute, input: input.identifier, options: options, type: V.self) return ( value.value.assumingMemoryBound(to: V.self).pointee, value.flags ) } - public func changedValue(of input: Attribute, options: OGValueOptions = []) -> (value: V, changed: Bool) { - let value = OGGraphGetInputValue(attribute, input: input.identifier, options: options, type: V.self) + public func changedValue(of input: Attribute, options: OAGValueOptions = []) -> (value: V, changed: Bool) { + let value = OAGGraphGetInputValue(attribute, input: input.identifier, options: options, type: V.self) return ( value.value.assumingMemoryBound(to: V.self).pointee, value.flags.contains(.changed) @@ -62,7 +62,7 @@ public struct AnyRuleContext: Equatable { } public func update(body: () -> Void) { - OGGraphWithUpdate(attribute, body: body) + OAGGraphWithUpdate(attribute, body: body) } public func unsafeCast(to _: V.Type) -> RuleContext { diff --git a/Sources/OpenGraph/Attribute/RuleContext/RuleContext.swift b/Sources/OpenAttributeGraph/Attribute/RuleContext/RuleContext.swift similarity index 62% rename from Sources/OpenGraph/Attribute/RuleContext/RuleContext.swift rename to Sources/OpenAttributeGraph/Attribute/RuleContext/RuleContext.swift index 32b3839b..126b494c 100644 --- a/Sources/OpenGraph/Attribute/RuleContext/RuleContext.swift +++ b/Sources/OpenAttributeGraph/Attribute/RuleContext/RuleContext.swift @@ -1,11 +1,11 @@ // // RuleContext.swift -// OpenGraph +// OpenAttributeGraph // // Audited for RELEASE_2021 // Status: Complete -public import OpenGraphCxx +public import OpenAttributeGraphCxx @frozen public struct RuleContext: Equatable { @@ -17,7 +17,7 @@ public struct RuleContext: Equatable { public subscript(attribute: Attribute) -> V { unsafeAddress { - OGGraphGetInputValue(self.attribute.identifier, input: attribute.identifier, type: V.self) + OAGGraphGetInputValue(self.attribute.identifier, input: attribute.identifier, type: V.self) .value .assumingMemoryBound(to: V.self) } @@ -25,7 +25,7 @@ public struct RuleContext: Equatable { public subscript(weakAttribute: WeakAttribute) -> V? { weakAttribute.attribute.map { attribute in - OGGraphGetInputValue(self.attribute.identifier, input: attribute.identifier, type: V.self) + OAGGraphGetInputValue(self.attribute.identifier, input: attribute.identifier, type: V.self) .value .assumingMemoryBound(to: V.self) .pointee @@ -34,7 +34,7 @@ public struct RuleContext: Equatable { public subscript(optionalAttribute: OptionalAttribute) -> V? { optionalAttribute.attribute.map { attribute in - OGGraphGetInputValue(self.attribute.identifier, input: attribute.identifier, type: V.self) + OAGGraphGetInputValue(self.attribute.identifier, input: attribute.identifier, type: V.self) .value .assumingMemoryBound(to: V.self) .pointee @@ -57,16 +57,16 @@ public struct RuleContext: Equatable { return valuePointer != nil } - public func valueAndFlags(of input: Attribute, options: OGValueOptions = []) -> (value: V, flags: OGChangedValueFlags) { - let value = OGGraphGetInputValue(attribute.identifier, input: input.identifier, options: options, type: V.self) + public func valueAndFlags(of input: Attribute, options: OAGValueOptions = []) -> (value: V, flags: OAGChangedValueFlags) { + let value = OAGGraphGetInputValue(attribute.identifier, input: input.identifier, options: options, type: V.self) return ( value.value.assumingMemoryBound(to: V.self).pointee, value.flags ) } - public func changedValue(of input: Attribute, options: OGValueOptions = []) -> (value: V, changed: Bool) { - let value = OGGraphGetInputValue(attribute.identifier, input: input.identifier, options: options, type: V.self) + public func changedValue(of input: Attribute, options: OAGValueOptions = []) -> (value: V, changed: Bool) { + let value = OAGGraphGetInputValue(attribute.identifier, input: input.identifier, options: options, type: V.self) return ( value.value.assumingMemoryBound(to: V.self).pointee, value.flags.contains(.changed) @@ -74,16 +74,16 @@ public struct RuleContext: Equatable { } public func update(body: () -> Void) { - OGGraphWithUpdate(attribute.identifier, body: body) + OAGGraphWithUpdate(attribute.identifier, body: body) } } -@_silgen_name("OGGraphGetInputValue") +@_silgen_name("OAGGraphGetInputValue") @inline(__always) @inlinable -func OGGraphGetInputValue(_ attribute: AnyAttribute, input: AnyAttribute, options: OGValueOptions = [], type: Value.Type = Value.self) -> OGValue +func OAGGraphGetInputValue(_ attribute: AnyAttribute, input: AnyAttribute, options: OAGValueOptions = [], type: Value.Type = Value.self) -> OAGValue -@_silgen_name("OGGraphWithUpdate") +@_silgen_name("OAGGraphWithUpdate") @inline(__always) @inlinable -func OGGraphWithUpdate(_ attribute: AnyAttribute, body: () -> Void) +func OAGGraphWithUpdate(_ attribute: AnyAttribute, body: () -> Void) diff --git a/Sources/OpenGraph/Attribute/Weak/AnyWeakAttribute.swift b/Sources/OpenAttributeGraph/Attribute/Weak/AnyWeakAttribute.swift similarity index 85% rename from Sources/OpenGraph/Attribute/Weak/AnyWeakAttribute.swift rename to Sources/OpenAttributeGraph/Attribute/Weak/AnyWeakAttribute.swift index 3c253bc9..40517085 100644 --- a/Sources/OpenGraph/Attribute/Weak/AnyWeakAttribute.swift +++ b/Sources/OpenAttributeGraph/Attribute/Weak/AnyWeakAttribute.swift @@ -1,18 +1,18 @@ // // AnyWeakAttribute.swift -// OpenGraph +// OpenAttributeGraph // // Audited for RELEASE_2021 // Status: Complete -public import OpenGraphCxx +public import OpenAttributeGraphCxx -public typealias AnyWeakAttribute = OGWeakAttribute +public typealias AnyWeakAttribute = OAGWeakAttribute extension AnyWeakAttribute { @_alwaysEmitIntoClient public init(_ attribute: AnyAttribute?) { - self = __OGCreateWeakAttribute(attribute ?? .nil) + self = __OAGCreateWeakAttribute(attribute ?? .nil) } @_alwaysEmitIntoClient @@ -28,7 +28,7 @@ extension AnyWeakAttribute { @_alwaysEmitIntoClient public var attribute: AnyAttribute? { get { - let attribute = __OGWeakAttributeGetAttribute(self) + let attribute = __OAGWeakAttributeGetAttribute(self) return attribute == .nil ? nil : attribute } set { diff --git a/Sources/OpenGraph/Attribute/Weak/WeakAttribute.swift b/Sources/OpenAttributeGraph/Attribute/Weak/WeakAttribute.swift similarity index 81% rename from Sources/OpenGraph/Attribute/Weak/WeakAttribute.swift rename to Sources/OpenAttributeGraph/Attribute/Weak/WeakAttribute.swift index e614c6b0..fd3636dc 100644 --- a/Sources/OpenGraph/Attribute/Weak/WeakAttribute.swift +++ b/Sources/OpenAttributeGraph/Attribute/Weak/WeakAttribute.swift @@ -1,11 +1,11 @@ // // WeakAttribute.swift -// OpenGraph +// OpenAttributeGraph // // Audited for RELEASE_2021 // Status: Complete -public import OpenGraphCxx +public import OpenAttributeGraphCxx @frozen @propertyWrapper @@ -49,14 +49,14 @@ public struct WeakAttribute { } public var value: Value? { - OGGraphGetWeakValue(base, type: Value.self) + OAGGraphGetWeakValue(base, type: Value.self) .value // TO BE CONFIRMED .assumingMemoryBound(to: Value?.self) .pointee } - public func changedValue(options: OGValueOptions = []) -> (value: Value, changed: Bool)? { + public func changedValue(options: OAGValueOptions = []) -> (value: Value, changed: Bool)? { attribute?.changedValue(options: options) } } @@ -67,7 +67,7 @@ extension WeakAttribute: CustomStringConvertible { public var description: String { base.description } } -@_silgen_name("OGGraphGetWeakValue") +@_silgen_name("OAGGraphGetWeakValue") @inline(__always) @inlinable -func OGGraphGetWeakValue(_ attribute: AnyWeakAttribute, options: OGValueOptions = [], type: Value.Type = Value.self) -> OGValue +func OAGGraphGetWeakValue(_ attribute: AnyWeakAttribute, options: OAGValueOptions = [], type: Value.Type = Value.self) -> OAGValue diff --git a/Sources/OpenGraph/Debug/DebugServer.swift b/Sources/OpenAttributeGraph/Debug/DebugServer.swift similarity index 100% rename from Sources/OpenGraph/Debug/DebugServer.swift rename to Sources/OpenAttributeGraph/Debug/DebugServer.swift diff --git a/Sources/OpenAttributeGraph/Export.swift b/Sources/OpenAttributeGraph/Export.swift new file mode 100644 index 00000000..d9c409e7 --- /dev/null +++ b/Sources/OpenAttributeGraph/Export.swift @@ -0,0 +1,5 @@ +// +// Export.swift +// OpenAttributeGraph + +@_exported public import OpenAttributeGraphCxx diff --git a/Sources/OpenGraph/Graph/Graph.swift b/Sources/OpenAttributeGraph/Graph/Graph.swift similarity index 79% rename from Sources/OpenGraph/Graph/Graph.swift rename to Sources/OpenAttributeGraph/Graph/Graph.swift index 9483afb0..796f211f 100644 --- a/Sources/OpenGraph/Graph/Graph.swift +++ b/Sources/OpenAttributeGraph/Graph/Graph.swift @@ -1,11 +1,11 @@ // // Graph.swift -// OpenGraph +// OpenAttributeGraph // // Audited for RELEASE_2021 // Status: WIP -public import OpenGraphCxx +public import OpenAttributeGraphCxx extension Graph { public static func typeIndex( @@ -20,14 +20,14 @@ extension Graph { } } -@_silgen_name("OGGraphSetInvalidationCallback") -private func OGGraphSetInvalidationCallback( +@_silgen_name("OAGGraphSetInvalidationCallback") +private func OAGGraphSetInvalidationCallback( graph: Graph, _ callback: @escaping (AnyAttribute) -> Void ) -@_silgen_name("OGGraphSetUpdateCallback") -private func OGGraphSetUpdateCallback( +@_silgen_name("OAGGraphSetUpdateCallback") +private func OAGGraphSetUpdateCallback( graph: Graph, _ callback: @escaping () -> Void ) @@ -51,15 +51,15 @@ extension Graph { } public func onInvalidation(_ callback: @escaping (AnyAttribute) -> Void) { - OGGraphSetInvalidationCallback(graph: self, callback) + OAGGraphSetInvalidationCallback(graph: self, callback) } public func onUpdate(_ callback: @escaping () -> Void) { - OGGraphSetUpdateCallback(graph: self, callback) + OAGGraphSetUpdateCallback(graph: self, callback) } public func withMainThreadHandler(_: (() -> Void) -> Void, do: () -> Void) { - // TODO: OGGraphWithMainThreadHandler + // TODO: OAGGraphWithMainThreadHandler preconditionFailure("TODO") } } @@ -67,29 +67,29 @@ extension Graph { extension Graph { @_transparent public func startProfiling() { - __OGGraphStartProfiling(self) + __OAGGraphStartProfiling(self) } @_transparent public func stopProfiling() { - __OGGraphStopProfiling(self) + __OAGGraphStopProfiling(self) } @_transparent public func resetProfile() { - __OGGraphResetProfile(self) + __OAGGraphResetProfile(self) } public static func startProfiling() { - __OGGraphStartProfiling(nil) + __OAGGraphStartProfiling(nil) } public static func stopProfiling() { - __OGGraphStopProfiling(nil) + __OAGGraphStopProfiling(nil) } public static func resetProfile() { - __OGGraphResetProfile(nil) + __OAGGraphResetProfile(nil) } } @@ -100,12 +100,12 @@ extension Graph { extension Graph { // NOTE: Currently Swift does not support generic computed variable - @_silgen_name("OGGraphGetOutputValue") + @_silgen_name("OAGGraphGetOutputValue") @inline(__always) @inlinable public static func outputValue() -> UnsafePointer? - @_silgen_name("OGGraphSetOutputValue") + @_silgen_name("OAGGraphSetOutputValue") @inline(__always) @inlinable public static func setOutputValue(_ value: UnsafePointer) @@ -114,7 +114,7 @@ extension Graph { extension Graph { @_transparent public static func anyInputsChanged(excluding excludedInputs: [AnyAttribute]) -> Bool { - return __OGGraphAnyInputsChanged(excludedInputs, excludedInputs.count) + return __OAGGraphAnyInputsChanged(excludedInputs, excludedInputs.count) } } diff --git a/Sources/OpenGraph/Graph/Subgraph.swift b/Sources/OpenAttributeGraph/Graph/Subgraph.swift similarity index 81% rename from Sources/OpenGraph/Graph/Subgraph.swift rename to Sources/OpenAttributeGraph/Graph/Subgraph.swift index 1724c63f..f66108a1 100644 --- a/Sources/OpenGraph/Graph/Subgraph.swift +++ b/Sources/OpenAttributeGraph/Graph/Subgraph.swift @@ -1,11 +1,11 @@ // // Subgraph.swift -// OpenGraph +// OpenAttributeGraph // // Audited for RELEASE_2021 // Status: WIP -public import OpenGraphCxx +public import OpenAttributeGraphCxx extension Subgraph { public typealias Flags = AnyAttribute.Flags @@ -42,28 +42,28 @@ extension Subgraph { extension Subgraph { public static func beginTreeElement(value: Attribute, flags: UInt32) { if shouldRecordTree { - __OGSubgraphBeginTreeElement(value.identifier, Metadata(Value.self), flags) + __OAGSubgraphBeginTreeElement(value.identifier, Metadata(Value.self), flags) } } public static func addTreeValue(_ value: Attribute, forKey key: UnsafePointer, flags: UInt32) { if shouldRecordTree { - __OGSubgraphAddTreeValue(value.identifier, Metadata(Value.self), key, flags) + __OAGSubgraphAddTreeValue(value.identifier, Metadata(Value.self), key, flags) } } public static func endTreeElement(value: Attribute) { if shouldRecordTree { - __OGSubgraphEndTreeElement(value.identifier) + __OAGSubgraphEndTreeElement(value.identifier) } } } // FIXME: migrate to use @_extern(c, "xx") in Swift 6 extension Subgraph { - @_silgen_name("OGSubgraphApply") + @_silgen_name("OAGSubgraphApply") private static func apply(_ graph: Subgraph, flags: Flags, callback: (AnyAttribute) -> Void) - @_silgen_name("OGSubgraphAddObserver") + @_silgen_name("OAGSubgraphAddObserver") private static func addObserver(_ graph: Subgraph, observer: () -> Void) -> Int } diff --git a/Sources/OpenGraph/Runtime/CompareValues.swift b/Sources/OpenAttributeGraph/Runtime/CompareValues.swift similarity index 77% rename from Sources/OpenGraph/Runtime/CompareValues.swift rename to Sources/OpenAttributeGraph/Runtime/CompareValues.swift index a5accf54..7f9677af 100644 --- a/Sources/OpenGraph/Runtime/CompareValues.swift +++ b/Sources/OpenAttributeGraph/Runtime/CompareValues.swift @@ -1,14 +1,14 @@ // // CompareValues.swift -// OpenGraph +// OpenAttributeGraph // // Audited for RELEASE_2021 // Status: Complete -public import OpenGraphCxx +public import OpenAttributeGraphCxx -@_silgen_name("OGCompareValues") -private func OGCompareValues( +@_silgen_name("OAGCompareValues") +private func OAGCompareValues( lhs: UnsafeRawPointer, rhs: UnsafeRawPointer, type: Any.Type, @@ -22,7 +22,7 @@ public func compareValues(_ lhs: Value, _ rhs: Value, mode: ComparisonMod public func compareValues(_ lhs: Value, _ rhs: Value, options: ComparisonOptions) -> Bool { withUnsafePointer(to: lhs) { p1 in withUnsafePointer(to: rhs) { p2 in - OGCompareValues(lhs: p1, rhs: p2, type: Value.self, options: options) + OAGCompareValues(lhs: p1, rhs: p2, type: Value.self, options: options) } } } diff --git a/Sources/OpenGraph/Runtime/Metadata.swift b/Sources/OpenAttributeGraph/Runtime/Metadata.swift similarity index 83% rename from Sources/OpenGraph/Runtime/Metadata.swift rename to Sources/OpenAttributeGraph/Runtime/Metadata.swift index d979b48b..0a3ee53a 100644 --- a/Sources/OpenGraph/Runtime/Metadata.swift +++ b/Sources/OpenAttributeGraph/Runtime/Metadata.swift @@ -1,23 +1,23 @@ // // Metadata.swift -// OpenGraph +// OpenAttributeGraph // // Audited for RELEASE_2021 // Status: WIP -public import OpenGraphCxx +public import OpenAttributeGraphCxx #if canImport(ObjectiveC) import Foundation #endif -@_silgen_name("OGTypeApplyFields") -private func OGTypeApplyFields( +@_silgen_name("OAGTypeApplyFields") +private func OAGTypeApplyFields( of type: Any.Type, body: (UnsafePointer, Int, Any.Type) -> Void ) -@_silgen_name("OGTypeApplyFields2") -private func OGTypeApplyFields2( +@_silgen_name("OAGTypeApplyFields2") +private func OAGTypeApplyFields2( of type: Any.Type, options: Metadata.ApplyOptions, body: (UnsafePointer, Int, Any.Type) -> Bool @@ -27,7 +27,7 @@ public func forEachField( of type: Any.Type, do body: (UnsafePointer, Int, Any.Type) -> Void ) { - OGTypeApplyFields(of: type, body: body) + OAGTypeApplyFields(of: type, body: body) } extension Metadata: Swift.Hashable, Swift.CustomStringConvertible { @@ -41,7 +41,7 @@ extension Metadata: Swift.Hashable, Swift.CustomStringConvertible { public var description: String { #if canImport(ObjectiveC) - __OGTypeDescription(self) as NSString as String + __OAGTypeDescription(self) as NSString as String #else fatalError("Unimplemented") #endif @@ -51,7 +51,7 @@ extension Metadata: Swift.Hashable, Swift.CustomStringConvertible { options: ApplyOptions, do body: (UnsafePointer, Int, Any.Type) -> Bool ) -> Bool { - OGTypeApplyFields2(of: type, options: options, body: body) + OAGTypeApplyFields2(of: type, options: options, body: body) } } diff --git a/Sources/OpenGraph/Runtime/OGTypeApplyEnumData.swift b/Sources/OpenAttributeGraph/Runtime/OGTypeApplyEnumData.swift similarity index 73% rename from Sources/OpenGraph/Runtime/OGTypeApplyEnumData.swift rename to Sources/OpenAttributeGraph/Runtime/OGTypeApplyEnumData.swift index 86392277..38561ea6 100644 --- a/Sources/OpenGraph/Runtime/OGTypeApplyEnumData.swift +++ b/Sources/OpenAttributeGraph/Runtime/OGTypeApplyEnumData.swift @@ -1,17 +1,17 @@ // -// OGTypeApplyEnumData.swift +// OAGTypeApplyEnumData.swift // // // -// public import OpenGraphCxx +// public import OpenAttributeGraphCxx @discardableResult public func withUnsafePointerToEnumCase( of value: UnsafeMutablePointer, do body: (Int, Any.Type, UnsafeRawPointer) -> () ) -> Bool { - // TODO: OGTypeApplyEnumData + // TODO: OAGTypeApplyEnumData return true } @@ -20,6 +20,6 @@ public func withUnsafeMutablePointerToEnumCase( of value: UnsafeMutablePointer, do body: (Int, Any.Type, UnsafeMutableRawPointer) -> () ) -> Bool { - // TODO: OGTypeApplyMutableEnumData + // TODO: OAGTypeApplyMutableEnumData return true } diff --git a/Sources/OpenGraph/Runtime/TupleType.swift b/Sources/OpenAttributeGraph/Runtime/TupleType.swift similarity index 94% rename from Sources/OpenGraph/Runtime/TupleType.swift rename to Sources/OpenAttributeGraph/Runtime/TupleType.swift index ab2e1139..58a2d102 100644 --- a/Sources/OpenGraph/Runtime/TupleType.swift +++ b/Sources/OpenAttributeGraph/Runtime/TupleType.swift @@ -1,11 +1,11 @@ // // TupleType.swift -// OpenGraph +// OpenAttributeGraph // // Audited for iOS 18.0 // Status: WIP -public import OpenGraphCxx +public import OpenAttributeGraphCxx // MARK: TupleType @@ -43,16 +43,16 @@ extension TupleType { @_transparent public func setElement(in tupleValue: UnsafeMutableRawPointer, at index: Int, from srcValue: UnsafePointer, options: CopyOptions) { - __OGTupleSetElement(self, tupleValue, index, srcValue, Metadata(T.self), options) + __OAGTupleSetElement(self, tupleValue, index, srcValue, Metadata(T.self), options) } @_transparent public func getElement(in tupleValue: UnsafeMutableRawPointer, at index: Int, to dstValue: UnsafeMutablePointer, options: CopyOptions) { - __OGTupleGetElement(self, tupleValue, index, dstValue, Metadata(T.self), options) + __OAGTupleGetElement(self, tupleValue, index, dstValue, Metadata(T.self), options) } } -@_silgen_name("OGTupleWithBuffer") +@_silgen_name("OAGTupleWithBuffer") public func withUnsafeTuple(of type: TupleType, count: Int, _ body: (UnsafeMutableTuple) -> Void) // MARK: - UnsafeTuple diff --git a/Sources/OpenAttributeGraphCxx/Attribute/AttributeID.cpp b/Sources/OpenAttributeGraphCxx/Attribute/AttributeID.cpp new file mode 100644 index 00000000..e98331d9 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/Attribute/AttributeID.cpp @@ -0,0 +1,5 @@ +// +// AttributeID.cpp +// OpenAttributeGraphCxx + +#include diff --git a/Sources/OpenAttributeGraphCxx/Attribute/AttributeType.cpp b/Sources/OpenAttributeGraphCxx/Attribute/AttributeType.cpp new file mode 100644 index 00000000..89cdd5c8 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/Attribute/AttributeType.cpp @@ -0,0 +1,5 @@ +// +// OAGAttributeType.cpp +// OpenAttributeGraphCxx + +#include diff --git a/Sources/OpenAttributeGraphCxx/Attribute/OAGAttribute.cpp b/Sources/OpenAttributeGraphCxx/Attribute/OAGAttribute.cpp new file mode 100644 index 00000000..79f7fc9d --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/Attribute/OAGAttribute.cpp @@ -0,0 +1,183 @@ +// +// OAGAttribute.cpp +// OpenAttributeGraphCxx + +#include +#include +#include +#include + +const OAGAttribute OAGAttributeNil = OAGAttribute(OAG::AttributeID::Kind::Null); + +OAGAttribute OAGGraphGetCurrentAttribute() { + // TODO + return OAGAttributeNil; +} + +namespace { +OAGAttribute create_offset_attribute(OAGAttribute attribute, uint64_t offset, std::optional size) { + // TODO + return OAGAttributeNil; +} +} + +OAGAttribute OAGGraphCreateOffsetAttribute(OAGAttribute attribute, long offset) { + return create_offset_attribute(attribute, offset, std::nullopt); +} + +OAGAttribute OAGGraphCreateOffsetAttribute2(OAGAttribute attribute, long offset, uint64_t size) { + return create_offset_attribute(attribute, offset, std::optional(size)); +} + +namespace { +OAGAttribute create_indirect_attribute(OAGAttribute attribute, std::optional size) { + // TODO + return OAGAttributeNil; +} +} + +OAGAttribute OAGGraphCreateIndirectAttribute(OAGAttribute attribute) { + return create_indirect_attribute(attribute, std::nullopt); +} + +OAGAttribute OAGGraphCreateIndirectAttribute2(OAGAttribute attribute, uint64_t size) { + return create_indirect_attribute(attribute, std::optional(size)); +} + +OAGAttributeFlags OAGGraphGetFlags(OAGAttribute attribute) { + const OAG::AttributeID id = OAG::AttributeID(attribute); + id.checkIsDirect(); + // TODO: data/table + return OAGAttributeFlagsNone; +} + +void OAGGraphSetFlags(OAGAttribute attribute, OAGAttributeFlags flags) { + const OAG::AttributeID id = OAG::AttributeID(attribute); + id.checkIsDirect(); + // TODO: data/table +} + +void OAGGraphAddInput(OAGAttribute attribute1, OAGAttribute attribute2, OAGInputOptions options, long token) { + const OAG::AttributeID id = OAG::AttributeID(attribute1); + id.checkIsDirect(); + // TODO: data/table +} + +const OAGAttributeInfo OAGGraphGetAttributeInfo(OAGAttribute attribute) { + const OAG::AttributeID id = OAG::AttributeID(attribute); + id.checkIsDirect(); + // TODO + return { nullptr, nullptr }; +} + +void OAGGraphMutateAttribute(OAGAttribute attribute, + const OAGTypeID type, + bool invalidating, + const void (*function)(const void * _Nullable context OAG_SWIFT_CONTEXT, void *body) OAG_SWIFT_CC(swift), + const void * _Nullable context) { + const OAG::AttributeID id = OAG::AttributeID(attribute); + id.checkIsDirect(); + // attribute_modify(AG::data::ptr, AGSwiftMetadata const*, AG::ClosureFunction, bool +} + +OAGAttribute OAGGraphGetIndirectDependency(OAGAttribute attribute) { + // TODO + return OAGAttributeNil; +} + +void OAGGraphSetIndirectDependency(OAGAttribute attribute1, OAGAttribute attribute2) { + // TODO +} + +OAGAttribute OAGGraphGetIndirectAttribute(OAGAttribute attribute) { + // TODO + return OAGAttributeNil; +} + +void OAGGraphSetIndirectAttribute(OAGAttribute attribute1, OAGAttribute attribute2) { + // TODO +} + +OAGAttribute OAGGraphCreateAttribute(long index, const void *body, const void * value) { + // TODO + return OAGAttributeNil; +} + +const OAGValue OAGGraphGetValue(OAGAttribute attribute, OAGValueOptions options, OAGTypeID type) { + // TODO + return OAGValue { nullptr, false }; +} + +bool OAGGraphSetValue(OAGAttribute attribute, const void *value, OAGTypeID type) { + // TODO + return false; +} + +const OAGValue OAGGraphGetInputValue(OAGAttribute attribute, OAGAttribute inputAttribute, OAGValueOptions options, const OAGTypeID type) { + // TODO + return OAGValue { nullptr, false }; +} + +const void * _Nullable OAGGraphGetOutputValue(OAGTypeID type) { + // TODO + return nullptr; +} + +void OAGGraphSetOutputValue(const void *value, const OAGTypeID type) { + // TODO +} + +OAGValueState OAGGraphGetValueState(OAGAttribute attribute) { + // TODO + return {}; +} + +bool OAGGraphHasValue(OAGAttribute attribute) { + // TODO + return false; +} + +void OAGGraphUpdateValue(OAGAttribute attribute) { + // TODO +} + +void OAGGraphPrefetchValue(OAGAttribute attribute) { + // TODO +} + +void OAGGraphInvalidateValue(OAGAttribute attribute) { + // TODO +} + +void OAGGraphVerifyType(OAGAttribute attribute, OAGTypeID type) { + // TODO +} + +OAGGraphRef OAGGraphGetAttributeGraph(OAGAttribute attribute) { + // TODO + return nullptr; +} + +OAGSubgraphRef OAGGraphGetAttributeSubgraph(OAGAttribute attribute) { + // TODO + return nullptr; +} + +const void * OAGGraphReadCachedAttribute(long hashValue, OAGTypeID bodyType, const void *bodyPointer, OAGTypeID valueType, OAGCachedValueOptions options, OAGAttribute attribute, bool unknown) { + // TODO + return nullptr; +} + +const void * _Nullable OAGGraphReadCachedAttributeIfExists(long hashValue, OAGTypeID bodyType, const void *bodyPointer, OAGTypeID valueType, OAGCachedValueOptions options, OAGAttribute attribute, bool unknown) { + // TODO + return nullptr; +} + +void OAGGraphWithUpdate( + OAGAttribute attribute, + void (* callback)(const void *context OAG_SWIFT_CONTEXT) OAG_SWIFT_CC(swift), + const void *context +) { + // TODO + callback(context); +} diff --git a/Sources/OpenAttributeGraphCxx/Attribute/OAGWeakAttribute.cpp b/Sources/OpenAttributeGraphCxx/Attribute/OAGWeakAttribute.cpp new file mode 100644 index 00000000..7da7b575 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/Attribute/OAGWeakAttribute.cpp @@ -0,0 +1,20 @@ +// +// OAGWeakAttribute.cpp +// OpenAttributeGraphCxx + +#include + +OAGWeakAttribute OAGCreateWeakAttribute(OAGAttribute attribute) { + // TODO + return {OAGAttributeNil , 0}; +} + +OAGAttribute OAGWeakAttributeGetAttribute(OAGWeakAttribute weakAttribute) { + // TODO + return OAGAttributeNil; +} + +OAGWeakValue OAGGraphGetWeakValue(OAGWeakAttribute weakAttribute, OAGValueOptions options, OAGTypeID type) { + // TODO + return {nullptr, false}; +} diff --git a/Sources/OpenAttributeGraphCxx/Comparison/OAGComparison.cpp b/Sources/OpenAttributeGraphCxx/Comparison/OAGComparison.cpp new file mode 100644 index 00000000..b1e6592e --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/Comparison/OAGComparison.cpp @@ -0,0 +1,38 @@ +// +// OAGCompareValues.cpp +// OpenAttributeGraphCxx + +#include +#include + +const void *OAGComparisonStateGetDestination(OAGComparisonState state) { + return ((const OAGComparisonStateStorage *)state)->destination; +} + +const void *OAGComparisonStateGetSource(OAGComparisonState state) { + return ((const OAGComparisonStateStorage *)state)->source; +} + +OAGFieldRange OAGComparisonStateGetFieldRange(OAGComparisonState state) { + return ((const OAGComparisonStateStorage *)state)->field_range; +} + +OAGTypeID OAGComparisonStateGetFieldType(OAGComparisonState state) { + return ((const OAGComparisonStateStorage *)state)->field_type; +} + +bool OAGCompareValues(const void *lhs, const void *rhs, OAGTypeID type, OAGComparisonOptions options) { + // TODO + return false; +} + +const unsigned char *_Nullable OAGPrefetchCompareValues(OAGTypeID type_id, + OAGComparisonOptions options, + uint32_t priority) { + // TODO + return nullptr; +} + +void OAGOverrideComparisonForTypeDescriptor(void *descriptor, OAGComparisonMode mode) { + // TODO +} diff --git a/Sources/OpenAttributeGraphCxx/Data/ClosureFunction.cpp b/Sources/OpenAttributeGraphCxx/Data/ClosureFunction.cpp new file mode 100644 index 00000000..f93350e2 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/Data/ClosureFunction.cpp @@ -0,0 +1,5 @@ +// +// ClosureFunction.cpp +// OpenAttributeGraphCxx + +#include diff --git a/Sources/OpenGraphCxx/Data/OGUniqueID.c b/Sources/OpenAttributeGraphCxx/Data/OAGUniqueID.c similarity index 56% rename from Sources/OpenGraphCxx/Data/OGUniqueID.c rename to Sources/OpenAttributeGraphCxx/Data/OAGUniqueID.c index 67cc2fe3..94a92b62 100644 --- a/Sources/OpenGraphCxx/Data/OGUniqueID.c +++ b/Sources/OpenAttributeGraphCxx/Data/OAGUniqueID.c @@ -1,14 +1,14 @@ // -// OGUniqueID.c -// OpenGraphCxx +// OAGUniqueID.c +// OpenAttributeGraphCxx // // Audited for iOS 18.0 // Status: Complete -#include +#include #include -OGUniqueID OGMakeUniqueID(void) { +OAGUniqueID OAGMakeUniqueID(void) { // Initial value is 1 static atomic_long counter = 1; return counter++; diff --git a/Sources/OpenGraphCxx/Data/table.cpp b/Sources/OpenAttributeGraphCxx/Data/table.cpp similarity index 88% rename from Sources/OpenGraphCxx/Data/table.cpp rename to Sources/OpenAttributeGraphCxx/Data/table.cpp index 5168b170..9213d3dc 100644 --- a/Sources/OpenGraphCxx/Data/table.cpp +++ b/Sources/OpenAttributeGraphCxx/Data/table.cpp @@ -1,34 +1,34 @@ // // table.cpp -// OpenGraphCxx +// OpenAttributeGraphCxx // // Audited for 6.5.1 // Status: WIP // Modified based Compute code -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include -#if OG_TARGET_OS_DARWIN +#if OAG_TARGET_OS_DARWIN #include #else #include #endif -#if OG_TARGET_OS_DARWIN +#if OAG_TARGET_OS_DARWIN #include #endif -void *OGGraphVMRegionBaseAddress; +void *OAGGraphVMRegionBaseAddress; -namespace OG { +namespace OAG { namespace data { -#if OG_TARGET_OS_DARWIN +#if OAG_TARGET_OS_DARWIN malloc_zone_t *table::_malloc_zone = nullptr; #endif @@ -45,25 +45,25 @@ table::table() { _region_capacity = initial_size; void *region = mmap(nullptr, initial_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); _region_base = reinterpret_cast(region); - OGGraphVMRegionBaseAddress = region; + OAGGraphVMRegionBaseAddress = region; if (region == MAP_FAILED) { - OG::precondition_failure("memory allocation failure (%u bytes, %u)", _region_capacity, errno); + OAG::precondition_failure("memory allocation failure (%u bytes, %u)", _region_capacity, errno); } _data_base = reinterpret_cast(region) - page_size; _data_capacity = initial_size + page_size; - #if OG_TARGET_OS_DARWIN + #if OAG_TARGET_OS_DARWIN if (_malloc_zone == nullptr) { malloc_zone_t *zone = malloc_create_zone(0, 0); _malloc_zone = zone; - malloc_set_zone_name(zone, "OpenGraph graph data"); + malloc_set_zone_name(zone, "OpenAttributeGraph graph data"); } #else precondition_failure("not implemented"); #endif } -void table::grow_region() OG_NOEXCEPT { - #if OG_TARGET_OS_DARWIN +void table::grow_region() OAG_NOEXCEPT { + #if OAG_TARGET_OS_DARWIN uint32_t new_size = 4 * _region_capacity; // Check size does not exceed 32 bits if (new_size <= _region_capacity) { @@ -91,7 +91,7 @@ void table::grow_region() OG_NOEXCEPT { precondition_failure("vm_remap failure: 0x%x", error); } _remapped_regions.push_back({this->region_base(), this->region_capacity()}); - OGGraphVMRegionBaseAddress = new_region; + OAGGraphVMRegionBaseAddress = new_region; _data_base = reinterpret_cast(new_region) - page_size; _region_base = reinterpret_cast(new_region); _region_capacity = new_size; @@ -101,14 +101,14 @@ void table::grow_region() OG_NOEXCEPT { #endif } -void table::make_pages_reusable(uint32_t page_index, bool reusable) OG_NOEXCEPT { - #if OG_TARGET_OS_DARWIN +void table::make_pages_reusable(uint32_t page_index, bool reusable) OAG_NOEXCEPT { + #if OAG_TARGET_OS_DARWIN static constexpr uint32_t mapped_pages_size = page_size * pages_per_map; // 64 * 512 = 0x8000 void *mapped_pages_address = reinterpret_cast(region_base() + ((page_index * page_size) & ~(mapped_pages_size - 1))); int advice = reusable ? MADV_FREE_REUSABLE : MADV_FREE_REUSE; madvise(mapped_pages_address, mapped_pages_size, advice); static bool unmap_reusable = []() -> bool { - char *result = getenv("OG_UNMAP_REUSABLE"); + char *result = getenv("OAG_UNMAP_REUSABLE"); if (result) { return atoi(result) != 0; } @@ -125,7 +125,7 @@ void table::make_pages_reusable(uint32_t page_index, bool reusable) OG_NOEXCEPT } // TO BE AUDITED -ptr table::alloc_page(zone *zone, uint32_t needed_size) OG_NOEXCEPT { +ptr table::alloc_page(zone *zone, uint32_t needed_size) OAG_NOEXCEPT { lock(); uint32_t needed_pages = (needed_size + page_mask) / page_size; @@ -217,7 +217,7 @@ ptr table::alloc_page(zone *zone, uint32_t needed_size) OG_NOEXCEPT { } // TO BE AUDITED -void table::dealloc_page_locked(ptr page) OG_NOEXCEPT { +void table::dealloc_page_locked(ptr page) OAG_NOEXCEPT { int32_t total_bytes = page.get(_data_base)->total; int32_t num_pages = total_bytes / page_size; _used_pages_num -= num_pages; @@ -242,8 +242,8 @@ void table::dealloc_page_locked(ptr page) OG_NOEXCEPT { } } -OG_CONSTEXPR -uint64_t table::raw_page_seed(ptr page) const OG_NOEXCEPT { +OAG_CONSTEXPR +uint64_t table::raw_page_seed(ptr page) const OAG_NOEXCEPT { assert_valid(page); lock(); uint32_t page_index = page.page_index(); @@ -263,7 +263,7 @@ uint64_t table::raw_page_seed(ptr page) const OG_NOEXCEPT { return result || uint64_t(w22 || w21); } -void table::print() const OG_NOEXCEPT { +void table::print() const OAG_NOEXCEPT { lock(); fprintf(stderr, "data::table %p:\n %.2fKB allocated, %.2fKB used, %.2fKB reusable.\n", this, @@ -274,6 +274,6 @@ void table::print() const OG_NOEXCEPT { } } /* data */ -} /* OG */ +} /* OAG */ // AG::data::table::malloc_zone_deleter diff --git a/Sources/OpenGraphCxx/Data/zone.cpp b/Sources/OpenAttributeGraphCxx/Data/zone.cpp similarity index 90% rename from Sources/OpenGraphCxx/Data/zone.cpp rename to Sources/OpenAttributeGraphCxx/Data/zone.cpp index 0a1e461c..20d5a673 100644 --- a/Sources/OpenGraphCxx/Data/zone.cpp +++ b/Sources/OpenAttributeGraphCxx/Data/zone.cpp @@ -1,18 +1,18 @@ // // zone.cpp -// OpenGraphCxx +// OpenAttributeGraphCxx -#include -#include -#include -#include -#if OG_TARGET_OS_DARWIN +#include +#include +#include +#include +#if OAG_TARGET_OS_DARWIN #include #else #include #endif -namespace OG { +namespace OAG { namespace data { //zone::zone() : _info(info(shared_table().make_zone_id())) {} @@ -35,7 +35,7 @@ void zone::clear() { shared_table().unlock(); } -ptr zone::alloc_slow(uint32_t size, uint32_t alignment_mask) OG_NOEXCEPT { +ptr zone::alloc_slow(uint32_t size, uint32_t alignment_mask) OAG_NOEXCEPT { if (last_page()) { // check if we can use remaining bytes in this page ptr next_bytes = last_page() + last_page()->in_use; @@ -83,7 +83,7 @@ ptr zone::alloc_slow(uint32_t size, uint32_t alignment_mask) OG_NOEXCEPT { return new_page + aligned_used_bytes; }; -void zone::print() const OG_NOEXCEPT { +void zone::print() const OAG_NOEXCEPT { unsigned long num_pages = 0; double pages_total_kb = 0.0; double pages_in_use_kb = 0.0; @@ -111,7 +111,7 @@ void zone::print() const OG_NOEXCEPT { unsigned long num_persistent_buffers = _malloc_buffers.size(); size_t malloc_total_size = 0; for (auto &element : _malloc_buffers) { - #if OG_TARGET_OS_DARWIN + #if OAG_TARGET_OS_DARWIN malloc_total_size += malloc_size(element.get()); #else malloc_total_size += malloc_usable_size(element.get()); @@ -131,10 +131,10 @@ void zone::print() const OG_NOEXCEPT { ); } -void zone::print_header() const OG_NOEXCEPT { +void zone::print_header() const OAG_NOEXCEPT { fprintf(stderr, "Zones\n%-16s %6s %8s %8s %6s %6s %6s %8s\n", "zone ptr", "pages", "total", "in-use", "free", "bytes", "malloc", "total"); } } /* data */ -} /* OG */ +} /* OAG */ diff --git a/Sources/OpenGraphCxx/DebugServer/DebugServer.mm b/Sources/OpenAttributeGraphCxx/DebugServer/DebugServer.mm similarity index 84% rename from Sources/OpenGraphCxx/DebugServer/DebugServer.mm rename to Sources/OpenAttributeGraphCxx/DebugServer/DebugServer.mm index 2aa163e1..665d223a 100644 --- a/Sources/OpenGraphCxx/DebugServer/DebugServer.mm +++ b/Sources/OpenAttributeGraphCxx/DebugServer/DebugServer.mm @@ -1,22 +1,22 @@ // // DebugServer.mm -// OpenGraphCxx +// OpenAttributeGraphCxx // // Audited for 6.5.1 // Status: Blocked by profile command // TODO: -// 1. select will both fail on AG and OG with different error. +// 1. select will both fail on AG and OAG with different error. // 2. run(timeout)'s purpose? And update documentation for hpp and h // 3. Implement profile commands. -#include -#if OG_TARGET_OS_DARWIN +#include +#if OAG_TARGET_OS_DARWIN -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -28,25 +28,25 @@ #include #include -OG_EXTERN_C_BEGIN +OAG_EXTERN_C_BEGIN // DYLD_INTERPOSE does not work. Directly use the hook one here to match the semantics. bool og_variant_has_internal_diagnostics(const char *subsystem); -OG_EXTERN_C_END +OAG_EXTERN_C_END // MARK: DebugServer public API Implementation -OG::DebugServer::DebugServer(OGDebugServerMode mode) { +OAG::DebugServer::DebugServer(OAGDebugServerMode mode) { sockfd = -1; ip = 0; port = 0; token = arc4random(); source = nullptr; - connections = OG::vector, 0, u_long>(); + connections = OAG::vector, 0, u_long>(); // Create socket sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0) { - perror("OGDebugServer: socket"); + perror("OAGDebugServer: socket"); return; } @@ -61,11 +61,11 @@ sockaddr_in addr; addr.sin_family = AF_INET; addr.sin_port = 0; // Let system assign port - addr.sin_addr.s_addr = (mode & OGDebugServerModeNetworkInterface) ? INADDR_ANY : htonl(INADDR_LOOPBACK); + addr.sin_addr.s_addr = (mode & OAGDebugServerModeNetworkInterface) ? INADDR_ANY : htonl(INADDR_LOOPBACK); // Bind socket if (bind(sockfd, (const sockaddr *)&addr, sizeof(addr))) { - perror("OGDebugServer: bind"); + perror("OAGDebugServer: bind"); shutdown(); return; } @@ -73,7 +73,7 @@ // Get assigned address and port socklen_t slen = sizeof(addr); if (getsockname(sockfd, (sockaddr *)&addr, &slen)) { - perror("OGDebugServer: getsockname"); + perror("OAGDebugServer: getsockname"); shutdown(); return; } @@ -81,7 +81,7 @@ port = ntohs(addr.sin_port); // If network interface mode, find external IP - if (mode & OGDebugServerModeNetworkInterface) { + if (mode & OAGDebugServerModeNetworkInterface) { ifaddrs *iaddrs = nullptr; if (getifaddrs(&iaddrs) == 0) { ifaddrs *current_iaddrs = iaddrs; @@ -102,7 +102,7 @@ // listen if (listen(sockfd, 5)) { - perror("OGDebugServer: listen"); + perror("OAGDebugServer: listen"); shutdown(); return; } @@ -121,7 +121,7 @@ fprintf(stderr, "debug server graph://%s:%d/?token=%u\n", address, port, token); } -OG::DebugServer::DebugServer(DebugServer&& other) OG_NOEXCEPT +OAG::DebugServer::DebugServer(DebugServer&& other) OAG_NOEXCEPT : sockfd(other.sockfd) , ip(other.ip) , port(other.port) @@ -136,7 +136,7 @@ other.source = nullptr; } -OG::DebugServer& OG::DebugServer::operator=(DebugServer&& other) OG_NOEXCEPT { +OAG::DebugServer& OAG::DebugServer::operator=(DebugServer&& other) OAG_NOEXCEPT { if (this != &other) { shutdown(); for (auto &connection : connections) { @@ -159,14 +159,14 @@ return *this; } -OG::DebugServer::~DebugServer() { +OAG::DebugServer::~DebugServer() { shutdown(); for (auto &connection : connections) { connection.reset(); } } -CFURLRef _Nullable OG::DebugServer::copy_url() const { +CFURLRef _Nullable OAG::DebugServer::copy_url() const { if (sockfd < 0) { return nullptr; } @@ -179,7 +179,7 @@ } // NOTE: Copilot implementation -void OG::DebugServer::run(int timeout) const { +void OAG::DebugServer::run(int timeout) const { bool accepted_connection = false; while (true) { @@ -221,7 +221,7 @@ // Continue the loop on EAGAIN continue; } - perror("OGDebugServer: select"); + perror("OAGDebugServer: select"); return; } @@ -261,19 +261,19 @@ } } } -OG::DebugServer* _Nullable OG::DebugServer::start(OGDebugServerMode mode) { +OAG::DebugServer* _Nullable OAG::DebugServer::start(OAGDebugServerMode mode) { if ( - (mode & OGDebugServerModeValid) - && !OG::DebugServer::has_shared_server() - && og_variant_has_internal_diagnostics("org.OpenSwiftUIProject.OpenGraph") + (mode & OAGDebugServerModeValid) + && !OAG::DebugServer::has_shared_server() + && og_variant_has_internal_diagnostics("org.OpenSwiftUIProject.OpenAttributeGraph") ) { _shared_server = new DebugServer(mode); } - return OG::DebugServer::_shared_server; + return OAG::DebugServer::_shared_server; } -void OG::DebugServer::stop() { - if (!OG::DebugServer::has_shared_server()) { +void OAG::DebugServer::stop() { + if (!OAG::DebugServer::has_shared_server()) { return; } delete _shared_server; @@ -282,7 +282,7 @@ // MARK: Blocking operation -namespace OG { +namespace OAG { namespace { bool blocking_read(int descriptor, void *buf, unsigned long count) { ssize_t offset = 0; @@ -293,7 +293,7 @@ bool blocking_read(int descriptor, void *buf, unsigned long count) { } else if (read_count < 0) { if (errno != EINTR) { if (errno != EAGAIN && errno != EWOULDBLOCK) { - perror("OGDebugServer: read"); + perror("OAGDebugServer: read"); return false; } assert("errno != EAGAIN && errno != EWOULDBLOCK"); @@ -314,7 +314,7 @@ bool blocking_write(int descriptor, void *buf, unsigned long count) { } else if (write_count < 0) { if (errno != EINTR) { if (errno != EAGAIN && errno != EWOULDBLOCK) { - perror("OGDebugServer: write"); + perror("OAGDebugServer: write"); return false; } assert("errno != EAGAIN && errno != EWOULDBLOCK"); @@ -326,11 +326,11 @@ bool blocking_write(int descriptor, void *buf, unsigned long count) { return true; } } /* anonymous namespace */ -} /* OG */ +} /* OAG */ // MARK: Connection Implementation -OG::DebugServer::Connection::Connection(DebugServer *s,int d) { +OAG::DebugServer::Connection::Connection(DebugServer *s,int d) { server = s; sockfd = d; source = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, sockfd, 0, dispatch_get_main_queue()); @@ -339,17 +339,17 @@ bool blocking_write(int descriptor, void *buf, unsigned long count) { dispatch_resume(source); } -OG::DebugServer::Connection::~Connection() { +OAG::DebugServer::Connection::~Connection() { dispatch_source_set_event_handler_f(source, nullptr); dispatch_set_context(source, nullptr); close(sockfd); } -void OG::DebugServer::Connection::handler(void *_Nullable context) { +void OAG::DebugServer::Connection::handler(void *_Nullable context) { Connection *connection = (Connection *)context; char buf[16] = {}; if (blocking_read(connection->sockfd, &buf, 16)) { - OGDebugServerMessageHeader *header = (OGDebugServerMessageHeader *)buf; + OAGDebugServerMessageHeader *header = (OAGDebugServerMessageHeader *)buf; header->unknown2 = 0; if (header->token == connection->server->token) { CFIndex length = header->length; @@ -384,7 +384,7 @@ bool blocking_write(int descriptor, void *buf, unsigned long count) { // MARK: DebugServer private API Implementation // TODO: part implemented -CFDataRef _Nullable OG::DebugServer::receive(Connection *, OGDebugServerMessageHeader &, CFDataRef data) { +CFDataRef _Nullable OAG::DebugServer::receive(Connection *, OAGDebugServerMessageHeader &, CFDataRef data) { @autoreleasepool { id object = [NSJSONSerialization JSONObjectWithData:(__bridge NSData *)data options:0 error:NULL]; if (object && [object isKindOfClass:NSDictionary.class]) { @@ -392,8 +392,8 @@ bool blocking_write(int descriptor, void *buf, unsigned long count) { NSString *command = dic[@"command"]; if ([command isEqual:@"graph/description"]) { NSMutableDictionary *mutableDic = [NSMutableDictionary dictionaryWithDictionary:dic]; - mutableDic[(__bridge NSString *)OGDescriptionFormat] = (__bridge NSString *)OGDescriptionFormatDictionary; - CFTypeRef description = OG::Graph::description(nullptr, mutableDic); + mutableDic[(__bridge NSString *)OAGDescriptionFormat] = (__bridge NSString *)OAGDescriptionFormatDictionary; + CFTypeRef description = OAG::Graph::description(nullptr, mutableDic); if (description) { NSData *descriptionData = [NSJSONSerialization dataWithJSONObject:(__bridge id)description options:0 error:NULL]; return (__bridge CFDataRef)descriptionData; @@ -428,7 +428,7 @@ bool blocking_write(int descriptor, void *buf, unsigned long count) { } } -void OG::DebugServer::close_connection(OG::DebugServer::Connection *target) { +void OAG::DebugServer::close_connection(OAG::DebugServer::Connection *target) { auto size = connections.size(); if (size == 0) { return; @@ -445,7 +445,7 @@ bool blocking_write(int descriptor, void *buf, unsigned long count) { } } -void OG::DebugServer::shutdown() { +void OAG::DebugServer::shutdown() { if (source != nullptr) { dispatch_source_set_event_handler_f(source, nullptr); dispatch_set_context(source, nullptr); @@ -457,19 +457,19 @@ bool blocking_write(int descriptor, void *buf, unsigned long count) { } } -void OG::DebugServer::accept_handler(void *_Nullable context) { +void OAG::DebugServer::accept_handler(void *_Nullable context) { DebugServer *server = (DebugServer *)context; sockaddr address; socklen_t address_len = 16; int sockfd = accept(server->sockfd, &address, &address_len); if (sockfd < 0) { - perror("OGDebugServer: accept"); + perror("OAGDebugServer: accept"); return; } fcntl(server->sockfd, F_SETFD, O_WRONLY); server->connections.push_back(std::unique_ptr(new Connection(server, sockfd))); } -OG::DebugServer* _Nullable OG::DebugServer::_shared_server = nullptr; +OAG::DebugServer* _Nullable OAG::DebugServer::_shared_server = nullptr; -#endif /* OG_TARGET_OS_DARWIN */ +#endif /* OAG_TARGET_OS_DARWIN */ diff --git a/Sources/OpenAttributeGraphCxx/DebugServer/OAGDebugServer.cpp b/Sources/OpenAttributeGraphCxx/DebugServer/OAGDebugServer.cpp new file mode 100644 index 00000000..41485a0f --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/DebugServer/OAGDebugServer.cpp @@ -0,0 +1,37 @@ +// +// OAGDebugServer.cpp +// OpenAttributeGraphCxx +// +// Audited for 6.5.1 +// Status: Complete + +#include +#include + +#if OAG_TARGET_OS_DARWIN + +// MARK: - Exported C functions + +OAGDebugServerRef _Nullable OAGDebugServerStart(OAGDebugServerMode port) { + return (OAGDebugServerRef)OAG::DebugServer::start(port); +} + +void OAGDebugServerStop() { + OAG::DebugServer::stop(); +} + +CFURLRef _Nullable OAGDebugServerCopyURL() { + if (!OAG::DebugServer::has_shared_server()) { + return nullptr; + } + return OAG::DebugServer::shared_server()->copy_url(); +} + +void OAGDebugServerRun(int timeout) { + if (!OAG::DebugServer::has_shared_server()) { + return; + } + OAG::DebugServer::shared_server()->run(timeout); +} + +#endif diff --git a/Sources/OpenGraphCxx/DebugServer/interpose.c b/Sources/OpenAttributeGraphCxx/DebugServer/interpose.c similarity index 79% rename from Sources/OpenGraphCxx/DebugServer/interpose.c rename to Sources/OpenAttributeGraphCxx/DebugServer/interpose.c index 637bd2bc..97559277 100644 --- a/Sources/OpenGraphCxx/DebugServer/interpose.c +++ b/Sources/OpenAttributeGraphCxx/DebugServer/interpose.c @@ -1,23 +1,23 @@ // // interpose.c -// OpenGraphCxx +// OpenAttributeGraphCxx -#include +#include #include "stdio.h" #include "stdbool.h" #include "string.h" -#if OG_TARGET_OS_DARWIN +#if OAG_TARGET_OS_DARWIN extern bool os_variant_has_internal_diagnostics(const char *subsystem); #endif bool og_variant_has_internal_diagnostics(const char *subsystem) { - if (strcmp(subsystem, "org.OpenSwiftUIProject.OpenGraph") == 0) { + if (strcmp(subsystem, "org.OpenSwiftUIProject.OpenAttributeGraph") == 0) { return true; } else if (strcmp(subsystem, "com.apple.AttributeGraph") == 0) { return true; } else { - #if OG_TARGET_OS_DARWIN + #if OAG_TARGET_OS_DARWIN return os_variant_has_internal_diagnostics(subsystem); #else return false; @@ -25,7 +25,7 @@ bool og_variant_has_internal_diagnostics(const char *subsystem) { } } -#if OG_TARGET_OS_DARWIN +#if OAG_TARGET_OS_DARWIN #define DYLD_INTERPOSE(_replacement,_replacee) \ __attribute__((used)) static struct{ const void* replacement; const void* replacee; } _interpose_##_replacee \ __attribute__ ((section ("__DATA,__interpose"))) = { (const void*)(unsigned long)&_replacement, (const void*)(unsigned long)&_replacee }; diff --git a/Sources/OpenAttributeGraphCxx/Graph/Graph.cpp b/Sources/OpenAttributeGraphCxx/Graph/Graph.cpp new file mode 100644 index 00000000..1fe6a6d4 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/Graph/Graph.cpp @@ -0,0 +1,62 @@ +// +// Graph.cpp +// OpenAttributeGraphCxx + +#include +#include +#include + +#if !OAG_TARGET_OS_WASI +#include +#endif + +#include + +pthread_key_t OAG::Graph::_current_update_key; + +OAG::Graph::Graph() OAG_NOEXCEPT { + // TODO + + // libdispatch is not supported on WASI + // Tracked via https://github.com/swiftwasm/swift/issues/5565 + #if !OAG_TARGET_OS_WASI + static dispatch_once_t make_keys; + dispatch_once_f(&make_keys, nullptr, [](void * _Nullable context){ + pthread_key_create(&_current_update_key, nullptr); + OAG::Subgraph::make_current_subgraph_key(); + }); + #endif + + // TODO +} + +const void OAG::Graph::value_mark_all() const OAG_NOEXCEPT { + // TODO +} + +void OAG::Graph::all_start_profiling(uint32_t) OAG_NOEXCEPT { + // TODO +} +void OAG::Graph::all_stop_profiling() OAG_NOEXCEPT { + // TODO +} +void OAG::Graph::start_profiling(uint32_t) OAG_NOEXCEPT { + // TODO +} +void OAG::Graph::stop_profiling() OAG_NOEXCEPT { + // TODO +} + +const bool OAG::Graph::thread_is_updating() const OAG_NOEXCEPT { + void *current = pthread_getspecific(current_key()); + if (!current) { + return false; + } + // TODO + return false; +} + +const bool OAG::Graph::is_context_updating(const OAG::Graph::Context&) const OAG_NOEXCEPT { + // TODO + return false; +} diff --git a/Sources/OpenGraphCxx/Graph/Graph.mm b/Sources/OpenAttributeGraphCxx/Graph/Graph.mm similarity index 76% rename from Sources/OpenGraphCxx/Graph/Graph.mm rename to Sources/OpenAttributeGraphCxx/Graph/Graph.mm index 476ad160..28dd329d 100644 --- a/Sources/OpenGraphCxx/Graph/Graph.mm +++ b/Sources/OpenAttributeGraphCxx/Graph/Graph.mm @@ -1,20 +1,20 @@ // // Graph.mm -// OpenGraphCxx +// OpenAttributeGraphCxx -#include -#include +#include +#include -#if OG_OBJC_FOUNDATION +#if OAG_OBJC_FOUNDATION #include #include -void OG::Graph::write_to_file(const Graph * _Nullable graph, const char * _Nullable name, uint8_t options) OG_NOEXCEPT { +void OAG::Graph::write_to_file(const Graph * _Nullable graph, const char * _Nullable name, uint8_t options) OAG_NOEXCEPT { @autoreleasepool { NSDictionary *options_dict = @{ - (__bridge NSString *)OGDescriptionFormat: (__bridge NSString *)OGDescriptionFormatDictionary, - (__bridge NSString *)OGDescriptionIncludeValues: @((options & 1) == 0), - (__bridge NSString *)OGDescriptionAllGraphs: @(graph == nil) + (__bridge NSString *)OAGDescriptionFormat: (__bridge NSString *)OAGDescriptionFormatDictionary, + (__bridge NSString *)OAGDescriptionIncludeValues: @((options & 1) == 0), + (__bridge NSString *)OAGDescriptionAllGraphs: @(graph == nil) }; NSString *description = (__bridge NSString *)Graph::description(graph, options_dict); if (description == nil) { @@ -56,4 +56,4 @@ } } -#endif /* OG_OBJC_FOUNDATION */ +#endif /* OAG_OBJC_FOUNDATION */ diff --git a/Sources/OpenAttributeGraphCxx/Graph/GraphContext.cpp b/Sources/OpenAttributeGraphCxx/Graph/GraphContext.cpp new file mode 100644 index 00000000..54e5f6b4 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/Graph/GraphContext.cpp @@ -0,0 +1,31 @@ +// +// GraphContext.cpp +// OpenAttributeGraphCxx + +#include +#include +#include + +OAG::Graph::Context &OAG::Graph::Context::from_cf(OAGGraphRef storage) OAG_NOEXCEPT { + if (storage->context.isInvalid()) { + OAG::precondition_failure("invalidated graph"); + } + return storage->context; +} + +OAG::Graph::Context::Context(OAG::Graph &graph) OAG_NOEXCEPT : +_graph(&graph), +_context(nullptr), +_id(OAGMakeUniqueID()), +_invalidation_callback(nullptr), +_update_callback(nullptr) { + // TODO +} + +OAG::Graph::Context::~Context() OAG_NOEXCEPT { + // TODO +} + +const bool OAG::Graph::Context::thread_is_updating() const OAG_NOEXCEPT { + return _graph->thread_is_updating() && _graph->is_context_updating(*this); +} diff --git a/Sources/OpenAttributeGraphCxx/Graph/GraphDescription.cpp b/Sources/OpenAttributeGraphCxx/Graph/GraphDescription.cpp new file mode 100644 index 00000000..5fc61462 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/Graph/GraphDescription.cpp @@ -0,0 +1,33 @@ +// +// GraphDescription.cpp +// OpenAttributeGraphCxx + +#include +#include +#include +#include + +CFTypeRef OAGGraphDescription(OAGGraphRef graph, CFDictionaryRef options) { + #if OAG_OBJC_FOUNDATION + if (graph == nullptr) { + return OAG::Graph::description(nullptr, (__bridge NSDictionary*)options); + } + if (graph->context.isInvalid()) { + OAG::precondition_failure("invalidated graph"); + } + return OAG::Graph::description(&graph->context.get_graph(), (__bridge NSDictionary*)options); + #endif +} + +void OAGGraphArchiveJSON(char const * _Nullable name) { + #if OAG_OBJC_FOUNDATION + OAG::Graph::write_to_file(nullptr, name, 0); + #endif +} + +void OAGGraphArchiveJSON2(char const * _Nullable name, uint8_t options) { + #if OAG_OBJC_FOUNDATION + OAG::Graph::write_to_file(nullptr, name, options); + #endif +} + diff --git a/Sources/OpenAttributeGraphCxx/Graph/GraphDescription.mm b/Sources/OpenAttributeGraphCxx/Graph/GraphDescription.mm new file mode 100644 index 00000000..19801fae --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/Graph/GraphDescription.mm @@ -0,0 +1,24 @@ +// +// GraphDescription.mm +// OpenAttributeGraphCxx + +#include +#include +#include +#include + +#if OAG_OBJC_FOUNDATION + +#include + +const CFStringRef OAGDescriptionFormat = CFSTR("format"); +const CFStringRef OAGDescriptionIncludeValues = CFSTR("include-values"); + +CFTypeRef OAG::Graph::description(const Graph * _Nullable graph, NSDictionary* dic) { + // TODO + // For "format": "graph/dict" - NSMutableDictionray + // For "format": "graph/dot" - NSMutableString + return NULL; +} + +#endif /* OAG_OBJC_FOUNDATION */ diff --git a/Sources/OpenAttributeGraphCxx/Graph/OAGGraph.cpp b/Sources/OpenAttributeGraphCxx/Graph/OAGGraph.cpp new file mode 100644 index 00000000..2bab8c2c --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/Graph/OAGGraph.cpp @@ -0,0 +1,211 @@ +// +// OAGGraph.cpp +// OpenAttributeGraphCxx + +#include +#include +#include +#include +#include + +OAGGraphRef OAGGraphCreate() { + return OAGGraphCreateShared(nullptr); +} + +OAGGraphRef OAGGraphCreateShared(OAGGraphRef storage) { + const CFIndex extraSize = sizeof(OAGGraphStorage)-sizeof(CFRuntimeBase); + OAGGraphRef instance = (OAGGraphRef)_CFRuntimeCreateInstance(kCFAllocatorDefault, OAGGraphGetTypeID(), extraSize, nullptr); + if (instance == nullptr) { + OAG::precondition_failure("memory allocation failure."); + } + OAG::Graph *graph = nullptr; + if (storage == nullptr) { + graph = new OAG::Graph(); + } else { + if (storage->context.isInvalid()) { + OAG::precondition_failure("invalidated graph"); + } + graph = &storage->context.get_graph(); + // [graph+0x10c] += 1 + } + // AG::Context(instance->graph, graph) + + // [graph+0x10c] -= 1 +// if ([graph+0x10c] == 0) { +// delete graph +// } + instance->context.setInvalid(false); + return instance; +} + +namespace { +CFRuntimeClass &graph_type_id() { + static auto dealloc = [](const void* ptr) { + OAGGraphRef storage = (OAGGraphRef)ptr; + if (storage->context.isInvalid()) { + return; + } + storage->context.~Context(); + }; + static CFRuntimeClass klass = { + 0, + "OAGGraphStorage", + NULL, // init + NULL, // copy + dealloc, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 0, + }; + return klass; +} +} + +CFTypeID OAGGraphGetTypeID() { + static CFTypeID type = _CFRuntimeRegisterClass(&graph_type_id()); + return type; +} + +void OAGGraphStartProfiling(_Nullable OAGGraphRef graph) { + if (!graph) { + OAG::Graph::all_start_profiling(1); + return; + } + if (graph->context.isInvalid()) { + OAG::precondition_failure("invalidated graph"); + } + graph->context.get_graph().start_profiling(1); +} + +void OAGGraphStopProfiling(_Nullable OAGGraphRef graph) { + if (!graph) { + OAG::Graph::all_stop_profiling(); + return; + } + if (graph->context.isInvalid()) { + OAG::precondition_failure("invalidated graph"); + } + graph->context.get_graph().stop_profiling(); +} + +void OAGGraphResetProfile(_Nullable OAGGraphRef graph) { + // TODO +} + +const void * _Nullable OAGGraphGetContext(OAGGraphRef graph) { + if (graph->context.isInvalid()) { + OAG::precondition_failure("invalidated graph"); + } + return graph->context.get_context(); +} + +void OAGGraphSetContext(OAGGraphRef graph, const void * _Nullable context) { + if (graph->context.isInvalid()) { + OAG::precondition_failure("invalidated graph"); + } + graph->context.set_context(context); +} + +OAGGraphContextRef OAGGraphGetGraphContext(OAGGraphRef graph) { + if (graph->context.isInvalid()) { + OAG::precondition_failure("invalidated graph"); + } + return reinterpret_cast(reinterpret_cast(graph) + sizeof(CFRuntimeBase)); +} + +void OAGGraphInvalidate(OAGGraphRef graph) { + if (graph->context.isInvalid()) { + return; + } + graph->context.~Context(); + graph->context.setInvalid(true); +} + +void OAGGraphInvalidateAllValues(OAGGraphRef graph) { + if (graph->context.isInvalid()) { + OAG::precondition_failure("invalidated graph"); + } + graph->context.get_graph().value_mark_all(); +} + + + +void OAGGraphSetInvalidationCallback(OAGGraphRef graph, + const void (*_Nullable function)(const void * _Nullable context OAG_SWIFT_CONTEXT, OAGAttribute) OAG_SWIFT_CC(swift), + const void * _Nullable context) { + if (graph->context.isInvalid()) { + OAG::precondition_failure("invalidated graph"); + } + graph->context.set_invalidation_callback(OAG::ClosureFunction(function, context)); +} + +void OAGGraphSetUpdateCallback(OAGGraphRef graph, + const void (*_Nullable function)(const void * _Nullable context OAG_SWIFT_CONTEXT) OAG_SWIFT_CC(swift), + const void * _Nullable context) { + if (graph->context.isInvalid()) { + OAG::precondition_failure("invalidated graph"); + } + graph->context.set_update_callback(OAG::ClosureFunction(function, context)); +} + +uint64_t OAGGraphGetCounter(OAGGraphRef graph, OAGGraphCounterQueryType query) { + if (graph->context.isInvalid()) { + OAG::precondition_failure("invalidated graph"); + } + OAG::Graph::Context& context = graph->context; + switch (query) { + case OAGGraphCounterQueryTypeNodes: + return context.get_graph().get_counter_0(); + case OAGGraphCounterQueryTypeTransactions: + return context.get_graph().get_counter_1(); + case OAGGraphCounterQueryTypeUpdates: + return context.get_graph().get_counter_2(); + case OAGGraphCounterQueryTypeChanges: + return context.get_graph().get_counter_3(); + case OAGGraphCounterQueryTypeContextID: + return context.get_graph().get_counter_4(); + case OAGGraphCounterQueryTypeGraphID: + return context.get_graph().get_counter_5(); + case OAGGraphCounterQueryTypeContextThreadUpdating: + return context.thread_is_updating(); + case OAGGraphCounterQueryTypeThreadUpdating: + return context.get_graph().thread_is_updating(); + case OAGGraphCounterQueryTypeContextNeedsUpdate: + return context.get_graph().get_counter_8(); + case OAGGraphCounterQueryTypeNeedsUpdate: + return context.get_graph().get_counter_9(); + case OAGGraphCounterQueryTypeMainThreadUpdates: + return context.get_graph().get_counter_10(); + default: + return 0; + } +} + +void OAGGraphSetUpdate(const void * _Nullable value) { + pthread_setspecific(OAG::Graph::current_key(), value); +} + +const void * _Nullable OAGGraphClearUpdate(void) { + void * value = pthread_getspecific(OAG::Graph::current_key()); + bool isDirty = (uint64_t)value & 0x1; + if (value != nullptr && isDirty) { + pthread_setspecific(OAG::Graph::current_key(), (void *)((uint64_t)value | 0x1)); + } + return value; +} + +void OAGGraphSetNeedsUpdate(OAGGraphRef graph) { + if (graph->context.isInvalid()) { + OAG::precondition_failure("invalidated graph"); + } + // graph->context->set_needs_update(); +} + +bool OAGGraphAnyInputsChanged(const OAGAttribute *excluded_inputs, size_t count) { + // TODO + return false; +} diff --git a/Sources/OpenAttributeGraphCxx/Graph/OAGGraphContext.cpp b/Sources/OpenAttributeGraphCxx/Graph/OAGGraphContext.cpp new file mode 100644 index 00000000..02cc8e11 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/Graph/OAGGraphContext.cpp @@ -0,0 +1,10 @@ +// +// OAGGraphContext.cpp +// OpenAttributeGraphCxx + +#include +#include + +OAGGraphRef OAGGraphContextGetGraph(OAGGraphContextRef context) { + return reinterpret_cast(reinterpret_cast(context) - sizeof(CFRuntimeBase)); +} diff --git a/Sources/OpenAttributeGraphCxx/Graph/OAGGraphTracing.cpp b/Sources/OpenAttributeGraphCxx/Graph/OAGGraphTracing.cpp new file mode 100644 index 00000000..dedaa8df --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/Graph/OAGGraphTracing.cpp @@ -0,0 +1,17 @@ +// +// OAGGraphTracing.mm +// OpenAttributeGraphCxx + +#include + +void OAGGraphStartTracing(_Nullable OAGGraphRef graph, OAGGraphTraceOptions options) { + OAGGraphStartTracing2(graph, options, NULL); +} + +void OAGGraphStartTracing2(_Nullable OAGGraphRef graph, OAGGraphTraceOptions options, _Nullable CFArrayRef array) { + // TODO +} + +void OAGGraphStopTracing(_Nullable OAGGraphRef graph) { + // TODO +} diff --git a/Sources/OpenAttributeGraphCxx/Graph/OAGSubgraph.cpp b/Sources/OpenAttributeGraphCxx/Graph/OAGSubgraph.cpp new file mode 100644 index 00000000..006dcc69 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/Graph/OAGSubgraph.cpp @@ -0,0 +1,220 @@ +// +// OAGSubgraph.cpp +// OpenAttributeGraphCxx + +#include +#include +#include +#include +#include +#include +#include +#if !OAG_TARGET_OS_WASI +#include +#endif + +namespace { +CFRuntimeClass &subgraph_type_id() { + static auto dealloc = [](const void* ptr) { + OAGSubgraphRef storage = (OAGSubgraphRef)ptr; + auto subgraph = storage->subgraph; + if (subgraph == nullptr) { + return; + } + subgraph->clear_object(); + subgraph->invalidate_and_delete_(false); + }; + static CFRuntimeClass klass = { + 0, + "OAGSubgraph", + NULL, // init + NULL, // copy + dealloc, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 0, + }; + return klass; +} +} + +CFTypeID OAGSubgraphGetTypeID() { + static CFTypeID type = _CFRuntimeRegisterClass(&subgraph_type_id()); + return type; +} + +OAGSubgraphRef OAGSubgraphCreate(OAGGraphRef cf_graph) { + return OAGSubgraphCreate2(cf_graph, OAGAttributeNil); +} + +OAGSubgraphRef OAGSubgraphCreate2(OAGGraphRef cf_graph, OAGAttribute attribute) { + OAG::Graph::Context &context = OAG::Graph::Context::from_cf(cf_graph); + const CFIndex extraSize = sizeof(OAGSubgraphStorage)-sizeof(CFRuntimeBase); + #if OAG_TARGET_CPU_WASM32 + // FIXME: extraSize will always be 8 thus it will fail on WASM. Investate later. + static_assert(extraSize == 8); + #else + static_assert(extraSize == sizeof(void *)); + #endif + OAGSubgraphRef cf_subgrah = (OAGSubgraphRef)_CFRuntimeCreateInstance(kCFAllocatorDefault, OAGSubgraphGetTypeID(), extraSize, nullptr); + if (cf_subgrah == nullptr) { + OAG::precondition_failure("memory allocation failure."); + } + cf_subgrah->subgraph = new OAG::Subgraph((OAG::SubgraphObject *)cf_subgrah, context, attribute); + return cf_subgrah; +} + +_Nullable OAGSubgraphRef OAGSubgraphGetCurrent() { + OAG::Subgraph *subgraph = OAG::Subgraph::get_current(); + if (subgraph == nullptr) { + return nullptr; + } + return subgraph->to_cf(); +} + +void OAGSubgraphSetCurrent(_Nullable OAGSubgraphRef cf_subgraph) { + OAG::Subgraph *old_subgraph = OAG::Subgraph::get_current(); + if (cf_subgraph == nullptr) { + OAG::Subgraph::set_current(nullptr); + } else { + OAG::Subgraph *subgraph = cf_subgraph->subgraph; + OAG::Subgraph::set_current(subgraph); + if (subgraph != nullptr) { + CFRetain(cf_subgraph); + } + } + if (old_subgraph != nullptr) { + OAGSubgraphRef old_cf_Subgraph = old_subgraph->to_cf(); + if (old_cf_Subgraph) { + CFRelease(old_cf_Subgraph); + } + } +} + +OAGGraphContextRef OAGSubgraphGetCurrentGraphContext() { + OAG::Subgraph *subgraph = OAG::Subgraph::get_current(); + if (subgraph == nullptr) { + return nullptr; + } + return subgraph->get_context(); +} + +void OAGSubgraphInvalidate(OAGSubgraphRef cf_subgraph) { + if (cf_subgraph->subgraph == nullptr) { + return; + } + cf_subgraph->subgraph->invalidate_and_delete_(false); +} + +bool OAGSubgraphIsValid(OAGSubgraphRef cf_subgraph) { + if (cf_subgraph->subgraph == nullptr) { + return false; + } + return !cf_subgraph->subgraph->isInvalid(); +} + +OAGGraphRef OAGSubgraphGetGraph(OAGSubgraphRef cf_subgraph) { + if (cf_subgraph->subgraph == nullptr) { + OAG::precondition_failure("accessing invalidated subgraph"); + } + return OAGGraphContextGetGraph(cf_subgraph->subgraph->get_context()); +} + +void OAGSubgraphAddChild(OAGSubgraphRef parent, OAGSubgraphRef child) { + OAGSubgraphAddChild2(parent, child, 0); +} + +void OAGSubgraphAddChild2(OAGSubgraphRef parent, OAGSubgraphRef child, uint8_t tag) { + // TODO +} + +void OAGSubgraphRemoveChild(OAGSubgraphRef parent, OAGSubgraphRef child) { + // TODO +} + +void OAGSubgraphApply(OAGSubgraphRef cf_subgraph, + OAGAttributeFlags flags, + const void (*function)(const void * _Nullable context OAG_SWIFT_CONTEXT, OAGAttribute attribute) OAG_SWIFT_CC(swift), + const void * _Nullable context) { + if (cf_subgraph->subgraph == nullptr) { + return; + } + return cf_subgraph->subgraph->apply(flags, OAG::ClosureFunction(function, context)); +} + +void OAGSubgraphUpdate(OAGSubgraphRef cf_subgraph, OAGAttributeFlags flags) { + OAG::Subgraph *subgraph = cf_subgraph->subgraph; + if (subgraph == nullptr) { + return; + } + // subgraph->update(flags); +} + +bool OAGSubgraphIsDirty(OAGSubgraphRef cf_subgraph, OAGAttributeFlags flags) { + OAG::Subgraph *subgraph = cf_subgraph->subgraph; + if (subgraph == nullptr) { + return false; + } + // TODO + return false; +} + +OAGUniqueID OAGSubgraphAddObserver(OAGSubgraphRef cf_subgraph, + const void (*function)(const void * _Nullable context OAG_SWIFT_CONTEXT) OAG_SWIFT_CC(swift), + const void * _Nullable context) { + OAG::Subgraph *subgraph = cf_subgraph->subgraph; + if (subgraph == nullptr) { + OAG::precondition_failure("accessing invalidated subgraph"); + } + return subgraph->add_observer(OAG::ClosureFunction(function, context)); +} + +#if !OAG_TARGET_OS_WASI +static bool should_record_tree; +static dispatch_once_t should_record_tree_once; + +void init_should_record_tree(void * _Nullable context) { + should_record_tree = OAG::get_env("OAG_TREE") != 0; +} +#endif + +bool OAGSubgraphShouldRecordTree() { + #if !OAG_TARGET_OS_WASI + dispatch_once_f(&should_record_tree_once, NULL, init_should_record_tree); + return should_record_tree; + #else + return false; + #endif +} + +void OAGSubgraphSetShouldRecordTree() { + #if !OAG_TARGET_OS_WASI + dispatch_once_f(&should_record_tree_once, NULL, init_should_record_tree); + should_record_tree = true; + #endif +} + +void OAGSubgraphBeginTreeElement(OAGAttribute attribute, OAGTypeID type, uint32_t flags) { + OAG::Subgraph * subgraph = OAG::Subgraph::get_current(); + if (subgraph) { + subgraph->begin_tree(attribute, reinterpret_cast(type), flags); + } +} + +void OAGSubgraphAddTreeValue(OAGAttribute attribute, OAGTypeID type, const char * key, uint32_t flags) { + OAG::Subgraph * subgraph = OAG::Subgraph::get_current(); + if (subgraph) { + subgraph->add_tree_value(attribute, reinterpret_cast(type), key, flags); + } +} + +void OAGSubgraphEndTreeElement(OAGAttribute attribute) { + OAG::Subgraph * subgraph = OAG::Subgraph::get_current(); + if (subgraph) { + subgraph->end_tree(attribute); + } +} diff --git a/Sources/OpenAttributeGraphCxx/Graph/Subgraph.cpp b/Sources/OpenAttributeGraphCxx/Graph/Subgraph.cpp new file mode 100644 index 00000000..1c7cdc16 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/Graph/Subgraph.cpp @@ -0,0 +1,47 @@ +// +// Subgraph.cpp +// OpenAttributeGraphCxx + +#include +#include + +pthread_key_t OAG::Subgraph::_current_subgraph_key; + +OAG::Subgraph* OAG::Subgraph::from_cf(OAGSubgraphRef storage) OAG_NOEXCEPT { + return storage->subgraph; +} + +void OAG::Subgraph::clear_object() const OAG_NOEXCEPT { + // TODO +} + +void OAG::Subgraph::invalidate_and_delete_(bool) const OAG_NOEXCEPT { + // TODO +} + +void OAG::Subgraph::apply(OAGAttributeFlags flags, OAG::ClosureFunction body) const OAG_NOEXCEPT { + // TODO +} + +OAG::Subgraph::Subgraph(OAG::SubgraphObject* cf_subgraph, OAG::Graph::Context& context, OAG::AttributeID): +_cf_subgraph((OAGSubgraphRef)cf_subgraph), // FIXME +_context((OAGGraphContextStorage &)context){ + // TODO +} + +OAGUniqueID OAG::Subgraph::add_observer(OAG::ClosureFunction observer) const OAG_NOEXCEPT { + // TODO + return OAGMakeUniqueID(); +} + +void OAG::Subgraph::begin_tree(OAG::AttributeID id, OAG::swift::metadata const* type, unsigned int flags) const OAG_NOEXCEPT { + // TODO +} + +void OAG::Subgraph::add_tree_value(OAG::AttributeID id, OAG::swift::metadata const *type, const char* key, uint32_t flags) const OAG_NOEXCEPT { + // TODO +} + +void OAG::Subgraph::end_tree(OAG::AttributeID id) const OAG_NOEXCEPT { + // TODO +} diff --git a/Sources/OpenAttributeGraphCxx/Graph/Subgraph.hpp b/Sources/OpenAttributeGraphCxx/Graph/Subgraph.hpp new file mode 100644 index 00000000..60fa4458 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/Graph/Subgraph.hpp @@ -0,0 +1,109 @@ +// +// Subgraph.hpp +// OpenAttributeGraphCxx + +#ifndef Subgraph_hpp +#define Subgraph_hpp + +#include "OAGBase.h" +#include +#include +#include +#include +#include + +typedef struct OAG_BRIDGED_TYPE(id) OAGSubgraphStorage * OAGSubgraphRef; + +namespace OAG { +class SubgraphObject; + +class Subgraph final { +private: + OAGSubgraphRef _cf_subgraph; + OAGGraphContextStorage& _context; + // TODO + bool _isInvalid; + static pthread_key_t _current_subgraph_key; +public: + // MARK: - CF related + + static Subgraph *from_cf(OAGSubgraphRef cf_subgraph) OAG_NOEXCEPT; + + OAGSubgraphRef to_cf() const OAG_NOEXCEPT { + return _cf_subgraph; + } + + // MARK: - pthread related + + OAG_INLINE + const static void make_current_subgraph_key() OAG_NOEXCEPT { + pthread_key_create(&_current_subgraph_key, nullptr); + } + + OAG_INLINE OAG_CONSTEXPR + const static pthread_key_t& current_key() OAG_NOEXCEPT { + return _current_subgraph_key; + } + + OAG_INLINE OAG_CONSTEXPR + static Subgraph *get_current() OAG_NOEXCEPT { + return (OAG::Subgraph*)pthread_getspecific(OAG::Subgraph::current_key()); + } + + OAG_INLINE OAG_CONSTEXPR + static int set_current(Subgraph *subgraph) OAG_NOEXCEPT { + return pthread_setspecific(OAG::Subgraph::current_key(), subgraph); + } + + // MARK: - Public API + void clear_object() const OAG_NOEXCEPT; + void invalidate_and_delete_(bool) const OAG_NOEXCEPT; + + void apply(OAGAttributeFlags flags, OAG::ClosureFunction body) const OAG_NOEXCEPT; + + OAGUniqueID add_observer(OAG::ClosureFunction observer) const OAG_NOEXCEPT; + + void begin_tree(OAG::AttributeID id, OAG::swift::metadata const *type, uint32_t flags) const OAG_NOEXCEPT; + void add_tree_value(OAG::AttributeID id, OAG::swift::metadata const *type, const char* key, uint32_t flags) const OAG_NOEXCEPT; + void end_tree(OAG::AttributeID id) const OAG_NOEXCEPT; + + // MARK: - Init and deinit + + Subgraph(SubgraphObject*, OAG::Graph::Context&, OAG::AttributeID); + + // MARK: - Getter and setter + + OAG_INLINE OAG_CONSTEXPR + const OAGGraphContextRef get_context() const OAG_NOEXCEPT { + return &_context; + } + + OAG_INLINE OAG_CONSTEXPR + OAGGraphContextRef get_context() OAG_NOEXCEPT { + return &_context; + } + + OAG_INLINE OAG_CONSTEXPR + const bool isInvalid() const OAG_NOEXCEPT { + return _isInvalid; + } + + OAG_INLINE OAG_CONSTEXPR + void setInvalid(bool invalid) OAG_NOEXCEPT { + _isInvalid = invalid; + } +}; /* Subgraph */ +} /* OAG */ + +struct OAGSubgraphStorage { + CFRuntimeBase base; + OAG::Subgraph *subgraph; +}; + +namespace OAG { +class SubgraphObject final { + OAGSubgraphStorage storage; +}; +} + +#endif /* Subgraph_hpp */ diff --git a/Sources/OpenGraphCxx/Misc/assert.cpp b/Sources/OpenAttributeGraphCxx/Misc/assert.cpp similarity index 58% rename from Sources/OpenGraphCxx/Misc/assert.cpp rename to Sources/OpenAttributeGraphCxx/Misc/assert.cpp index 3243e81b..4ed12250 100644 --- a/Sources/OpenGraphCxx/Misc/assert.cpp +++ b/Sources/OpenAttributeGraphCxx/Misc/assert.cpp @@ -1,16 +1,16 @@ // // assert.cpp -// OpenGraphCxx +// OpenAttributeGraphCxx -#include -#include +#include +#include #include #include char* error_message = nullptr; -namespace OG { +namespace OAG { void precondition_failure(const char *format, ...) { char* s = nullptr; va_list va; @@ -18,14 +18,14 @@ void precondition_failure(const char *format, ...) { vasprintf(&s, format, va); va_end(va); if (s != nullptr) { - #if OG_TARGET_OS_DARWIN + #if OAG_TARGET_OS_DARWIN os_log_error(error_log(), "precondition failure: %s", s); - #endif /* OG_TARGET_OS_DARWIN */ - #if OG_TARGET_RELEASE >= OG_RELEASE_2023 - // OG::Graph::trace_assertion_failure(true, "precondition failure: %s", s) + #endif /* OAG_TARGET_OS_DARWIN */ + #if OAG_TARGET_RELEASE >= OAG_RELEASE_2023 + // OAG::Graph::trace_assertion_failure(true, "precondition failure: %s", s) #endif if (error_message == nullptr) { - asprintf(&error_message, "OpenGraph precondition failure: %s.\n", s); + asprintf(&error_message, "OpenAttributeGraph precondition failure: %s.\n", s); } free(s); } @@ -39,11 +39,11 @@ void non_fatal_precondition_failure(const char *format, ...) { vasprintf(&s, format, va); va_end(va); if (s != nullptr) { - #if OG_TARGET_OS_DARWIN + #if OAG_TARGET_OS_DARWIN os_log_fault(error_log(), "precondition failure: %s", s); - #endif /* OG_TARGET_OS_DARWIN */ + #endif /* OAG_TARGET_OS_DARWIN */ free(s); } return; } -} /* OG */ +} /* OAG */ diff --git a/Sources/OpenGraphCxx/Misc/log.cpp b/Sources/OpenAttributeGraphCxx/Misc/log.cpp similarity index 51% rename from Sources/OpenGraphCxx/Misc/log.cpp rename to Sources/OpenAttributeGraphCxx/Misc/log.cpp index 322971b0..bad49392 100644 --- a/Sources/OpenGraphCxx/Misc/log.cpp +++ b/Sources/OpenAttributeGraphCxx/Misc/log.cpp @@ -1,22 +1,22 @@ // -// OGLog.cpp -// OpenGraphCxx +// OAGLog.cpp +// OpenAttributeGraphCxx // // Audited for 2021 Release -#include +#include -#if OG_TARGET_OS_DARWIN +#if OAG_TARGET_OS_DARWIN -namespace OG { +namespace OAG { os_log_t misc_log() { - static os_log_t log = os_log_create("org.OpenSwiftUIProject.OpenGraph", "misc"); + static os_log_t log = os_log_create("org.OpenSwiftUIProject.OpenAttributeGraph", "misc"); return log; } os_log_t error_log() { - static os_log_t log = os_log_create("org.OpenSwiftUIProject.OpenGraph", "error"); + static os_log_t log = os_log_create("org.OpenSwiftUIProject.OpenAttributeGraph", "error"); return log; } -} /* OG */ +} /* OAG */ -#endif /* OG_TARGET_OS_DARWIN */ +#endif /* OAG_TARGET_OS_DARWIN */ diff --git a/Sources/OpenAttributeGraphCxx/Runtime/OAGTupleType.cpp b/Sources/OpenAttributeGraphCxx/Runtime/OAGTupleType.cpp new file mode 100644 index 00000000..8d200d49 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/Runtime/OAGTupleType.cpp @@ -0,0 +1,260 @@ +// +// OAGTupleType.cpp +// OpenAttributeGraphCxx +// +// Audited for iOS 18.0 +// Status: Complete + +#include +#include +#include + +#ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED +#include +#endif + +OAGTupleType OAGNewTupleType(size_t count, const OAGTypeID *elements) { + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + if (count == 1) { + return elements[0]; + } + auto metadata_elements = reinterpret_cast(elements); + const auto response = swift_getTupleTypeMetadata(MetadataState::Complete, count, metadata_elements, nullptr, nullptr); + if (response.State != MetadataState::Complete) { + OAG::precondition_failure("invalid tuple type."); + } + return reinterpret_cast(response.Value); + #else + return nullptr; + #endif +} + +size_t OAGTupleCount(OAGTupleType tuple_type) { + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + auto metadata = reinterpret_cast(tuple_type); + if (metadata->getKind() != swift::MetadataKind::Tuple) { + return 1; + } + auto tuple_metadata = reinterpret_cast(metadata); + return tuple_metadata->NumElements; + #else + return 0; + #endif +} + +size_t OAGTupleSize(OAGTupleType tuple_type) { + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + auto metadata = reinterpret_cast(tuple_type); + return metadata->vw_size(); + #else + return 0; + #endif +} + +OAGTypeID OAGTupleElementType(OAGTupleType tuple_type, size_t index) { + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + auto metadata = reinterpret_cast(tuple_type); + if (metadata->getKind() != swift::MetadataKind::Tuple) { + if (index != 0) { + OAG::precondition_failure("index out of range: %d", index); + } + return reinterpret_cast(metadata); + } + auto tuple_metadata = reinterpret_cast(metadata); + if (tuple_metadata->NumElements <= index) { + OAG::precondition_failure("index out of range: %d", index); + } + auto element = tuple_metadata->getElement(unsigned(index)); + return reinterpret_cast(element.Type); + #else + return nullptr; + #endif +} + +size_t OAGTupleElementSize(OAGTupleType tuple_type, size_t index) { + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + auto metadata = reinterpret_cast(tuple_type); + if (metadata->getKind() != swift::MetadataKind::Tuple) { + if (index != 0) { + OAG::precondition_failure("index out of range: %d", index); + } + return metadata->vw_size(); + } + auto tuple_metadata = reinterpret_cast(metadata); + if (tuple_metadata->NumElements <= index) { + OAG::precondition_failure("index out of range: %d", index); + } + auto element = tuple_metadata->getElement(unsigned(index)); + return element.Type->vw_size(); + #else + return 0; + #endif +} + +size_t OAGTupleElementOffset(OAGTupleType tuple_type, size_t index) { + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + auto metadata = reinterpret_cast(tuple_type); + if (metadata->getKind() != swift::MetadataKind::Tuple) { + if (index != 0) { + OAG::precondition_failure("index out of range: %d", index); + } + return 0; + } + auto tuple_metadata = reinterpret_cast(metadata); + if (tuple_metadata->NumElements <= index) { + OAG::precondition_failure("index out of range: %d", index); + } + auto element = tuple_metadata->getElement(unsigned(index)); + return element.Offset; + #else + return 0; + #endif +} + +size_t OAGTupleElementOffsetChecked(OAGTupleType tuple_type, size_t index, OAGTypeID check_type) { + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + auto metadata = reinterpret_cast(tuple_type); + if (metadata->getKind() != swift::MetadataKind::Tuple) { + if (index != 0) { + OAG::precondition_failure("index out of range: %d", index); + } + if (reinterpret_cast(metadata) != check_type) { + OAG::precondition_failure("element type mismatch"); + } + return 0; + } + auto tuple_metadata = reinterpret_cast(metadata); + if (tuple_metadata->NumElements <= index) { + OAG::precondition_failure("index out of range: %d", index); + } + auto element = tuple_metadata->getElement(unsigned(index)); + if (reinterpret_cast(element.Type) != check_type) { + OAG::precondition_failure("element type mismatch"); + } + return element.Offset; + #else + return 0; + #endif +} + +#ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED +void *update(void* dst_ptr, const void *src_ptr, const OAG::swift::metadata * metadata, OAGTupleCopyOptions options) { + auto dst = reinterpret_cast(dst_ptr); + auto src = reinterpret_cast(const_cast(src_ptr)); + switch (options) { + case OAGTupleCopyOptionsAssignCopy: + return metadata->vw_assignWithCopy(dst, src); + case OAGTupleCopyOptionsInitCopy: + return metadata->vw_initializeWithCopy(dst, src); + case OAGTupleCopyOptionsAssignTake: + return metadata->vw_assignWithTake(dst, src); + case OAGTupleCopyOptionsInitTake: + return metadata->vw_initializeWithTake(dst, src); + default: + OAG::precondition_failure("unknown copy options: %d", options); + } +} +#endif + +void *OAGTupleSetElement(OAGTupleType tuple_type, void* tuple_value, size_t index, const void *element_value, OAGTypeID check_type, OAGTupleCopyOptions options) { + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + auto metadata = reinterpret_cast(tuple_type); + if (metadata->getKind() != swift::MetadataKind::Tuple) { + if (index != 0) { + OAG::precondition_failure("index out of range: %d", index); + } + if (reinterpret_cast(metadata) != check_type) { + OAG::precondition_failure("element type mismatch"); + } + return update(tuple_value, element_value, metadata, options); + } + auto tuple_metadata = reinterpret_cast(metadata); + if (tuple_metadata->NumElements <= index) { + OAG::precondition_failure("index out of range: %d", index); + } + auto element = tuple_metadata->getElement(unsigned(index)); + if (reinterpret_cast(element.Type) != check_type) { + OAG::precondition_failure("element type mismatch"); + } + return update((void *)(element.findIn(reinterpret_cast(tuple_value))), element_value, reinterpret_cast(element.Type), options); + #else + return nullptr; + #endif +} + +void *OAGTupleGetElement(OAGTupleType tuple_type, void* tuple_value, size_t index, void *element_value, OAGTypeID check_type, OAGTupleCopyOptions options) { + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + auto metadata = reinterpret_cast(tuple_type); + if (metadata->getKind() != swift::MetadataKind::Tuple) { + if (index != 0) { + OAG::precondition_failure("index out of range: %d", index); + } + if (reinterpret_cast(metadata) != check_type) { + OAG::precondition_failure("element type mismatch"); + } + return update(element_value, tuple_value, metadata, options); + } + auto tuple_metadata = reinterpret_cast(metadata); + if (tuple_metadata->NumElements <= index) { + OAG::precondition_failure("index out of range: %d", index); + } + auto element = tuple_metadata->getElement(unsigned(index)); + if (reinterpret_cast(element.Type) != check_type) { + OAG::precondition_failure("element type mismatch"); + } + return update(element_value, (const void *)(element.findIn(reinterpret_cast(tuple_value))), reinterpret_cast(element.Type), options); + #else + return nullptr; + #endif +} + +void OAGTupleDestroy(OAGTupleType tuple_type, void *value) { + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + auto metadata = reinterpret_cast(tuple_type); + metadata->vw_destroy(reinterpret_cast(value)); + #endif +} + +void OAGTupleDestroyElement(OAGTupleType tuple_type, void *value, size_t index) { + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + auto metadata = reinterpret_cast(tuple_type); + if (metadata->getKind() != swift::MetadataKind::Tuple) { + if (index != 0) { + OAG::precondition_failure("index out of range: %d", index); + } + metadata->vw_destroy(reinterpret_cast(value)); + } + auto tuple_metadata = reinterpret_cast(metadata); + if (tuple_metadata->NumElements <= index) { + OAG::precondition_failure("index out of range: %d", index); + } + auto element = tuple_metadata->getElement(unsigned(index)); + auto element_type = element.Type; + element_type->vw_destroy(reinterpret_cast((intptr_t)value + index)); + #endif +} + +void OAGTupleWithBuffer(OAGTupleType tuple_type, size_t count, const void (* function)(const OAGUnsafeMutableTuple mutableTuple, const void * context OAG_SWIFT_CONTEXT) OAG_SWIFT_CC(swift), const void *context) { + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + auto metadata = reinterpret_cast(tuple_type); + auto buffer_size = metadata->vw_stride() * count; + OAGUnsafeMutableTuple tuple; + tuple.type = tuple_type; + if (buffer_size <= 0x1000) { + char buffer[buffer_size]; + bzero(buffer, buffer_size); + tuple.value = buffer; + // NOTE: If you use buffer out of the scope, the stack may be malformed. + // So we need to call function in this scope. + function(tuple, context); + } else { + void *buffer = malloc_type_malloc(buffer_size, 0x100004077774924); + if (buffer == nullptr) { + OAG::precondition_failure("memory allocation failure"); + } + tuple.value = buffer; + function(tuple, context); + free(buffer); + } + #endif +} diff --git a/Sources/OpenAttributeGraphCxx/Runtime/OAGTypeID.cpp b/Sources/OpenAttributeGraphCxx/Runtime/OAGTypeID.cpp new file mode 100644 index 00000000..e48fa72a --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/Runtime/OAGTypeID.cpp @@ -0,0 +1,161 @@ +// +// OAGTypeID.cpp +// OpenAttributeGraphCxx +// +// Audited for iOS 18.0 +// Status: WIP + +#include +#include +#include + +#ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED +#include +#endif + +OAGTypeKind OAGTypeGetKind(OAGTypeID typeID) { + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + auto metadata = reinterpret_cast(typeID); + switch (metadata->getKind()) { + case swift::MetadataKind::Class: // 0x0 + return OAGTypeKindClass; + case swift::MetadataKind::Struct: // 0x200 + return OAGTypeKindStruct; + case swift::MetadataKind::Enum: // 0x201 + return OAGTypeKindEnum; + case swift::MetadataKind::Optional: // 0x202 + return OAGTypeKindOptional; + case swift::MetadataKind::Tuple: // 0x301 + return OAGTypeKindTuple; + case swift::MetadataKind::Function: // 0x302 + return OAGTypeKindFunction; + case swift::MetadataKind::Existential: // 0x303 + return OAGTypeKindExistential; + case swift::MetadataKind::Metatype: // 0x304 + return OAGTypeKindMetatype; + default: + return OAGTypeKindNone; + } + #else + return OAGTypeKindNone; + #endif +} + +void OAGTypeApplyFields(const void *type, const void *block, void *context) { + // TODO + return; +} + +bool OAGTypeApplyFields2(const void *type, OAGTypeApplyOptions options, const void *block, void *context) { + // TODO + return false; +} + +#if OPENATTRIBUTEGRAPH_RELEASE >= OPENATTRIBUTEGRAPH_RELEASE_2024 + +uint32_t OAGTypeGetEnumTag(OAGTypeID typeID, const void *value) { + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + auto metadata = reinterpret_cast(typeID); + auto vwt = metadata->getValueWitnesses(); + if (!swift::EnumValueWitnessTable::classof(vwt)) { + OAG::precondition_failure("not an enum type: %s", metadata->name(false).data); + } + auto enum_vwt = static_cast(vwt); + return enum_vwt->getEnumTag(static_cast(value), metadata); + #else + return 0; + #endif +} + +void OAGTypeProjectEnumData(OAGTypeID typeID, void *value) { + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + auto metadata = reinterpret_cast(typeID); + auto vwt = metadata->getValueWitnesses(); + if (!swift::EnumValueWitnessTable::classof(vwt)) { + OAG::precondition_failure("not an enum type: %s", metadata->name(false).data); + } + auto enum_vwt = static_cast(vwt); + enum_vwt->destructiveProjectEnumData(static_cast(value), metadata); + #else + return; + #endif +} + +void OAGTypeInjectEnumTag(OAGTypeID typeID, uint32_t tag, void *value) { + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + auto metadata = reinterpret_cast(typeID); + auto vwt = metadata->getValueWitnesses(); + if (!swift::EnumValueWitnessTable::classof(vwt)) { + OAG::precondition_failure("not an enum type: %s", metadata->name(false).data); + } + auto enum_vwt = static_cast(vwt); + return enum_vwt->destructiveInjectEnumTag(static_cast(value), tag, metadata); + #else + return; + #endif +} + +#endif /* OPENATTRIBUTEGRAPH_RELEASE */ + +bool OAGTypeApplyEnumData() { + // TODO + return false; +} + +bool OAGTypeApplyMutableEnumData() { + // TODO + return false; +} + +CFStringRef OAGTypeDescription(OAGTypeID typeID) { + CFMutableStringRef ref = CFStringCreateMutable(CFAllocatorGetDefault(), 0); + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + auto metadata = reinterpret_cast(typeID); + metadata->append_description(ref); + #endif + return ref; +} + +#if OPENATTRIBUTEGRAPH_RELEASE >= OPENATTRIBUTEGRAPH_RELEASE_2024 + +OAGTypeSignature const OAGTypeGetSignature(OAGTypeID typeID) { + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + auto metadata = reinterpret_cast(typeID); + // TODO + return OAGTypeSignature{}; + #else + return OAGTypeSignature{}; + #endif +} +void const* OAGTypeGetDescriptor(OAGTypeID typeID) { + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + auto metadata = reinterpret_cast(typeID); + return metadata->descriptor(); + #else + return nullptr; + #endif +} + +#endif /* OPENATTRIBUTEGRAPH_RELEASE */ + +void const* OAGTypeNominalDescriptor(OAGTypeID typeID) { + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + auto metadata = reinterpret_cast(typeID); + return metadata->nominal_descriptor(); + #else + return nullptr; + #endif +} + +char const* OAGTypeNominalDescriptorName(OAGTypeID typeID) { + #ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + auto metadata = reinterpret_cast(typeID); + auto nominal_descriptor = metadata->nominal_descriptor(); + if (nominal_descriptor == nullptr) { + return nullptr; + } + return nominal_descriptor->Name.get(); + #else + return nullptr; + #endif +} diff --git a/Sources/OpenAttributeGraphCxx/Runtime/metadata.cpp b/Sources/OpenAttributeGraphCxx/Runtime/metadata.cpp new file mode 100644 index 00000000..aaae688f --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/Runtime/metadata.cpp @@ -0,0 +1,18 @@ +// +// metadata.cpp +// OpenAttributeGraphCxx +// +// Audited for iOS 18.0 +// Status: WIP + +#include + +#ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED + +using OAG::swift::metadata; + +void metadata::append_description(CFMutableStringRef description) const OAG_NOEXCEPT { + // TODO +} + +#endif /* OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED */ diff --git a/Sources/OpenGraphCxx/Vector/realloc_vector.cpp b/Sources/OpenAttributeGraphCxx/Vector/realloc_vector.cpp similarity index 72% rename from Sources/OpenGraphCxx/Vector/realloc_vector.cpp rename to Sources/OpenAttributeGraphCxx/Vector/realloc_vector.cpp index e5ddcd88..77be5d80 100644 --- a/Sources/OpenGraphCxx/Vector/realloc_vector.cpp +++ b/Sources/OpenAttributeGraphCxx/Vector/realloc_vector.cpp @@ -1,18 +1,18 @@ // // realloc_vector.cpp -// OpenGraphCxx +// OpenAttributeGraphCxx -#include -#include +#include +#include -#if OG_TARGET_OS_DARWIN +#if OAG_TARGET_OS_DARWIN #include #else #include -#endif /* OG_TARGET_OS_DARWIN */ +#endif /* OAG_TARGET_OS_DARWIN */ template -void *_Nullable OG::details::realloc_vector(void* ptr, T& size, T new_size) { +void *_Nullable OAG::details::realloc_vector(void* ptr, T& size, T new_size) { if (new_size == 0) { size = 0; free(ptr); @@ -24,7 +24,7 @@ void *_Nullable OG::details::realloc_vector(void* ptr, T& size, T new_size) { } else { void *new_ptr = realloc(ptr, msize); if (new_ptr == nullptr) { - OG::precondition_failure("memory allocation failed"); + OAG::precondition_failure("memory allocation failed"); } else { size = msize / Alignment; return new_ptr; @@ -34,7 +34,7 @@ void *_Nullable OG::details::realloc_vector(void* ptr, T& size, T new_size) { } template -void *_Nullable OG::details::realloc_vector(void* src, void* dst, T dstSize, T& size, T newSize) { +void *_Nullable OAG::details::realloc_vector(void* src, void* dst, T dstSize, T& size, T newSize) { if (newSize < dstSize) { if (src == dst) { return src; @@ -52,7 +52,7 @@ void *_Nullable OG::details::realloc_vector(void* src, void* dst, T dstSize, T& if (src == dst) { void *new_ptr = malloc(msize); if (new_ptr == nullptr) { - OG::precondition_failure("memory allocation failed"); + OAG::precondition_failure("memory allocation failed"); } else { memcpy(new_ptr, src, size * Alignment); size = msize / Alignment; @@ -61,7 +61,7 @@ void *_Nullable OG::details::realloc_vector(void* src, void* dst, T dstSize, T& } else { void *new_ptr = realloc(src, msize); if (new_ptr == nullptr) { - OG::precondition_failure("memory allocation failed"); + OAG::precondition_failure("memory allocation failed"); } else { size = msize / Alignment; return new_ptr; diff --git a/Sources/OpenAttributeGraphCxx/Version/OAGVersion.c b/Sources/OpenAttributeGraphCxx/Version/OAGVersion.c new file mode 100644 index 00000000..2d96fb02 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/Version/OAGVersion.c @@ -0,0 +1,16 @@ +// +// OAGVersion.c +// OpenAttributeGraph + +#include +#include + +#if OPENATTRIBUTEGRAPH_RELEASE == OPENATTRIBUTEGRAPH_RELEASE_2024 +const double OpenAttributeGraphVersionNumber __attribute__ ((used)) = (double)6.0; +const unsigned char OpenAttributeGraphVersionString[] __attribute__ ((used)) = "@(#)PROAGRAM:OpenAttributeGraph PROJECT:OpenAttributeGraph-6.0.87\n"; +const uint64_t OAGVersion = 0x2001e; +#elif OPENATTRIBUTEGRAPH_RELEASE == OPENATTRIBUTEGRAPH_RELEASE_2021 +const double OpenAttributeGraphVersionNumber __attribute__ ((used)) = (double)3.2; +const unsigned char OpenAttributeGraphVersionString[] __attribute__ ((used)) = "@(#)PROAGRAM:OpenAttributeGraph PROJECT:OpenAttributeGraph-3.2.1\n"; +const uint64_t OAGVersion = 0x20014; +#endif diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGAttribute.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGAttribute.h new file mode 100644 index 00000000..1e9786c7 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGAttribute.h @@ -0,0 +1,163 @@ +// +// OAGAttribute.h +// OpenAttributeGraphCxx + +#ifndef OAGAttribute_h +#define OAGAttribute_h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +OAG_ASSUME_NONNULL_BEGIN + +OAG_EXTERN_C_BEGIN + +OAG_EXPORT +const OAGAttribute OAGAttributeNil; + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGAttribute OAGGraphGetCurrentAttribute(void); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGAttribute OAGGraphCreateOffsetAttribute(OAGAttribute attribute, long offset) OAG_SWIFT_NAME(OAGAttribute.create(self:offset:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGAttribute OAGGraphCreateOffsetAttribute2(OAGAttribute attribute, long offset, uint64_t size) OAG_SWIFT_NAME(OAGAttribute.create(self:offset:size:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGAttribute OAGGraphCreateIndirectAttribute(OAGAttribute attribute) OAG_SWIFT_NAME(OAGAttribute.createIndirect(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGAttribute OAGGraphCreateIndirectAttribute2(OAGAttribute attribute, uint64_t size) OAG_SWIFT_NAME(OAGAttribute.createIndirect(self:size:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGAttributeFlags OAGGraphGetFlags(OAGAttribute attribute) OAG_SWIFT_NAME(getter:OAGAttribute.flags(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphSetFlags(OAGAttribute attribute, OAGAttributeFlags flags) OAG_SWIFT_NAME(setter:OAGAttribute.flags(self:_:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphAddInput(OAGAttribute attribute1, OAGAttribute attribute2, OAGInputOptions options, long token); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +const OAGAttributeInfo OAGGraphGetAttributeInfo(OAGAttribute attribute) OAG_SWIFT_NAME(getter:OAGAttribute.info(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphMutateAttribute(OAGAttribute attribute, + const OAGTypeID type, + bool invalidating, + const void (*function)(const void * _Nullable context OAG_SWIFT_CONTEXT, void *body) OAG_SWIFT_CC(swift), + const void * _Nullable context); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGAttribute OAGGraphGetIndirectDependency(OAGAttribute attribute) OAG_SWIFT_NAME(getter:OAGAttribute._indirectDependency(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphSetIndirectDependency(OAGAttribute attribute1, OAGAttribute attribute2) OAG_SWIFT_NAME(setter:OAGAttribute._indirectDependency(self:_:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGAttribute OAGGraphGetIndirectAttribute(OAGAttribute attribute) OAG_SWIFT_NAME(getter:OAGAttribute.source(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphSetIndirectAttribute(OAGAttribute attribute1, OAGAttribute attribute2) OAG_SWIFT_NAME(setter:OAGAttribute.source(self:_:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGAttribute OAGGraphCreateAttribute(long index, const void *body, const void * _Nullable value); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +const OAGValue OAGGraphGetValue(OAGAttribute attribute, OAGValueOptions options, const OAGTypeID type); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +bool OAGGraphSetValue(OAGAttribute attribute, const void *value, const OAGTypeID type); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +const OAGValue OAGGraphGetInputValue(OAGAttribute attribute, OAGAttribute inputAttribute, OAGValueOptions options, const OAGTypeID type); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +const void * _Nullable OAGGraphGetOutputValue(OAGTypeID type); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphSetOutputValue(const void *value, const OAGTypeID type); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGValueState OAGGraphGetValueState(OAGAttribute attribute) OAG_SWIFT_NAME(getter:OAGAttribute.valueState(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +bool OAGGraphHasValue(OAGAttribute attribute) OAG_SWIFT_NAME(getter:OAGAttribute.hasValue(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphUpdateValue(OAGAttribute attribute) OAG_SWIFT_NAME(OAGAttribute.updateValue(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphPrefetchValue(OAGAttribute attribute) OAG_SWIFT_NAME(OAGAttribute.prefetchValue(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphInvalidateValue(OAGAttribute attribute) OAG_SWIFT_NAME(OAGAttribute.invalidateValue(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphVerifyType(OAGAttribute attribute, OAGTypeID type) OAG_SWIFT_NAME(OAGAttribute.verify(self:type:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGGraphRef OAGGraphGetAttributeGraph(OAGAttribute attribute) OAG_SWIFT_NAME(getter:OAGAttribute.graph(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGSubgraphRef OAGGraphGetAttributeSubgraph(OAGAttribute attribute) OAG_SWIFT_NAME(getter:OAGAttribute.subgraph(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +const void * OAGGraphReadCachedAttribute(long hashValue, OAGTypeID bodyType, const void *bodyPointer, OAGTypeID valueType, OAGCachedValueOptions options, OAGAttribute attribute, bool unknown/*, ...*/); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +const void * _Nullable OAGGraphReadCachedAttributeIfExists(long hashValue, OAGTypeID bodyType, const void *bodyPointer, OAGTypeID valueType, OAGCachedValueOptions options, OAGAttribute attribute, bool unknown); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphWithUpdate( + OAGAttribute attribute, + void (* callback)(const void *context OAG_SWIFT_CONTEXT) OAG_SWIFT_CC(swift), + const void *context +); + +OAG_EXTERN_C_END + +OAG_ASSUME_NONNULL_END + +#endif /* OAGAttribute_h */ + diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGAttributeFlags.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGAttributeFlags.h new file mode 100644 index 00000000..be9b21c7 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGAttributeFlags.h @@ -0,0 +1,19 @@ +// +// OAGAttributeFlags.h +// OpenAttributeGraphCxx +// +// Audited for RELEASE_2021 +// Status: Complete + +#ifndef OAGAttributeFlags_h +#define OAGAttributeFlags_h + +#include +#include + +typedef OAG_OPTIONS(uint8_t, OAGAttributeFlags) { + OAGAttributeFlagsNone = 0, + OAGAttributeFlagsAll = 0xFF, +} OAG_SWIFT_NAME(OAGAttribute.Flags); + +#endif /* OAGAttributeFlags_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGAttributeInfo.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGAttributeInfo.h new file mode 100644 index 00000000..b9015555 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGAttributeInfo.h @@ -0,0 +1,20 @@ +// +// OAGAttributeInfo.h +// OpenAttributeGraphCxx + +#ifndef OAGAttributeInfo_h +#define OAGAttributeInfo_h + +#include +#include + +OAG_ASSUME_NONNULL_BEGIN + +typedef struct OAGAttributeInfo { + const OAGAttributeType* type; + const void *body; +} OAGAttributeInfo; + +OAG_ASSUME_NONNULL_END + +#endif /* OAGAttributeInfo_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGAttributeType.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGAttributeType.h new file mode 100644 index 00000000..ccac3a24 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGAttributeType.h @@ -0,0 +1,44 @@ +// +// OAGAttributeType.h +// OpenAttributeGraphCxx + +#ifndef OAGAttributeType_h +#define OAGAttributeType_h + +#include +#include +#include +#include + +OAG_ASSUME_NONNULL_BEGIN + +typedef struct OAGAttributeType OAGAttributeType; + +typedef struct OAG_SWIFT_NAME(_AttributeVTable) OAGAttributeVTable { + unsigned long version; + void (*_Nullable type_destroy)(OAGAttributeType *); + void (*_Nullable self_destroy)(const OAGAttributeType *, void *); + CFStringRef _Nullable (*_Nullable self_description)(const OAGAttributeType *, const void *); + CFStringRef _Nullable (*_Nullable value_description)(const OAGAttributeType *, const void *); + void (*_Nullable update_default)(const OAGAttributeType *, void *); +} OAGAttributeVTable; + +typedef struct OAG_SWIFT_NAME(_AttributeType) OAGAttributeType { + OAGTypeID self_id; + OAGTypeID value_id; + OAGClosureStorage update; + const OAGAttributeVTable *vtable; + OAGAttributeTypeFlags flags; + + uint32_t internal_offset; + const unsigned char *_Nullable value_layout; + + struct { + OAGTypeID type_id; + const void *witness_table; + } body_conformance; +} OAGAttributeType; + +OAG_ASSUME_NONNULL_END + +#endif /* OAGAttributeType_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGAttributeTypeFlags.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGAttributeTypeFlags.h new file mode 100644 index 00000000..9fe519b7 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGAttributeTypeFlags.h @@ -0,0 +1,24 @@ +// +// OAGAttributeTypeFlags.h +// OpenAttributeGraphCxx + +#ifndef OAGAttributeTypeFlags_h +#define OAGAttributeTypeFlags_h + +#include + +typedef OAG_OPTIONS(uint32_t, OAGAttributeTypeFlags) { + OAGAttributeTypeFlagsComparisonModeBitwise = 0, + OAGAttributeTypeFlagsComparisonModeIndirect = 1, + OAGAttributeTypeFlagsComparisonModeEquatableUnlessPOD = 2, + OAGAttributeTypeFlagsComparisonModeEquatableAlways = 3, + OAGAttributeTypeFlagsComparisonModeMask = 0x03, + + OAGAttributeTypeFlagsHasDestroySelf = 1 << 2, + OAGAttributeTypeFlagsMainThread = 1 << 3, + OAGAttributeTypeFlagsExternal = 1 << 4, + OAGAttributeTypeFlagsAsyncThread = 1 << 5, +} OAG_SWIFT_NAME(OAGAttributeType.Flags); + +#endif /* OAGAttributeTypeFlags_h */ + diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGBase.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGBase.h new file mode 100644 index 00000000..5795f762 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGBase.h @@ -0,0 +1,84 @@ +// +// OAGBase.h +// OpenAttributeGraphCxx + +#ifndef OAGBase_h +#define OAGBase_h + +#if DEBUG +#define OAG_ASSERTION +#else +#undef OAG_ASSERTION +#endif + +#if __has_attribute(cold) +#define __cold __attribute__((__cold__)) +#else +#define __cold +#endif + +#if __has_attribute(noreturn) +#define __dead2 __attribute__((__noreturn__)) +#else +#define __dead2 +#endif + +#if defined(__cplusplus) +#define OAG_NOEXCEPT noexcept +#else +#define OAG_NOEXCEPT +#endif + +#if defined(__GNUC__) +#define OAG_INLINE __inline__ __attribute__((always_inline)) +#elif defined(__cplusplus) +#define OAG_INLINE inline +#else +#define OAG_INLINE +#endif + +#if defined(__cplusplus) +#define OAG_CONSTEXPR constexpr +#else +#define OAG_CONSTEXPR +#endif + +#if __has_include() // Fix conflict define issue of the SDK +#include +#define OAG_COUNTED_BY(N) __counted_by(N) +#else +#if !defined(__counted_by) +#if __has_attribute(__counted_by__) +#define __counted_by(N) __attribute__((__counted_by__(N))) +#else +#define __counted_by(N) +#endif +#endif +#define OAG_COUNTED_BY(N) __counted_by(N) +#endif + +#include "OAGSwiftSupport.h" +#include "OAGTargetConditionals.h" +#include +#include +#include + +#define OAG_ENUM CF_ENUM +#define OAG_CLOSED_ENUM CF_CLOSED_ENUM +#define OAG_OPTIONS CF_OPTIONS +#define OAG_EXTERN_C_BEGIN CF_EXTERN_C_BEGIN +#define OAG_EXTERN_C_END CF_EXTERN_C_END +#define OAG_ASSUME_NONNULL_BEGIN CF_ASSUME_NONNULL_BEGIN +#define OAG_ASSUME_NONNULL_END CF_ASSUME_NONNULL_END +#define OAG_IMPLICIT_BRIDGING_ENABLED CF_IMPLICIT_BRIDGING_ENABLED +#define OAG_IMPLICIT_BRIDGING_DISABLED CF_IMPLICIT_BRIDGING_DISABLED +#define OAG_EXPORT CF_EXPORT +#define OAG_BRIDGED_TYPE CF_BRIDGED_TYPE + +#if OAG_TARGET_OS_DARWIN && __OBJC__ +#define OAG_OBJC_FOUNDATION 1 +#else +#define OAG_OBJC_FOUNDATION 0 +#endif /* OAG_TARGET_OS_DARWIN && __OBJC__ */ + +#endif /* OAGBase_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGCachedValueOptions.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGCachedValueOptions.h new file mode 100644 index 00000000..1a9cdeb1 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGCachedValueOptions.h @@ -0,0 +1,20 @@ +// +// OAGCachedValueOptions.h +// OpenAttributeGraphCxx + +#ifndef OAGCachedValueOptions_h +#define OAGCachedValueOptions_h + +#include + +typedef OAG_OPTIONS(uint32_t, OAGCachedValueOptions) { + OAGCachedValueOptions_0 = 0, + OAGCachedValueOptions_1 = 1 << 0, + OAGCachedValueOptions_2 = 1 << 1, + OAGCachedValueOptions_4 = 1 << 2, + OAGCachedValueOptions_8 = 1 << 3, + OAGCachedValueOptions_16 = 1 << 4, +}; + +#endif /* OAGCachedValueOptions_h */ + diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGChangedValueFlags.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGChangedValueFlags.h new file mode 100644 index 00000000..03945b74 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGChangedValueFlags.h @@ -0,0 +1,15 @@ +// +// OAGChangedValueFlags.h +// OpenAttributeGraphCxx + +#ifndef OAGChangedValueFlags_h +#define OAGChangedValueFlags_h + +#include + +typedef OAG_OPTIONS(uint32_t, OAGChangedValueFlags) { + OAGChangedValueFlagsChanged = 1 << 0, + OAGChangedValueFlagsRequiresMainThread = 1 << 1, +}; + +#endif /* OAGChangedValueFlags_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGClosure.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGClosure.h new file mode 100644 index 00000000..2bb9070d --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGClosure.h @@ -0,0 +1,32 @@ +// +// OAGClosure.h +// OpenAttributeGraphCxx + +#ifndef OAGClosure_h +#define OAGClosure_h + +#include + +OAG_ASSUME_NONNULL_BEGIN + +OAG_EXTERN_C_BEGIN + +typedef struct OAGClosureStorage { + const void *thunk; + const void *_Nullable context; +} OAGClosureStorage OAG_SWIFT_NAME(_OAGClosureStorage); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGClosureStorage OAGRetainClosure(void (*thunk)(void *_Nullable context OAG_SWIFT_CONTEXT) OAG_SWIFT_CC(swift), + void *_Nullable context); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGReleaseClosure(OAGClosureStorage closure); + +OAG_EXTERN_C_END + +OAG_ASSUME_NONNULL_END + +#endif /* OAGClosure_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGComparison.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGComparison.h new file mode 100644 index 00000000..d8a9f455 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGComparison.h @@ -0,0 +1,85 @@ +// +// OAGComparison.h +// OpenAttributeGraphCxx +// +// Audited for 6.5.1 +// Status: Complete + +#ifndef OAGComparison_h +#define OAGComparison_h + +#include +#include + +OAG_ASSUME_NONNULL_BEGIN + +OAG_IMPLICIT_BRIDGING_ENABLED + +OAG_EXTERN_C_BEGIN + +typedef struct OAG_SWIFT_NAME(FieldRange) OAGFieldRange { + size_t offset; + size_t size; +} OAGFieldRange; + +typedef const void *OAGComparisonState OAG_SWIFT_STRUCT OAG_SWIFT_NAME(ComparisonState); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +const void *OAGComparisonStateGetDestination(OAGComparisonState state) OAG_SWIFT_NAME(getter:OAGComparisonState.destination(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +const void *OAGComparisonStateGetSource(OAGComparisonState state) OAG_SWIFT_NAME(getter:OAGComparisonState.source(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGFieldRange OAGComparisonStateGetFieldRange(OAGComparisonState state) OAG_SWIFT_NAME(getter:OAGComparisonState.fieldRange(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGTypeID OAGComparisonStateGetFieldType(OAGComparisonState state) OAG_SWIFT_NAME(getter:OAGComparisonState.fieldType(self:)); + +typedef OAG_ENUM(uint8_t, OAGComparisonMode) { + OAGComparisonModeBitwise = 0, + OAGComparisonModeIndirect = 1, + OAGComparisonModeEquatableUnlessPOD = 2, + OAGComparisonModeEquatableAlways = 3, +} OAG_SWIFT_NAME(ComparisonMode); + +typedef OAG_OPTIONS(uint32_t, OAGComparisonOptions) { + OAGComparisonOptionsComparisonModeBitwise = 0, + OAGComparisonOptionsComparisonModeIndirect = 1, + OAGComparisonOptionsComparisonModeEquatableUnlessPOD = 2, + OAGComparisonOptionsComparisonModeEquatableAlways = 3, + OAGComparisonOptionsComparisonModeMask = 0xff, + + OAGComparisonOptionsCopyOnWrite = 1 << 8, + OAGComparisonOptionsFetchLayoutsSynchronously = 1 << 9, + OAGComparisonOptionsTraceCompareFailed = 1ul << 31, // -1 signed int +} OAG_SWIFT_NAME(ComparisonOptions); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +bool OAGCompareValues(const void *lhs, + const void *rhs, + OAGTypeID type_id, + OAGComparisonOptions options); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +const unsigned char *_Nullable OAGPrefetchCompareValues(OAGTypeID type_id, + OAGComparisonOptions options, + uint32_t priority); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGOverrideComparisonForTypeDescriptor(void *descriptor, OAGComparisonMode mode); + +OAG_EXTERN_C_END + +OAG_IMPLICIT_BRIDGING_DISABLED + +OAG_ASSUME_NONNULL_END + +#endif /* OAGComparison_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGDebugServer.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGDebugServer.h similarity index 62% rename from Sources/OpenGraphCxx/include/OpenGraph/OGDebugServer.h rename to Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGDebugServer.h index 7d9945f8..2cc51edc 100644 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGDebugServer.h +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGDebugServer.h @@ -1,90 +1,90 @@ // -// OGDebugServer.h -// OpenGraphCxx +// OAGDebugServer.h +// OpenAttributeGraphCxx // // Audited for 6.5.1 // Status: Complete -#ifndef OGDebugServer_h -#define OGDebugServer_h +#ifndef OAGDebugServer_h +#define OAGDebugServer_h -#include +#include -#if OG_TARGET_OS_DARWIN +#if OAG_TARGET_OS_DARWIN /** - * @header OGDebugServer.h - * @abstract OpenGraph Debug Server API for runtime debugging and inspection. - * @discussion The debug server provides runtime debugging capabilities for OpenGraph applications, + * @header OAGDebugServer.h + * @abstract OpenAttributeGraph Debug Server API for runtime debugging and inspection. + * @discussion The debug server provides runtime debugging capabilities for OpenAttributeGraph applications, * allowing external tools to connect and inspect graph state, dependencies, and execution. * This API is only available on Darwin platforms and requires network interface access * when used in network mode. */ -OG_ASSUME_NONNULL_BEGIN +OAG_ASSUME_NONNULL_BEGIN -OG_IMPLICIT_BRIDGING_ENABLED +OAG_IMPLICIT_BRIDGING_ENABLED /** - * @typedef OGDebugServerRef + * @typedef OAGDebugServerRef * @abstract An opaque reference to a debug server instance. * @discussion The debug server manages a connection endpoint that external debugging tools - * can use to inspect OpenGraph runtime state. Only one debug server instance + * can use to inspect OpenAttributeGraph runtime state. Only one debug server instance * can be active at a time. */ -typedef struct OGDebugServerStorage *OGDebugServerRef OG_SWIFT_STRUCT OG_SWIFT_NAME(DebugServer); +typedef struct OAGDebugServerStorage *OAGDebugServerRef OAG_SWIFT_STRUCT OAG_SWIFT_NAME(DebugServer); /** - * @typedef OGDebugServerMode + * @typedef OAGDebugServerMode * @abstract Configuration modes for the debug server. * @discussion These flags control how the debug server operates and what interfaces it exposes. * Multiple modes can be combined using bitwise OR operations. */ -typedef OG_OPTIONS(uint32_t, OGDebugServerMode) { +typedef OAG_OPTIONS(uint32_t, OAGDebugServerMode) { /** * @abstract No debug server functionality. * @discussion Use this mode to disable all debug server operations. */ - OGDebugServerModeNone = 0, + OAGDebugServerModeNone = 0, /** * @abstract Enable basic debug server validation and setup. * @discussion This mode enables the debug server with minimal functionality and is required * for any debug server operation. All other modes must be combined with this flag. */ - OGDebugServerModeValid = 1 << 0, + OAGDebugServerModeValid = 1 << 0, /** * @abstract Enable network interface for remote debugging. * @discussion When enabled, the debug server will listen on a network interface, allowing - * remote debugging tools to connect. Requires OGDebugServerModeValid to be set. + * remote debugging tools to connect. Requires OAGDebugServerModeValid to be set. */ - OGDebugServerModeNetworkInterface = 1 << 1, -} OG_SWIFT_NAME(OGDebugServerRef.Mode); + OAGDebugServerModeNetworkInterface = 1 << 1, +} OAG_SWIFT_NAME(OAGDebugServerRef.Mode); // MARK: - Exported C functions -OG_EXTERN_C_BEGIN +OAG_EXTERN_C_BEGIN /** - * @function OGDebugServerStart + * @function OAGDebugServerStart * @abstract Starts the shared debug server with the specified mode. * @discussion Creates and starts a new shared debug server instance. If a server is already * running, this function will return the existing instance. * - * The returned reference should not be manually managed. Use OGDebugServerStop() + * The returned reference should not be manually managed. Use OAGDebugServerStop() * to properly shut down the shared server. * @param mode Configuration flags controlling server behavior. - * Must include OGDebugServerModeValid for basic operation. + * Must include OAGDebugServerModeValid for basic operation. * @result A reference to the started shared debug server, or NULL if the server * could not be started (e.g., due to network permissions, conflicts, or existing server). */ -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGDebugServerRef _Nullable OGDebugServerStart(OGDebugServerMode mode) OG_SWIFT_NAME(OGDebugServerRef.start(mode:)); +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGDebugServerRef _Nullable OAGDebugServerStart(OAGDebugServerMode mode) OAG_SWIFT_NAME(OAGDebugServerRef.start(mode:)); /** - * @function OGDebugServerStop + * @function OAGDebugServerStop * @abstract Stops and deletes the running shared debug server. * @discussion Shuts down the active shared debug server instance and cleans up all associated * resources. If no shared debug server is currently running, this function has no effect. @@ -92,12 +92,12 @@ OGDebugServerRef _Nullable OGDebugServerStart(OGDebugServerMode mode) OG_SWIFT_N * This function should be called before application termination to ensure * proper cleanup of network resources and connections. */ -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGDebugServerStop(void) OG_SWIFT_NAME(OGDebugServerRef.stop()); +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGDebugServerStop(void) OAG_SWIFT_NAME(OAGDebugServerRef.stop()); /** - * @function OGDebugServerCopyURL + * @function OAGDebugServerCopyURL * @abstract Returns the URL for connecting to the shared debug server. * @discussion Returns the URL that external debugging tools should use to connect to * the currently running shared debug server. The URL format depends on the server @@ -109,24 +109,24 @@ void OGDebugServerStop(void) OG_SWIFT_NAME(OGDebugServerRef.stop()); * is currently running or if the server doesn't expose a connectable interface. * The caller is responsible for releasing the returned URL. */ -OG_EXPORT -OG_REFINED_FOR_SWIFT -CFURLRef _Nullable OGDebugServerCopyURL(void) OG_SWIFT_NAME(OGDebugServerRef.copyURL()); +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +CFURLRef _Nullable OAGDebugServerCopyURL(void) OAG_SWIFT_NAME(OAGDebugServerRef.copyURL()); /** - * @function OGDebugServerRun + * @function OAGDebugServerRun * @abstract Runs the shared debug server event loop. */ -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGDebugServerRun(int timeout) OG_SWIFT_NAME(OGDebugServerRef.run(timeout:)); +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGDebugServerRun(int timeout) OAG_SWIFT_NAME(OAGDebugServerRef.run(timeout:)); -OG_EXTERN_C_END +OAG_EXTERN_C_END -OG_IMPLICIT_BRIDGING_DISABLED +OAG_IMPLICIT_BRIDGING_DISABLED -OG_ASSUME_NONNULL_END +OAG_ASSUME_NONNULL_END #endif -#endif /* OGDebugServer_h */ +#endif /* OAGDebugServer_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGGraph.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGGraph.h new file mode 100644 index 00000000..bda9886e --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGGraph.h @@ -0,0 +1,123 @@ +// +// OAGGraph.h +// OpenAttributeGraphCxx + +#ifndef OAGGraph_h +#define OAGGraph_h + +#include +#include +#include + +// Note: Place all structure declaration in a single place to avoid header cycle dependency + +typedef struct OAG_BRIDGED_TYPE(id) OAGGraphStorage * OAGGraphRef OAG_SWIFT_NAME(Graph); +typedef struct OAG_BRIDGED_TYPE(id) OAGSubgraphStorage * OAGSubgraphRef OAG_SWIFT_NAME(Subgraph); +typedef struct OAG_BRIDGED_TYPE(id) OAGGraphContextStorage * OAGGraphContextRef OAG_SWIFT_NAME(GraphContext); + +struct OAGGraphStorage; +struct OAGGraphContextStorage; +struct OAGSubgraphStorage; + +typedef uint32_t OAGAttribute OAG_SWIFT_STRUCT OAG_SWIFT_NAME(AnyAttribute); + +OAG_ASSUME_NONNULL_BEGIN + +OAG_IMPLICIT_BRIDGING_ENABLED + +// MARK: - Exported C functions + +OAG_EXTERN_C_BEGIN + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGGraphRef OAGGraphCreate(void) OAG_SWIFT_NAME(OAGGraphRef.init()); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGGraphRef OAGGraphCreateShared(_Nullable OAGGraphRef graph) OAG_SWIFT_NAME(OAGGraphRef.init(shared:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +CFTypeID OAGGraphGetTypeID(void) OAG_SWIFT_NAME(getter:OAGGraphRef.typeID()); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphStartProfiling(_Nullable OAGGraphRef graph); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphStopProfiling(_Nullable OAGGraphRef graph); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphResetProfile(_Nullable OAGGraphRef graph); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +const void * _Nullable OAGGraphGetContext(OAGGraphRef graph) OAG_SWIFT_NAME(getter:OAGGraphRef.context(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphSetContext(OAGGraphRef graph, const void * _Nullable context) OAG_SWIFT_NAME(setter:OAGGraphRef.context(self:_:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGGraphContextRef OAGGraphGetGraphContext(OAGGraphRef graph) OAG_SWIFT_NAME(getter:OAGGraphRef.graphContext(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphInvalidate(OAGGraphRef graph) OAG_SWIFT_NAME(OAGGraphRef.invalidate(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphInvalidateAllValues(OAGGraphRef graph) OAG_SWIFT_NAME(OAGGraphRef.invalidateAllValues(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphSetInvalidationCallback(OAGGraphRef graph, + const void (*_Nullable function)(const void * _Nullable context OAG_SWIFT_CONTEXT, OAGAttribute) OAG_SWIFT_CC(swift), + const void * _Nullable context); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphSetUpdateCallback(OAGGraphRef graph, + const void (*_Nullable function)(const void * _Nullable context OAG_SWIFT_CONTEXT) OAG_SWIFT_CC(swift), + const void * _Nullable context); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +uint64_t OAGGraphGetCounter(OAGGraphRef graph, OAGGraphCounterQueryType query) OAG_SWIFT_NAME(OAGGraphRef.counter(self:for:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphSetUpdate(const void * _Nullable value) OAG_SWIFT_NAME(OAGGraphRef.setUpdate(_:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +const void * _Nullable OAGGraphClearUpdate(void) OAG_SWIFT_NAME(OAGGraphRef.clearUpdate()); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphSetNeedsUpdate(OAGGraphRef graph) OAG_SWIFT_NAME(OAGGraphRef.setNeedsUpdate(self:)); + +#if OAG_TARGET_OS_DARWIN +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +bool OAGGraphAnyInputsChanged(const OAGAttribute *excluded_inputs OAG_COUNTED_BY(count), size_t count); +#else +// __counted_by__ is supported with Swift 6.1+ toolchain's clang on Linux. +// But it required the count to be declared first which is not required on Apple clang. +// See https://github.com/OpenSwiftUIProject/OpenAttributeGraph/issues/130 +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +bool OAGGraphAnyInputsChanged(const OAGAttribute *excluded_inputs, size_t count); +#endif + +OAG_EXTERN_C_END + +OAG_IMPLICIT_BRIDGING_DISABLED + +OAG_ASSUME_NONNULL_END + +#endif /* OAGGraph_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGGraphContext.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGGraphContext.h new file mode 100644 index 00000000..150b7b41 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGGraphContext.h @@ -0,0 +1,29 @@ +// +// OAGGraphContext.h +// OpenAttributeGraphCxx + +#ifndef OAGGraphContext_h +#define OAGGraphContext_h + +#include +#include + +// MARK: - Exported C functions + +OAG_ASSUME_NONNULL_BEGIN + +OAG_IMPLICIT_BRIDGING_ENABLED + +OAG_EXTERN_C_BEGIN + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGGraphRef OAGGraphContextGetGraph(OAGGraphContextRef context) OAG_SWIFT_NAME(getter:OAGGraphContextRef.graph(self:)); + +OAG_EXTERN_C_END + +OAG_IMPLICIT_BRIDGING_DISABLED + +OAG_ASSUME_NONNULL_END + +#endif /* OAGGraphContext_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGGraphCounterQueryType.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGGraphCounterQueryType.h new file mode 100644 index 00000000..6dbd9427 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGGraphCounterQueryType.h @@ -0,0 +1,27 @@ +// +// OAGGraphCounterQueryType.h +// OpenAttributeGraphCxx + +#ifndef OAGGraphCounterQueryType_h +#define OAGGraphCounterQueryType_h + +#include + +typedef OAG_ENUM(uint32_t, OAGGraphCounterQueryType) { + OAGGraphCounterQueryTypeNodes, + OAGGraphCounterQueryTypeTransactions, + OAGGraphCounterQueryTypeUpdates, + OAGGraphCounterQueryTypeChanges, + OAGGraphCounterQueryTypeContextID, + OAGGraphCounterQueryTypeGraphID, + OAGGraphCounterQueryTypeContextThreadUpdating, + OAGGraphCounterQueryTypeThreadUpdating, + OAGGraphCounterQueryTypeContextNeedsUpdate, + OAGGraphCounterQueryTypeNeedsUpdate, + OAGGraphCounterQueryTypeMainThreadUpdates, + OAGGraphCounterQueryTypeCreatedNodes, + OAGGraphCounterQueryTypeSubgraphs, + OAGGraphCounterQueryTypeCreatedSubgraphs, +} OAG_SWIFT_NAME(OAGGraphRef.CounterQueryType); + +#endif /* OAGGraphCounterQueryType_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGGraphDescription.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGGraphDescription.h new file mode 100644 index 00000000..3bc0783c --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGGraphDescription.h @@ -0,0 +1,59 @@ +// +// OAGGraphDescription.h +// OpenAttributeGraphCxx + +#ifndef OAGGraphDescription_h +#define OAGGraphDescription_h + +#include +#include + +OAG_ASSUME_NONNULL_BEGIN + +OAG_IMPLICIT_BRIDGING_ENABLED + +OAG_EXTERN_C_BEGIN + +#if OAG_OBJC_FOUNDATION + +typedef CFStringRef OAGDescriptionOption OAG_SWIFT_STRUCT OAG_SWIFT_NAME(DescriptionOption); + +OAG_EXPORT +const OAGDescriptionOption OAGDescriptionFormat OAG_SWIFT_NAME(DescriptionOption.format); + +OAG_EXPORT +const OAGDescriptionOption OAGDescriptionIncludeValues OAG_SWIFT_NAME(DescriptionOption.includeValues); + +OAG_EXPORT +const OAGDescriptionOption OAGDescriptionTruncationLimit OAG_SWIFT_NAME(DescriptionOption.truncationLimit); + +OAG_EXPORT +const OAGDescriptionOption OAGDescriptionMaxFrames OAG_SWIFT_NAME(DescriptionOption.maxFrames); + +static const CFStringRef OAGDescriptionFormatDot OAG_SWIFT_NAME(OAGGraphRef.descriptionFormatDot) = CFSTR("graph/dot"); + +static const CFStringRef OAGDescriptionFormatDictionary OAG_SWIFT_NAME(OAGGraphRef.descriptionFormatDictionary) = CFSTR("graph/dict"); + +static const CFStringRef OAGDescriptionAllGraphs OAG_SWIFT_NAME(OAGGraphRef.descriptionAllGraphs) = CFSTR("all_graphs"); + +#endif + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphArchiveJSON(char const * _Nullable name) OAG_SWIFT_NAME(OAGGraphRef.archiveJSON(name:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphArchiveJSON2(char const * _Nullable name, bool exclude_values) OAG_SWIFT_NAME(OAGGraphRef.archiveJSON(name:excludeValues:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +_Nullable CFTypeRef OAGGraphDescription(_Nullable OAGGraphRef graph, CFDictionaryRef options) OAG_SWIFT_NAME(OAGGraphRef.description(_:options:)); + +OAG_EXTERN_C_END + +OAG_IMPLICIT_BRIDGING_DISABLED + +OAG_ASSUME_NONNULL_END + +#endif /* OAGGraphDescription_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGGraphTracing.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGGraphTracing.h new file mode 100644 index 00000000..062edf4c --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGGraphTracing.h @@ -0,0 +1,56 @@ +// +// OAGGraphTracing.h +// OpenAttributeGraphCxx + +#ifndef OAGGraphTracing_hpp +#define OAGGraphTracing_hpp + +#include +#include +#include + +typedef OAG_OPTIONS(uint32_t, OAGGraphTraceOptions) { + OAGGraphTraceOptionsEnabled = 1 << 0, + OAGGraphTraceOptionsFull = 1 << 1, + OAGGraphTraceOptionsBacktrace = 1 << 2, + OAGGraphTraceOptionsPrepare = 1 << 3, + OAGGraphTraceOptionsCustom = 1 << 4, + OAGGraphTraceOptionsAll = 1 << 5, +} OAG_SWIFT_NAME(OAGGraphRef.TraceOptions); + +typedef struct OAGTrace *OAGTraceRef; + +OAG_ASSUME_NONNULL_BEGIN + +OAG_IMPLICIT_BRIDGING_ENABLED + +OAG_EXTERN_C_BEGIN + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphStartTracing(_Nullable OAGGraphRef graph, OAGGraphTraceOptions options) OAG_SWIFT_NAME(OAGGraphRef.startTracing(_:options:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphStartTracing2(_Nullable OAGGraphRef graph, OAGGraphTraceOptions options, _Nullable CFArrayRef subsystems) OAG_SWIFT_NAME(OAGGraphRef.startTracing(_:flags:subsystems:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphStopTracing(_Nullable OAGGraphRef graph) OAG_SWIFT_NAME(OAGGraphRef.stopTracing(_:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGUniqueID OAGGraphAddTrace(OAGGraphRef graph, const OAGTraceRef trace, void *_Nullable context) +OAG_SWIFT_NAME(OAGGraphRef.addTrace(self:_:context:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphRemoveTrace(OAGGraphRef graph, OAGUniqueID trace_id) OAG_SWIFT_NAME(OAGGraphRef.removeTrace(self:traceID:)); + +OAG_EXTERN_C_END + +OAG_IMPLICIT_BRIDGING_DISABLED + +OAG_ASSUME_NONNULL_END + +#endif /* OAGGraphTracing_hpp */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGInputOptions.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGInputOptions.h new file mode 100644 index 00000000..2ee20e1f --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGInputOptions.h @@ -0,0 +1,16 @@ +// +// OAGInputOptions.h +// OpenAttributeGraphCxx + +#ifndef OAGInputOptions_h +#define OAGInputOptions_h + +#include + +typedef OAG_OPTIONS(uint32_t, OAGInputOptions) { + OAGInputOptionsNone = 0, + OAGInputOptionsUnprefetched = 1 << 0, + OAGInputOptionsSyncMainRef = 1 << 1, +}; + +#endif /* OAGInputOptions_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGSearchOptions.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGSearchOptions.h new file mode 100644 index 00000000..6bc50162 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGSearchOptions.h @@ -0,0 +1,16 @@ +// +// OAGSearchOptions.h +// OpenAttributeGraphCxx + +#ifndef OAGSearchOptions_h +#define OAGSearchOptions_h + +#include + +typedef OAG_OPTIONS(uint32_t, OAGSearchOptions) { + OAGSearchOptionsSearchInputs = 1 << 0, + OAGSearchOptionsSearchOutputs = 1 << 1, + OAGSearchOptionsTraverseGraphContexts = 1 << 2, +} OAG_SWIFT_NAME(SearchOptions); + +#endif /* Header_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGSubgraph.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGSubgraph.h new file mode 100644 index 00000000..84c6386e --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGSubgraph.h @@ -0,0 +1,122 @@ +// +// OAGSubgraph.h +// OpenAttributeGraphCxx + +#ifndef OAGSubgraph_h +#define OAGSubgraph_h + +#include +#include +#include +#include +#include +#include + +OAG_ASSUME_NONNULL_BEGIN + +OAG_IMPLICIT_BRIDGING_ENABLED + +// MARK: - Exported C functions + +OAG_EXTERN_C_BEGIN + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +CFTypeID OAGSubgraphGetTypeID(); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGSubgraphRef OAGSubgraphCreate(OAGGraphRef cf_graph) OAG_SWIFT_NAME(OAGSubgraphRef.init(graph:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGSubgraphRef OAGSubgraphCreate2(OAGGraphRef cf_graph, OAGAttribute attribute) OAG_SWIFT_NAME(OAGSubgraphRef.init(graph:attribute:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +_Nullable OAGSubgraphRef OAGSubgraphGetCurrent(void) OAG_SWIFT_NAME(getter:OAGSubgraphRef.current()); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGSubgraphSetCurrent(_Nullable OAGSubgraphRef cf_subgraph) OAG_SWIFT_NAME(setter:OAGSubgraphRef.current(_:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +_Nullable OAGGraphContextRef OAGSubgraphGetCurrentGraphContext(void) OAG_SWIFT_NAME(getter:OAGSubgraphRef.currentGraphContext()); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGSubgraphInvalidate(OAGSubgraphRef cf_subgraph) OAG_SWIFT_NAME(OAGSubgraphRef.invalidate(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +bool OAGSubgraphIsValid(OAGSubgraphRef cf_subgraph) OAG_SWIFT_NAME(getter:OAGSubgraphRef.isValid(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGGraphRef OAGSubgraphGetGraph(OAGSubgraphRef cf_subgraph) OAG_SWIFT_NAME(getter:OAGSubgraphRef.graph(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGSubgraphAddChild(OAGSubgraphRef parent, OAGSubgraphRef child) OAG_SWIFT_NAME(OAGSubgraphRef.addChild(self:_:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGSubgraphAddChild2(OAGSubgraphRef parent, OAGSubgraphRef child, uint8_t tag) OAG_SWIFT_NAME(OAGSubgraphRef.addChild(self:_:tag:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGSubgraphRemoveChild(OAGSubgraphRef parent, OAGSubgraphRef child) OAG_SWIFT_NAME(OAGSubgraphRef.removeChild(self:_:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +bool OAGSubgraphIntersects(OAGSubgraphRef subgraph, OAGAttributeFlags flags) OAG_SWIFT_NAME(OAGSubgraphRef.intersects(self:flags:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGSubgraphApply(OAGSubgraphRef cf_subgraph, + OAGAttributeFlags flags, + const void (*function)(const void * _Nullable context OAG_SWIFT_CONTEXT, OAGAttribute attribute) OAG_SWIFT_CC(swift), + const void * _Nullable context); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGSubgraphUpdate(OAGSubgraphRef cf_subgraph, OAGAttributeFlags flags) OAG_SWIFT_NAME(OAGSubgraphRef.update(self:flags:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +bool OAGSubgraphIsDirty(OAGSubgraphRef cf_subgraph, OAGAttributeFlags flags) OAG_SWIFT_NAME(OAGSubgraphRef.isDirty(self:flags:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGUniqueID OAGSubgraphAddObserver(OAGSubgraphRef cf_subgraph, + const void (*function)(const void * _Nullable context OAG_SWIFT_CONTEXT) OAG_SWIFT_CC(swift), + const void * _Nullable context); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +bool OAGSubgraphShouldRecordTree(void) OAG_SWIFT_NAME(getter:OAGSubgraphRef.shouldRecordTree()); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGSubgraphSetShouldRecordTree(void) OAG_SWIFT_NAME(OAGSubgraphRef.setShouldRecordTree()); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGSubgraphBeginTreeElement(OAGAttribute attribute, OAGTypeID type, uint32_t flags); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGSubgraphAddTreeValue(OAGAttribute attribute, OAGTypeID type, const char * key, uint32_t flags); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGSubgraphEndTreeElement(OAGAttribute attribute); + +OAG_EXTERN_C_END + +OAG_IMPLICIT_BRIDGING_DISABLED + +OAG_ASSUME_NONNULL_END + +#endif /* OAGSubgraph_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGSwiftSupport.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGSwiftSupport.h new file mode 100644 index 00000000..bec6e672 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGSwiftSupport.h @@ -0,0 +1,45 @@ +// +// OAGSwiftSupport.h +// OpenAttributeGraphCxx + +#ifndef OAGSwiftSupport_h +#define OAGSwiftSupport_h + +#if __has_attribute(swift_name) +#define OAG_SWIFT_NAME(_name) __attribute__((swift_name(#_name))) +#else +#define OAG_SWIFT_NAME +#endif + +#if __has_attribute(swift_wrapper) +#define OAG_SWIFT_STRUCT __attribute__((swift_wrapper(struct))) +#else +#define OAG_SWIFT_STRUCT +#endif + +#if __has_attribute(swift_private) +#define OAG_REFINED_FOR_SWIFT __attribute__((swift_private)) +#else +#define OAG_REFINED_FOR_SWIFT +#endif + +// MARK: - Call Convension + +#define OAG_SWIFT_CC(CC) OAG_SWIFT_CC_##CC +// OAG_SWIFT_CC(c) is the C calling convention. +#define OAG_SWIFT_CC_c + +// OAG_SWIFT_CC(swift) is the Swift calling convention. +#if __has_attribute(swiftcall) +#define OAG_SWIFT_CC_swift __attribute__((swiftcall)) +#define OAG_SWIFT_CONTEXT __attribute__((swift_context)) +#define OAG_SWIFT_ERROR_RESULT __attribute__((swift_error_result)) +#define OAG_SWIFT_INDIRECT_RESULT __attribute__((swift_indirect_result)) +#else +#define OAG_SWIFT_CC_swift +#define OAG_SWIFT_CONTEXT +#define OAG_SWIFT_ERROR_RESULT +#define OAG_SWIFT_INDIRECT_RESULT +#endif + +#endif /* OAGSwiftSupport_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGTargetConditionals.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGTargetConditionals.h new file mode 100644 index 00000000..95d0351a --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGTargetConditionals.h @@ -0,0 +1,277 @@ +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// + +/* + File: OAGTargetConditionals.h + + Contains: Autoconfiguration of TARGET_ conditionals for Mac OS X and iPhone + + Note: OpenSwiftUITargetConditionals.h in 3.4 Universal Interfaces works + with all compilers. This header only recognizes compilers + known to run on Mac OS X. + +*/ + +#ifndef __OPENATTRIBUTEGRAPHTARGETCONDITIONALS__ +#define __OPENATTRIBUTEGRAPHTARGETCONDITIONALS__ +/**************************************************************************************************** + + TARGET_CPU_* + These conditionals specify which microprocessor instruction set is being + generated. At most one of these is true, the rest are false. + + TARGET_CPU_PPC - Compiler is generating PowerPC instructions for 32-bit mode + TARGET_CPU_PPC64 - Compiler is generating PowerPC instructions for 64-bit mode + TARGET_CPU_68K - Compiler is generating 680x0 instructions + TARGET_CPU_X86 - Compiler is generating x86 instructions + TARGET_CPU_ARM - Compiler is generating ARM instructions + TARGET_CPU_MIPS - Compiler is generating MIPS instructions + TARGET_CPU_SPARC - Compiler is generating Sparc instructions + TARGET_CPU_ALPHA - Compiler is generating Dec Alpha instructions + TARGET_CPU_WASM32 - Compiler is generating WebAssembly instructions for 32-bit mode + + + TARGET_OS_* + These conditionals specify in which Operating System the generated code will + run. Indention is used to show which conditionals are evolutionary subclasses. + + The MAC/WIN32/UNIX conditionals are mutually exclusive. + The IOS/TV/WATCH conditionals are mutually exclusive. + + + TARGET_OS_WIN32 - Generated code will run under 32-bit Windows + TARGET_OS_UNIX - Generated code will run under some Unix (not OSX) + TARGET_OS_CYGWIN - Generated code will run under 64-bit Cygwin + TARGET_OS_WASI - Generated code will run under WebAssembly System Interface + TARGET_OS_MAC - Generated code will run under Mac OS X variant + TARGET_OS_IPHONE - Generated code for firmware, devices, or simulator + TARGET_OS_IOS - Generated code will run under iOS + TARGET_OS_TV - Generated code will run under Apple TV OS + TARGET_OS_WATCH - Generated code will run under Apple Watch OS + TARGET_OS_SIMULATOR - Generated code will run under a simulator + TARGET_OS_EMBEDDED - Generated code for firmware + + TARGET_IPHONE_SIMULATOR - DEPRECATED: Same as TARGET_OS_SIMULATOR + TARGET_OS_NANO - DEPRECATED: Same as TARGET_OS_WATCH + + TARGET_RT_* + These conditionals specify in which runtime the generated code will + run. This is needed when the OS and CPU support more than one runtime + (e.g. Mac OS X supports CFM and mach-o). + + TARGET_RT_LITTLE_ENDIAN - Generated code uses little endian format for integers + TARGET_RT_BIG_ENDIAN - Generated code uses big endian format for integers + TARGET_RT_64_BIT - Generated code uses 64-bit pointers + TARGET_RT_MAC_CFM - TARGET_OS_MAC is true and CFM68K or PowerPC CFM (TVectors) are used + TARGET_RT_MAC_MACHO - TARGET_OS_MAC is true and Mach-O/dlyd runtime is used + + +****************************************************************************************************/ + +#if __APPLE__ +#define OAG_TARGET_OS_DARWIN 1 +#define OAG_TARGET_OS_LINUX 0 +#define OAG_TARGET_OS_WINDOWS 0 +#define OAG_TARGET_OS_BSD 0 +#define OAG_TARGET_OS_ANDROID 0 +#define OAG_TARGET_OS_CYGWIN 0 +#define OAG_TARGET_OS_WASI 0 +#elif __ANDROID__ +#define OAG_TARGET_OS_DARWIN 0 +#define OAG_TARGET_OS_LINUX 1 +#define OAG_TARGET_OS_WINDOWS 0 +#define OAG_TARGET_OS_BSD 0 +#define OAG_TARGET_OS_ANDROID 1 +#define OAG_TARGET_OS_CYGWIN 0 +#define OAG_TARGET_OS_WASI 0 +#elif __linux__ +#define OAG_TARGET_OS_DARWIN 0 +#define OAG_TARGET_OS_LINUX 1 +#define OAG_TARGET_OS_WINDOWS 0 +#define OAG_TARGET_OS_BSD 0 +#define OAG_TARGET_OS_ANDROID 0 +#define OAG_TARGET_OS_CYGWIN 0 +#define OAG_TARGET_OS_WASI 0 +#elif __CYGWIN__ +#define OAG_TARGET_OS_DARWIN 0 +#define OAG_TARGET_OS_LINUX 1 +#define OAG_TARGET_OS_WINDOWS 0 +#define OAG_TARGET_OS_BSD 0 +#define OAG_TARGET_OS_ANDROID 0 +#define OAG_TARGET_OS_CYGWIN 1 +#define OAG_TARGET_OS_WASI 0 +#elif _WIN32 || _WIN64 +#define OAG_TARGET_OS_DARWIN 0 +#define OAG_TARGET_OS_LINUX 0 +#define OAG_TARGET_OS_WINDOWS 1 +#define OAG_TARGET_OS_BSD 0 +#define OAG_TARGET_OS_ANDROID 0 +#define OAG_TARGET_OS_CYGWIN 0 +#define OAG_TARGET_OS_WASI 0 +#elif __unix__ +#define OAG_TARGET_OS_DARWIN 0 +#define OAG_TARGET_OS_LINUX 0 +#define OAG_TARGET_OS_WINDOWS 0 +#define OAG_TARGET_OS_BSD 1 +#define OAG_TARGET_OS_ANDROID 0 +#define OAG_TARGET_OS_CYGWIN 0 +#define OAG_TARGET_OS_WASI 0 +#elif __wasi__ +#define OAG_TARGET_OS_DARWIN 0 +#define OAG_TARGET_OS_LINUX 0 +#define OAG_TARGET_OS_WINDOWS 0 +#define OAG_TARGET_OS_BSD 0 +#define OAG_TARGET_OS_ANDROID 0 +#define OAG_TARGET_OS_CYGWIN 0 +#define OAG_TARGET_OS_WASI 1 +#else +#error unknown operating system +#endif + +#define OAG_TARGET_OS_WIN32 OAG_TARGET_OS_WINDOWS +#define OAG_TARGET_OS_MAC OAG_TARGET_OS_DARWIN +#define OAG_TARGET_OS_OSX OAG_TARGET_OS_DARWIN + +// iOS, watchOS, and tvOS are not supported +#define OAG_TARGET_OS_IPHONE 0 +#define OAG_TARGET_OS_IOS 0 +#define OAG_TARGET_OS_WATCH 0 +#define OAG_TARGET_OS_TV 0 + +#if __x86_64__ +#define OAG_TARGET_CPU_PPC 0 +#define OAG_TARGET_CPU_PPC64 0 +#define OAG_TARGET_CPU_X86 0 +#define OAG_TARGET_CPU_X86_64 1 +#define OAG_TARGET_CPU_ARM 0 +#define OAG_TARGET_CPU_ARM64 0 +#define OAG_TARGET_CPU_MIPS 0 +#define OAG_TARGET_CPU_MIPS64 0 +#define OAG_TARGET_CPU_S390X 0 +#define OAG_TARGET_CPU_WASM32 0 +#elif __arm64__ || __aarch64__ +#define OAG_TARGET_CPU_PPC 0 +#define OAG_TARGET_CPU_PPC64 0 +#define OAG_TARGET_CPU_X86 0 +#define OAG_TARGET_CPU_X86_64 0 +#define OAG_TARGET_CPU_ARM 0 +#define OAG_TARGET_CPU_ARM64 1 +#define OAG_TARGET_CPU_MIPS 0 +#define OAG_TARGET_CPU_MIPS64 0 +#define OAG_TARGET_CPU_S390X 0 +#define OAG_TARGET_CPU_WASM32 0 +#elif __mips64__ +#define OAG_TARGET_CPU_PPC 0 +#define OAG_TARGET_CPU_PPC64 0 +#define OAG_TARGET_CPU_X86 0 +#define OAG_TARGET_CPU_X86_64 0 +#define OAG_TARGET_CPU_ARM 0 +#define OAG_TARGET_CPU_ARM64 0 +#define OAG_TARGET_CPU_MIPS 0 +#define OAG_TARGET_CPU_MIPS64 1 +#define OAG_TARGET_CPU_S390X 0 +#define OAG_TARGET_CPU_WASM32 0 +#elif __powerpc64__ +#define OAG_TARGET_CPU_PPC 0 +#define OAG_TARGET_CPU_PPC64 1 +#define OAG_TARGET_CPU_X86 0 +#define OAG_TARGET_CPU_X86_64 0 +#define OAG_TARGET_CPU_ARM 0 +#define OAG_TARGET_CPU_ARM64 0 +#define OAG_TARGET_CPU_MIPS 0 +#define OAG_TARGET_CPU_MIPS64 0 +#define OAG_TARGET_CPU_S390X 0 +#define OAG_TARGET_CPU_WASM32 0 +#elif __i386__ +#define OAG_TARGET_CPU_PPC 0 +#define OAG_TARGET_CPU_PPC64 0 +#define OAG_TARGET_CPU_X86 1 +#define OAG_TARGET_CPU_X86_64 0 +#define OAG_TARGET_CPU_ARM 0 +#define OAG_TARGET_CPU_ARM64 0 +#define OAG_TARGET_CPU_MIPS 0 +#define OAG_TARGET_CPU_MIPS64 0 +#define OAG_TARGET_CPU_S390X 0 +#define OAG_TARGET_CPU_WASM32 0 +#elif __arm__ +#define OAG_TARGET_CPU_PPC 0 +#define OAG_TARGET_CPU_PPC64 0 +#define OAG_TARGET_CPU_X86 0 +#define OAG_TARGET_CPU_X86_64 0 +#define OAG_TARGET_CPU_ARM 1 +#define OAG_TARGET_CPU_ARM64 0 +#define OAG_TARGET_CPU_MIPS 0 +#define OAG_TARGET_CPU_MIPS64 0 +#define OAG_TARGET_CPU_S390X 0 +#define OAG_TARGET_CPU_WASM32 0 +#elif __mips__ +#define OAG_TARGET_CPU_PPC 0 +#define OAG_TARGET_CPU_PPC64 0 +#define OAG_TARGET_CPU_X86 0 +#define OAG_TARGET_CPU_X86_64 0 +#define OAG_TARGET_CPU_ARM 0 +#define OAG_TARGET_CPU_ARM64 0 +#define OAG_TARGET_CPU_MIPS 1 +#define OAG_TARGET_CPU_MIPS64 0 +#define OAG_TARGET_CPU_S390X 0 +#define OAG_TARGET_CPU_WASM32 0 +#elif __powerpc__ +#define OAG_TARGET_CPU_PPC 1 +#define OAG_TARGET_CPU_PPC64 0 +#define OAG_TARGET_CPU_X86 0 +#define OAG_TARGET_CPU_X86_64 0 +#define OAG_TARGET_CPU_ARM 0 +#define OAG_TARGET_CPU_ARM64 0 +#define OAG_TARGET_CPU_MIPS 0 +#define OAG_TARGET_CPU_MIPS64 0 +#define OAG_TARGET_CPU_S390X 0 +#define OAG_TARGET_CPU_WASM32 0 +#elif __s390x__ +#define OAG_TARGET_CPU_PPC 0 +#define OAG_TARGET_CPU_PPC64 0 +#define OAG_TARGET_CPU_X86 0 +#define OAG_TARGET_CPU_X86_64 0 +#define OAG_TARGET_CPU_ARM 0 +#define OAG_TARGET_CPU_ARM64 0 +#define OAG_TARGET_CPU_MIPS 0 +#define OAG_TARGET_CPU_MIPS64 0 +#define OAG_TARGET_CPU_S390X 1 +#define OAG_TARGET_CPU_WASM32 0 +#elif __wasm32__ +#define OAG_TARGET_CPU_PPC 0 +#define OAG_TARGET_CPU_PPC64 0 +#define OAG_TARGET_CPU_X86 0 +#define OAG_TARGET_CPU_X86_64 0 +#define OAG_TARGET_CPU_ARM 0 +#define OAG_TARGET_CPU_ARM64 0 +#define OAG_TARGET_CPU_MIPS 0 +#define OAG_TARGET_CPU_MIPS64 0 +#define OAG_TARGET_CPU_S390X 0 +#define OAG_TARGET_CPU_WASM32 1 +#else +#error unknown architecture +#endif + +#if __LITTLE_ENDIAN__ +#define OAG_TARGET_RT_LITTLE_ENDIAN 1 +#define OAG_TARGET_RT_BIG_ENDIAN 0 +#elif __BIG_ENDIAN__ +#define OAG_TARGET_RT_LITTLE_ENDIAN 0 +#define OAG_TARGET_RT_BIG_ENDIAN 1 +#else +#error unknown endian +#endif + +#if __LP64__ || __LLP64__ || __POINTER_WIDTH__-0 == 64 +#define OAG_TARGET_RT_64_BIT 1 +#else +#define OAG_TARGET_RT_64_BIT 0 +#endif + +#endif /* __OPENATTRIBUTEGRAPHTARGETCONDITIONALS__ */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGTrace.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGTrace.h new file mode 100644 index 00000000..53dff07e --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGTrace.h @@ -0,0 +1,83 @@ +// +// OAGTrace.h +// OpenAttributeGraphCxx + +#ifndef OAGTrace_h +#define OAGTrace_h + +#include +#include + +OAG_ASSUME_NONNULL_BEGIN + +typedef OAG_ENUM(uint64_t, OAGTraceEvents) { + OAGTraceEventsCustom = 1, + OAGTraceEventsNamed = 2, + OAGTraceEventsDeadline = 3, + OAGTraceEventsCompareFailed = 4, +} OAG_SWIFT_NAME(TraceEvents); + +typedef struct OAGTrace { + OAGTraceEvents events; + + void (*_Nullable begin_trace)(void *_Nullable context, OAGGraphRef graph); + void (*_Nullable end_trace)(void *_Nullable context, OAGGraphRef graph); + + void (*_Nullable begin_update_subgraph)(void *_Nullable context, OAGSubgraphRef subgraph, uint32_t options); + void (*_Nullable end_update_subgraph)(void *_Nullable context, OAGSubgraphRef subgraph); + void (*_Nullable begin_update_stack)(void *_Nullable context, OAGAttribute attribute); + void (*_Nullable end_update_stack)(void *_Nullable context, bool changed); + void (*_Nullable begin_update_attribute)(void *_Nullable context, OAGAttribute attribute); + void (*_Nullable end_update_attribute)(void *_Nullable context, OAGAttribute attribute, bool changed); + void (*_Nullable begin_update_graph)(void *_Nullable context, OAGGraphRef graph); + void (*_Nullable end_update_graph)(void *_Nullable context, OAGGraphRef graph); + + void (*_Nullable begin_invalidation)(void *_Nullable context, OAGGraphRef graph, OAGAttribute attribute); + void (*_Nullable end_invalidation)(void *_Nullable context, OAGGraphRef graph, OAGAttribute attribute); + + void (*_Nullable begin_modify)(void *_Nullable context, OAGAttribute attribute); + void (*_Nullable end_modify)(void *_Nullable context, OAGAttribute attribute); + + void (*_Nullable begin_event)(void *_Nullable context, OAGAttribute attribute, const char *event_name); + void (*_Nullable end_event)(void *_Nullable context, OAGAttribute attribute, const char *event_name); + + void (*_Nullable created_graph)(void *_Nullable context, OAGGraphRef graph); + void (*_Nullable destroy_graph)(void *_Nullable context, OAGGraphRef graph); + void (*_Nullable needs_update)(void *_Nullable context, OAGGraphRef graph); + + void (*_Nullable created_subgraph)(void *_Nullable context, OAGSubgraphRef subgraph); + void (*_Nullable invalidate_subgraph)(void *_Nullable context, OAGSubgraphRef subgraph); + void (*_Nullable add_child_subgraph)(void *_Nullable context, OAGSubgraphRef subgraph, OAGSubgraphRef child); + void (*_Nullable remove_child_subgraph)(void *_Nullable context, OAGSubgraphRef subgraph, OAGSubgraphRef child); + + void (*_Nullable added_attribute)(void *_Nullable context, OAGAttribute attribute); + void (*_Nullable add_edge)(void *_Nullable context, OAGAttribute attribute, OAGAttribute input, unsigned int flags); + void (*_Nullable remove_edge)(void *_Nullable context, OAGAttribute attribute, size_t index); + void (*_Nullable set_edge_pending)(void *_Nullable context, OAGAttribute attribute, OAGAttribute input, bool pending); + + void (*_Nullable set_dirty)(void *_Nullable context, OAGAttribute attribute, bool dirty); + void (*_Nullable set_pending)(void *_Nullable context, OAGAttribute attribute, bool pending); + void (*_Nullable set_value)(void *_Nullable context, OAGAttribute attribute); + void (*_Nullable mark_value)(void *_Nullable context, OAGAttribute attribute); + + void (*_Nullable added_indirect_attribute)(void *_Nullable context, OAGAttribute attribute); + void (*_Nullable set_source)(void *_Nullable context, OAGAttribute attribute, OAGAttribute source); + void (*_Nullable set_dependency)(void *_Nullable context, OAGAttribute attribute, OAGAttribute dependency); + + void (*_Nullable mark_profile)(void *_Nullable context, const char *event_name); + + void (*_Nullable custom_event)(void *_Nullable context, OAGGraphRef graph, const char *event_name, const void *value, + OAGTypeID type); + void (*_Nullable named_event)(void *_Nullable context, OAGGraphRef graph, uint32_t eventID, uint32_t eventArgCount, + const void *eventArgs, CFDataRef data, uint32_t arg6); + bool (*_Nullable named_event_enabled)(void *_Nullable context); + + void (*_Nullable set_deadline)(void *_Nullable context); + void (*_Nullable passed_deadline)(void *_Nullable context); + + void (*_Nullable compare_failed)(void *_Nullable context, OAGAttribute attribute, OAGComparisonState comparisonState); +} OAGTrace OAG_SWIFT_NAME(Trace); + +OAG_ASSUME_NONNULL_END + +#endif /* OAGTrace_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGTupleType.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGTupleType.h new file mode 100644 index 00000000..27231631 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGTupleType.h @@ -0,0 +1,93 @@ +// +// OAGTupleType.h +// OpenAttributeGraphCxx +// +// Audited for iOS 18.0 +// Status: Complete + +#ifndef OAGTupleType_h +#define OAGTupleType_h + +#include +#include + +OAG_ASSUME_NONNULL_BEGIN + +OAG_IMPLICIT_BRIDGING_ENABLED + +typedef const OAGSwiftMetadata *OAGTupleType OAG_SWIFT_STRUCT OAG_SWIFT_NAME(TupleType); + +typedef OAG_CLOSED_ENUM(uint32_t, OAGTupleCopyOptions) { + OAGTupleCopyOptionsAssignCopy = 0, + OAGTupleCopyOptionsInitCopy = 1, + OAGTupleCopyOptionsAssignTake = 2, + OAGTupleCopyOptionsInitTake = 3 +} OAG_SWIFT_NAME(TupleType.CopyOptions); + +typedef struct OAG_SWIFT_NAME(UnsafeTuple) OAGUnsafeTuple { + OAGTupleType type; + const void *value; +} OAGUnsafeTuple; + +typedef struct OAG_SWIFT_NAME(UnsafeMutableTuple) OAGUnsafeMutableTuple { + OAGTupleType type; + void *value; +} OAGUnsafeMutableTuple; + +OAG_EXTERN_C_BEGIN + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGTupleType OAGNewTupleType(size_t count, const OAGTypeID _Nonnull * _Nonnull elements) OAG_SWIFT_NAME(TupleType.init(count:elements:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +size_t OAGTupleCount(OAGTupleType tuple_type) OAG_SWIFT_NAME(getter:TupleType.count(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +size_t OAGTupleSize(OAGTupleType tuple_type) OAG_SWIFT_NAME(getter:TupleType.size(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGTypeID OAGTupleElementType(OAGTupleType tuple_type, size_t index) OAG_SWIFT_NAME(TupleType.elementType(self:at:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +size_t OAGTupleElementSize(OAGTupleType tuple_type, size_t index) OAG_SWIFT_NAME(TupleType.elementSize(self:at:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +size_t OAGTupleElementOffset(OAGTupleType tuple_type, size_t index) OAG_SWIFT_NAME(TupleType.elementOffset(self:at:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +size_t OAGTupleElementOffsetChecked(OAGTupleType tuple_type, size_t index, OAGTypeID check_type) OAG_SWIFT_NAME(TupleType.elementOffset(self:at:type:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void *OAGTupleSetElement(OAGTupleType tuple_type, void* tuple_value, size_t index, const void *element_value, OAGTypeID check_type, OAGTupleCopyOptions mode); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void *OAGTupleGetElement(OAGTupleType tuple_type, void* tuple_value, size_t index, void *element_value, OAGTypeID check_type, OAGTupleCopyOptions mode); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGTupleDestroy(OAGTupleType tuple_type, void *buffer) OAG_SWIFT_NAME(TupleType.destroy(self:_:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGTupleDestroyElement(OAGTupleType tuple_type, void *buffer, size_t index) OAG_SWIFT_NAME(TupleType.destroy(self:_:at:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGTupleWithBuffer(OAGTupleType tuple_type, size_t count, const void (* function)(const OAGUnsafeMutableTuple mutableTuple, const void * context OAG_SWIFT_CONTEXT) OAG_SWIFT_CC(swift), const void *context); + +OAG_EXTERN_C_END + +OAG_IMPLICIT_BRIDGING_DISABLED + +OAG_ASSUME_NONNULL_END + +#endif /* OAGTupleType_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGTypeID.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGTypeID.h new file mode 100644 index 00000000..1cb4d03f --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGTypeID.h @@ -0,0 +1,123 @@ +// +// OAGTypeID.h +// OpenAttributeGraphCxx +// +// Audited for iOS 18.0 +// Status: Complete + +#ifndef OAGTypeID_h +#define OAGTypeID_h + +#include +#include + +OAG_ASSUME_NONNULL_BEGIN + +OAG_IMPLICIT_BRIDGING_ENABLED + +typedef struct OAG_SWIFT_NAME(_Metadata) OAGSwiftMetadata { +} OAGSwiftMetadata; + +typedef const OAGSwiftMetadata *OAGTypeID OAG_SWIFT_STRUCT OAG_SWIFT_NAME(Metadata); + +typedef OAG_CLOSED_ENUM(uint32_t, OAGTypeKind) { + OAGTypeKindNone, + OAGTypeKindClass, + OAGTypeKindStruct, + OAGTypeKindEnum, + OAGTypeKindOptional, + OAGTypeKindTuple, + OAGTypeKindFunction, + OAGTypeKindExistential, + OAGTypeKindMetatype, +} OAG_SWIFT_NAME(Metadata.Kind); + +typedef OAG_OPTIONS(uint32_t, OAGTypeApplyOptions) { + OAGTypeApplyOptionsEnumerateStructFields = 0, + OAGTypeApplyOptionsEnumerateClassFields = 1 << 0, + OAGTypeApplyOptionsContinueAfterUnknownField = 1 << 1, + OAGTypeApplyOptionsEnumerateEnumCases = 1 << 2, +} OAG_SWIFT_NAME(Metadata.ApplyOptions); + +#if OPENATTRIBUTEGRAPH_RELEASE >= OPENATTRIBUTEGRAPH_RELEASE_2024 + +typedef struct OAG_SWIFT_NAME(Signature) OAGTypeSignature { + uint8_t bytes[20]; +} OAGTypeSignature; + +#endif + +OAG_EXTERN_C_BEGIN + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGTypeKind OAGTypeGetKind(OAGTypeID typeID) OAG_SWIFT_NAME(getter:Metadata.kind(self:)); + +// TODO +// OAGOverrideComparisonForTypeDescriptor(); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGTypeApplyFields(const void *type, const void *block, void *context); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +bool OAGTypeApplyFields2(const void *type, OAGTypeApplyOptions options, const void *block, void *context); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +uint32_t OAGTypeGetEnumTag(OAGTypeID typeID, const void *value) OAG_SWIFT_NAME(Metadata.enumTag(self:_:)); + +#if OPENATTRIBUTEGRAPH_RELEASE >= OPENATTRIBUTEGRAPH_RELEASE_2024 + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGTypeProjectEnumData(OAGTypeID typeID, void *value) OAG_SWIFT_NAME(Metadata.projectEnumData(self:_:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGTypeInjectEnumTag(OAGTypeID typeID, uint32_t tag, void *value) OAG_SWIFT_NAME(Metadata.injectEnumTag(self:tag:_:)); + +#endif /* OPENATTRIBUTEGRAPH_RELEASE */ + +// TODO +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +bool OAGTypeApplyEnumData(); + +// TODO +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +bool OAGTypeApplyMutableEnumData(); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +CFStringRef OAGTypeDescription(OAGTypeID typeID); + +#if OPENATTRIBUTEGRAPH_RELEASE >= OPENATTRIBUTEGRAPH_RELEASE_2024 + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGTypeSignature const OAGTypeGetSignature(OAGTypeID typeID) OAG_SWIFT_NAME(getter:Metadata.signature(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void const* _Nullable OAGTypeGetDescriptor(OAGTypeID typeID) OAG_SWIFT_NAME(getter:Metadata.descriptor(self:)); + +#endif /* OPENATTRIBUTEGRAPH_RELEASE */ + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void const* _Nullable OAGTypeNominalDescriptor(OAGTypeID typeID) OAG_SWIFT_NAME(getter:Metadata.nominalDescriptor(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +char const* _Nullable OAGTypeNominalDescriptorName(OAGTypeID typeID) OAG_SWIFT_NAME(getter:Metadata.nominalDescriptorName(self:)); + +OAG_EXTERN_C_END + +OAG_IMPLICIT_BRIDGING_DISABLED + +OAG_ASSUME_NONNULL_END + +#endif /* OAGTypeID_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGUniqueID.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGUniqueID.h new file mode 100644 index 00000000..9a906b51 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGUniqueID.h @@ -0,0 +1,20 @@ +// +// OAGUniqueID.h +// OpenAttributeGraphCxx +// +// Audited for iOS 18.0 +// Status: Complete + +#ifndef OAGUniqueID_h +#define OAGUniqueID_h + +#include +typedef long OAGUniqueID; + +OAG_EXTERN_C_BEGIN +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGUniqueID OAGMakeUniqueID(void) OAG_SWIFT_NAME(makeUniqueID()); +OAG_EXTERN_C_END + +#endif /* OAGUniqueID_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGValue.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGValue.h new file mode 100644 index 00000000..10c9d80a --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGValue.h @@ -0,0 +1,20 @@ +// +// OAGValue.h +// OpenAttributeGraphCxx + +#ifndef OAGValue_h +#define OAGValue_h + +#include +#include + +OAG_ASSUME_NONNULL_BEGIN + +typedef struct OAGValue { + const void *value; + OAGChangedValueFlags flags; +} OAGValue; + +OAG_ASSUME_NONNULL_END + +#endif /* OAGValue_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGValueOptions.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGValueOptions.h new file mode 100644 index 00000000..4dd08a86 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGValueOptions.h @@ -0,0 +1,19 @@ +// +// OAGValueOptions.h +// OpenAttributeGraphCxx + +#ifndef OAGValueOptions_h +#define OAGValueOptions_h + +#include + +typedef OAG_OPTIONS(uint32_t, OAGValueOptions) { + OAGValueOptionsNone = 0, + OAGValueOptionsInputOptionsUnprefetched = 1 << 0, + OAGValueOptionsInputOptionsSyncMainRef = 1 << 1, + OAGValueOptionsInputOptionsMask = 0x03, + + OAGValueOptionsIncrementGraphVersion = 1 << 2, // AsTopLevelOutput +}; + +#endif /* OAGValueOptions_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGValueState.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGValueState.h new file mode 100644 index 00000000..faaf2810 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGValueState.h @@ -0,0 +1,26 @@ +// +// OAGValueState.h +// OpenAttributeGraphCxx + +#ifndef OAGValueState_h +#define OAGValueState_h + +#include + +OAG_ASSUME_NONNULL_BEGIN + +typedef OAG_OPTIONS(uint8_t, OAGValueState) { + OAGValueStateNone = 0, + OAGValueStateDirty = 1 << 0, + OAGValueStatePending = 1 << 1, + OAGValueStateUpdating = 1 << 2, + OAGValueStateValueExists = 1 << 3, + OAGValueStateMainThread = 1 << 4, + OAGValueStateMainRef = 1 << 5, + OAGValueStateRequiresMainThread = 1 << 6, + OAGValueStateSelfModified = 1 << 7, +} OAG_SWIFT_NAME(ValueState); + +OAG_ASSUME_NONNULL_END + +#endif /* OAGValueState_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGVersion.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGVersion.h new file mode 100644 index 00000000..39798015 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGVersion.h @@ -0,0 +1,25 @@ +// +// OAGVersion.h +// OpenAttributeGraphCxx + +#ifndef OAGVersion_h +#define OAGVersion_h + +#include + +#define OPENATTRIBUTEGRAPH_RELEASE 2024 + +#define OPENATTRIBUTEGRAPH_RELEASE_2021 2021 +#define OPENATTRIBUTEGRAPH_RELEASE_2024 2024 + +#ifndef OPENATTRIBUTEGRAPH_RELEASE +#define OPENATTRIBUTEGRAPH_RELEASE OPENATTRIBUTEGRAPH_RELEASE_2024 +#endif + +OAG_EXTERN_C_BEGIN + +OAG_EXPORT const uint64_t OAGVersion; + +OAG_EXTERN_C_END + +#endif /* OAGVersion_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGWeakAttribute.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGWeakAttribute.h new file mode 100644 index 00000000..7ed8a4d2 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGWeakAttribute.h @@ -0,0 +1,39 @@ +// +// OAGWeakAttribute.h +// OpenAttributeGraphCxx + +#ifndef OAGWeakAttribute_hpp +#define OAGWeakAttribute_hpp + +#include +#include +#include + +OAG_ASSUME_NONNULL_BEGIN + +typedef struct OAGWeakAttribute { + struct { + OAGAttribute identifier; + uint32_t seed; + } _details; +} OAGWeakAttribute OAG_SWIFT_NAME(AnyWeakAttribute); + +OAG_EXTERN_C_BEGIN + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGWeakAttribute OAGCreateWeakAttribute(OAGAttribute attribute); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGAttribute OAGWeakAttributeGetAttribute(OAGWeakAttribute weakAttribute); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGWeakValue OAGGraphGetWeakValue(OAGWeakAttribute weakAttribute, OAGValueOptions options, OAGTypeID type); + +OAG_EXTERN_C_END + +OAG_ASSUME_NONNULL_END + +#endif /* OAGWeakAttribute_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGWeakValue.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGWeakValue.h new file mode 100644 index 00000000..aa13d564 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGWeakValue.h @@ -0,0 +1,20 @@ +// +// OAGWeakValue.h +// OpenAttributeGraphCxx + +#ifndef OAGWeakValue_h +#define OAGWeakValue_h + +#include +#include + +OAG_ASSUME_NONNULL_BEGIN + +typedef struct OAGWeakValue { + const void * _Nullable value; + OAGChangedValueFlags flags; +} OAGWeakValue; + +OAG_ASSUME_NONNULL_END + +#endif /* OAGWeakValue_h */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OpenAttributeGraph-umbrella.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OpenAttributeGraph-umbrella.h new file mode 100644 index 00000000..c67c2aba --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OpenAttributeGraph-umbrella.h @@ -0,0 +1,32 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +OAG_EXPORT double OpenAttributeGraphVersionNumber; +OAG_EXPORT const unsigned char OpenAttributeGraphVersionString[]; diff --git a/Sources/OpenGraphCxx/include/OpenGraph/Private/CFRuntime.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/Private/CFRuntime.h similarity index 99% rename from Sources/OpenGraphCxx/include/OpenGraph/Private/CFRuntime.h rename to Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/Private/CFRuntime.h index 862c13fd..3a15cc8e 100644 --- a/Sources/OpenGraphCxx/include/OpenGraph/Private/CFRuntime.h +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/Private/CFRuntime.h @@ -1,5 +1,5 @@ -#include -#if OG_TARGET_OS_DARWIN +#include +#if OAG_TARGET_OS_DARWIN // Copied from https://github.com/apple/swift-corelibs-foundation/blob/d8e8a8b92b3a8af8381a11155328c1bba1c6bd2c/CoreFoundation/Base.subproj/CFRuntime.h /* CFRuntime.h Copyright (c) 1999-2019, Apple Inc. All rights reserved. @@ -283,4 +283,4 @@ CF_EXTERN_C_END #endif /* ! __COREFOUNDATION_CFRUNTIME__ */ #else #include -#endif /* OG_TARGET_OS_DARWIN */ +#endif /* OAG_TARGET_OS_DARWIN */ diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Attribute/AttributeID.hpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Attribute/AttributeID.hpp similarity index 54% rename from Sources/OpenGraphCxx/include/OpenGraphCxx/Attribute/AttributeID.hpp rename to Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Attribute/AttributeID.hpp index 9e332433..5b07dfc8 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Attribute/AttributeID.hpp +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Attribute/AttributeID.hpp @@ -1,15 +1,15 @@ // // AttributeID.hpp -// OpenGraphCxx +// OpenAttributeGraphCxx #ifndef AttributeID_hpp #define AttributeID_hpp -#include -#include -#include +#include +#include +#include -namespace OG { +namespace OAG { class AttributeID final { public: enum : uint32_t { @@ -24,46 +24,46 @@ class AttributeID final { private: uint32_t _rawValue; - OG_INLINE OG_CONSTEXPR - const Kind getKind() const OG_NOEXCEPT { + OAG_INLINE OAG_CONSTEXPR + const Kind getKind() const OAG_NOEXCEPT { return Kind(_rawValue & KindMask); } public: - OG_INLINE OG_CONSTEXPR - AttributeID(OGAttribute& attribute) OG_NOEXCEPT: + OAG_INLINE OAG_CONSTEXPR + AttributeID(OAGAttribute& attribute) OAG_NOEXCEPT: _rawValue(attribute) {} - OG_INLINE OG_CONSTEXPR + OAG_INLINE OAG_CONSTEXPR AttributeID(const AttributeID &) noexcept = default; - OG_INLINE OG_CONSTEXPR + OAG_INLINE OAG_CONSTEXPR AttributeID(AttributeID &&) noexcept = default; - OG_INLINE OG_CONSTEXPR + OAG_INLINE OAG_CONSTEXPR AttributeID &operator=(const AttributeID &) noexcept = default; - OG_INLINE OG_CONSTEXPR + OAG_INLINE OAG_CONSTEXPR AttributeID &operator=(AttributeID &&) noexcept = default; - OG_INLINE OG_CONSTEXPR - const bool isDirect() const OG_NOEXCEPT { + OAG_INLINE OAG_CONSTEXPR + const bool isDirect() const OAG_NOEXCEPT { return getKind() == Kind::Direct; } - OG_INLINE OG_CONSTEXPR - const bool isIndirect() const OG_NOEXCEPT { + OAG_INLINE OAG_CONSTEXPR + const bool isIndirect() const OAG_NOEXCEPT { return getKind() == Kind::Indirect; } - OG_INLINE OG_CONSTEXPR - const bool isNull() const OG_NOEXCEPT { + OAG_INLINE OAG_CONSTEXPR + const bool isNull() const OAG_NOEXCEPT { return getKind() == Kind::Null; } - OG_INLINE OG_CONSTEXPR - const void checkIsDirect() const OG_NOEXCEPT { + OAG_INLINE OAG_CONSTEXPR + const void checkIsDirect() const OAG_NOEXCEPT { if (!isDirect()) { - OG::precondition_failure("non-direct attribute id: %u", _rawValue); + OAG::precondition_failure("non-direct attribute id: %u", _rawValue); } } }; diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Attribute/AttributeType.hpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Attribute/AttributeType.hpp new file mode 100644 index 00000000..bfadcac6 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Attribute/AttributeType.hpp @@ -0,0 +1,16 @@ +// +// AttributeType.hpp +// OpenAttributeGraphCxx + +#ifndef AttributeType_hpp +#define AttributeType_hpp + +#include +#include + +namespace OAG { +struct AttributeType { + OAGAttributeType storage; +}; +} +#endif /* AttributeType_hpp */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Comparison/OAGComparisonPrivate.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Comparison/OAGComparisonPrivate.h new file mode 100644 index 00000000..dd8c35c4 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Comparison/OAGComparisonPrivate.h @@ -0,0 +1,31 @@ +// +// OAGComparisonPrivate.h +// OpenAttributeGraphCxx +// +// Audited for 6.5.1 +// Status: Complete + +#ifndef OAGComparisonPrivate_h +#define OAGComparisonPrivate_h + +#include +#include +#include + +OAG_ASSUME_NONNULL_BEGIN + +OAG_EXTERN_C_BEGIN + +typedef struct OAGComparisonStateStorage { + const void *destination; + const void *source; + OAGFieldRange field_range; + OAGTypeID field_type; +} OAGComparisonStateStorage; + +OAG_EXTERN_C_END + +OAG_ASSUME_NONNULL_END + +#endif /* OAGComparisonPrivate_h */ + diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Data/ClosureFunction.hpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Data/ClosureFunction.hpp new file mode 100644 index 00000000..8fa23678 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Data/ClosureFunction.hpp @@ -0,0 +1,74 @@ +// +// ClosureFunction.hpp +// OpenAttributeGraphCxx + +#ifndef ClosureFunction_hpp +#define ClosureFunction_hpp + +#include +#include + +OAG_ASSUME_NONNULL_BEGIN + +namespace OAG { +template +class ClosureFunction final { +public: + typedef const void * _Nullable Context; + typedef const ReturnType (* _Nullable Callable)(Context OAG_SWIFT_CONTEXT, Args...) OAG_SWIFT_CC(swift); + + OAG_INLINE OAG_CONSTEXPR + ClosureFunction(Callable function, Context context) OAG_NOEXCEPT : + _function(function), + _context(context) { + } + + OAG_INLINE OAG_CONSTEXPR + ClosureFunction(std::nullptr_t) OAG_NOEXCEPT : + _function(nullptr), + _context(nullptr) { + } + + OAG_INLINE + ~ClosureFunction() noexcept { + } + + OAG_INLINE OAG_CONSTEXPR + ClosureFunction(const ClosureFunction &value) OAG_NOEXCEPT : + _function(value._function), + _context(value._context) { + } + + OAG_INLINE OAG_CONSTEXPR + explicit operator bool() const OAG_NOEXCEPT { + return _function != nullptr; + } + + OAG_INLINE OAG_CONSTEXPR + bool operator==(const ClosureFunction &rhs) const OAG_NOEXCEPT { + return _function == rhs._function && _context == rhs._context; + } + + OAG_INLINE OAG_CONSTEXPR + bool operator==(std::nullptr_t) const OAG_NOEXCEPT { + return _function == nullptr; + } + + OAG_INLINE OAG_CONSTEXPR + bool operator!=(std::nullptr_t) const OAG_NOEXCEPT { + return _function != nullptr; + } + + OAG_INLINE OAG_CONSTEXPR + const ReturnType operator()(Args... args) const OAG_NOEXCEPT { + return _function(_context, std::forward(args)...); + } +private: + Callable _function; + Context _context; +}; +} + +OAG_ASSUME_NONNULL_END + +#endif /* ClosureFunction_hpp */ diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Data/page.hpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Data/page.hpp similarity index 65% rename from Sources/OpenGraphCxx/include/OpenGraphCxx/Data/page.hpp rename to Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Data/page.hpp index 8d197d2e..0618fb3e 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Data/page.hpp +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Data/page.hpp @@ -1,14 +1,14 @@ // // page.hpp -// OpenGraphCxx +// OpenAttributeGraphCxx #ifndef page_hpp #define page_hpp -#include -#include +#include +#include -namespace OG { +namespace OAG { namespace data { class zone; @@ -22,6 +22,6 @@ struct page { }; /* page */ } /* data */ -} /* OG */ +} /* OAG */ #endif /* page_hpp */ diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Data/page_const.hpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Data/page_const.hpp similarity index 80% rename from Sources/OpenGraphCxx/include/OpenGraphCxx/Data/page_const.hpp rename to Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Data/page_const.hpp index 516c553d..b8155418 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Data/page_const.hpp +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Data/page_const.hpp @@ -1,13 +1,13 @@ // // page_const.hpp -// OpenGraphCxx +// OpenAttributeGraphCxx #ifndef page_const_hpp #define page_const_hpp -#include +#include -namespace OG { +namespace OAG { namespace data { constexpr const uint32_t page_mask_bits = 9; @@ -22,7 +22,7 @@ constexpr const uint32_t page_mask = page_size - 1; constexpr const uintptr_t page_alignment = ~page_mask; } /* data */ -} /* OG */ +} /* OAG */ #endif /* page_const_hpp */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Data/ptr.hpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Data/ptr.hpp new file mode 100644 index 00000000..9673cb58 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Data/ptr.hpp @@ -0,0 +1,104 @@ +// +// ptr.hpp +// OpenAttributeGraphCxx +// +// Status: Complete +// Modified based Compute code + +#ifndef ptr_hpp +#define ptr_hpp + +#include +#include +#include +#include + +OAG_ASSUME_NONNULL_BEGIN + +namespace OAG { +namespace data { + +struct page; + +template class ptr { +public: + using element_type = T; + using difference_type = uint32_t; + +public: + OAG_INLINE OAG_CONSTEXPR ptr(difference_type offset = 0) : _offset(offset){}; + OAG_INLINE OAG_CONSTEXPR ptr(std::nullptr_t){}; + + // FIXME: this should be put into table API + OAG_INLINE + element_type *_Nonnull get(vm_address_t base = shared_table().data_base()) const OAG_NOEXCEPT { + assert(_offset != 0); + return reinterpret_cast(base + _offset); + } + + OAG_INLINE OAG_CONSTEXPR + ptr page_ptr() const OAG_NOEXCEPT { return ptr(_offset & page_alignment); } + + OAG_INLINE OAG_CONSTEXPR + uint32_t page_index() const OAG_NOEXCEPT { return (_offset >> page_mask_bits) - 1; } + + OAG_INLINE OAG_CONSTEXPR + difference_type page_relative_offset() const OAG_NOEXCEPT { return _offset & page_mask; } + + template ptr aligned(difference_type alignment_mask = sizeof(difference_type) - 1) const { + return ptr((_offset + alignment_mask) & ~alignment_mask); + }; + + OAG_INLINE OAG_CONSTEXPR + operator bool() const OAG_NOEXCEPT { return _offset != 0; }; + + OAG_INLINE OAG_CONSTEXPR + std::add_lvalue_reference_t operator*() const OAG_NOEXCEPT { return *get(); }; + + OAG_INLINE OAG_CONSTEXPR + T *_Nonnull operator->() const OAG_NOEXCEPT { return get(); }; + + OAG_INLINE OAG_CONSTEXPR + bool operator==(std::nullptr_t) const OAG_NOEXCEPT { return _offset == 0; }; + + OAG_INLINE OAG_CONSTEXPR + bool operator!=(std::nullptr_t) const OAG_NOEXCEPT { return _offset != 0; }; + + OAG_INLINE OAG_CONSTEXPR + bool operator<(difference_type offset) const OAG_NOEXCEPT { return _offset < offset; }; + + OAG_INLINE OAG_CONSTEXPR + bool operator<=(difference_type offset) const OAG_NOEXCEPT { return _offset <= offset; }; + + OAG_INLINE OAG_CONSTEXPR + bool operator>(difference_type offset) const OAG_NOEXCEPT { return _offset > offset; }; + + OAG_INLINE OAG_CONSTEXPR + bool operator>=(difference_type offset) const OAG_NOEXCEPT { return _offset >= offset; }; + + template + OAG_INLINE OAG_CONSTEXPR + ptr operator+(difference_type shift) const OAG_NOEXCEPT { return ptr(_offset + shift); }; + + template + OAG_INLINE OAG_CONSTEXPR + ptr operator-(difference_type shift) const OAG_NOEXCEPT { return ptr(_offset - shift); }; + + template + OAG_INLINE OAG_CONSTEXPR + difference_type operator-(const ptr &other) const OAG_NOEXCEPT { + return _offset - other._offset; + }; +private: + difference_type _offset; + + template friend class ptr; + friend class table; +}; /* ptr */ + +} /* data */ +} /* OAG */ + +OAG_ASSUME_NONNULL_END + +#endif /* ptr_hpp */ diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Data/table.hpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Data/table.hpp similarity index 53% rename from Sources/OpenGraphCxx/include/OpenGraphCxx/Data/table.hpp rename to Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Data/table.hpp index 01088232..31873c32 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Data/table.hpp +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Data/table.hpp @@ -1,14 +1,14 @@ // // table.hpp -// OpenGraphCxx +// OpenAttributeGraphCxx #ifndef table_hpp #define table_hpp -#include -#include +#include +#include -#if OG_TARGET_OS_DARWIN +#if OAG_TARGET_OS_DARWIN #include #else typedef uintptr_t vm_size_t; @@ -16,13 +16,13 @@ typedef uintptr_t vm_offset_t; typedef vm_offset_t vm_address_t; #endif #include -#if OG_TARGET_OS_DARWIN +#if OAG_TARGET_OS_DARWIN #include #endif -OG_ASSUME_NONNULL_BEGIN +OAG_ASSUME_NONNULL_BEGIN -namespace OG { +namespace OAG { namespace data { class zone; class page; @@ -32,65 +32,65 @@ class table { public: class malloc_zone_deleter { void operator()(void* ptr) const { - #if OG_TARGET_OS_DARWIN + #if OAG_TARGET_OS_DARWIN malloc_zone_free(_malloc_zone, ptr); #endif } }; - #if OG_TARGET_OS_DARWIN + #if OAG_TARGET_OS_DARWIN static malloc_zone_t *_malloc_zone; #endif public: static table &ensure_shared(); - OG_INLINE OG_CONSTEXPR - vm_address_t data_base() const OG_NOEXCEPT { return _data_base; }; + OAG_INLINE OAG_CONSTEXPR + vm_address_t data_base() const OAG_NOEXCEPT { return _data_base; }; - OG_INLINE OG_CONSTEXPR - vm_address_t region_base() const OG_NOEXCEPT { return _region_base; }; + OAG_INLINE OAG_CONSTEXPR + vm_address_t region_base() const OAG_NOEXCEPT { return _region_base; }; - OG_INLINE OG_CONSTEXPR - void lock() const OG_NOEXCEPT { - #if OG_TARGET_OS_DARWIN + OAG_INLINE OAG_CONSTEXPR + void lock() const OAG_NOEXCEPT { + #if OAG_TARGET_OS_DARWIN return os_unfair_lock_lock(&_lock); #endif }; - OG_INLINE OG_CONSTEXPR - void unlock() const OG_NOEXCEPT { - #if OG_TARGET_OS_DARWIN + OAG_INLINE OAG_CONSTEXPR + void unlock() const OAG_NOEXCEPT { + #if OAG_TARGET_OS_DARWIN return os_unfair_lock_unlock(&_lock); #endif }; - OG_INLINE OG_CONSTEXPR - uint32_t region_capacity() const OG_NOEXCEPT { return _region_capacity; }; + OAG_INLINE OAG_CONSTEXPR + uint32_t region_capacity() const OAG_NOEXCEPT { return _region_capacity; }; - OG_INLINE OG_CONSTEXPR - uint32_t data_capacity() const OG_NOEXCEPT { return _data_capacity; }; + OAG_INLINE OAG_CONSTEXPR + uint32_t data_capacity() const OAG_NOEXCEPT { return _data_capacity; }; - OG_INLINE OG_CONSTEXPR - uint32_t used_pages_num() const OG_NOEXCEPT { return _used_pages_num; }; + OAG_INLINE OAG_CONSTEXPR + uint32_t used_pages_num() const OAG_NOEXCEPT { return _used_pages_num; }; - OG_INLINE OG_CONSTEXPR - uint32_t reusable_pages_num() const OG_NOEXCEPT { return _reusable_pages_num; }; + OAG_INLINE OAG_CONSTEXPR + uint32_t reusable_pages_num() const OAG_NOEXCEPT { return _reusable_pages_num; }; - OG_INLINE OG_CONSTEXPR - uint32_t map_search_start() const OG_NOEXCEPT { return _map_search_start; }; + OAG_INLINE OAG_CONSTEXPR + uint32_t map_search_start() const OAG_NOEXCEPT { return _map_search_start; }; - OG_INLINE OG_CONSTEXPR - uint32_t zones_num() const OG_NOEXCEPT { return _zones_num; }; + OAG_INLINE OAG_CONSTEXPR + uint32_t zones_num() const OAG_NOEXCEPT { return _zones_num; }; - OG_INLINE OG_CONSTEXPR + OAG_INLINE OAG_CONSTEXPR uint32_t make_zone_id() { _zones_num += 1; return _zones_num; } template - OG_INLINE + OAG_INLINE void assert_valid(const ptr& p) const { if (data_capacity() <= p._offset) { precondition_failure("invalid data offset: %u", p._offset); @@ -99,25 +99,25 @@ class table { table(); - void grow_region() OG_NOEXCEPT; + void grow_region() OAG_NOEXCEPT; - void make_pages_reusable(uint32_t page_index, bool reusable) OG_NOEXCEPT; + void make_pages_reusable(uint32_t page_index, bool reusable) OAG_NOEXCEPT; - ptr alloc_page(zone *zone, uint32_t size) OG_NOEXCEPT; + ptr alloc_page(zone *zone, uint32_t size) OAG_NOEXCEPT; - void dealloc_page_locked(ptr page) OG_NOEXCEPT; + void dealloc_page_locked(ptr page) OAG_NOEXCEPT; - OG_INLINE OG_CONSTEXPR - uint64_t raw_page_seed(ptr page) const OG_NOEXCEPT; + OAG_INLINE OAG_CONSTEXPR + uint64_t raw_page_seed(ptr page) const OAG_NOEXCEPT; - void print() const OG_NOEXCEPT; + void print() const OAG_NOEXCEPT; private: /// _region_base - page_size vm_address_t _data_base; vm_address_t _region_base; - #if OG_TARGET_OS_DARWIN + #if OAG_TARGET_OS_DARWIN mutable os_unfair_lock _lock = OS_UNFAIR_LOCK_INIT; #endif @@ -137,7 +137,7 @@ class table { using remapped_region = std::pair; vector _remapped_regions = {}; - OG_CONSTEXPR static unsigned int pages_per_map = 64; + OAG_CONSTEXPR static unsigned int pages_per_map = 64; using page_map_type = std::bitset; vector _page_maps = {}; @@ -146,14 +146,14 @@ class table { static uint8_t _shared_table_bytes[sizeof(table) / sizeof(uint8_t)] = {}; -OG_INLINE +OAG_INLINE static table &shared_table() { return *reinterpret_cast(&_shared_table_bytes); } } /* data */ -} /* OG */ +} /* OAG */ -OG_ASSUME_NONNULL_END +OAG_ASSUME_NONNULL_END #endif /* table_hpp */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Data/zone.hpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Data/zone.hpp new file mode 100644 index 00000000..4e618adc --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Data/zone.hpp @@ -0,0 +1,95 @@ +// +// zone.hpp +// OpenAttributeGraphCxx + +#ifndef zone_hpp +#define zone_hpp + +#include +#include + +namespace OAG { +namespace data { + +class zone { +public: + class info { + public: + OAG_INLINE OAG_CONSTEXPR + info() OAG_NOEXCEPT : _value(0) {}; + + OAG_INLINE OAG_CONSTEXPR + info(uint32_t value) OAG_NOEXCEPT : _value(value){}; + + OAG_INLINE OAG_CONSTEXPR + info(uint32_t zone_id, bool deleted) OAG_NOEXCEPT : _value((zone_id & zone_id_mask) | (deleted ? 1 : 0)) {}; + + OAG_INLINE OAG_CONSTEXPR + uint32_t value() const OAG_NOEXCEPT { return _value; }; + + OAG_INLINE OAG_CONSTEXPR + uint32_t zone_id() const OAG_NOEXCEPT { return _value & zone_id_mask; }; + + OAG_INLINE OAG_CONSTEXPR + bool is_deleted() const OAG_NOEXCEPT { return (_value & deleted) != 0; }; + + OAG_INLINE OAG_CONSTEXPR + info with_zone_id(uint32_t zone_id) const OAG_NOEXCEPT { + return info((_value & ~zone_id_mask) | (zone_id & zone_id_mask), is_deleted()); + }; + + OAG_INLINE OAG_CONSTEXPR + info with_deleted(bool deleted) const OAG_NOEXCEPT { + return info(zone_id(), deleted); + } + private: + enum : uint32_t { + zone_id_mask = 0x7fffffff, + deleted = 0x80000000, + }; + uint32_t _value; + }; /* info */ +public: +// zone() OAG_NOEXCEPT = default; +// ~zone() OAG_NOEXCEPT; + + OAG_INLINE OAG_CONSTEXPR + auto& malloc_buffers() const OAG_NOEXCEPT { return _malloc_buffers; }; + + OAG_INLINE OAG_CONSTEXPR + ptr last_page() const OAG_NOEXCEPT { return _last_page; }; + + OAG_INLINE OAG_CONSTEXPR + info info() const OAG_NOEXCEPT { return _info; }; + + OAG_INLINE + void clear(); + + ptr alloc_slow(uint32_t size, uint32_t alignment_mask) OAG_NOEXCEPT; + + void *alloc_persistent(size_t size) OAG_NOEXCEPT; + + void realloc_bytes(ptr *buffer, uint32_t size, uint32_t new_size, uint32_t alignment_mask) OAG_NOEXCEPT; + +// ptr alloc_bytes(uint32_t size, uint32_t alignment_mask); + ptr alloc_bytes_recycle(uint32_t size, uint32_t alignment_mask) OAG_NOEXCEPT; + + // Printing + void print() const OAG_NOEXCEPT; + + void print_header() const OAG_NOEXCEPT; +private: + typedef struct _bytes_info { + ptr next; + uint32_t size; + } bytes_info; + vector, 0, uint32_t> _malloc_buffers; + ptr _last_page; + ptr _free_bytes; + class info _info; +}; /* zone */ + +} /* data */ +} /* OAG */ + +#endif /* zone_hpp */ diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/DebugServer/DebugServer.hpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/DebugServer/DebugServer.hpp similarity index 77% rename from Sources/OpenGraphCxx/include/OpenGraphCxx/DebugServer/DebugServer.hpp rename to Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/DebugServer/DebugServer.hpp index eff658c0..3f4e7260 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/DebugServer/DebugServer.hpp +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/DebugServer/DebugServer.hpp @@ -1,28 +1,28 @@ // // DebugServer.hpp -// OpenGraphCxx +// OpenAttributeGraphCxx // // Audited for 6.5.1 // Status: Complete -#ifndef OPENGRAPH_CXX_DEBUGSERVER_DEBUGSERVER_HPP -#define OPENGRAPH_CXX_DEBUGSERVER_DEBUGSERVER_HPP +#ifndef OPENATTRIBUTEGRAPH_CXX_DEBUGSERVER_DEBUGSERVER_HPP +#define OPENATTRIBUTEGRAPH_CXX_DEBUGSERVER_DEBUGSERVER_HPP -#include -#if OG_TARGET_OS_DARWIN -#include -#include +#include +#if OAG_TARGET_OS_DARWIN +#include +#include #include #include #include -OG_ASSUME_NONNULL_BEGIN +OAG_ASSUME_NONNULL_BEGIN -OG_IMPLICIT_BRIDGING_ENABLED +OAG_IMPLICIT_BRIDGING_ENABLED /// Message header structure for debug server communication protocol. /// Contains metadata for messages exchanged between the debug server and clients. -typedef struct OG_SWIFT_NAME(DebugServerMessageHeader) OGDebugServerMessageHeader { +typedef struct OAG_SWIFT_NAME(DebugServerMessageHeader) OAGDebugServerMessageHeader { /// Authentication token for the message uint32_t token; /// Reserved field for future use @@ -31,35 +31,35 @@ typedef struct OG_SWIFT_NAME(DebugServerMessageHeader) OGDebugServerMessageHeade uint32_t length; /// Additional reserved field for protocol extensions uint32_t unknown2; -} OGDebugServerMessageHeader; /* OGDebugServerMessageHeader */ +} OAGDebugServerMessageHeader; /* OAGDebugServerMessageHeader */ -namespace OG { +namespace OAG { -/// Debug server for OpenGraph runtime inspection and debugging. +/// Debug server for OpenAttributeGraph runtime inspection and debugging. /// /// The DebugServer provides a network interface for external tools to connect -/// and inspect the internal state of OpenGraph. It supports both listening for +/// and inspect the internal state of OpenAttributeGraph. It supports both listening for /// incoming connections and handling client requests for graph data. /// -/// The server operates in different modes as specified by OGDebugServerMode +/// The server operates in different modes as specified by OAGDebugServerMode /// and manages multiple concurrent client connections using GCD dispatch sources. class DebugServer { public: /// Creates a new debug server instance with the specified mode. /// /// @param mode The operating mode for the debug server - DebugServer(OGDebugServerMode mode); + DebugServer(OAGDebugServerMode mode); /// Move constructor for transferring ownership of server resources. /// /// @param other The DebugServer instance to move from - DebugServer(DebugServer&& other) OG_NOEXCEPT; + DebugServer(DebugServer&& other) OAG_NOEXCEPT; /// Move assignment operator for transferring ownership of server resources. /// /// @param other The DebugServer instance to move from /// @return Reference to this instance after the move - DebugServer& operator=(DebugServer&& other) OG_NOEXCEPT; + DebugServer& operator=(DebugServer&& other) OAG_NOEXCEPT; /// Deleted copy constructor to prevent accidental copying. DebugServer(const DebugServer&) = delete; @@ -90,19 +90,19 @@ class DebugServer { /// Returns the shared debug server instance. /// /// @return Pointer to the shared server, or nullptr if none exists - static OG_INLINE DebugServer *shared_server() { return _shared_server; } + static OAG_INLINE DebugServer *shared_server() { return _shared_server; } /// Checks if a shared debug server instance exists. /// /// @return true if a shared server is active, false otherwise - static OG_INLINE bool has_shared_server() { return _shared_server != nullptr; } + static OAG_INLINE bool has_shared_server() { return _shared_server != nullptr; } /// Starts a new shared debug server with the specified mode. /// /// @param mode Configuration flags controlling server behavior. - /// Must include OGDebugServerModeValid for basic operation. + /// Must include OAGDebugServerModeValid for basic operation. /// @return Pointer to the started server, or nullptr if startup failed - static DebugServer *_Nullable start(OGDebugServerMode mode); + static DebugServer *_Nullable start(OAGDebugServerMode mode); /// Stops the shared debug server and releases all resources. /// This will close all client connections and shut down the server. @@ -144,7 +144,7 @@ class DebugServer { /// @param header Reference to store the received message header /// @param data Existing data buffer to append to, or nullptr for new data /// @return CFDataRef containing the complete message, or nullptr on error - CFDataRef _Nullable receive(Connection *connection, OGDebugServerMessageHeader &header, CFDataRef data); + CFDataRef _Nullable receive(Connection *connection, OAGDebugServerMessageHeader &header, CFDataRef data); /// Closes and removes the specified client connection. /// @@ -161,25 +161,25 @@ class DebugServer { uint32_t port; ///< Server port number uint32_t token; ///< Authentication token _Nullable dispatch_source_t source; ///< GCD source for accepting connections - OG::vector, 0, u_long> connections; ///< Active client connections + OAG::vector, 0, u_long> connections; ///< Active client connections static DebugServer *_Nullable _shared_server; ///< Global shared server instance }; /* DebugServer */ -} /* OG */ +} /* OAG */ /// C-compatible storage wrapper for DebugServer instances. /// /// This structure provides a C-compatible interface for storing /// DebugServer objects in contexts where C++ objects cannot be /// used directly. -typedef struct OGDebugServerStorage { - OG::DebugServer debugServer; ///< The wrapped DebugServer instance -} OGDebugServerStorage; +typedef struct OAGDebugServerStorage { + OAG::DebugServer debugServer; ///< The wrapped DebugServer instance +} OAGDebugServerStorage; -OG_IMPLICIT_BRIDGING_DISABLED +OAG_IMPLICIT_BRIDGING_DISABLED -OG_ASSUME_NONNULL_END +OAG_ASSUME_NONNULL_END -#endif /* OG_TARGET_OS_DARWIN */ -#endif /* OPENGRAPH_CXX_DEBUGSERVER_DEBUGSERVER_HPP */ +#endif /* OAG_TARGET_OS_DARWIN */ +#endif /* OPENATTRIBUTEGRAPH_CXX_DEBUGSERVER_DEBUGSERVER_HPP */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Graph/Graph.hpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Graph/Graph.hpp new file mode 100644 index 00000000..37dbc0d8 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Graph/Graph.hpp @@ -0,0 +1,189 @@ +// +// Graph.hpp +// OpenAttributeGraphCxx + + +#ifndef Graph_hpp +#define Graph_hpp + +#include +#include +#include +#include +#include + +OAG_ASSUME_NONNULL_BEGIN + +#if OAG_OBJC_FOUNDATION +@class NSDictionary; +#endif /* OAG_OBJC_FOUNDATION */ + +namespace OAG { +class Graph final { +public: + class Context final { + private: + Graph * _Nullable _graph; + const void * _Nullable _context; + OAGUniqueID _id; + ClosureFunction _invalidation_callback; + ClosureFunction _update_callback; + uint64_t unknown1; + uint32_t unknown2; + uint32_t unknown3; + bool _isInvalid; + public: + static Context &from_cf(OAGGraphRef graph) OAG_NOEXCEPT; + Context(Graph &graph) OAG_NOEXCEPT; + ~Context() OAG_NOEXCEPT; + + const bool thread_is_updating() const OAG_NOEXCEPT; + + OAG_INLINE OAG_CONSTEXPR + const bool has_graph() const OAG_NOEXCEPT { + return _graph != nullptr; + } + + OAG_INLINE OAG_CONSTEXPR + const Graph &get_graph() const OAG_NOEXCEPT { + return *_graph; + } + + OAG_INLINE OAG_CONSTEXPR + Graph &get_graph() OAG_NOEXCEPT { + return *_graph; + } + + OAG_INLINE OAG_CONSTEXPR + const void * _Nullable get_context() const OAG_NOEXCEPT { + return _context; + } + + OAG_INLINE OAG_CONSTEXPR + void set_context(const void * _Nullable context) OAG_NOEXCEPT { + _context = context; + } + + OAG_INLINE + void set_invalidation_callback(ClosureFunction invalidation_callback) OAG_NOEXCEPT { + _invalidation_callback = invalidation_callback; + } + + OAG_INLINE + void set_update_callback(ClosureFunction update_callback) OAG_NOEXCEPT { + _update_callback = update_callback; + } + + OAG_INLINE OAG_CONSTEXPR + const bool isInvalid() const OAG_NOEXCEPT { + return _isInvalid; + } + + OAG_INLINE OAG_CONSTEXPR + void setInvalid(bool invalid) OAG_NOEXCEPT { + _isInvalid = invalid; + } + }; + #if OAG_TARGET_CPU_WASM32 + static_assert(sizeof(Context) == 0x38); + #else + static_assert(sizeof(Context) == 0x50); + #endif +private: + static pthread_key_t _current_update_key; + uint64_t _counter_4; + uint32_t _counter_8; + uint64_t _counter_0; + bool _counter_9; + uint64_t _counter_5; + uint64_t _counter_1; + uint64_t _counter_2; + uint64_t _counter_10; + uint64_t _counter_3; +public: + #if OAG_OBJC_FOUNDATION + static CFTypeRef description(const Graph * _Nullable graph, NSDictionary* dic); + #endif /* OAG_OBJC_FOUNDATION */ + + // MARK: - pthread related + + OAG_INLINE OAG_CONSTEXPR + const static pthread_key_t& current_key() OAG_NOEXCEPT { + return _current_update_key; + } + + Graph() OAG_NOEXCEPT; + + const void value_mark_all() const OAG_NOEXCEPT; + + static void all_start_profiling(uint32_t) OAG_NOEXCEPT; + static void all_stop_profiling() OAG_NOEXCEPT; + void start_profiling(uint32_t) OAG_NOEXCEPT; + void stop_profiling() OAG_NOEXCEPT; + + #if OAG_OBJC_FOUNDATION + static void write_to_file(const Graph * _Nullable, const char * _Nullable, uint8_t) OAG_NOEXCEPT; + #endif + + const bool thread_is_updating() const OAG_NOEXCEPT; + const bool is_context_updating(const OAG::Graph::Context&) const OAG_NOEXCEPT; + + OAG_INLINE OAG_CONSTEXPR + const uint64_t get_counter_4() const OAG_NOEXCEPT { + return _counter_4; + } + + OAG_INLINE OAG_CONSTEXPR + const uint32_t get_counter_8() const OAG_NOEXCEPT { + return _counter_8; + } + + OAG_INLINE OAG_CONSTEXPR + const uint64_t get_counter_0() const OAG_NOEXCEPT { + return _counter_0; + } + + OAG_INLINE OAG_CONSTEXPR + const bool get_counter_9() const OAG_NOEXCEPT { + return _counter_9; + } + + OAG_INLINE OAG_CONSTEXPR + const uint64_t get_counter_5() const OAG_NOEXCEPT { + return _counter_5; + } + + OAG_INLINE OAG_CONSTEXPR + const uint64_t get_counter_1() const OAG_NOEXCEPT { + return _counter_1; + } + + OAG_INLINE OAG_CONSTEXPR + const uint64_t get_counter_2() const OAG_NOEXCEPT { + return _counter_2; + } + + OAG_INLINE OAG_CONSTEXPR + const uint64_t get_counter_10() const OAG_NOEXCEPT { + return _counter_10; + } + + OAG_INLINE OAG_CONSTEXPR + const uint64_t get_counter_3() const OAG_NOEXCEPT { + return _counter_3; + } +}; /* Graph */ +} /* OAG */ + +struct OAGGraphStorage { + CFRuntimeBase base; + OAG::Graph::Context context; +}; + +struct OAGGraphContextStorage { + OAG::Graph::Context context; +}; + +OAG_ASSUME_NONNULL_END + +#endif /* Graph_hpp */ diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Graph/Subgraph.hpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Graph/Subgraph.hpp new file mode 100644 index 00000000..b1d6eb37 --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Graph/Subgraph.hpp @@ -0,0 +1,109 @@ +// +// Subgraph.hpp +// OpenAttributeGraphCxx + +#ifndef Subgraph_hpp +#define Subgraph_hpp + +#include +#include +#include +#include +#include +#include + +typedef struct OAG_BRIDGED_TYPE(id) OAGSubgraphStorage * OAGSubgraphRef; + +namespace OAG { +class SubgraphObject; + +class Subgraph final { +private: + OAGSubgraphRef _cf_subgraph; + OAGGraphContextStorage& _context; + // TODO + bool _isInvalid; + static pthread_key_t _current_subgraph_key; +public: + // MARK: - CF related + + static Subgraph *from_cf(OAGSubgraphRef cf_subgraph) OAG_NOEXCEPT; + + OAGSubgraphRef to_cf() const OAG_NOEXCEPT { + return _cf_subgraph; + } + + // MARK: - pthread related + + OAG_INLINE + const static void make_current_subgraph_key() OAG_NOEXCEPT { + pthread_key_create(&_current_subgraph_key, nullptr); + } + + OAG_INLINE OAG_CONSTEXPR + const static pthread_key_t& current_key() OAG_NOEXCEPT { + return _current_subgraph_key; + } + + OAG_INLINE OAG_CONSTEXPR + static Subgraph *get_current() OAG_NOEXCEPT { + return (OAG::Subgraph*)pthread_getspecific(OAG::Subgraph::current_key()); + } + + OAG_INLINE OAG_CONSTEXPR + static int set_current(Subgraph *subgraph) OAG_NOEXCEPT { + return pthread_setspecific(OAG::Subgraph::current_key(), subgraph); + } + + // MARK: - Public API + void clear_object() const OAG_NOEXCEPT; + void invalidate_and_delete_(bool) const OAG_NOEXCEPT; + + void apply(OAGAttributeFlags flags, OAG::ClosureFunction body) const OAG_NOEXCEPT; + + OAGUniqueID add_observer(OAG::ClosureFunction observer) const OAG_NOEXCEPT; + + void begin_tree(OAG::AttributeID id, OAG::swift::metadata const *type, uint32_t flags) const OAG_NOEXCEPT; + void add_tree_value(OAG::AttributeID id, OAG::swift::metadata const *type, const char* key, uint32_t flags) const OAG_NOEXCEPT; + void end_tree(OAG::AttributeID id) const OAG_NOEXCEPT; + + // MARK: - Init and deinit + + Subgraph(SubgraphObject*, OAG::Graph::Context&, OAG::AttributeID); + + // MARK: - Getter and setter + + OAG_INLINE OAG_CONSTEXPR + const OAGGraphContextRef get_context() const OAG_NOEXCEPT { + return &_context; + } + + OAG_INLINE OAG_CONSTEXPR + OAGGraphContextRef get_context() OAG_NOEXCEPT { + return &_context; + } + + OAG_INLINE OAG_CONSTEXPR + const bool isInvalid() const OAG_NOEXCEPT { + return _isInvalid; + } + + OAG_INLINE OAG_CONSTEXPR + void setInvalid(bool invalid) OAG_NOEXCEPT { + _isInvalid = invalid; + } +}; /* Subgraph */ +} /* OAG */ + +struct OAGSubgraphStorage { + CFRuntimeBase base; + OAG::Subgraph *subgraph; +}; + +namespace OAG { +class SubgraphObject final { + OAGSubgraphStorage storage; +}; +} + +#endif /* Subgraph_hpp */ diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Misc/assert.hpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Misc/assert.hpp similarity index 69% rename from Sources/OpenGraphCxx/include/OpenGraphCxx/Misc/assert.hpp rename to Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Misc/assert.hpp index ca05e342..622046ee 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Misc/assert.hpp +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Misc/assert.hpp @@ -1,15 +1,15 @@ // // assert.hpp -// OpenGraphCxx +// OpenAttributeGraphCxx #ifndef assert_hpp #define assert_hpp -#include +#include -namespace OG { +namespace OAG { void precondition_failure(const char *format, ...) __cold __dead2; void non_fatal_precondition_failure(const char *format, ...); -} /* OG */ +} /* OAG */ #endif /* assert_hpp */ diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Misc/env.hpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Misc/env.hpp similarity index 70% rename from Sources/OpenGraphCxx/include/OpenGraphCxx/Misc/env.hpp rename to Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Misc/env.hpp index 826efd89..d1d6bfe6 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Misc/env.hpp +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Misc/env.hpp @@ -1,14 +1,14 @@ // // env.hpp -// OpenGraphCxx +// OpenAttributeGraphCxx #ifndef env_hpp #define env_hpp -#include +#include -namespace OG { -OG_INLINE +namespace OAG { +OAG_INLINE int get_env(const char *name) { char *value = getenv(name); if (value) { diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Misc/log.hpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Misc/log.hpp similarity index 52% rename from Sources/OpenGraphCxx/include/OpenGraphCxx/Misc/log.hpp rename to Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Misc/log.hpp index 4094182c..56d6e9bc 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Misc/log.hpp +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Misc/log.hpp @@ -1,23 +1,23 @@ // // log.hpp -// OpenGraphCxx +// OpenAttributeGraphCxx // // Audited for 2021 Release #ifndef log_hpp #define log_hpp -#include +#include -#if OG_TARGET_OS_DARWIN +#if OAG_TARGET_OS_DARWIN #include -namespace OG { +namespace OAG { os_log_t misc_log(); os_log_t error_log(); -} /* OG */ +} /* OAG */ -#endif /* OG_TARGET_OS_DARWIN */ +#endif /* OAG_TARGET_OS_DARWIN */ #endif /* log_hpp */ diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Runtime/metadata.hpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Runtime/metadata.hpp similarity index 67% rename from Sources/OpenGraphCxx/include/OpenGraphCxx/Runtime/metadata.hpp rename to Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Runtime/metadata.hpp index 6826ab81..e369164f 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Runtime/metadata.hpp +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Runtime/metadata.hpp @@ -1,6 +1,6 @@ // // metadata.hpp -// OpenGraphCxx +// OpenAttributeGraphCxx // // Audited for iOS 18.0 // Status: WIP @@ -8,36 +8,36 @@ #ifndef metadata_hpp #define metadata_hpp -#include +#include -#ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED +#ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED #include #include using namespace swift; -#endif /* OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED */ +#endif /* OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED */ -namespace OG { +namespace OAG { namespace swift { -#ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED +#ifdef OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED class metadata: public Metadata { public: - OG_INLINE OG_CONSTEXPR - Metadata const* getType() const OG_NOEXCEPT { + OAG_INLINE OAG_CONSTEXPR + Metadata const* getType() const OAG_NOEXCEPT { return this; } - OG_INLINE OG_CONSTEXPR - TypeNamePair const name(bool qualified) const OG_NOEXCEPT { + OAG_INLINE OAG_CONSTEXPR + TypeNamePair const name(bool qualified) const OAG_NOEXCEPT { return swift_getTypeName(getType(), qualified); } - OG_INLINE OG_CONSTEXPR - MetadataKind const getKind() const OG_NOEXCEPT { + OAG_INLINE OAG_CONSTEXPR + MetadataKind const getKind() const OAG_NOEXCEPT { return getType()->getKind(); } - OG_INLINE OG_CONSTEXPR - TypeContextDescriptor const* descriptor() const OG_NOEXCEPT { + OAG_INLINE OAG_CONSTEXPR + TypeContextDescriptor const* descriptor() const OAG_NOEXCEPT { switch (getKind()) { case MetadataKind::Class: { const auto cls = static_cast(getType()); @@ -57,8 +57,8 @@ class metadata: public Metadata { } } - OG_INLINE OG_CONSTEXPR - TypeContextDescriptor const* nominal_descriptor() const OG_NOEXCEPT { + OAG_INLINE OAG_CONSTEXPR + TypeContextDescriptor const* nominal_descriptor() const OAG_NOEXCEPT { auto descriptor = this->descriptor(); if (descriptor == nullptr) { return nullptr; @@ -72,12 +72,12 @@ class metadata: public Metadata { } } - void append_description(CFMutableStringRef description) const OG_NOEXCEPT; -}; /* OG::swift::metadata */ + void append_description(CFMutableStringRef description) const OAG_NOEXCEPT; +}; /* OAG::swift::metadata */ #else class metadata {}; -#endif /* OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED */ -} /* OG::swift */ -} /* OG */ +#endif /* OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED */ +} /* OAG::swift */ +} /* OAG */ #endif /* metadata_hpp */ diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Util/cf_ptr.hpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Util/cf_ptr.hpp similarity index 57% rename from Sources/OpenGraphCxx/include/OpenGraphCxx/Util/cf_ptr.hpp rename to Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Util/cf_ptr.hpp index 59f78326..91e914dc 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Util/cf_ptr.hpp +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Util/cf_ptr.hpp @@ -1,17 +1,17 @@ // // cf_ptr.hpp -// OpenGraphCxx +// OpenAttributeGraphCxx // // Status: Complete // Modified based Compute code -#ifndef OPENGRAPH_CXX_UTIL_CF_PTR_HPP -#define OPENGRAPH_CXX_UTIL_CF_PTR_HPP +#ifndef OPENATTRIBUTEGRAPH_CXX_UTIL_CF_PTR_HPP +#define OPENATTRIBUTEGRAPH_CXX_UTIL_CF_PTR_HPP -#include +#include #include -OG_ASSUME_NONNULL_BEGIN +OAG_ASSUME_NONNULL_BEGIN namespace util { @@ -19,12 +19,12 @@ template class cf_ptr { private: CFTypeRef _storage; - static OG_INLINE CFTypeRef to_storage(T ref) { return (CFTypeRef)(ref); } - static OG_INLINE T from_storage(CFTypeRef storage) { return (T)storage; } + static OAG_INLINE CFTypeRef to_storage(T ref) { return (CFTypeRef)(ref); } + static OAG_INLINE T from_storage(CFTypeRef storage) { return (T)storage; } public: - OG_CONSTEXPR cf_ptr() OG_NOEXCEPT : _storage(nullptr) {} - OG_CONSTEXPR cf_ptr(std::nullptr_t) OG_NOEXCEPT : _storage(nullptr) {} + OAG_CONSTEXPR cf_ptr() OAG_NOEXCEPT : _storage(nullptr) {} + OAG_CONSTEXPR cf_ptr(std::nullptr_t) OAG_NOEXCEPT : _storage(nullptr) {} explicit cf_ptr(T ref) : _storage(to_storage(ref)) { if (_storage) { @@ -40,17 +40,17 @@ template class cf_ptr { // Copy and move constructors - cf_ptr(const cf_ptr &other) OG_NOEXCEPT : _storage(other._storage) { + cf_ptr(const cf_ptr &other) OAG_NOEXCEPT : _storage(other._storage) { if (_storage) { CFRetain(_storage); } }; - cf_ptr(cf_ptr &&other) OG_NOEXCEPT : _storage(std::exchange(other._storage, nullptr)) {}; + cf_ptr(cf_ptr &&other) OAG_NOEXCEPT : _storage(std::exchange(other._storage, nullptr)) {}; // Copy and move assignment operators - cf_ptr &operator=(const cf_ptr &other) OG_NOEXCEPT { + cf_ptr &operator=(const cf_ptr &other) OAG_NOEXCEPT { if (this != &other) { if (_storage) { CFRelease(_storage); @@ -63,7 +63,7 @@ template class cf_ptr { return *this; }; - cf_ptr &operator=(cf_ptr &&other) OG_NOEXCEPT { + cf_ptr &operator=(cf_ptr &&other) OAG_NOEXCEPT { if (this != &other) { if (_storage) { CFRelease(_storage); @@ -76,9 +76,9 @@ template class cf_ptr { // Modifiers - void reset() OG_NOEXCEPT { reset(nullptr); } + void reset() OAG_NOEXCEPT { reset(nullptr); } - void reset(T ref = nullptr) OG_NOEXCEPT { + void reset(T ref = nullptr) OAG_NOEXCEPT { if (_storage != ref) { if (_storage) { CFRelease(_storage); @@ -92,9 +92,9 @@ template class cf_ptr { // Observers - T get() const OG_NOEXCEPT { return from_storage(_storage); }; + T get() const OAG_NOEXCEPT { return from_storage(_storage); }; - explicit operator bool() const OG_NOEXCEPT { return _storage != nullptr; } + explicit operator bool() const OAG_NOEXCEPT { return _storage != nullptr; } }; /* class cf_ptr */ using cf_data_ptr = cf_ptr; @@ -102,6 +102,6 @@ using cf_mutable_data_ptr = cf_ptr; } /* namespace util */ -OG_ASSUME_NONNULL_END +OAG_ASSUME_NONNULL_END -#endif /* OPENGRAPH_CXX_UTIL_CF_PTR_HPP */ +#endif /* OPENATTRIBUTEGRAPH_CXX_UTIL_CF_PTR_HPP */ diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Util/free_deleter.hpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Util/free_deleter.hpp similarity index 52% rename from Sources/OpenGraphCxx/include/OpenGraphCxx/Util/free_deleter.hpp rename to Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Util/free_deleter.hpp index 820b2093..f5f110a7 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Util/free_deleter.hpp +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Util/free_deleter.hpp @@ -1,16 +1,16 @@ // // free_deleter.hpp -// OpenGraphCxx +// OpenAttributeGraphCxx // // Status: Complete // Modified based Compute code -#ifndef OPENGRAPH_CXX_UTIL_FREE_DELETER_HPP -#define OPENGRAPH_CXX_UTIL_FREE_DELETER_HPP +#ifndef OPENATTRIBUTEGRAPH_CXX_UTIL_FREE_DELETER_HPP +#define OPENATTRIBUTEGRAPH_CXX_UTIL_FREE_DELETER_HPP -#include +#include -OG_ASSUME_NONNULL_BEGIN +OAG_ASSUME_NONNULL_BEGIN namespace util { @@ -25,6 +25,6 @@ class free_deleter { } /* namespace util */ -OG_ASSUME_NONNULL_END +OAG_ASSUME_NONNULL_END -#endif /* OPENGRAPH_CXX_UTIL_FREE_DELETER_HPP */ +#endif /* OPENATTRIBUTEGRAPH_CXX_UTIL_FREE_DELETER_HPP */ diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Util/objc_ptr.hpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Util/objc_ptr.hpp similarity index 61% rename from Sources/OpenGraphCxx/include/OpenGraphCxx/Util/objc_ptr.hpp rename to Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Util/objc_ptr.hpp index 4e1d0e17..5130f595 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Util/objc_ptr.hpp +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Util/objc_ptr.hpp @@ -1,20 +1,20 @@ // // objc_ptr.hpp -// OpenGraphCxx +// OpenAttributeGraphCxx // // Status: Complete // Modified based Compute code -#ifndef OPENGRAPH_CXX_UTIL_OBJC_PTR_HPP -#define OPENGRAPH_CXX_UTIL_OBJC_PTR_HPP +#ifndef OPENATTRIBUTEGRAPH_CXX_UTIL_OBJC_PTR_HPP +#define OPENATTRIBUTEGRAPH_CXX_UTIL_OBJC_PTR_HPP -#include +#include -#if OG_TARGET_OS_DARWIN +#if OAG_TARGET_OS_DARWIN #include #include -OG_ASSUME_NONNULL_BEGIN +OAG_ASSUME_NONNULL_BEGIN // Redeclare APIs from the Objective-C runtime. // These functions are not available through public headers, but are guaranteed @@ -28,12 +28,12 @@ template class objc_ptr { private: id _storage; - static OG_INLINE id to_storage(T obj) { return (id)obj; } - static OG_INLINE T from_storage(id storage) { return (T)storage; } + static OAG_INLINE id to_storage(T obj) { return (id)obj; } + static OAG_INLINE T from_storage(id storage) { return (T)storage; } public: - OG_CONSTEXPR objc_ptr() OG_NOEXCEPT : _storage(nil) {} - OG_CONSTEXPR objc_ptr(std::nullptr_t) OG_NOEXCEPT : _storage(nil) {} + OAG_CONSTEXPR objc_ptr() OAG_NOEXCEPT : _storage(nil) {} + OAG_CONSTEXPR objc_ptr(std::nullptr_t) OAG_NOEXCEPT : _storage(nil) {} explicit objc_ptr(T obj) : _storage(to_storage(obj)) { if (_storage) { @@ -49,19 +49,19 @@ template class objc_ptr { // MARK: - Copy and move constructors - objc_ptr(const objc_ptr &other) OG_NOEXCEPT : _storage(other._storage) { + objc_ptr(const objc_ptr &other) OAG_NOEXCEPT : _storage(other._storage) { if (_storage) { objc_retain(_storage); } } - objc_ptr(objc_ptr &&other) OG_NOEXCEPT : _storage(other._storage) { + objc_ptr(objc_ptr &&other) OAG_NOEXCEPT : _storage(other._storage) { other._storage = nil; } // MARK: - Copy and move assignment operators - objc_ptr &operator=(const objc_ptr &other) OG_NOEXCEPT { + objc_ptr &operator=(const objc_ptr &other) OAG_NOEXCEPT { if (this != &other) { if (_storage) { objc_release(_storage); @@ -74,7 +74,7 @@ template class objc_ptr { return *this; } - objc_ptr &operator=(objc_ptr &&other) OG_NOEXCEPT { + objc_ptr &operator=(objc_ptr &&other) OAG_NOEXCEPT { if (this != &other) { if (_storage) { objc_release(_storage); @@ -87,9 +87,9 @@ template class objc_ptr { // MARK: - Modifiers - void reset() OG_NOEXCEPT { reset(nil); } + void reset() OAG_NOEXCEPT { reset(nil); } - void reset(T obj = nil) OG_NOEXCEPT { + void reset(T obj = nil) OAG_NOEXCEPT { if (_storage != obj) { if (_storage) { objc_release(_storage); @@ -101,15 +101,15 @@ template class objc_ptr { } } - T get() const OG_NOEXCEPT { return from_storage(_storage); } + T get() const OAG_NOEXCEPT { return from_storage(_storage); } - explicit operator bool() const OG_NOEXCEPT { return _storage != nil; } + explicit operator bool() const OAG_NOEXCEPT { return _storage != nil; } }; /* class objc_ptr */ } /* namespace util */ -OG_ASSUME_NONNULL_END +OAG_ASSUME_NONNULL_END #endif -#endif /* OPENGRAPH_CXX_UTIL_OBJC_PTR_HPP */ +#endif /* OPENATTRIBUTEGRAPH_CXX_UTIL_OBJC_PTR_HPP */ diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Vector/realloc_vector.hpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Vector/realloc_vector.hpp similarity index 74% rename from Sources/OpenGraphCxx/include/OpenGraphCxx/Vector/realloc_vector.hpp rename to Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Vector/realloc_vector.hpp index 8caea6d9..f0a6b16c 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Vector/realloc_vector.hpp +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Vector/realloc_vector.hpp @@ -1,15 +1,15 @@ // // realloc_vector.hpp -// OpenGraphCxx +// OpenAttributeGraphCxx #ifndef realloc_vector_hpp #define realloc_vector_hpp -#include +#include -OG_ASSUME_NONNULL_BEGIN +OAG_ASSUME_NONNULL_BEGIN -namespace OG { +namespace OAG { namespace details { template void *_Nullable realloc_vector(void* ptr, T& size, T new_size); @@ -17,8 +17,8 @@ void *_Nullable realloc_vector(void* ptr, T& size, T new_size); template void *_Nullable realloc_vector(void* src, void* dst, T dstSize, T& size, T newSize); } /* details */ -} /* OG */ +} /* OAG */ -OG_ASSUME_NONNULL_END +OAG_ASSUME_NONNULL_END #endif /* realloc_vector_hpp */ diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Vector/vector.hpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Vector/vector.hpp similarity index 97% rename from Sources/OpenGraphCxx/include/OpenGraphCxx/Vector/vector.hpp rename to Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Vector/vector.hpp index 0f99f3c2..72e2b5cb 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Vector/vector.hpp +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Vector/vector.hpp @@ -1,6 +1,6 @@ // // vector.hpp -// OpenGraphCxx +// OpenAttributeGraphCxx // // Status: Complete // Modified based Compute code @@ -8,14 +8,14 @@ #ifndef vector_hpp #define vector_hpp -#include +#include #include #include #include -OG_ASSUME_NONNULL_BEGIN +OAG_ASSUME_NONNULL_BEGIN -namespace OG { +namespace OAG { template requires std::unsigned_integral @@ -224,16 +224,16 @@ class vector, 0, size_type> { void clear(); void push_back(const std::unique_ptr &value) = delete; - OG_INLINE void push_back(std::unique_ptr &&value); - OG_INLINE void pop_back(); + OAG_INLINE void push_back(std::unique_ptr &&value); + OAG_INLINE void pop_back(); void resize(size_type count); void resize(size_type count, const value_type &value); }; -} /* OG */ +} /* OAG */ -OG_ASSUME_NONNULL_END +OAG_ASSUME_NONNULL_END #include "vector.tpp" diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Vector/vector.tpp b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Vector/vector.tpp similarity index 96% rename from Sources/OpenGraphCxx/include/OpenGraphCxx/Vector/vector.tpp rename to Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Vector/vector.tpp index 98446f40..b3dbeab7 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Vector/vector.tpp +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/Vector/vector.tpp @@ -1,23 +1,23 @@ // // vector.tpp -// OpenGraphCxx +// OpenAttributeGraphCxx // // Status: Complete // Modified based Compute code -#include -#include +#include +#include #include -#if OG_TARGET_OS_DARWIN +#if OAG_TARGET_OS_DARWIN #include #else #include -#endif /* OG_TARGET_OS_DARWIN */ +#endif /* OAG_TARGET_OS_DARWIN */ #include #include -namespace OG { +namespace OAG { #pragma mark - Base implementation @@ -37,7 +37,7 @@ void *realloc_vector(void *buffer, void *stack_buffer, size_type stack_size, siz return nullptr; } - #if OG_TARGET_OS_DARWIN + #if OAG_TARGET_OS_DARWIN size_t new_size_bytes = malloc_good_size(preferred_new_size * element_size_bytes); #else size_t new_size_bytes = malloc_good_size(preferred_new_size * element_size_bytes); @@ -179,7 +179,7 @@ void *realloc_vector(void *buffer, size_type *size, size_type preferred_new_size return nullptr; } - #if OG_TARGET_OS_DARWIN + #if OAG_TARGET_OS_DARWIN size_t new_size_bytes = malloc_good_size(preferred_new_size * element_size); #else size_t new_size_bytes = preferred_new_size * element_size; @@ -360,7 +360,7 @@ void vector, 0, size_type>::reserve(size_type new_cap) { template requires std::unsigned_integral -OG_INLINE void vector, 0, size_type>::push_back(std::unique_ptr &&value) { +OAG_INLINE void vector, 0, size_type>::push_back(std::unique_ptr &&value) { reserve(_size + 1); new (&_buffer[_size]) std::unique_ptr(std::move(value)); ++_size; @@ -368,7 +368,7 @@ OG_INLINE void vector, 0, size_type>::push_back(std::unique_p template requires std::unsigned_integral -OG_INLINE void vector, 0, size_type>::pop_back() { +OAG_INLINE void vector, 0, size_type>::pop_back() { assert(_size > 0); _buffer[_size - 1].reset(); _buffer[_size - 1].~unique_ptr(); @@ -392,4 +392,4 @@ void vector, 0, size_type>::resize(size_type count) { _size = count; } -} /* OG */ +} /* OAG */ diff --git a/Sources/OpenAttributeGraphCxx/include/module.modulemap b/Sources/OpenAttributeGraphCxx/include/module.modulemap new file mode 100644 index 00000000..5f1dfb3b --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/module.modulemap @@ -0,0 +1,8 @@ +module OpenAttributeGraphCxx { + export * +} + +module OpenAttributeGraphCxx.C { + umbrella header "OpenAttributeGraph/OpenAttributeGraph-umbrella.h" + export * +} diff --git a/Sources/OpenAttributeGraphCxx/include/module.private.modulemap b/Sources/OpenAttributeGraphCxx/include/module.private.modulemap new file mode 100644 index 00000000..3acc99fb --- /dev/null +++ b/Sources/OpenAttributeGraphCxx/include/module.private.modulemap @@ -0,0 +1,58 @@ +module OpenAttributeGraphCxx_Private { + export * +} + +module OpenAttributeGraphCxx_Private.Attribute { + requires cplusplus + umbrella "OpenAttributeGraphCxx/Attribute" + export * +} + +module OpenAttributeGraphCxx_Private.Comparison { + requires cplusplus + umbrella "OpenAttributeGraphCxx/Comparison" + export * +} + +module OpenAttributeGraphCxx_Private.Data { + requires cplusplus + umbrella "OpenAttributeGraphCxx/Data" + export * +} + +module OpenAttributeGraphCxx_Private.DebugServer { + requires cplusplus + umbrella "OpenAttributeGraphCxx/DebugServer" + export * +} + +module OpenAttributeGraphCxx_Private.Graph { + requires cplusplus + umbrella "OpenAttributeGraphCxx/Graph" + export * +} + +module OpenAttributeGraphCxx_Private.Misc { + requires cplusplus + umbrella "OpenAttributeGraphCxx/Misc" + export * +} + +module OpenAttributeGraphCxx_Private.Runtime { + requires cplusplus + umbrella "OpenAttributeGraphCxx/Runtime" + export * +} + +module OpenAttributeGraphCxx_Private.Util { + requires cplusplus + umbrella "OpenAttributeGraphCxx/Util" + export * + module * { export * } +} + +module OpenAttributeGraphCxx_Private.Vector { + requires cplusplus + umbrella "OpenAttributeGraphCxx/Vector" + export * +} diff --git a/Sources/OpenGraphShims/Attribute+Debug.swift b/Sources/OpenAttributeGraphShims/Attribute+Debug.swift similarity index 99% rename from Sources/OpenGraphShims/Attribute+Debug.swift rename to Sources/OpenAttributeGraphShims/Attribute+Debug.swift index 15c6e03c..350962b7 100644 --- a/Sources/OpenGraphShims/Attribute+Debug.swift +++ b/Sources/OpenAttributeGraphShims/Attribute+Debug.swift @@ -1,6 +1,6 @@ // // Attribute+Debug.swift -// OpenGraphShims +// OpenAttributeGraphShims #if canImport(Darwin) && DEBUG // Compiler crash for Darwin + release and non-Darwin build diff --git a/Sources/OpenGraphShims/DebugClient.swift b/Sources/OpenAttributeGraphShims/DebugClient.swift similarity index 99% rename from Sources/OpenGraphShims/DebugClient.swift rename to Sources/OpenAttributeGraphShims/DebugClient.swift index ab9181ff..0afe23dd 100644 --- a/Sources/OpenGraphShims/DebugClient.swift +++ b/Sources/OpenAttributeGraphShims/DebugClient.swift @@ -1,6 +1,6 @@ // // DebugServerTests.swift -// OpenGraphShims +// OpenAttributeGraphShims #if canImport(Darwin) public import Foundation diff --git a/Sources/OpenGraphShims/DebugServerMessageHeader.swift b/Sources/OpenAttributeGraphShims/DebugServerMessageHeader.swift similarity index 93% rename from Sources/OpenGraphShims/DebugServerMessageHeader.swift rename to Sources/OpenAttributeGraphShims/DebugServerMessageHeader.swift index bc6df06d..183dda24 100644 --- a/Sources/OpenGraphShims/DebugServerMessageHeader.swift +++ b/Sources/OpenAttributeGraphShims/DebugServerMessageHeader.swift @@ -1,6 +1,6 @@ // // DebugServerMessageHeader.swift -// OpenGraphShims +// OpenAttributeGraphShims @_spi(Debug) public struct DebugServerMessageHeader { diff --git a/Sources/OpenGraphShims/Graph+Debug.swift b/Sources/OpenAttributeGraphShims/Graph+Debug.swift similarity index 97% rename from Sources/OpenGraphShims/Graph+Debug.swift rename to Sources/OpenAttributeGraphShims/Graph+Debug.swift index 662bf4b9..bce0044c 100644 --- a/Sources/OpenGraphShims/Graph+Debug.swift +++ b/Sources/OpenAttributeGraphShims/Graph+Debug.swift @@ -1,6 +1,6 @@ // // Graph+Debug.swift -// OpenGraphShims +// OpenAttributeGraphShims #if canImport(Darwin) diff --git a/Sources/OpenAttributeGraphShims/GraphShims.swift b/Sources/OpenAttributeGraphShims/GraphShims.swift new file mode 100644 index 00000000..41b0abde --- /dev/null +++ b/Sources/OpenAttributeGraphShims/GraphShims.swift @@ -0,0 +1,24 @@ +// +// GraphShims.swift +// OpenAttributeGraphShims + +#if OPENATTRIBUTEGRAPH_ATTRIBUTEGRAPH +@_exported public import AttributeGraph +public typealias OAGAttributeInfo = AGAttributeInfo +public typealias OAGCachedValueOptions = AGCachedValueOptions +public typealias OAGChangedValueFlags = AGChangedValueFlags +public typealias OAGInputOptions = AGInputOptions +public typealias OAGUniqueID = AGUniqueID +public typealias OAGValue = AGValue +public typealias OAGValueOptions = AGValueOptions +public let attributeGraphEnabled = true +public let swiftToolchainSupported = true +#else +@_exported import OpenAttributeGraph +public let attributeGraphEnabled = false +#if OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED +public let swiftToolchainSupported = true +#else +public let swiftToolchainSupported = false +#endif +#endif diff --git a/Sources/OpenGraphShims/Metadata+Debug.swift b/Sources/OpenAttributeGraphShims/Metadata+Debug.swift similarity index 99% rename from Sources/OpenGraphShims/Metadata+Debug.swift rename to Sources/OpenAttributeGraphShims/Metadata+Debug.swift index 4bc962b5..3686b22f 100644 --- a/Sources/OpenGraphShims/Metadata+Debug.swift +++ b/Sources/OpenAttributeGraphShims/Metadata+Debug.swift @@ -1,6 +1,6 @@ // // Metadata+Debug.swift -// OpenGraphShims +// OpenAttributeGraphShims import Foundation diff --git a/Sources/OpenGraph/Export.swift b/Sources/OpenGraph/Export.swift deleted file mode 100644 index a926fe77..00000000 --- a/Sources/OpenGraph/Export.swift +++ /dev/null @@ -1,5 +0,0 @@ -// -// Export.swift -// OpenGraph - -@_exported public import OpenGraphCxx diff --git a/Sources/OpenGraphCxx/Attribute/AttributeID.cpp b/Sources/OpenGraphCxx/Attribute/AttributeID.cpp deleted file mode 100644 index 261db98b..00000000 --- a/Sources/OpenGraphCxx/Attribute/AttributeID.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// -// AttributeID.cpp -// OpenGraphCxx - -#include diff --git a/Sources/OpenGraphCxx/Attribute/AttributeType.cpp b/Sources/OpenGraphCxx/Attribute/AttributeType.cpp deleted file mode 100644 index 2b44b10d..00000000 --- a/Sources/OpenGraphCxx/Attribute/AttributeType.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// -// OGAttributeType.cpp -// OpenGraphCxx - -#include diff --git a/Sources/OpenGraphCxx/Attribute/OGAttribute.cpp b/Sources/OpenGraphCxx/Attribute/OGAttribute.cpp deleted file mode 100644 index bcecbfe2..00000000 --- a/Sources/OpenGraphCxx/Attribute/OGAttribute.cpp +++ /dev/null @@ -1,183 +0,0 @@ -// -// OGAttribute.cpp -// OpenGraphCxx - -#include -#include -#include -#include - -const OGAttribute OGAttributeNil = OGAttribute(OG::AttributeID::Kind::Null); - -OGAttribute OGGraphGetCurrentAttribute() { - // TODO - return OGAttributeNil; -} - -namespace { -OGAttribute create_offset_attribute(OGAttribute attribute, uint64_t offset, std::optional size) { - // TODO - return OGAttributeNil; -} -} - -OGAttribute OGGraphCreateOffsetAttribute(OGAttribute attribute, long offset) { - return create_offset_attribute(attribute, offset, std::nullopt); -} - -OGAttribute OGGraphCreateOffsetAttribute2(OGAttribute attribute, long offset, uint64_t size) { - return create_offset_attribute(attribute, offset, std::optional(size)); -} - -namespace { -OGAttribute create_indirect_attribute(OGAttribute attribute, std::optional size) { - // TODO - return OGAttributeNil; -} -} - -OGAttribute OGGraphCreateIndirectAttribute(OGAttribute attribute) { - return create_indirect_attribute(attribute, std::nullopt); -} - -OGAttribute OGGraphCreateIndirectAttribute2(OGAttribute attribute, uint64_t size) { - return create_indirect_attribute(attribute, std::optional(size)); -} - -OGAttributeFlags OGGraphGetFlags(OGAttribute attribute) { - const OG::AttributeID id = OG::AttributeID(attribute); - id.checkIsDirect(); - // TODO: data/table - return OGAttributeFlagsNone; -} - -void OGGraphSetFlags(OGAttribute attribute, OGAttributeFlags flags) { - const OG::AttributeID id = OG::AttributeID(attribute); - id.checkIsDirect(); - // TODO: data/table -} - -void OGGraphAddInput(OGAttribute attribute1, OGAttribute attribute2, OGInputOptions options, long token) { - const OG::AttributeID id = OG::AttributeID(attribute1); - id.checkIsDirect(); - // TODO: data/table -} - -const OGAttributeInfo OGGraphGetAttributeInfo(OGAttribute attribute) { - const OG::AttributeID id = OG::AttributeID(attribute); - id.checkIsDirect(); - // TODO - return { nullptr, nullptr }; -} - -void OGGraphMutateAttribute(OGAttribute attribute, - const OGTypeID type, - bool invalidating, - const void (*function)(const void * _Nullable context OG_SWIFT_CONTEXT, void *body) OG_SWIFT_CC(swift), - const void * _Nullable context) { - const OG::AttributeID id = OG::AttributeID(attribute); - id.checkIsDirect(); - // attribute_modify(AG::data::ptr, AGSwiftMetadata const*, AG::ClosureFunction, bool -} - -OGAttribute OGGraphGetIndirectDependency(OGAttribute attribute) { - // TODO - return OGAttributeNil; -} - -void OGGraphSetIndirectDependency(OGAttribute attribute1, OGAttribute attribute2) { - // TODO -} - -OGAttribute OGGraphGetIndirectAttribute(OGAttribute attribute) { - // TODO - return OGAttributeNil; -} - -void OGGraphSetIndirectAttribute(OGAttribute attribute1, OGAttribute attribute2) { - // TODO -} - -OGAttribute OGGraphCreateAttribute(long index, const void *body, const void * value) { - // TODO - return OGAttributeNil; -} - -const OGValue OGGraphGetValue(OGAttribute attribute, OGValueOptions options, OGTypeID type) { - // TODO - return OGValue { nullptr, false }; -} - -bool OGGraphSetValue(OGAttribute attribute, const void *value, OGTypeID type) { - // TODO - return false; -} - -const OGValue OGGraphGetInputValue(OGAttribute attribute, OGAttribute inputAttribute, OGValueOptions options, const OGTypeID type) { - // TODO - return OGValue { nullptr, false }; -} - -const void * _Nullable OGGraphGetOutputValue(OGTypeID type) { - // TODO - return nullptr; -} - -void OGGraphSetOutputValue(const void *value, const OGTypeID type) { - // TODO -} - -OGValueState OGGraphGetValueState(OGAttribute attribute) { - // TODO - return {}; -} - -bool OGGraphHasValue(OGAttribute attribute) { - // TODO - return false; -} - -void OGGraphUpdateValue(OGAttribute attribute) { - // TODO -} - -void OGGraphPrefetchValue(OGAttribute attribute) { - // TODO -} - -void OGGraphInvalidateValue(OGAttribute attribute) { - // TODO -} - -void OGGraphVerifyType(OGAttribute attribute, OGTypeID type) { - // TODO -} - -OGGraphRef OGGraphGetAttributeGraph(OGAttribute attribute) { - // TODO - return nullptr; -} - -OGSubgraphRef OGGraphGetAttributeSubgraph(OGAttribute attribute) { - // TODO - return nullptr; -} - -const void * OGGraphReadCachedAttribute(long hashValue, OGTypeID bodyType, const void *bodyPointer, OGTypeID valueType, OGCachedValueOptions options, OGAttribute attribute, bool unknown) { - // TODO - return nullptr; -} - -const void * _Nullable OGGraphReadCachedAttributeIfExists(long hashValue, OGTypeID bodyType, const void *bodyPointer, OGTypeID valueType, OGCachedValueOptions options, OGAttribute attribute, bool unknown) { - // TODO - return nullptr; -} - -void OGGraphWithUpdate( - OGAttribute attribute, - void (* callback)(const void *context OG_SWIFT_CONTEXT) OG_SWIFT_CC(swift), - const void *context -) { - // TODO - callback(context); -} diff --git a/Sources/OpenGraphCxx/Attribute/OGWeakAttribute.cpp b/Sources/OpenGraphCxx/Attribute/OGWeakAttribute.cpp deleted file mode 100644 index 6b623941..00000000 --- a/Sources/OpenGraphCxx/Attribute/OGWeakAttribute.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// -// OGWeakAttribute.cpp -// OpenGraphCxx - -#include - -OGWeakAttribute OGCreateWeakAttribute(OGAttribute attribute) { - // TODO - return {OGAttributeNil , 0}; -} - -OGAttribute OGWeakAttributeGetAttribute(OGWeakAttribute weakAttribute) { - // TODO - return OGAttributeNil; -} - -OGWeakValue OGGraphGetWeakValue(OGWeakAttribute weakAttribute, OGValueOptions options, OGTypeID type) { - // TODO - return {nullptr, false}; -} diff --git a/Sources/OpenGraphCxx/Comparison/OGComparison.cpp b/Sources/OpenGraphCxx/Comparison/OGComparison.cpp deleted file mode 100644 index 915f590e..00000000 --- a/Sources/OpenGraphCxx/Comparison/OGComparison.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// -// OGCompareValues.cpp -// OpenGraphCxx - -#include -#include - -const void *OGComparisonStateGetDestination(OGComparisonState state) { - return ((const OGComparisonStateStorage *)state)->destination; -} - -const void *OGComparisonStateGetSource(OGComparisonState state) { - return ((const OGComparisonStateStorage *)state)->source; -} - -OGFieldRange OGComparisonStateGetFieldRange(OGComparisonState state) { - return ((const OGComparisonStateStorage *)state)->field_range; -} - -OGTypeID OGComparisonStateGetFieldType(OGComparisonState state) { - return ((const OGComparisonStateStorage *)state)->field_type; -} - -bool OGCompareValues(const void *lhs, const void *rhs, OGTypeID type, OGComparisonOptions options) { - // TODO - return false; -} - -const unsigned char *_Nullable OGPrefetchCompareValues(OGTypeID type_id, - OGComparisonOptions options, - uint32_t priority) { - // TODO - return nullptr; -} - -void OGOverrideComparisonForTypeDescriptor(void *descriptor, OGComparisonMode mode) { - // TODO -} diff --git a/Sources/OpenGraphCxx/Data/ClosureFunction.cpp b/Sources/OpenGraphCxx/Data/ClosureFunction.cpp deleted file mode 100644 index 253e14cb..00000000 --- a/Sources/OpenGraphCxx/Data/ClosureFunction.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// -// ClosureFunction.cpp -// OpenGraphCxx - -#include diff --git a/Sources/OpenGraphCxx/DebugServer/OGDebugServer.cpp b/Sources/OpenGraphCxx/DebugServer/OGDebugServer.cpp deleted file mode 100644 index 282104b0..00000000 --- a/Sources/OpenGraphCxx/DebugServer/OGDebugServer.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// -// OGDebugServer.cpp -// OpenGraphCxx -// -// Audited for 6.5.1 -// Status: Complete - -#include -#include - -#if OG_TARGET_OS_DARWIN - -// MARK: - Exported C functions - -OGDebugServerRef _Nullable OGDebugServerStart(OGDebugServerMode port) { - return (OGDebugServerRef)OG::DebugServer::start(port); -} - -void OGDebugServerStop() { - OG::DebugServer::stop(); -} - -CFURLRef _Nullable OGDebugServerCopyURL() { - if (!OG::DebugServer::has_shared_server()) { - return nullptr; - } - return OG::DebugServer::shared_server()->copy_url(); -} - -void OGDebugServerRun(int timeout) { - if (!OG::DebugServer::has_shared_server()) { - return; - } - OG::DebugServer::shared_server()->run(timeout); -} - -#endif diff --git a/Sources/OpenGraphCxx/Graph/Graph.cpp b/Sources/OpenGraphCxx/Graph/Graph.cpp deleted file mode 100644 index 10619c77..00000000 --- a/Sources/OpenGraphCxx/Graph/Graph.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// -// Graph.cpp -// OpenGraphCxx - -#include -#include -#include - -#if !OG_TARGET_OS_WASI -#include -#endif - -#include - -pthread_key_t OG::Graph::_current_update_key; - -OG::Graph::Graph() OG_NOEXCEPT { - // TODO - - // libdispatch is not supported on WASI - // Tracked via https://github.com/swiftwasm/swift/issues/5565 - #if !OG_TARGET_OS_WASI - static dispatch_once_t make_keys; - dispatch_once_f(&make_keys, nullptr, [](void * _Nullable context){ - pthread_key_create(&_current_update_key, nullptr); - OG::Subgraph::make_current_subgraph_key(); - }); - #endif - - // TODO -} - -const void OG::Graph::value_mark_all() const OG_NOEXCEPT { - // TODO -} - -void OG::Graph::all_start_profiling(uint32_t) OG_NOEXCEPT { - // TODO -} -void OG::Graph::all_stop_profiling() OG_NOEXCEPT { - // TODO -} -void OG::Graph::start_profiling(uint32_t) OG_NOEXCEPT { - // TODO -} -void OG::Graph::stop_profiling() OG_NOEXCEPT { - // TODO -} - -const bool OG::Graph::thread_is_updating() const OG_NOEXCEPT { - void *current = pthread_getspecific(current_key()); - if (!current) { - return false; - } - // TODO - return false; -} - -const bool OG::Graph::is_context_updating(const OG::Graph::Context&) const OG_NOEXCEPT { - // TODO - return false; -} diff --git a/Sources/OpenGraphCxx/Graph/GraphContext.cpp b/Sources/OpenGraphCxx/Graph/GraphContext.cpp deleted file mode 100644 index 6700fb4d..00000000 --- a/Sources/OpenGraphCxx/Graph/GraphContext.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// -// GraphContext.cpp -// OpenGraphCxx - -#include -#include -#include - -OG::Graph::Context &OG::Graph::Context::from_cf(OGGraphRef storage) OG_NOEXCEPT { - if (storage->context.isInvalid()) { - OG::precondition_failure("invalidated graph"); - } - return storage->context; -} - -OG::Graph::Context::Context(OG::Graph &graph) OG_NOEXCEPT : -_graph(&graph), -_context(nullptr), -_id(OGMakeUniqueID()), -_invalidation_callback(nullptr), -_update_callback(nullptr) { - // TODO -} - -OG::Graph::Context::~Context() OG_NOEXCEPT { - // TODO -} - -const bool OG::Graph::Context::thread_is_updating() const OG_NOEXCEPT { - return _graph->thread_is_updating() && _graph->is_context_updating(*this); -} diff --git a/Sources/OpenGraphCxx/Graph/GraphDescription.cpp b/Sources/OpenGraphCxx/Graph/GraphDescription.cpp deleted file mode 100644 index 60c99606..00000000 --- a/Sources/OpenGraphCxx/Graph/GraphDescription.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// -// GraphDescription.cpp -// OpenGraphCxx - -#include -#include -#include -#include - -CFTypeRef OGGraphDescription(OGGraphRef graph, CFDictionaryRef options) { - #if OG_OBJC_FOUNDATION - if (graph == nullptr) { - return OG::Graph::description(nullptr, (__bridge NSDictionary*)options); - } - if (graph->context.isInvalid()) { - OG::precondition_failure("invalidated graph"); - } - return OG::Graph::description(&graph->context.get_graph(), (__bridge NSDictionary*)options); - #endif -} - -void OGGraphArchiveJSON(char const * _Nullable name) { - #if OG_OBJC_FOUNDATION - OG::Graph::write_to_file(nullptr, name, 0); - #endif -} - -void OGGraphArchiveJSON2(char const * _Nullable name, uint8_t options) { - #if OG_OBJC_FOUNDATION - OG::Graph::write_to_file(nullptr, name, options); - #endif -} - diff --git a/Sources/OpenGraphCxx/Graph/GraphDescription.mm b/Sources/OpenGraphCxx/Graph/GraphDescription.mm deleted file mode 100644 index ca73a2ea..00000000 --- a/Sources/OpenGraphCxx/Graph/GraphDescription.mm +++ /dev/null @@ -1,24 +0,0 @@ -// -// GraphDescription.mm -// OpenGraphCxx - -#include -#include -#include -#include - -#if OG_OBJC_FOUNDATION - -#include - -const CFStringRef OGDescriptionFormat = CFSTR("format"); -const CFStringRef OGDescriptionIncludeValues = CFSTR("include-values"); - -CFTypeRef OG::Graph::description(const Graph * _Nullable graph, NSDictionary* dic) { - // TODO - // For "format": "graph/dict" - NSMutableDictionray - // For "format": "graph/dot" - NSMutableString - return NULL; -} - -#endif /* OG_OBJC_FOUNDATION */ diff --git a/Sources/OpenGraphCxx/Graph/OGGraph.cpp b/Sources/OpenGraphCxx/Graph/OGGraph.cpp deleted file mode 100644 index 3556c9d6..00000000 --- a/Sources/OpenGraphCxx/Graph/OGGraph.cpp +++ /dev/null @@ -1,211 +0,0 @@ -// -// OGGraph.cpp -// OpenGraphCxx - -#include -#include -#include -#include -#include - -OGGraphRef OGGraphCreate() { - return OGGraphCreateShared(nullptr); -} - -OGGraphRef OGGraphCreateShared(OGGraphRef storage) { - const CFIndex extraSize = sizeof(OGGraphStorage)-sizeof(CFRuntimeBase); - OGGraphRef instance = (OGGraphRef)_CFRuntimeCreateInstance(kCFAllocatorDefault, OGGraphGetTypeID(), extraSize, nullptr); - if (instance == nullptr) { - OG::precondition_failure("memory allocation failure."); - } - OG::Graph *graph = nullptr; - if (storage == nullptr) { - graph = new OG::Graph(); - } else { - if (storage->context.isInvalid()) { - OG::precondition_failure("invalidated graph"); - } - graph = &storage->context.get_graph(); - // [graph+0x10c] += 1 - } - // AG::Context(instance->graph, graph) - - // [graph+0x10c] -= 1 -// if ([graph+0x10c] == 0) { -// delete graph -// } - instance->context.setInvalid(false); - return instance; -} - -namespace { -CFRuntimeClass &graph_type_id() { - static auto dealloc = [](const void* ptr) { - OGGraphRef storage = (OGGraphRef)ptr; - if (storage->context.isInvalid()) { - return; - } - storage->context.~Context(); - }; - static CFRuntimeClass klass = { - 0, - "OGGraphStorage", - NULL, // init - NULL, // copy - dealloc, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - 0, - }; - return klass; -} -} - -CFTypeID OGGraphGetTypeID() { - static CFTypeID type = _CFRuntimeRegisterClass(&graph_type_id()); - return type; -} - -void OGGraphStartProfiling(_Nullable OGGraphRef graph) { - if (!graph) { - OG::Graph::all_start_profiling(1); - return; - } - if (graph->context.isInvalid()) { - OG::precondition_failure("invalidated graph"); - } - graph->context.get_graph().start_profiling(1); -} - -void OGGraphStopProfiling(_Nullable OGGraphRef graph) { - if (!graph) { - OG::Graph::all_stop_profiling(); - return; - } - if (graph->context.isInvalid()) { - OG::precondition_failure("invalidated graph"); - } - graph->context.get_graph().stop_profiling(); -} - -void OGGraphResetProfile(_Nullable OGGraphRef graph) { - // TODO -} - -const void * _Nullable OGGraphGetContext(OGGraphRef graph) { - if (graph->context.isInvalid()) { - OG::precondition_failure("invalidated graph"); - } - return graph->context.get_context(); -} - -void OGGraphSetContext(OGGraphRef graph, const void * _Nullable context) { - if (graph->context.isInvalid()) { - OG::precondition_failure("invalidated graph"); - } - graph->context.set_context(context); -} - -OGGraphContextRef OGGraphGetGraphContext(OGGraphRef graph) { - if (graph->context.isInvalid()) { - OG::precondition_failure("invalidated graph"); - } - return reinterpret_cast(reinterpret_cast(graph) + sizeof(CFRuntimeBase)); -} - -void OGGraphInvalidate(OGGraphRef graph) { - if (graph->context.isInvalid()) { - return; - } - graph->context.~Context(); - graph->context.setInvalid(true); -} - -void OGGraphInvalidateAllValues(OGGraphRef graph) { - if (graph->context.isInvalid()) { - OG::precondition_failure("invalidated graph"); - } - graph->context.get_graph().value_mark_all(); -} - - - -void OGGraphSetInvalidationCallback(OGGraphRef graph, - const void (*_Nullable function)(const void * _Nullable context OG_SWIFT_CONTEXT, OGAttribute) OG_SWIFT_CC(swift), - const void * _Nullable context) { - if (graph->context.isInvalid()) { - OG::precondition_failure("invalidated graph"); - } - graph->context.set_invalidation_callback(OG::ClosureFunction(function, context)); -} - -void OGGraphSetUpdateCallback(OGGraphRef graph, - const void (*_Nullable function)(const void * _Nullable context OG_SWIFT_CONTEXT) OG_SWIFT_CC(swift), - const void * _Nullable context) { - if (graph->context.isInvalid()) { - OG::precondition_failure("invalidated graph"); - } - graph->context.set_update_callback(OG::ClosureFunction(function, context)); -} - -uint64_t OGGraphGetCounter(OGGraphRef graph, OGGraphCounterQueryType query) { - if (graph->context.isInvalid()) { - OG::precondition_failure("invalidated graph"); - } - OG::Graph::Context& context = graph->context; - switch (query) { - case OGGraphCounterQueryTypeNodes: - return context.get_graph().get_counter_0(); - case OGGraphCounterQueryTypeTransactions: - return context.get_graph().get_counter_1(); - case OGGraphCounterQueryTypeUpdates: - return context.get_graph().get_counter_2(); - case OGGraphCounterQueryTypeChanges: - return context.get_graph().get_counter_3(); - case OGGraphCounterQueryTypeContextID: - return context.get_graph().get_counter_4(); - case OGGraphCounterQueryTypeGraphID: - return context.get_graph().get_counter_5(); - case OGGraphCounterQueryTypeContextThreadUpdating: - return context.thread_is_updating(); - case OGGraphCounterQueryTypeThreadUpdating: - return context.get_graph().thread_is_updating(); - case OGGraphCounterQueryTypeContextNeedsUpdate: - return context.get_graph().get_counter_8(); - case OGGraphCounterQueryTypeNeedsUpdate: - return context.get_graph().get_counter_9(); - case OGGraphCounterQueryTypeMainThreadUpdates: - return context.get_graph().get_counter_10(); - default: - return 0; - } -} - -void OGGraphSetUpdate(const void * _Nullable value) { - pthread_setspecific(OG::Graph::current_key(), value); -} - -const void * _Nullable OGGraphClearUpdate(void) { - void * value = pthread_getspecific(OG::Graph::current_key()); - bool isDirty = (uint64_t)value & 0x1; - if (value != nullptr && isDirty) { - pthread_setspecific(OG::Graph::current_key(), (void *)((uint64_t)value | 0x1)); - } - return value; -} - -void OGGraphSetNeedsUpdate(OGGraphRef graph) { - if (graph->context.isInvalid()) { - OG::precondition_failure("invalidated graph"); - } - // graph->context->set_needs_update(); -} - -bool OGGraphAnyInputsChanged(const OGAttribute *excluded_inputs, size_t count) { - // TODO - return false; -} diff --git a/Sources/OpenGraphCxx/Graph/OGGraphContext.cpp b/Sources/OpenGraphCxx/Graph/OGGraphContext.cpp deleted file mode 100644 index 4cd4fed6..00000000 --- a/Sources/OpenGraphCxx/Graph/OGGraphContext.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// -// OGGraphContext.cpp -// OpenGraphCxx - -#include -#include - -OGGraphRef OGGraphContextGetGraph(OGGraphContextRef context) { - return reinterpret_cast(reinterpret_cast(context) - sizeof(CFRuntimeBase)); -} diff --git a/Sources/OpenGraphCxx/Graph/OGGraphTracing.cpp b/Sources/OpenGraphCxx/Graph/OGGraphTracing.cpp deleted file mode 100644 index 79c177c3..00000000 --- a/Sources/OpenGraphCxx/Graph/OGGraphTracing.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// -// OGGraphTracing.mm -// OpenGraphCxx - -#include - -void OGGraphStartTracing(_Nullable OGGraphRef graph, OGGraphTraceOptions options) { - OGGraphStartTracing2(graph, options, NULL); -} - -void OGGraphStartTracing2(_Nullable OGGraphRef graph, OGGraphTraceOptions options, _Nullable CFArrayRef array) { - // TODO -} - -void OGGraphStopTracing(_Nullable OGGraphRef graph) { - // TODO -} diff --git a/Sources/OpenGraphCxx/Graph/OGSubgraph.cpp b/Sources/OpenGraphCxx/Graph/OGSubgraph.cpp deleted file mode 100644 index 449fdeee..00000000 --- a/Sources/OpenGraphCxx/Graph/OGSubgraph.cpp +++ /dev/null @@ -1,220 +0,0 @@ -// -// OGSubgraph.cpp -// OpenGraphCxx - -#include -#include -#include -#include -#include -#include -#include -#if !OG_TARGET_OS_WASI -#include -#endif - -namespace { -CFRuntimeClass &subgraph_type_id() { - static auto dealloc = [](const void* ptr) { - OGSubgraphRef storage = (OGSubgraphRef)ptr; - auto subgraph = storage->subgraph; - if (subgraph == nullptr) { - return; - } - subgraph->clear_object(); - subgraph->invalidate_and_delete_(false); - }; - static CFRuntimeClass klass = { - 0, - "OGSubgraph", - NULL, // init - NULL, // copy - dealloc, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - 0, - }; - return klass; -} -} - -CFTypeID OGSubgraphGetTypeID() { - static CFTypeID type = _CFRuntimeRegisterClass(&subgraph_type_id()); - return type; -} - -OGSubgraphRef OGSubgraphCreate(OGGraphRef cf_graph) { - return OGSubgraphCreate2(cf_graph, OGAttributeNil); -} - -OGSubgraphRef OGSubgraphCreate2(OGGraphRef cf_graph, OGAttribute attribute) { - OG::Graph::Context &context = OG::Graph::Context::from_cf(cf_graph); - const CFIndex extraSize = sizeof(OGSubgraphStorage)-sizeof(CFRuntimeBase); - #if OG_TARGET_CPU_WASM32 - // FIXME: extraSize will always be 8 thus it will fail on WASM. Investate later. - static_assert(extraSize == 8); - #else - static_assert(extraSize == sizeof(void *)); - #endif - OGSubgraphRef cf_subgrah = (OGSubgraphRef)_CFRuntimeCreateInstance(kCFAllocatorDefault, OGSubgraphGetTypeID(), extraSize, nullptr); - if (cf_subgrah == nullptr) { - OG::precondition_failure("memory allocation failure."); - } - cf_subgrah->subgraph = new OG::Subgraph((OG::SubgraphObject *)cf_subgrah, context, attribute); - return cf_subgrah; -} - -_Nullable OGSubgraphRef OGSubgraphGetCurrent() { - OG::Subgraph *subgraph = OG::Subgraph::get_current(); - if (subgraph == nullptr) { - return nullptr; - } - return subgraph->to_cf(); -} - -void OGSubgraphSetCurrent(_Nullable OGSubgraphRef cf_subgraph) { - OG::Subgraph *old_subgraph = OG::Subgraph::get_current(); - if (cf_subgraph == nullptr) { - OG::Subgraph::set_current(nullptr); - } else { - OG::Subgraph *subgraph = cf_subgraph->subgraph; - OG::Subgraph::set_current(subgraph); - if (subgraph != nullptr) { - CFRetain(cf_subgraph); - } - } - if (old_subgraph != nullptr) { - OGSubgraphRef old_cf_Subgraph = old_subgraph->to_cf(); - if (old_cf_Subgraph) { - CFRelease(old_cf_Subgraph); - } - } -} - -OGGraphContextRef OGSubgraphGetCurrentGraphContext() { - OG::Subgraph *subgraph = OG::Subgraph::get_current(); - if (subgraph == nullptr) { - return nullptr; - } - return subgraph->get_context(); -} - -void OGSubgraphInvalidate(OGSubgraphRef cf_subgraph) { - if (cf_subgraph->subgraph == nullptr) { - return; - } - cf_subgraph->subgraph->invalidate_and_delete_(false); -} - -bool OGSubgraphIsValid(OGSubgraphRef cf_subgraph) { - if (cf_subgraph->subgraph == nullptr) { - return false; - } - return !cf_subgraph->subgraph->isInvalid(); -} - -OGGraphRef OGSubgraphGetGraph(OGSubgraphRef cf_subgraph) { - if (cf_subgraph->subgraph == nullptr) { - OG::precondition_failure("accessing invalidated subgraph"); - } - return OGGraphContextGetGraph(cf_subgraph->subgraph->get_context()); -} - -void OGSubgraphAddChild(OGSubgraphRef parent, OGSubgraphRef child) { - OGSubgraphAddChild2(parent, child, 0); -} - -void OGSubgraphAddChild2(OGSubgraphRef parent, OGSubgraphRef child, uint8_t tag) { - // TODO -} - -void OGSubgraphRemoveChild(OGSubgraphRef parent, OGSubgraphRef child) { - // TODO -} - -void OGSubgraphApply(OGSubgraphRef cf_subgraph, - OGAttributeFlags flags, - const void (*function)(const void * _Nullable context OG_SWIFT_CONTEXT, OGAttribute attribute) OG_SWIFT_CC(swift), - const void * _Nullable context) { - if (cf_subgraph->subgraph == nullptr) { - return; - } - return cf_subgraph->subgraph->apply(flags, OG::ClosureFunction(function, context)); -} - -void OGSubgraphUpdate(OGSubgraphRef cf_subgraph, OGAttributeFlags flags) { - OG::Subgraph *subgraph = cf_subgraph->subgraph; - if (subgraph == nullptr) { - return; - } - // subgraph->update(flags); -} - -bool OGSubgraphIsDirty(OGSubgraphRef cf_subgraph, OGAttributeFlags flags) { - OG::Subgraph *subgraph = cf_subgraph->subgraph; - if (subgraph == nullptr) { - return false; - } - // TODO - return false; -} - -OGUniqueID OGSubgraphAddObserver(OGSubgraphRef cf_subgraph, - const void (*function)(const void * _Nullable context OG_SWIFT_CONTEXT) OG_SWIFT_CC(swift), - const void * _Nullable context) { - OG::Subgraph *subgraph = cf_subgraph->subgraph; - if (subgraph == nullptr) { - OG::precondition_failure("accessing invalidated subgraph"); - } - return subgraph->add_observer(OG::ClosureFunction(function, context)); -} - -#if !OG_TARGET_OS_WASI -static bool should_record_tree; -static dispatch_once_t should_record_tree_once; - -void init_should_record_tree(void * _Nullable context) { - should_record_tree = OG::get_env("OG_TREE") != 0; -} -#endif - -bool OGSubgraphShouldRecordTree() { - #if !OG_TARGET_OS_WASI - dispatch_once_f(&should_record_tree_once, NULL, init_should_record_tree); - return should_record_tree; - #else - return false; - #endif -} - -void OGSubgraphSetShouldRecordTree() { - #if !OG_TARGET_OS_WASI - dispatch_once_f(&should_record_tree_once, NULL, init_should_record_tree); - should_record_tree = true; - #endif -} - -void OGSubgraphBeginTreeElement(OGAttribute attribute, OGTypeID type, uint32_t flags) { - OG::Subgraph * subgraph = OG::Subgraph::get_current(); - if (subgraph) { - subgraph->begin_tree(attribute, reinterpret_cast(type), flags); - } -} - -void OGSubgraphAddTreeValue(OGAttribute attribute, OGTypeID type, const char * key, uint32_t flags) { - OG::Subgraph * subgraph = OG::Subgraph::get_current(); - if (subgraph) { - subgraph->add_tree_value(attribute, reinterpret_cast(type), key, flags); - } -} - -void OGSubgraphEndTreeElement(OGAttribute attribute) { - OG::Subgraph * subgraph = OG::Subgraph::get_current(); - if (subgraph) { - subgraph->end_tree(attribute); - } -} diff --git a/Sources/OpenGraphCxx/Graph/Subgraph.cpp b/Sources/OpenGraphCxx/Graph/Subgraph.cpp deleted file mode 100644 index 00fba29d..00000000 --- a/Sources/OpenGraphCxx/Graph/Subgraph.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// -// Subgraph.cpp -// OpenGraphCxx - -#include -#include - -pthread_key_t OG::Subgraph::_current_subgraph_key; - -OG::Subgraph* OG::Subgraph::from_cf(OGSubgraphRef storage) OG_NOEXCEPT { - return storage->subgraph; -} - -void OG::Subgraph::clear_object() const OG_NOEXCEPT { - // TODO -} - -void OG::Subgraph::invalidate_and_delete_(bool) const OG_NOEXCEPT { - // TODO -} - -void OG::Subgraph::apply(OGAttributeFlags flags, OG::ClosureFunction body) const OG_NOEXCEPT { - // TODO -} - -OG::Subgraph::Subgraph(OG::SubgraphObject* cf_subgraph, OG::Graph::Context& context, OG::AttributeID): -_cf_subgraph((OGSubgraphRef)cf_subgraph), // FIXME -_context((OGGraphContextStorage &)context){ - // TODO -} - -OGUniqueID OG::Subgraph::add_observer(OG::ClosureFunction observer) const OG_NOEXCEPT { - // TODO - return OGMakeUniqueID(); -} - -void OG::Subgraph::begin_tree(OG::AttributeID id, OG::swift::metadata const* type, unsigned int flags) const OG_NOEXCEPT { - // TODO -} - -void OG::Subgraph::add_tree_value(OG::AttributeID id, OG::swift::metadata const *type, const char* key, uint32_t flags) const OG_NOEXCEPT { - // TODO -} - -void OG::Subgraph::end_tree(OG::AttributeID id) const OG_NOEXCEPT { - // TODO -} diff --git a/Sources/OpenGraphCxx/Graph/Subgraph.hpp b/Sources/OpenGraphCxx/Graph/Subgraph.hpp deleted file mode 100644 index dbf3944e..00000000 --- a/Sources/OpenGraphCxx/Graph/Subgraph.hpp +++ /dev/null @@ -1,109 +0,0 @@ -// -// Subgraph.hpp -// OpenGraphCxx - -#ifndef Subgraph_hpp -#define Subgraph_hpp - -#include "OGBase.h" -#include -#include -#include -#include -#include - -typedef struct OG_BRIDGED_TYPE(id) OGSubgraphStorage * OGSubgraphRef; - -namespace OG { -class SubgraphObject; - -class Subgraph final { -private: - OGSubgraphRef _cf_subgraph; - OGGraphContextStorage& _context; - // TODO - bool _isInvalid; - static pthread_key_t _current_subgraph_key; -public: - // MARK: - CF related - - static Subgraph *from_cf(OGSubgraphRef cf_subgraph) OG_NOEXCEPT; - - OGSubgraphRef to_cf() const OG_NOEXCEPT { - return _cf_subgraph; - } - - // MARK: - pthread related - - OG_INLINE - const static void make_current_subgraph_key() OG_NOEXCEPT { - pthread_key_create(&_current_subgraph_key, nullptr); - } - - OG_INLINE OG_CONSTEXPR - const static pthread_key_t& current_key() OG_NOEXCEPT { - return _current_subgraph_key; - } - - OG_INLINE OG_CONSTEXPR - static Subgraph *get_current() OG_NOEXCEPT { - return (OG::Subgraph*)pthread_getspecific(OG::Subgraph::current_key()); - } - - OG_INLINE OG_CONSTEXPR - static int set_current(Subgraph *subgraph) OG_NOEXCEPT { - return pthread_setspecific(OG::Subgraph::current_key(), subgraph); - } - - // MARK: - Public API - void clear_object() const OG_NOEXCEPT; - void invalidate_and_delete_(bool) const OG_NOEXCEPT; - - void apply(OGAttributeFlags flags, OG::ClosureFunction body) const OG_NOEXCEPT; - - OGUniqueID add_observer(OG::ClosureFunction observer) const OG_NOEXCEPT; - - void begin_tree(OG::AttributeID id, OG::swift::metadata const *type, uint32_t flags) const OG_NOEXCEPT; - void add_tree_value(OG::AttributeID id, OG::swift::metadata const *type, const char* key, uint32_t flags) const OG_NOEXCEPT; - void end_tree(OG::AttributeID id) const OG_NOEXCEPT; - - // MARK: - Init and deinit - - Subgraph(SubgraphObject*, OG::Graph::Context&, OG::AttributeID); - - // MARK: - Getter and setter - - OG_INLINE OG_CONSTEXPR - const OGGraphContextRef get_context() const OG_NOEXCEPT { - return &_context; - } - - OG_INLINE OG_CONSTEXPR - OGGraphContextRef get_context() OG_NOEXCEPT { - return &_context; - } - - OG_INLINE OG_CONSTEXPR - const bool isInvalid() const OG_NOEXCEPT { - return _isInvalid; - } - - OG_INLINE OG_CONSTEXPR - void setInvalid(bool invalid) OG_NOEXCEPT { - _isInvalid = invalid; - } -}; /* Subgraph */ -} /* OG */ - -struct OGSubgraphStorage { - CFRuntimeBase base; - OG::Subgraph *subgraph; -}; - -namespace OG { -class SubgraphObject final { - OGSubgraphStorage storage; -}; -} - -#endif /* Subgraph_hpp */ diff --git a/Sources/OpenGraphCxx/Runtime/OGTupleType.cpp b/Sources/OpenGraphCxx/Runtime/OGTupleType.cpp deleted file mode 100644 index e639cf90..00000000 --- a/Sources/OpenGraphCxx/Runtime/OGTupleType.cpp +++ /dev/null @@ -1,260 +0,0 @@ -// -// OGTupleType.cpp -// OpenGraphCxx -// -// Audited for iOS 18.0 -// Status: Complete - -#include -#include -#include - -#ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED -#include -#endif - -OGTupleType OGNewTupleType(size_t count, const OGTypeID *elements) { - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - if (count == 1) { - return elements[0]; - } - auto metadata_elements = reinterpret_cast(elements); - const auto response = swift_getTupleTypeMetadata(MetadataState::Complete, count, metadata_elements, nullptr, nullptr); - if (response.State != MetadataState::Complete) { - OG::precondition_failure("invalid tuple type."); - } - return reinterpret_cast(response.Value); - #else - return nullptr; - #endif -} - -size_t OGTupleCount(OGTupleType tuple_type) { - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - auto metadata = reinterpret_cast(tuple_type); - if (metadata->getKind() != swift::MetadataKind::Tuple) { - return 1; - } - auto tuple_metadata = reinterpret_cast(metadata); - return tuple_metadata->NumElements; - #else - return 0; - #endif -} - -size_t OGTupleSize(OGTupleType tuple_type) { - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - auto metadata = reinterpret_cast(tuple_type); - return metadata->vw_size(); - #else - return 0; - #endif -} - -OGTypeID OGTupleElementType(OGTupleType tuple_type, size_t index) { - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - auto metadata = reinterpret_cast(tuple_type); - if (metadata->getKind() != swift::MetadataKind::Tuple) { - if (index != 0) { - OG::precondition_failure("index out of range: %d", index); - } - return reinterpret_cast(metadata); - } - auto tuple_metadata = reinterpret_cast(metadata); - if (tuple_metadata->NumElements <= index) { - OG::precondition_failure("index out of range: %d", index); - } - auto element = tuple_metadata->getElement(unsigned(index)); - return reinterpret_cast(element.Type); - #else - return nullptr; - #endif -} - -size_t OGTupleElementSize(OGTupleType tuple_type, size_t index) { - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - auto metadata = reinterpret_cast(tuple_type); - if (metadata->getKind() != swift::MetadataKind::Tuple) { - if (index != 0) { - OG::precondition_failure("index out of range: %d", index); - } - return metadata->vw_size(); - } - auto tuple_metadata = reinterpret_cast(metadata); - if (tuple_metadata->NumElements <= index) { - OG::precondition_failure("index out of range: %d", index); - } - auto element = tuple_metadata->getElement(unsigned(index)); - return element.Type->vw_size(); - #else - return 0; - #endif -} - -size_t OGTupleElementOffset(OGTupleType tuple_type, size_t index) { - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - auto metadata = reinterpret_cast(tuple_type); - if (metadata->getKind() != swift::MetadataKind::Tuple) { - if (index != 0) { - OG::precondition_failure("index out of range: %d", index); - } - return 0; - } - auto tuple_metadata = reinterpret_cast(metadata); - if (tuple_metadata->NumElements <= index) { - OG::precondition_failure("index out of range: %d", index); - } - auto element = tuple_metadata->getElement(unsigned(index)); - return element.Offset; - #else - return 0; - #endif -} - -size_t OGTupleElementOffsetChecked(OGTupleType tuple_type, size_t index, OGTypeID check_type) { - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - auto metadata = reinterpret_cast(tuple_type); - if (metadata->getKind() != swift::MetadataKind::Tuple) { - if (index != 0) { - OG::precondition_failure("index out of range: %d", index); - } - if (reinterpret_cast(metadata) != check_type) { - OG::precondition_failure("element type mismatch"); - } - return 0; - } - auto tuple_metadata = reinterpret_cast(metadata); - if (tuple_metadata->NumElements <= index) { - OG::precondition_failure("index out of range: %d", index); - } - auto element = tuple_metadata->getElement(unsigned(index)); - if (reinterpret_cast(element.Type) != check_type) { - OG::precondition_failure("element type mismatch"); - } - return element.Offset; - #else - return 0; - #endif -} - -#ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED -void *update(void* dst_ptr, const void *src_ptr, const OG::swift::metadata * metadata, OGTupleCopyOptions options) { - auto dst = reinterpret_cast(dst_ptr); - auto src = reinterpret_cast(const_cast(src_ptr)); - switch (options) { - case OGTupleCopyOptionsAssignCopy: - return metadata->vw_assignWithCopy(dst, src); - case OGTupleCopyOptionsInitCopy: - return metadata->vw_initializeWithCopy(dst, src); - case OGTupleCopyOptionsAssignTake: - return metadata->vw_assignWithTake(dst, src); - case OGTupleCopyOptionsInitTake: - return metadata->vw_initializeWithTake(dst, src); - default: - OG::precondition_failure("unknown copy options: %d", options); - } -} -#endif - -void *OGTupleSetElement(OGTupleType tuple_type, void* tuple_value, size_t index, const void *element_value, OGTypeID check_type, OGTupleCopyOptions options) { - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - auto metadata = reinterpret_cast(tuple_type); - if (metadata->getKind() != swift::MetadataKind::Tuple) { - if (index != 0) { - OG::precondition_failure("index out of range: %d", index); - } - if (reinterpret_cast(metadata) != check_type) { - OG::precondition_failure("element type mismatch"); - } - return update(tuple_value, element_value, metadata, options); - } - auto tuple_metadata = reinterpret_cast(metadata); - if (tuple_metadata->NumElements <= index) { - OG::precondition_failure("index out of range: %d", index); - } - auto element = tuple_metadata->getElement(unsigned(index)); - if (reinterpret_cast(element.Type) != check_type) { - OG::precondition_failure("element type mismatch"); - } - return update((void *)(element.findIn(reinterpret_cast(tuple_value))), element_value, reinterpret_cast(element.Type), options); - #else - return nullptr; - #endif -} - -void *OGTupleGetElement(OGTupleType tuple_type, void* tuple_value, size_t index, void *element_value, OGTypeID check_type, OGTupleCopyOptions options) { - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - auto metadata = reinterpret_cast(tuple_type); - if (metadata->getKind() != swift::MetadataKind::Tuple) { - if (index != 0) { - OG::precondition_failure("index out of range: %d", index); - } - if (reinterpret_cast(metadata) != check_type) { - OG::precondition_failure("element type mismatch"); - } - return update(element_value, tuple_value, metadata, options); - } - auto tuple_metadata = reinterpret_cast(metadata); - if (tuple_metadata->NumElements <= index) { - OG::precondition_failure("index out of range: %d", index); - } - auto element = tuple_metadata->getElement(unsigned(index)); - if (reinterpret_cast(element.Type) != check_type) { - OG::precondition_failure("element type mismatch"); - } - return update(element_value, (const void *)(element.findIn(reinterpret_cast(tuple_value))), reinterpret_cast(element.Type), options); - #else - return nullptr; - #endif -} - -void OGTupleDestroy(OGTupleType tuple_type, void *value) { - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - auto metadata = reinterpret_cast(tuple_type); - metadata->vw_destroy(reinterpret_cast(value)); - #endif -} - -void OGTupleDestroyElement(OGTupleType tuple_type, void *value, size_t index) { - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - auto metadata = reinterpret_cast(tuple_type); - if (metadata->getKind() != swift::MetadataKind::Tuple) { - if (index != 0) { - OG::precondition_failure("index out of range: %d", index); - } - metadata->vw_destroy(reinterpret_cast(value)); - } - auto tuple_metadata = reinterpret_cast(metadata); - if (tuple_metadata->NumElements <= index) { - OG::precondition_failure("index out of range: %d", index); - } - auto element = tuple_metadata->getElement(unsigned(index)); - auto element_type = element.Type; - element_type->vw_destroy(reinterpret_cast((intptr_t)value + index)); - #endif -} - -void OGTupleWithBuffer(OGTupleType tuple_type, size_t count, const void (* function)(const OGUnsafeMutableTuple mutableTuple, const void * context OG_SWIFT_CONTEXT) OG_SWIFT_CC(swift), const void *context) { - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - auto metadata = reinterpret_cast(tuple_type); - auto buffer_size = metadata->vw_stride() * count; - OGUnsafeMutableTuple tuple; - tuple.type = tuple_type; - if (buffer_size <= 0x1000) { - char buffer[buffer_size]; - bzero(buffer, buffer_size); - tuple.value = buffer; - // NOTE: If you use buffer out of the scope, the stack may be malformed. - // So we need to call function in this scope. - function(tuple, context); - } else { - void *buffer = malloc_type_malloc(buffer_size, 0x100004077774924); - if (buffer == nullptr) { - OG::precondition_failure("memory allocation failure"); - } - tuple.value = buffer; - function(tuple, context); - free(buffer); - } - #endif -} diff --git a/Sources/OpenGraphCxx/Runtime/OGTypeID.cpp b/Sources/OpenGraphCxx/Runtime/OGTypeID.cpp deleted file mode 100644 index ba13defd..00000000 --- a/Sources/OpenGraphCxx/Runtime/OGTypeID.cpp +++ /dev/null @@ -1,161 +0,0 @@ -// -// OGTypeID.cpp -// OpenGraphCxx -// -// Audited for iOS 18.0 -// Status: WIP - -#include -#include -#include - -#ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED -#include -#endif - -OGTypeKind OGTypeGetKind(OGTypeID typeID) { - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - auto metadata = reinterpret_cast(typeID); - switch (metadata->getKind()) { - case swift::MetadataKind::Class: // 0x0 - return OGTypeKindClass; - case swift::MetadataKind::Struct: // 0x200 - return OGTypeKindStruct; - case swift::MetadataKind::Enum: // 0x201 - return OGTypeKindEnum; - case swift::MetadataKind::Optional: // 0x202 - return OGTypeKindOptional; - case swift::MetadataKind::Tuple: // 0x301 - return OGTypeKindTuple; - case swift::MetadataKind::Function: // 0x302 - return OGTypeKindFunction; - case swift::MetadataKind::Existential: // 0x303 - return OGTypeKindExistential; - case swift::MetadataKind::Metatype: // 0x304 - return OGTypeKindMetatype; - default: - return OGTypeKindNone; - } - #else - return OGTypeKindNone; - #endif -} - -void OGTypeApplyFields(const void *type, const void *block, void *context) { - // TODO - return; -} - -bool OGTypeApplyFields2(const void *type, OGTypeApplyOptions options, const void *block, void *context) { - // TODO - return false; -} - -#if OPENGRAPH_RELEASE >= OPENGRAPH_RELEASE_2024 - -uint32_t OGTypeGetEnumTag(OGTypeID typeID, const void *value) { - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - auto metadata = reinterpret_cast(typeID); - auto vwt = metadata->getValueWitnesses(); - if (!swift::EnumValueWitnessTable::classof(vwt)) { - OG::precondition_failure("not an enum type: %s", metadata->name(false).data); - } - auto enum_vwt = static_cast(vwt); - return enum_vwt->getEnumTag(static_cast(value), metadata); - #else - return 0; - #endif -} - -void OGTypeProjectEnumData(OGTypeID typeID, void *value) { - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - auto metadata = reinterpret_cast(typeID); - auto vwt = metadata->getValueWitnesses(); - if (!swift::EnumValueWitnessTable::classof(vwt)) { - OG::precondition_failure("not an enum type: %s", metadata->name(false).data); - } - auto enum_vwt = static_cast(vwt); - enum_vwt->destructiveProjectEnumData(static_cast(value), metadata); - #else - return; - #endif -} - -void OGTypeInjectEnumTag(OGTypeID typeID, uint32_t tag, void *value) { - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - auto metadata = reinterpret_cast(typeID); - auto vwt = metadata->getValueWitnesses(); - if (!swift::EnumValueWitnessTable::classof(vwt)) { - OG::precondition_failure("not an enum type: %s", metadata->name(false).data); - } - auto enum_vwt = static_cast(vwt); - return enum_vwt->destructiveInjectEnumTag(static_cast(value), tag, metadata); - #else - return; - #endif -} - -#endif /* OPENGRAPH_RELEASE */ - -bool OGTypeApplyEnumData() { - // TODO - return false; -} - -bool OGTypeApplyMutableEnumData() { - // TODO - return false; -} - -CFStringRef OGTypeDescription(OGTypeID typeID) { - CFMutableStringRef ref = CFStringCreateMutable(CFAllocatorGetDefault(), 0); - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - auto metadata = reinterpret_cast(typeID); - metadata->append_description(ref); - #endif - return ref; -} - -#if OPENGRAPH_RELEASE >= OPENGRAPH_RELEASE_2024 - -OGTypeSignature const OGTypeGetSignature(OGTypeID typeID) { - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - auto metadata = reinterpret_cast(typeID); - // TODO - return OGTypeSignature{}; - #else - return OGTypeSignature{}; - #endif -} -void const* OGTypeGetDescriptor(OGTypeID typeID) { - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - auto metadata = reinterpret_cast(typeID); - return metadata->descriptor(); - #else - return nullptr; - #endif -} - -#endif /* OPENGRAPH_RELEASE */ - -void const* OGTypeNominalDescriptor(OGTypeID typeID) { - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - auto metadata = reinterpret_cast(typeID); - return metadata->nominal_descriptor(); - #else - return nullptr; - #endif -} - -char const* OGTypeNominalDescriptorName(OGTypeID typeID) { - #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - auto metadata = reinterpret_cast(typeID); - auto nominal_descriptor = metadata->nominal_descriptor(); - if (nominal_descriptor == nullptr) { - return nullptr; - } - return nominal_descriptor->Name.get(); - #else - return nullptr; - #endif -} diff --git a/Sources/OpenGraphCxx/Runtime/metadata.cpp b/Sources/OpenGraphCxx/Runtime/metadata.cpp deleted file mode 100644 index dd7217f5..00000000 --- a/Sources/OpenGraphCxx/Runtime/metadata.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// -// metadata.cpp -// OpenGraphCxx -// -// Audited for iOS 18.0 -// Status: WIP - -#include - -#ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED - -using OG::swift::metadata; - -void metadata::append_description(CFMutableStringRef description) const OG_NOEXCEPT { - // TODO -} - -#endif /* OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED */ diff --git a/Sources/OpenGraphCxx/Version/OGVersion.c b/Sources/OpenGraphCxx/Version/OGVersion.c deleted file mode 100644 index f49ff4c8..00000000 --- a/Sources/OpenGraphCxx/Version/OGVersion.c +++ /dev/null @@ -1,16 +0,0 @@ -// -// OGVersion.c -// OpenGraph - -#include -#include - -#if OPENGRAPH_RELEASE == OPENGRAPH_RELEASE_2024 -const double OpenGraphVersionNumber __attribute__ ((used)) = (double)6.0; -const unsigned char OpenGraphVersionString[] __attribute__ ((used)) = "@(#)PROGRAM:OpenGraph PROJECT:OpenGraph-6.0.87\n"; -const uint64_t OGVersion = 0x2001e; -#elif OPENGRAPH_RELEASE == OPENGRAPH_RELEASE_2021 -const double OpenGraphVersionNumber __attribute__ ((used)) = (double)3.2; -const unsigned char OpenGraphVersionString[] __attribute__ ((used)) = "@(#)PROGRAM:OpenGraph PROJECT:OpenGraph-3.2.1\n"; -const uint64_t OGVersion = 0x20014; -#endif diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGAttribute.h b/Sources/OpenGraphCxx/include/OpenGraph/OGAttribute.h deleted file mode 100644 index 6cc6d051..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGAttribute.h +++ /dev/null @@ -1,163 +0,0 @@ -// -// OGAttribute.h -// OpenGraphCxx - -#ifndef OGAttribute_h -#define OGAttribute_h - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -OG_ASSUME_NONNULL_BEGIN - -OG_EXTERN_C_BEGIN - -OG_EXPORT -const OGAttribute OGAttributeNil; - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGAttribute OGGraphGetCurrentAttribute(void); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGAttribute OGGraphCreateOffsetAttribute(OGAttribute attribute, long offset) OG_SWIFT_NAME(OGAttribute.create(self:offset:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGAttribute OGGraphCreateOffsetAttribute2(OGAttribute attribute, long offset, uint64_t size) OG_SWIFT_NAME(OGAttribute.create(self:offset:size:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGAttribute OGGraphCreateIndirectAttribute(OGAttribute attribute) OG_SWIFT_NAME(OGAttribute.createIndirect(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGAttribute OGGraphCreateIndirectAttribute2(OGAttribute attribute, uint64_t size) OG_SWIFT_NAME(OGAttribute.createIndirect(self:size:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGAttributeFlags OGGraphGetFlags(OGAttribute attribute) OG_SWIFT_NAME(getter:OGAttribute.flags(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphSetFlags(OGAttribute attribute, OGAttributeFlags flags) OG_SWIFT_NAME(setter:OGAttribute.flags(self:_:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphAddInput(OGAttribute attribute1, OGAttribute attribute2, OGInputOptions options, long token); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -const OGAttributeInfo OGGraphGetAttributeInfo(OGAttribute attribute) OG_SWIFT_NAME(getter:OGAttribute.info(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphMutateAttribute(OGAttribute attribute, - const OGTypeID type, - bool invalidating, - const void (*function)(const void * _Nullable context OG_SWIFT_CONTEXT, void *body) OG_SWIFT_CC(swift), - const void * _Nullable context); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGAttribute OGGraphGetIndirectDependency(OGAttribute attribute) OG_SWIFT_NAME(getter:OGAttribute._indirectDependency(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphSetIndirectDependency(OGAttribute attribute1, OGAttribute attribute2) OG_SWIFT_NAME(setter:OGAttribute._indirectDependency(self:_:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGAttribute OGGraphGetIndirectAttribute(OGAttribute attribute) OG_SWIFT_NAME(getter:OGAttribute.source(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphSetIndirectAttribute(OGAttribute attribute1, OGAttribute attribute2) OG_SWIFT_NAME(setter:OGAttribute.source(self:_:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGAttribute OGGraphCreateAttribute(long index, const void *body, const void * _Nullable value); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -const OGValue OGGraphGetValue(OGAttribute attribute, OGValueOptions options, const OGTypeID type); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -bool OGGraphSetValue(OGAttribute attribute, const void *value, const OGTypeID type); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -const OGValue OGGraphGetInputValue(OGAttribute attribute, OGAttribute inputAttribute, OGValueOptions options, const OGTypeID type); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -const void * _Nullable OGGraphGetOutputValue(OGTypeID type); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphSetOutputValue(const void *value, const OGTypeID type); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGValueState OGGraphGetValueState(OGAttribute attribute) OG_SWIFT_NAME(getter:OGAttribute.valueState(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -bool OGGraphHasValue(OGAttribute attribute) OG_SWIFT_NAME(getter:OGAttribute.hasValue(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphUpdateValue(OGAttribute attribute) OG_SWIFT_NAME(OGAttribute.updateValue(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphPrefetchValue(OGAttribute attribute) OG_SWIFT_NAME(OGAttribute.prefetchValue(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphInvalidateValue(OGAttribute attribute) OG_SWIFT_NAME(OGAttribute.invalidateValue(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphVerifyType(OGAttribute attribute, OGTypeID type) OG_SWIFT_NAME(OGAttribute.verify(self:type:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGGraphRef OGGraphGetAttributeGraph(OGAttribute attribute) OG_SWIFT_NAME(getter:OGAttribute.graph(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGSubgraphRef OGGraphGetAttributeSubgraph(OGAttribute attribute) OG_SWIFT_NAME(getter:OGAttribute.subgraph(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -const void * OGGraphReadCachedAttribute(long hashValue, OGTypeID bodyType, const void *bodyPointer, OGTypeID valueType, OGCachedValueOptions options, OGAttribute attribute, bool unknown/*, ...*/); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -const void * _Nullable OGGraphReadCachedAttributeIfExists(long hashValue, OGTypeID bodyType, const void *bodyPointer, OGTypeID valueType, OGCachedValueOptions options, OGAttribute attribute, bool unknown); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphWithUpdate( - OGAttribute attribute, - void (* callback)(const void *context OG_SWIFT_CONTEXT) OG_SWIFT_CC(swift), - const void *context -); - -OG_EXTERN_C_END - -OG_ASSUME_NONNULL_END - -#endif /* OGAttribute_h */ - diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGAttributeFlags.h b/Sources/OpenGraphCxx/include/OpenGraph/OGAttributeFlags.h deleted file mode 100644 index 8a19e370..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGAttributeFlags.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// OGAttributeFlags.h -// OpenGraphCxx -// -// Audited for RELEASE_2021 -// Status: Complete - -#ifndef OGAttributeFlags_h -#define OGAttributeFlags_h - -#include -#include - -typedef OG_OPTIONS(uint8_t, OGAttributeFlags) { - OGAttributeFlagsNone = 0, - OGAttributeFlagsAll = 0xFF, -} OG_SWIFT_NAME(OGAttribute.Flags); - -#endif /* OGAttributeFlags_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGAttributeInfo.h b/Sources/OpenGraphCxx/include/OpenGraph/OGAttributeInfo.h deleted file mode 100644 index be401467..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGAttributeInfo.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// OGAttributeInfo.h -// OpenGraphCxx - -#ifndef OGAttributeInfo_h -#define OGAttributeInfo_h - -#include -#include - -OG_ASSUME_NONNULL_BEGIN - -typedef struct OGAttributeInfo { - const OGAttributeType* type; - const void *body; -} OGAttributeInfo; - -OG_ASSUME_NONNULL_END - -#endif /* OGAttributeInfo_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGAttributeType.h b/Sources/OpenGraphCxx/include/OpenGraph/OGAttributeType.h deleted file mode 100644 index 4e10e128..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGAttributeType.h +++ /dev/null @@ -1,44 +0,0 @@ -// -// OGAttributeType.h -// OpenGraphCxx - -#ifndef OGAttributeType_h -#define OGAttributeType_h - -#include -#include -#include -#include - -OG_ASSUME_NONNULL_BEGIN - -typedef struct OGAttributeType OGAttributeType; - -typedef struct OG_SWIFT_NAME(_AttributeVTable) OGAttributeVTable { - unsigned long version; - void (*_Nullable type_destroy)(OGAttributeType *); - void (*_Nullable self_destroy)(const OGAttributeType *, void *); - CFStringRef _Nullable (*_Nullable self_description)(const OGAttributeType *, const void *); - CFStringRef _Nullable (*_Nullable value_description)(const OGAttributeType *, const void *); - void (*_Nullable update_default)(const OGAttributeType *, void *); -} OGAttributeVTable; - -typedef struct OG_SWIFT_NAME(_AttributeType) OGAttributeType { - OGTypeID self_id; - OGTypeID value_id; - OGClosureStorage update; - const OGAttributeVTable *vtable; - OGAttributeTypeFlags flags; - - uint32_t internal_offset; - const unsigned char *_Nullable value_layout; - - struct { - OGTypeID type_id; - const void *witness_table; - } body_conformance; -} OGAttributeType; - -OG_ASSUME_NONNULL_END - -#endif /* OGAttributeType_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGAttributeTypeFlags.h b/Sources/OpenGraphCxx/include/OpenGraph/OGAttributeTypeFlags.h deleted file mode 100644 index 3bf83989..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGAttributeTypeFlags.h +++ /dev/null @@ -1,24 +0,0 @@ -// -// OGAttributeTypeFlags.h -// OpenGraphCxx - -#ifndef OGAttributeTypeFlags_h -#define OGAttributeTypeFlags_h - -#include - -typedef OG_OPTIONS(uint32_t, OGAttributeTypeFlags) { - OGAttributeTypeFlagsComparisonModeBitwise = 0, - OGAttributeTypeFlagsComparisonModeIndirect = 1, - OGAttributeTypeFlagsComparisonModeEquatableUnlessPOD = 2, - OGAttributeTypeFlagsComparisonModeEquatableAlways = 3, - OGAttributeTypeFlagsComparisonModeMask = 0x03, - - OGAttributeTypeFlagsHasDestroySelf = 1 << 2, - OGAttributeTypeFlagsMainThread = 1 << 3, - OGAttributeTypeFlagsExternal = 1 << 4, - OGAttributeTypeFlagsAsyncThread = 1 << 5, -} OG_SWIFT_NAME(OGAttributeType.Flags); - -#endif /* OGAttributeTypeFlags_h */ - diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGBase.h b/Sources/OpenGraphCxx/include/OpenGraph/OGBase.h deleted file mode 100644 index 8cec261b..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGBase.h +++ /dev/null @@ -1,84 +0,0 @@ -// -// OGBase.h -// OpenGraphCxx - -#ifndef OGBase_h -#define OGBase_h - -#if DEBUG -#define OG_ASSERTION -#else -#undef OG_ASSERTION -#endif - -#if __has_attribute(cold) -#define __cold __attribute__((__cold__)) -#else -#define __cold -#endif - -#if __has_attribute(noreturn) -#define __dead2 __attribute__((__noreturn__)) -#else -#define __dead2 -#endif - -#if defined(__cplusplus) -#define OG_NOEXCEPT noexcept -#else -#define OG_NOEXCEPT -#endif - -#if defined(__GNUC__) -#define OG_INLINE __inline__ __attribute__((always_inline)) -#elif defined(__cplusplus) -#define OG_INLINE inline -#else -#define OG_INLINE -#endif - -#if defined(__cplusplus) -#define OG_CONSTEXPR constexpr -#else -#define OG_CONSTEXPR -#endif - -#if __has_include() // Fix conflict define issue of the SDK -#include -#define OG_COUNTED_BY(N) __counted_by(N) -#else -#if !defined(__counted_by) -#if __has_attribute(__counted_by__) -#define __counted_by(N) __attribute__((__counted_by__(N))) -#else -#define __counted_by(N) -#endif -#endif -#define OG_COUNTED_BY(N) __counted_by(N) -#endif - -#include "OGSwiftSupport.h" -#include "OGTargetConditionals.h" -#include -#include -#include - -#define OG_ENUM CF_ENUM -#define OG_CLOSED_ENUM CF_CLOSED_ENUM -#define OG_OPTIONS CF_OPTIONS -#define OG_EXTERN_C_BEGIN CF_EXTERN_C_BEGIN -#define OG_EXTERN_C_END CF_EXTERN_C_END -#define OG_ASSUME_NONNULL_BEGIN CF_ASSUME_NONNULL_BEGIN -#define OG_ASSUME_NONNULL_END CF_ASSUME_NONNULL_END -#define OG_IMPLICIT_BRIDGING_ENABLED CF_IMPLICIT_BRIDGING_ENABLED -#define OG_IMPLICIT_BRIDGING_DISABLED CF_IMPLICIT_BRIDGING_DISABLED -#define OG_EXPORT CF_EXPORT -#define OG_BRIDGED_TYPE CF_BRIDGED_TYPE - -#if OG_TARGET_OS_DARWIN && __OBJC__ -#define OG_OBJC_FOUNDATION 1 -#else -#define OG_OBJC_FOUNDATION 0 -#endif /* OG_TARGET_OS_DARWIN && __OBJC__ */ - -#endif /* OGBase_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGCachedValueOptions.h b/Sources/OpenGraphCxx/include/OpenGraph/OGCachedValueOptions.h deleted file mode 100644 index fbf89a78..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGCachedValueOptions.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// OGCachedValueOptions.h -// OpenGraphCxx - -#ifndef OGCachedValueOptions_h -#define OGCachedValueOptions_h - -#include - -typedef OG_OPTIONS(uint32_t, OGCachedValueOptions) { - OGCachedValueOptions_0 = 0, - OGCachedValueOptions_1 = 1 << 0, - OGCachedValueOptions_2 = 1 << 1, - OGCachedValueOptions_4 = 1 << 2, - OGCachedValueOptions_8 = 1 << 3, - OGCachedValueOptions_16 = 1 << 4, -}; - -#endif /* OGCachedValueOptions_h */ - diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGChangedValueFlags.h b/Sources/OpenGraphCxx/include/OpenGraph/OGChangedValueFlags.h deleted file mode 100644 index 70bc05a1..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGChangedValueFlags.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// OGChangedValueFlags.h -// OpenGraphCxx - -#ifndef OGChangedValueFlags_h -#define OGChangedValueFlags_h - -#include - -typedef OG_OPTIONS(uint32_t, OGChangedValueFlags) { - OGChangedValueFlagsChanged = 1 << 0, - OGChangedValueFlagsRequiresMainThread = 1 << 1, -}; - -#endif /* OGChangedValueFlags_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGClosure.h b/Sources/OpenGraphCxx/include/OpenGraph/OGClosure.h deleted file mode 100644 index 8730811e..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGClosure.h +++ /dev/null @@ -1,32 +0,0 @@ -// -// OGClosure.h -// OpenGraphCxx - -#ifndef OGClosure_h -#define OGClosure_h - -#include - -OG_ASSUME_NONNULL_BEGIN - -OG_EXTERN_C_BEGIN - -typedef struct OGClosureStorage { - const void *thunk; - const void *_Nullable context; -} OGClosureStorage OG_SWIFT_NAME(_OGClosureStorage); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGClosureStorage OGRetainClosure(void (*thunk)(void *_Nullable context OG_SWIFT_CONTEXT) OG_SWIFT_CC(swift), - void *_Nullable context); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGReleaseClosure(OGClosureStorage closure); - -OG_EXTERN_C_END - -OG_ASSUME_NONNULL_END - -#endif /* OGClosure_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGComparison.h b/Sources/OpenGraphCxx/include/OpenGraph/OGComparison.h deleted file mode 100644 index 305acd61..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGComparison.h +++ /dev/null @@ -1,85 +0,0 @@ -// -// OGComparison.h -// OpenGraphCxx -// -// Audited for 6.5.1 -// Status: Complete - -#ifndef OGComparison_h -#define OGComparison_h - -#include -#include - -OG_ASSUME_NONNULL_BEGIN - -OG_IMPLICIT_BRIDGING_ENABLED - -OG_EXTERN_C_BEGIN - -typedef struct OG_SWIFT_NAME(FieldRange) OGFieldRange { - size_t offset; - size_t size; -} OGFieldRange; - -typedef const void *OGComparisonState OG_SWIFT_STRUCT OG_SWIFT_NAME(ComparisonState); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -const void *OGComparisonStateGetDestination(OGComparisonState state) OG_SWIFT_NAME(getter:OGComparisonState.destination(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -const void *OGComparisonStateGetSource(OGComparisonState state) OG_SWIFT_NAME(getter:OGComparisonState.source(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGFieldRange OGComparisonStateGetFieldRange(OGComparisonState state) OG_SWIFT_NAME(getter:OGComparisonState.fieldRange(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGTypeID OGComparisonStateGetFieldType(OGComparisonState state) OG_SWIFT_NAME(getter:OGComparisonState.fieldType(self:)); - -typedef OG_ENUM(uint8_t, OGComparisonMode) { - OGComparisonModeBitwise = 0, - OGComparisonModeIndirect = 1, - OGComparisonModeEquatableUnlessPOD = 2, - OGComparisonModeEquatableAlways = 3, -} OG_SWIFT_NAME(ComparisonMode); - -typedef OG_OPTIONS(uint32_t, OGComparisonOptions) { - OGComparisonOptionsComparisonModeBitwise = 0, - OGComparisonOptionsComparisonModeIndirect = 1, - OGComparisonOptionsComparisonModeEquatableUnlessPOD = 2, - OGComparisonOptionsComparisonModeEquatableAlways = 3, - OGComparisonOptionsComparisonModeMask = 0xff, - - OGComparisonOptionsCopyOnWrite = 1 << 8, - OGComparisonOptionsFetchLayoutsSynchronously = 1 << 9, - OGComparisonOptionsTraceCompareFailed = 1ul << 31, // -1 signed int -} OG_SWIFT_NAME(ComparisonOptions); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -bool OGCompareValues(const void *lhs, - const void *rhs, - OGTypeID type_id, - OGComparisonOptions options); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -const unsigned char *_Nullable OGPrefetchCompareValues(OGTypeID type_id, - OGComparisonOptions options, - uint32_t priority); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGOverrideComparisonForTypeDescriptor(void *descriptor, OGComparisonMode mode); - -OG_EXTERN_C_END - -OG_IMPLICIT_BRIDGING_DISABLED - -OG_ASSUME_NONNULL_END - -#endif /* OGComparison_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGGraph.h b/Sources/OpenGraphCxx/include/OpenGraph/OGGraph.h deleted file mode 100644 index 01e1d61a..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGGraph.h +++ /dev/null @@ -1,123 +0,0 @@ -// -// OGGraph.h -// OpenGraphCxx - -#ifndef OGGraph_h -#define OGGraph_h - -#include -#include -#include - -// Note: Place all structure declaration in a single place to avoid header cycle dependency - -typedef struct OG_BRIDGED_TYPE(id) OGGraphStorage * OGGraphRef OG_SWIFT_NAME(Graph); -typedef struct OG_BRIDGED_TYPE(id) OGSubgraphStorage * OGSubgraphRef OG_SWIFT_NAME(Subgraph); -typedef struct OG_BRIDGED_TYPE(id) OGGraphContextStorage * OGGraphContextRef OG_SWIFT_NAME(GraphContext); - -struct OGGraphStorage; -struct OGGraphContextStorage; -struct OGSubgraphStorage; - -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 - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGGraphRef OGGraphCreate(void) OG_SWIFT_NAME(OGGraphRef.init()); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGGraphRef OGGraphCreateShared(_Nullable OGGraphRef graph) OG_SWIFT_NAME(OGGraphRef.init(shared:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -CFTypeID OGGraphGetTypeID(void) OG_SWIFT_NAME(getter:OGGraphRef.typeID()); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphStartProfiling(_Nullable OGGraphRef graph); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphStopProfiling(_Nullable OGGraphRef graph); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphResetProfile(_Nullable OGGraphRef graph); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -const void * _Nullable OGGraphGetContext(OGGraphRef graph) OG_SWIFT_NAME(getter:OGGraphRef.context(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphSetContext(OGGraphRef graph, const void * _Nullable context) OG_SWIFT_NAME(setter:OGGraphRef.context(self:_:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGGraphContextRef OGGraphGetGraphContext(OGGraphRef graph) OG_SWIFT_NAME(getter:OGGraphRef.graphContext(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphInvalidate(OGGraphRef graph) OG_SWIFT_NAME(OGGraphRef.invalidate(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphInvalidateAllValues(OGGraphRef graph) OG_SWIFT_NAME(OGGraphRef.invalidateAllValues(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphSetInvalidationCallback(OGGraphRef graph, - const void (*_Nullable function)(const void * _Nullable context OG_SWIFT_CONTEXT, OGAttribute) OG_SWIFT_CC(swift), - const void * _Nullable context); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphSetUpdateCallback(OGGraphRef graph, - const void (*_Nullable function)(const void * _Nullable context OG_SWIFT_CONTEXT) OG_SWIFT_CC(swift), - const void * _Nullable context); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -uint64_t OGGraphGetCounter(OGGraphRef graph, OGGraphCounterQueryType query) OG_SWIFT_NAME(OGGraphRef.counter(self:for:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphSetUpdate(const void * _Nullable value) OG_SWIFT_NAME(OGGraphRef.setUpdate(_:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -const void * _Nullable OGGraphClearUpdate(void) OG_SWIFT_NAME(OGGraphRef.clearUpdate()); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphSetNeedsUpdate(OGGraphRef graph) OG_SWIFT_NAME(OGGraphRef.setNeedsUpdate(self:)); - -#if OG_TARGET_OS_DARWIN -OG_EXPORT -OG_REFINED_FOR_SWIFT -bool OGGraphAnyInputsChanged(const OGAttribute *excluded_inputs OG_COUNTED_BY(count), size_t count); -#else -// __counted_by__ is supported with Swift 6.1+ toolchain's clang on Linux. -// But it required the count to be declared first which is not required on Apple clang. -// See https://github.com/OpenSwiftUIProject/OpenGraph/issues/130 -OG_EXPORT -OG_REFINED_FOR_SWIFT -bool OGGraphAnyInputsChanged(const OGAttribute *excluded_inputs, size_t count); -#endif - -OG_EXTERN_C_END - -OG_IMPLICIT_BRIDGING_DISABLED - -OG_ASSUME_NONNULL_END - -#endif /* OGGraph_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGGraphContext.h b/Sources/OpenGraphCxx/include/OpenGraph/OGGraphContext.h deleted file mode 100644 index 6eae3975..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGGraphContext.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// OGGraphContext.h -// OpenGraphCxx - -#ifndef OGGraphContext_h -#define OGGraphContext_h - -#include -#include - -// MARK: - Exported C functions - -OG_ASSUME_NONNULL_BEGIN - -OG_IMPLICIT_BRIDGING_ENABLED - -OG_EXTERN_C_BEGIN - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGGraphRef OGGraphContextGetGraph(OGGraphContextRef context) OG_SWIFT_NAME(getter:OGGraphContextRef.graph(self:)); - -OG_EXTERN_C_END - -OG_IMPLICIT_BRIDGING_DISABLED - -OG_ASSUME_NONNULL_END - -#endif /* OGGraphContext_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGGraphCounterQueryType.h b/Sources/OpenGraphCxx/include/OpenGraph/OGGraphCounterQueryType.h deleted file mode 100644 index 98a5afbe..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGGraphCounterQueryType.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// OGGraphCounterQueryType.h -// OpenGraphCxx - -#ifndef OGGraphCounterQueryType_h -#define OGGraphCounterQueryType_h - -#include - -typedef OG_ENUM(uint32_t, OGGraphCounterQueryType) { - OGGraphCounterQueryTypeNodes, - OGGraphCounterQueryTypeTransactions, - OGGraphCounterQueryTypeUpdates, - OGGraphCounterQueryTypeChanges, - OGGraphCounterQueryTypeContextID, - OGGraphCounterQueryTypeGraphID, - OGGraphCounterQueryTypeContextThreadUpdating, - OGGraphCounterQueryTypeThreadUpdating, - OGGraphCounterQueryTypeContextNeedsUpdate, - OGGraphCounterQueryTypeNeedsUpdate, - OGGraphCounterQueryTypeMainThreadUpdates, - OGGraphCounterQueryTypeCreatedNodes, - OGGraphCounterQueryTypeSubgraphs, - OGGraphCounterQueryTypeCreatedSubgraphs, -} OG_SWIFT_NAME(OGGraphRef.CounterQueryType); - -#endif /* OGGraphCounterQueryType_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGGraphDescription.h b/Sources/OpenGraphCxx/include/OpenGraph/OGGraphDescription.h deleted file mode 100644 index dd358cd4..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGGraphDescription.h +++ /dev/null @@ -1,59 +0,0 @@ -// -// OGGraphDescription.h -// OpenGraphCxx - -#ifndef OGGraphDescription_h -#define OGGraphDescription_h - -#include -#include - -OG_ASSUME_NONNULL_BEGIN - -OG_IMPLICIT_BRIDGING_ENABLED - -OG_EXTERN_C_BEGIN - -#if OG_OBJC_FOUNDATION - -typedef CFStringRef OGDescriptionOption OG_SWIFT_STRUCT OG_SWIFT_NAME(DescriptionOption); - -OG_EXPORT -const OGDescriptionOption OGDescriptionFormat OG_SWIFT_NAME(DescriptionOption.format); - -OG_EXPORT -const OGDescriptionOption OGDescriptionIncludeValues OG_SWIFT_NAME(DescriptionOption.includeValues); - -OG_EXPORT -const OGDescriptionOption OGDescriptionTruncationLimit OG_SWIFT_NAME(DescriptionOption.truncationLimit); - -OG_EXPORT -const OGDescriptionOption OGDescriptionMaxFrames OG_SWIFT_NAME(DescriptionOption.maxFrames); - -static const CFStringRef OGDescriptionFormatDot OG_SWIFT_NAME(OGGraphRef.descriptionFormatDot) = CFSTR("graph/dot"); - -static const CFStringRef OGDescriptionFormatDictionary OG_SWIFT_NAME(OGGraphRef.descriptionFormatDictionary) = CFSTR("graph/dict"); - -static const CFStringRef OGDescriptionAllGraphs OG_SWIFT_NAME(OGGraphRef.descriptionAllGraphs) = CFSTR("all_graphs"); - -#endif - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphArchiveJSON(char const * _Nullable name) OG_SWIFT_NAME(OGGraphRef.archiveJSON(name:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphArchiveJSON2(char const * _Nullable name, bool exclude_values) OG_SWIFT_NAME(OGGraphRef.archiveJSON(name:excludeValues:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -_Nullable CFTypeRef OGGraphDescription(_Nullable OGGraphRef graph, CFDictionaryRef options) OG_SWIFT_NAME(OGGraphRef.description(_:options:)); - -OG_EXTERN_C_END - -OG_IMPLICIT_BRIDGING_DISABLED - -OG_ASSUME_NONNULL_END - -#endif /* OGGraphDescription_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGGraphTracing.h b/Sources/OpenGraphCxx/include/OpenGraph/OGGraphTracing.h deleted file mode 100644 index 38d91a2d..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGGraphTracing.h +++ /dev/null @@ -1,56 +0,0 @@ -// -// OGGraphTracing.h -// OpenGraphCxx - -#ifndef OGGraphTracing_hpp -#define OGGraphTracing_hpp - -#include -#include -#include - -typedef OG_OPTIONS(uint32_t, OGGraphTraceOptions) { - OGGraphTraceOptionsEnabled = 1 << 0, - OGGraphTraceOptionsFull = 1 << 1, - OGGraphTraceOptionsBacktrace = 1 << 2, - OGGraphTraceOptionsPrepare = 1 << 3, - OGGraphTraceOptionsCustom = 1 << 4, - OGGraphTraceOptionsAll = 1 << 5, -} OG_SWIFT_NAME(OGGraphRef.TraceOptions); - -typedef struct OGTrace *OGTraceRef; - -OG_ASSUME_NONNULL_BEGIN - -OG_IMPLICIT_BRIDGING_ENABLED - -OG_EXTERN_C_BEGIN - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphStartTracing(_Nullable OGGraphRef graph, OGGraphTraceOptions options) OG_SWIFT_NAME(OGGraphRef.startTracing(_:options:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphStartTracing2(_Nullable OGGraphRef graph, OGGraphTraceOptions options, _Nullable CFArrayRef subsystems) OG_SWIFT_NAME(OGGraphRef.startTracing(_:flags:subsystems:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphStopTracing(_Nullable OGGraphRef graph) OG_SWIFT_NAME(OGGraphRef.stopTracing(_:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGUniqueID OGGraphAddTrace(OGGraphRef graph, const OGTraceRef trace, void *_Nullable context) -OG_SWIFT_NAME(OGGraphRef.addTrace(self:_:context:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGGraphRemoveTrace(OGGraphRef graph, OGUniqueID trace_id) OG_SWIFT_NAME(OGGraphRef.removeTrace(self:traceID:)); - -OG_EXTERN_C_END - -OG_IMPLICIT_BRIDGING_DISABLED - -OG_ASSUME_NONNULL_END - -#endif /* OGGraphTracing_hpp */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGInputOptions.h b/Sources/OpenGraphCxx/include/OpenGraph/OGInputOptions.h deleted file mode 100644 index c632b2a7..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGInputOptions.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// OGInputOptions.h -// OpenGraphCxx - -#ifndef OGInputOptions_h -#define OGInputOptions_h - -#include - -typedef OG_OPTIONS(uint32_t, OGInputOptions) { - OGInputOptionsNone = 0, - OGInputOptionsUnprefetched = 1 << 0, - OGInputOptionsSyncMainRef = 1 << 1, -}; - -#endif /* OGInputOptions_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGSearchOptions.h b/Sources/OpenGraphCxx/include/OpenGraph/OGSearchOptions.h deleted file mode 100644 index 81952693..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGSearchOptions.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// OGSearchOptions.h -// OpenGraphCxx - -#ifndef OGSearchOptions_h -#define OGSearchOptions_h - -#include - -typedef OG_OPTIONS(uint32_t, OGSearchOptions) { - OGSearchOptionsSearchInputs = 1 << 0, - OGSearchOptionsSearchOutputs = 1 << 1, - OGSearchOptionsTraverseGraphContexts = 1 << 2, -} OG_SWIFT_NAME(SearchOptions); - -#endif /* Header_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGSubgraph.h b/Sources/OpenGraphCxx/include/OpenGraph/OGSubgraph.h deleted file mode 100644 index 1857a650..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGSubgraph.h +++ /dev/null @@ -1,122 +0,0 @@ -// -// OGSubgraph.h -// OpenGraphCxx - -#ifndef OGSubgraph_h -#define OGSubgraph_h - -#include -#include -#include -#include -#include -#include - -OG_ASSUME_NONNULL_BEGIN - -OG_IMPLICIT_BRIDGING_ENABLED - -// MARK: - Exported C functions - -OG_EXTERN_C_BEGIN - -OG_EXPORT -OG_REFINED_FOR_SWIFT -CFTypeID OGSubgraphGetTypeID(); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGSubgraphRef OGSubgraphCreate(OGGraphRef cf_graph) OG_SWIFT_NAME(OGSubgraphRef.init(graph:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGSubgraphRef OGSubgraphCreate2(OGGraphRef cf_graph, OGAttribute attribute) OG_SWIFT_NAME(OGSubgraphRef.init(graph:attribute:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -_Nullable OGSubgraphRef OGSubgraphGetCurrent(void) OG_SWIFT_NAME(getter:OGSubgraphRef.current()); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGSubgraphSetCurrent(_Nullable OGSubgraphRef cf_subgraph) OG_SWIFT_NAME(setter:OGSubgraphRef.current(_:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -_Nullable OGGraphContextRef OGSubgraphGetCurrentGraphContext(void) OG_SWIFT_NAME(getter:OGSubgraphRef.currentGraphContext()); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGSubgraphInvalidate(OGSubgraphRef cf_subgraph) OG_SWIFT_NAME(OGSubgraphRef.invalidate(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -bool OGSubgraphIsValid(OGSubgraphRef cf_subgraph) OG_SWIFT_NAME(getter:OGSubgraphRef.isValid(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGGraphRef OGSubgraphGetGraph(OGSubgraphRef cf_subgraph) OG_SWIFT_NAME(getter:OGSubgraphRef.graph(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGSubgraphAddChild(OGSubgraphRef parent, OGSubgraphRef child) OG_SWIFT_NAME(OGSubgraphRef.addChild(self:_:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGSubgraphAddChild2(OGSubgraphRef parent, OGSubgraphRef child, uint8_t tag) OG_SWIFT_NAME(OGSubgraphRef.addChild(self:_:tag:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGSubgraphRemoveChild(OGSubgraphRef parent, OGSubgraphRef child) OG_SWIFT_NAME(OGSubgraphRef.removeChild(self:_:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -bool OGSubgraphIntersects(OGSubgraphRef subgraph, OGAttributeFlags flags) OG_SWIFT_NAME(OGSubgraphRef.intersects(self:flags:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGSubgraphApply(OGSubgraphRef cf_subgraph, - OGAttributeFlags flags, - const void (*function)(const void * _Nullable context OG_SWIFT_CONTEXT, OGAttribute attribute) OG_SWIFT_CC(swift), - const void * _Nullable context); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGSubgraphUpdate(OGSubgraphRef cf_subgraph, OGAttributeFlags flags) OG_SWIFT_NAME(OGSubgraphRef.update(self:flags:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -bool OGSubgraphIsDirty(OGSubgraphRef cf_subgraph, OGAttributeFlags flags) OG_SWIFT_NAME(OGSubgraphRef.isDirty(self:flags:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGUniqueID OGSubgraphAddObserver(OGSubgraphRef cf_subgraph, - const void (*function)(const void * _Nullable context OG_SWIFT_CONTEXT) OG_SWIFT_CC(swift), - const void * _Nullable context); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -bool OGSubgraphShouldRecordTree(void) OG_SWIFT_NAME(getter:OGSubgraphRef.shouldRecordTree()); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGSubgraphSetShouldRecordTree(void) OG_SWIFT_NAME(OGSubgraphRef.setShouldRecordTree()); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGSubgraphBeginTreeElement(OGAttribute attribute, OGTypeID type, uint32_t flags); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGSubgraphAddTreeValue(OGAttribute attribute, OGTypeID type, const char * key, uint32_t flags); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGSubgraphEndTreeElement(OGAttribute attribute); - -OG_EXTERN_C_END - -OG_IMPLICIT_BRIDGING_DISABLED - -OG_ASSUME_NONNULL_END - -#endif /* OGSubgraph_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGSwiftSupport.h b/Sources/OpenGraphCxx/include/OpenGraph/OGSwiftSupport.h deleted file mode 100644 index 82c52787..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGSwiftSupport.h +++ /dev/null @@ -1,45 +0,0 @@ -// -// OGSwiftSupport.h -// OpenGraphCxx - -#ifndef OGSwiftSupport_h -#define OGSwiftSupport_h - -#if __has_attribute(swift_name) -#define OG_SWIFT_NAME(_name) __attribute__((swift_name(#_name))) -#else -#define OG_SWIFT_NAME -#endif - -#if __has_attribute(swift_wrapper) -#define OG_SWIFT_STRUCT __attribute__((swift_wrapper(struct))) -#else -#define OG_SWIFT_STRUCT -#endif - -#if __has_attribute(swift_private) -#define OG_REFINED_FOR_SWIFT __attribute__((swift_private)) -#else -#define OG_REFINED_FOR_SWIFT -#endif - -// MARK: - Call Convension - -#define OG_SWIFT_CC(CC) OG_SWIFT_CC_##CC -// OG_SWIFT_CC(c) is the C calling convention. -#define OG_SWIFT_CC_c - -// OG_SWIFT_CC(swift) is the Swift calling convention. -#if __has_attribute(swiftcall) -#define OG_SWIFT_CC_swift __attribute__((swiftcall)) -#define OG_SWIFT_CONTEXT __attribute__((swift_context)) -#define OG_SWIFT_ERROR_RESULT __attribute__((swift_error_result)) -#define OG_SWIFT_INDIRECT_RESULT __attribute__((swift_indirect_result)) -#else -#define OG_SWIFT_CC_swift -#define OG_SWIFT_CONTEXT -#define OG_SWIFT_ERROR_RESULT -#define OG_SWIFT_INDIRECT_RESULT -#endif - -#endif /* OGSwiftSupport_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGTargetConditionals.h b/Sources/OpenGraphCxx/include/OpenGraph/OGTargetConditionals.h deleted file mode 100644 index d9691620..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGTargetConditionals.h +++ /dev/null @@ -1,277 +0,0 @@ -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See http://swift.org/LICENSE.txt for license information -// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// - -/* - File: OGTargetConditionals.h - - Contains: Autoconfiguration of TARGET_ conditionals for Mac OS X and iPhone - - Note: OpenSwiftUITargetConditionals.h in 3.4 Universal Interfaces works - with all compilers. This header only recognizes compilers - known to run on Mac OS X. - -*/ - -#ifndef __OPENGRAPHTARGETCONDITIONALS__ -#define __OPENGRAPHTARGETCONDITIONALS__ -/**************************************************************************************************** - - TARGET_CPU_* - These conditionals specify which microprocessor instruction set is being - generated. At most one of these is true, the rest are false. - - TARGET_CPU_PPC - Compiler is generating PowerPC instructions for 32-bit mode - TARGET_CPU_PPC64 - Compiler is generating PowerPC instructions for 64-bit mode - TARGET_CPU_68K - Compiler is generating 680x0 instructions - TARGET_CPU_X86 - Compiler is generating x86 instructions - TARGET_CPU_ARM - Compiler is generating ARM instructions - TARGET_CPU_MIPS - Compiler is generating MIPS instructions - TARGET_CPU_SPARC - Compiler is generating Sparc instructions - TARGET_CPU_ALPHA - Compiler is generating Dec Alpha instructions - TARGET_CPU_WASM32 - Compiler is generating WebAssembly instructions for 32-bit mode - - - TARGET_OS_* - These conditionals specify in which Operating System the generated code will - run. Indention is used to show which conditionals are evolutionary subclasses. - - The MAC/WIN32/UNIX conditionals are mutually exclusive. - The IOS/TV/WATCH conditionals are mutually exclusive. - - - TARGET_OS_WIN32 - Generated code will run under 32-bit Windows - TARGET_OS_UNIX - Generated code will run under some Unix (not OSX) - TARGET_OS_CYGWIN - Generated code will run under 64-bit Cygwin - TARGET_OS_WASI - Generated code will run under WebAssembly System Interface - TARGET_OS_MAC - Generated code will run under Mac OS X variant - TARGET_OS_IPHONE - Generated code for firmware, devices, or simulator - TARGET_OS_IOS - Generated code will run under iOS - TARGET_OS_TV - Generated code will run under Apple TV OS - TARGET_OS_WATCH - Generated code will run under Apple Watch OS - TARGET_OS_SIMULATOR - Generated code will run under a simulator - TARGET_OS_EMBEDDED - Generated code for firmware - - TARGET_IPHONE_SIMULATOR - DEPRECATED: Same as TARGET_OS_SIMULATOR - TARGET_OS_NANO - DEPRECATED: Same as TARGET_OS_WATCH - - TARGET_RT_* - These conditionals specify in which runtime the generated code will - run. This is needed when the OS and CPU support more than one runtime - (e.g. Mac OS X supports CFM and mach-o). - - TARGET_RT_LITTLE_ENDIAN - Generated code uses little endian format for integers - TARGET_RT_BIG_ENDIAN - Generated code uses big endian format for integers - TARGET_RT_64_BIT - Generated code uses 64-bit pointers - TARGET_RT_MAC_CFM - TARGET_OS_MAC is true and CFM68K or PowerPC CFM (TVectors) are used - TARGET_RT_MAC_MACHO - TARGET_OS_MAC is true and Mach-O/dlyd runtime is used - - -****************************************************************************************************/ - -#if __APPLE__ -#define OG_TARGET_OS_DARWIN 1 -#define OG_TARGET_OS_LINUX 0 -#define OG_TARGET_OS_WINDOWS 0 -#define OG_TARGET_OS_BSD 0 -#define OG_TARGET_OS_ANDROID 0 -#define OG_TARGET_OS_CYGWIN 0 -#define OG_TARGET_OS_WASI 0 -#elif __ANDROID__ -#define OG_TARGET_OS_DARWIN 0 -#define OG_TARGET_OS_LINUX 1 -#define OG_TARGET_OS_WINDOWS 0 -#define OG_TARGET_OS_BSD 0 -#define OG_TARGET_OS_ANDROID 1 -#define OG_TARGET_OS_CYGWIN 0 -#define OG_TARGET_OS_WASI 0 -#elif __linux__ -#define OG_TARGET_OS_DARWIN 0 -#define OG_TARGET_OS_LINUX 1 -#define OG_TARGET_OS_WINDOWS 0 -#define OG_TARGET_OS_BSD 0 -#define OG_TARGET_OS_ANDROID 0 -#define OG_TARGET_OS_CYGWIN 0 -#define OG_TARGET_OS_WASI 0 -#elif __CYGWIN__ -#define OG_TARGET_OS_DARWIN 0 -#define OG_TARGET_OS_LINUX 1 -#define OG_TARGET_OS_WINDOWS 0 -#define OG_TARGET_OS_BSD 0 -#define OG_TARGET_OS_ANDROID 0 -#define OG_TARGET_OS_CYGWIN 1 -#define OG_TARGET_OS_WASI 0 -#elif _WIN32 || _WIN64 -#define OG_TARGET_OS_DARWIN 0 -#define OG_TARGET_OS_LINUX 0 -#define OG_TARGET_OS_WINDOWS 1 -#define OG_TARGET_OS_BSD 0 -#define OG_TARGET_OS_ANDROID 0 -#define OG_TARGET_OS_CYGWIN 0 -#define OG_TARGET_OS_WASI 0 -#elif __unix__ -#define OG_TARGET_OS_DARWIN 0 -#define OG_TARGET_OS_LINUX 0 -#define OG_TARGET_OS_WINDOWS 0 -#define OG_TARGET_OS_BSD 1 -#define OG_TARGET_OS_ANDROID 0 -#define OG_TARGET_OS_CYGWIN 0 -#define OG_TARGET_OS_WASI 0 -#elif __wasi__ -#define OG_TARGET_OS_DARWIN 0 -#define OG_TARGET_OS_LINUX 0 -#define OG_TARGET_OS_WINDOWS 0 -#define OG_TARGET_OS_BSD 0 -#define OG_TARGET_OS_ANDROID 0 -#define OG_TARGET_OS_CYGWIN 0 -#define OG_TARGET_OS_WASI 1 -#else -#error unknown operating system -#endif - -#define OG_TARGET_OS_WIN32 OG_TARGET_OS_WINDOWS -#define OG_TARGET_OS_MAC OG_TARGET_OS_DARWIN -#define OG_TARGET_OS_OSX OG_TARGET_OS_DARWIN - -// iOS, watchOS, and tvOS are not supported -#define OG_TARGET_OS_IPHONE 0 -#define OG_TARGET_OS_IOS 0 -#define OG_TARGET_OS_WATCH 0 -#define OG_TARGET_OS_TV 0 - -#if __x86_64__ -#define OG_TARGET_CPU_PPC 0 -#define OG_TARGET_CPU_PPC64 0 -#define OG_TARGET_CPU_X86 0 -#define OG_TARGET_CPU_X86_64 1 -#define OG_TARGET_CPU_ARM 0 -#define OG_TARGET_CPU_ARM64 0 -#define OG_TARGET_CPU_MIPS 0 -#define OG_TARGET_CPU_MIPS64 0 -#define OG_TARGET_CPU_S390X 0 -#define OG_TARGET_CPU_WASM32 0 -#elif __arm64__ || __aarch64__ -#define OG_TARGET_CPU_PPC 0 -#define OG_TARGET_CPU_PPC64 0 -#define OG_TARGET_CPU_X86 0 -#define OG_TARGET_CPU_X86_64 0 -#define OG_TARGET_CPU_ARM 0 -#define OG_TARGET_CPU_ARM64 1 -#define OG_TARGET_CPU_MIPS 0 -#define OG_TARGET_CPU_MIPS64 0 -#define OG_TARGET_CPU_S390X 0 -#define OG_TARGET_CPU_WASM32 0 -#elif __mips64__ -#define OG_TARGET_CPU_PPC 0 -#define OG_TARGET_CPU_PPC64 0 -#define OG_TARGET_CPU_X86 0 -#define OG_TARGET_CPU_X86_64 0 -#define OG_TARGET_CPU_ARM 0 -#define OG_TARGET_CPU_ARM64 0 -#define OG_TARGET_CPU_MIPS 0 -#define OG_TARGET_CPU_MIPS64 1 -#define OG_TARGET_CPU_S390X 0 -#define OG_TARGET_CPU_WASM32 0 -#elif __powerpc64__ -#define OG_TARGET_CPU_PPC 0 -#define OG_TARGET_CPU_PPC64 1 -#define OG_TARGET_CPU_X86 0 -#define OG_TARGET_CPU_X86_64 0 -#define OG_TARGET_CPU_ARM 0 -#define OG_TARGET_CPU_ARM64 0 -#define OG_TARGET_CPU_MIPS 0 -#define OG_TARGET_CPU_MIPS64 0 -#define OG_TARGET_CPU_S390X 0 -#define OG_TARGET_CPU_WASM32 0 -#elif __i386__ -#define OG_TARGET_CPU_PPC 0 -#define OG_TARGET_CPU_PPC64 0 -#define OG_TARGET_CPU_X86 1 -#define OG_TARGET_CPU_X86_64 0 -#define OG_TARGET_CPU_ARM 0 -#define OG_TARGET_CPU_ARM64 0 -#define OG_TARGET_CPU_MIPS 0 -#define OG_TARGET_CPU_MIPS64 0 -#define OG_TARGET_CPU_S390X 0 -#define OG_TARGET_CPU_WASM32 0 -#elif __arm__ -#define OG_TARGET_CPU_PPC 0 -#define OG_TARGET_CPU_PPC64 0 -#define OG_TARGET_CPU_X86 0 -#define OG_TARGET_CPU_X86_64 0 -#define OG_TARGET_CPU_ARM 1 -#define OG_TARGET_CPU_ARM64 0 -#define OG_TARGET_CPU_MIPS 0 -#define OG_TARGET_CPU_MIPS64 0 -#define OG_TARGET_CPU_S390X 0 -#define OG_TARGET_CPU_WASM32 0 -#elif __mips__ -#define OG_TARGET_CPU_PPC 0 -#define OG_TARGET_CPU_PPC64 0 -#define OG_TARGET_CPU_X86 0 -#define OG_TARGET_CPU_X86_64 0 -#define OG_TARGET_CPU_ARM 0 -#define OG_TARGET_CPU_ARM64 0 -#define OG_TARGET_CPU_MIPS 1 -#define OG_TARGET_CPU_MIPS64 0 -#define OG_TARGET_CPU_S390X 0 -#define OG_TARGET_CPU_WASM32 0 -#elif __powerpc__ -#define OG_TARGET_CPU_PPC 1 -#define OG_TARGET_CPU_PPC64 0 -#define OG_TARGET_CPU_X86 0 -#define OG_TARGET_CPU_X86_64 0 -#define OG_TARGET_CPU_ARM 0 -#define OG_TARGET_CPU_ARM64 0 -#define OG_TARGET_CPU_MIPS 0 -#define OG_TARGET_CPU_MIPS64 0 -#define OG_TARGET_CPU_S390X 0 -#define OG_TARGET_CPU_WASM32 0 -#elif __s390x__ -#define OG_TARGET_CPU_PPC 0 -#define OG_TARGET_CPU_PPC64 0 -#define OG_TARGET_CPU_X86 0 -#define OG_TARGET_CPU_X86_64 0 -#define OG_TARGET_CPU_ARM 0 -#define OG_TARGET_CPU_ARM64 0 -#define OG_TARGET_CPU_MIPS 0 -#define OG_TARGET_CPU_MIPS64 0 -#define OG_TARGET_CPU_S390X 1 -#define OG_TARGET_CPU_WASM32 0 -#elif __wasm32__ -#define OG_TARGET_CPU_PPC 0 -#define OG_TARGET_CPU_PPC64 0 -#define OG_TARGET_CPU_X86 0 -#define OG_TARGET_CPU_X86_64 0 -#define OG_TARGET_CPU_ARM 0 -#define OG_TARGET_CPU_ARM64 0 -#define OG_TARGET_CPU_MIPS 0 -#define OG_TARGET_CPU_MIPS64 0 -#define OG_TARGET_CPU_S390X 0 -#define OG_TARGET_CPU_WASM32 1 -#else -#error unknown architecture -#endif - -#if __LITTLE_ENDIAN__ -#define OG_TARGET_RT_LITTLE_ENDIAN 1 -#define OG_TARGET_RT_BIG_ENDIAN 0 -#elif __BIG_ENDIAN__ -#define OG_TARGET_RT_LITTLE_ENDIAN 0 -#define OG_TARGET_RT_BIG_ENDIAN 1 -#else -#error unknown endian -#endif - -#if __LP64__ || __LLP64__ || __POINTER_WIDTH__-0 == 64 -#define OG_TARGET_RT_64_BIT 1 -#else -#define OG_TARGET_RT_64_BIT 0 -#endif - -#endif /* __OPENGRAPHTARGETCONDITIONALS__ */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGTrace.h b/Sources/OpenGraphCxx/include/OpenGraph/OGTrace.h deleted file mode 100644 index 2f1dc461..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGTrace.h +++ /dev/null @@ -1,83 +0,0 @@ -// -// OGTrace.h -// OpenGraphCxx - -#ifndef OGTrace_h -#define OGTrace_h - -#include -#include - -OG_ASSUME_NONNULL_BEGIN - -typedef OG_ENUM(uint64_t, OGTraceEvents) { - OGTraceEventsCustom = 1, - OGTraceEventsNamed = 2, - OGTraceEventsDeadline = 3, - OGTraceEventsCompareFailed = 4, -} OG_SWIFT_NAME(TraceEvents); - -typedef struct OGTrace { - OGTraceEvents events; - - void (*_Nullable begin_trace)(void *_Nullable context, OGGraphRef graph); - void (*_Nullable end_trace)(void *_Nullable context, OGGraphRef graph); - - void (*_Nullable begin_update_subgraph)(void *_Nullable context, OGSubgraphRef subgraph, uint32_t options); - void (*_Nullable end_update_subgraph)(void *_Nullable context, OGSubgraphRef subgraph); - void (*_Nullable begin_update_stack)(void *_Nullable context, OGAttribute attribute); - void (*_Nullable end_update_stack)(void *_Nullable context, bool changed); - void (*_Nullable begin_update_attribute)(void *_Nullable context, OGAttribute attribute); - void (*_Nullable end_update_attribute)(void *_Nullable context, OGAttribute attribute, bool changed); - void (*_Nullable begin_update_graph)(void *_Nullable context, OGGraphRef graph); - void (*_Nullable end_update_graph)(void *_Nullable context, OGGraphRef graph); - - void (*_Nullable begin_invalidation)(void *_Nullable context, OGGraphRef graph, OGAttribute attribute); - void (*_Nullable end_invalidation)(void *_Nullable context, OGGraphRef graph, OGAttribute attribute); - - void (*_Nullable begin_modify)(void *_Nullable context, OGAttribute attribute); - void (*_Nullable end_modify)(void *_Nullable context, OGAttribute attribute); - - void (*_Nullable begin_event)(void *_Nullable context, OGAttribute attribute, const char *event_name); - void (*_Nullable end_event)(void *_Nullable context, OGAttribute attribute, const char *event_name); - - void (*_Nullable created_graph)(void *_Nullable context, OGGraphRef graph); - void (*_Nullable destroy_graph)(void *_Nullable context, OGGraphRef graph); - void (*_Nullable needs_update)(void *_Nullable context, OGGraphRef graph); - - void (*_Nullable created_subgraph)(void *_Nullable context, OGSubgraphRef subgraph); - void (*_Nullable invalidate_subgraph)(void *_Nullable context, OGSubgraphRef subgraph); - void (*_Nullable add_child_subgraph)(void *_Nullable context, OGSubgraphRef subgraph, OGSubgraphRef child); - void (*_Nullable remove_child_subgraph)(void *_Nullable context, OGSubgraphRef subgraph, OGSubgraphRef child); - - void (*_Nullable added_attribute)(void *_Nullable context, OGAttribute attribute); - void (*_Nullable add_edge)(void *_Nullable context, OGAttribute attribute, OGAttribute input, unsigned int flags); - void (*_Nullable remove_edge)(void *_Nullable context, OGAttribute attribute, size_t index); - void (*_Nullable set_edge_pending)(void *_Nullable context, OGAttribute attribute, OGAttribute input, bool pending); - - void (*_Nullable set_dirty)(void *_Nullable context, OGAttribute attribute, bool dirty); - void (*_Nullable set_pending)(void *_Nullable context, OGAttribute attribute, bool pending); - void (*_Nullable set_value)(void *_Nullable context, OGAttribute attribute); - void (*_Nullable mark_value)(void *_Nullable context, OGAttribute attribute); - - void (*_Nullable added_indirect_attribute)(void *_Nullable context, OGAttribute attribute); - void (*_Nullable set_source)(void *_Nullable context, OGAttribute attribute, OGAttribute source); - void (*_Nullable set_dependency)(void *_Nullable context, OGAttribute attribute, OGAttribute dependency); - - void (*_Nullable mark_profile)(void *_Nullable context, const char *event_name); - - void (*_Nullable custom_event)(void *_Nullable context, OGGraphRef graph, const char *event_name, const void *value, - OGTypeID type); - void (*_Nullable named_event)(void *_Nullable context, OGGraphRef graph, uint32_t eventID, uint32_t eventArgCount, - const void *eventArgs, CFDataRef data, uint32_t arg6); - bool (*_Nullable named_event_enabled)(void *_Nullable context); - - void (*_Nullable set_deadline)(void *_Nullable context); - void (*_Nullable passed_deadline)(void *_Nullable context); - - void (*_Nullable compare_failed)(void *_Nullable context, OGAttribute attribute, OGComparisonState comparisonState); -} OGTrace OG_SWIFT_NAME(Trace); - -OG_ASSUME_NONNULL_END - -#endif /* OGTrace_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGTupleType.h b/Sources/OpenGraphCxx/include/OpenGraph/OGTupleType.h deleted file mode 100644 index f58a0dba..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGTupleType.h +++ /dev/null @@ -1,93 +0,0 @@ -// -// OGTupleType.h -// OpenGraphCxx -// -// Audited for iOS 18.0 -// Status: Complete - -#ifndef OGTupleType_h -#define OGTupleType_h - -#include -#include - -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) { - OGTupleCopyOptionsAssignCopy = 0, - OGTupleCopyOptionsInitCopy = 1, - OGTupleCopyOptionsAssignTake = 2, - OGTupleCopyOptionsInitTake = 3 -} OG_SWIFT_NAME(TupleType.CopyOptions); - -typedef struct OG_SWIFT_NAME(UnsafeTuple) OGUnsafeTuple { - OGTupleType type; - const void *value; -} OGUnsafeTuple; - -typedef struct OG_SWIFT_NAME(UnsafeMutableTuple) OGUnsafeMutableTuple { - OGTupleType type; - void *value; -} OGUnsafeMutableTuple; - -OG_EXTERN_C_BEGIN - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGTupleType OGNewTupleType(size_t count, const OGTypeID _Nonnull * _Nonnull elements) OG_SWIFT_NAME(TupleType.init(count:elements:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -size_t OGTupleCount(OGTupleType tuple_type) OG_SWIFT_NAME(getter:TupleType.count(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -size_t OGTupleSize(OGTupleType tuple_type) OG_SWIFT_NAME(getter:TupleType.size(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGTypeID OGTupleElementType(OGTupleType tuple_type, size_t index) OG_SWIFT_NAME(TupleType.elementType(self:at:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -size_t OGTupleElementSize(OGTupleType tuple_type, size_t index) OG_SWIFT_NAME(TupleType.elementSize(self:at:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -size_t OGTupleElementOffset(OGTupleType tuple_type, size_t index) OG_SWIFT_NAME(TupleType.elementOffset(self:at:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -size_t OGTupleElementOffsetChecked(OGTupleType tuple_type, size_t index, OGTypeID check_type) OG_SWIFT_NAME(TupleType.elementOffset(self:at:type:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void *OGTupleSetElement(OGTupleType tuple_type, void* tuple_value, size_t index, const void *element_value, OGTypeID check_type, OGTupleCopyOptions mode); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void *OGTupleGetElement(OGTupleType tuple_type, void* tuple_value, size_t index, void *element_value, OGTypeID check_type, OGTupleCopyOptions mode); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGTupleDestroy(OGTupleType tuple_type, void *buffer) OG_SWIFT_NAME(TupleType.destroy(self:_:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGTupleDestroyElement(OGTupleType tuple_type, void *buffer, size_t index) OG_SWIFT_NAME(TupleType.destroy(self:_:at:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGTupleWithBuffer(OGTupleType tuple_type, size_t count, const void (* function)(const OGUnsafeMutableTuple mutableTuple, const void * context OG_SWIFT_CONTEXT) OG_SWIFT_CC(swift), const void *context); - -OG_EXTERN_C_END - -OG_IMPLICIT_BRIDGING_DISABLED - -OG_ASSUME_NONNULL_END - -#endif /* OGTupleType_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGTypeID.h b/Sources/OpenGraphCxx/include/OpenGraph/OGTypeID.h deleted file mode 100644 index 5c58cd7a..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGTypeID.h +++ /dev/null @@ -1,123 +0,0 @@ -// -// OGTypeID.h -// OpenGraphCxx -// -// Audited for iOS 18.0 -// Status: Complete - -#ifndef OGTypeID_h -#define OGTypeID_h - -#include -#include - -OG_ASSUME_NONNULL_BEGIN - -OG_IMPLICIT_BRIDGING_ENABLED - -typedef struct OG_SWIFT_NAME(_Metadata) OGSwiftMetadata { -} OGSwiftMetadata; - -typedef const OGSwiftMetadata *OGTypeID OG_SWIFT_STRUCT OG_SWIFT_NAME(Metadata); - -typedef OG_CLOSED_ENUM(uint32_t, OGTypeKind) { - OGTypeKindNone, - OGTypeKindClass, - OGTypeKindStruct, - OGTypeKindEnum, - OGTypeKindOptional, - OGTypeKindTuple, - OGTypeKindFunction, - OGTypeKindExistential, - OGTypeKindMetatype, -} OG_SWIFT_NAME(Metadata.Kind); - -typedef OG_OPTIONS(uint32_t, OGTypeApplyOptions) { - OGTypeApplyOptionsEnumerateStructFields = 0, - OGTypeApplyOptionsEnumerateClassFields = 1 << 0, - OGTypeApplyOptionsContinueAfterUnknownField = 1 << 1, - OGTypeApplyOptionsEnumerateEnumCases = 1 << 2, -} OG_SWIFT_NAME(Metadata.ApplyOptions); - -#if OPENGRAPH_RELEASE >= OPENGRAPH_RELEASE_2024 - -typedef struct OG_SWIFT_NAME(Signature) OGTypeSignature { - uint8_t bytes[20]; -} OGTypeSignature; - -#endif - -OG_EXTERN_C_BEGIN - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGTypeKind OGTypeGetKind(OGTypeID typeID) OG_SWIFT_NAME(getter:Metadata.kind(self:)); - -// TODO -// OGOverrideComparisonForTypeDescriptor(); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGTypeApplyFields(const void *type, const void *block, void *context); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -bool OGTypeApplyFields2(const void *type, OGTypeApplyOptions options, const void *block, void *context); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -uint32_t OGTypeGetEnumTag(OGTypeID typeID, const void *value) OG_SWIFT_NAME(Metadata.enumTag(self:_:)); - -#if OPENGRAPH_RELEASE >= OPENGRAPH_RELEASE_2024 - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGTypeProjectEnumData(OGTypeID typeID, void *value) OG_SWIFT_NAME(Metadata.projectEnumData(self:_:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void OGTypeInjectEnumTag(OGTypeID typeID, uint32_t tag, void *value) OG_SWIFT_NAME(Metadata.injectEnumTag(self:tag:_:)); - -#endif /* OPENGRAPH_RELEASE */ - -// TODO -OG_EXPORT -OG_REFINED_FOR_SWIFT -bool OGTypeApplyEnumData(); - -// TODO -OG_EXPORT -OG_REFINED_FOR_SWIFT -bool OGTypeApplyMutableEnumData(); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -CFStringRef OGTypeDescription(OGTypeID typeID); - -#if OPENGRAPH_RELEASE >= OPENGRAPH_RELEASE_2024 - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGTypeSignature const OGTypeGetSignature(OGTypeID typeID) OG_SWIFT_NAME(getter:Metadata.signature(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void const* _Nullable OGTypeGetDescriptor(OGTypeID typeID) OG_SWIFT_NAME(getter:Metadata.descriptor(self:)); - -#endif /* OPENGRAPH_RELEASE */ - -OG_EXPORT -OG_REFINED_FOR_SWIFT -void const* _Nullable OGTypeNominalDescriptor(OGTypeID typeID) OG_SWIFT_NAME(getter:Metadata.nominalDescriptor(self:)); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -char const* _Nullable OGTypeNominalDescriptorName(OGTypeID typeID) OG_SWIFT_NAME(getter:Metadata.nominalDescriptorName(self:)); - -OG_EXTERN_C_END - -OG_IMPLICIT_BRIDGING_DISABLED - -OG_ASSUME_NONNULL_END - -#endif /* OGTypeID_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGUniqueID.h b/Sources/OpenGraphCxx/include/OpenGraph/OGUniqueID.h deleted file mode 100644 index c57eeb47..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGUniqueID.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// OGUniqueID.h -// OpenGraphCxx -// -// Audited for iOS 18.0 -// Status: Complete - -#ifndef OGUniqueID_h -#define OGUniqueID_h - -#include -typedef long OGUniqueID; - -OG_EXTERN_C_BEGIN -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGUniqueID OGMakeUniqueID(void) OG_SWIFT_NAME(makeUniqueID()); -OG_EXTERN_C_END - -#endif /* OGUniqueID_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGValue.h b/Sources/OpenGraphCxx/include/OpenGraph/OGValue.h deleted file mode 100644 index e5dda87b..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGValue.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// OGValue.h -// OpenGraphCxx - -#ifndef OGValue_h -#define OGValue_h - -#include -#include - -OG_ASSUME_NONNULL_BEGIN - -typedef struct OGValue { - const void *value; - OGChangedValueFlags flags; -} OGValue; - -OG_ASSUME_NONNULL_END - -#endif /* OGValue_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGValueOptions.h b/Sources/OpenGraphCxx/include/OpenGraph/OGValueOptions.h deleted file mode 100644 index 6c148abf..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGValueOptions.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// OGValueOptions.h -// OpenGraphCxx - -#ifndef OGValueOptions_h -#define OGValueOptions_h - -#include - -typedef OG_OPTIONS(uint32_t, OGValueOptions) { - OGValueOptionsNone = 0, - OGValueOptionsInputOptionsUnprefetched = 1 << 0, - OGValueOptionsInputOptionsSyncMainRef = 1 << 1, - OGValueOptionsInputOptionsMask = 0x03, - - OGValueOptionsIncrementGraphVersion = 1 << 2, // AsTopLevelOutput -}; - -#endif /* OGValueOptions_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGValueState.h b/Sources/OpenGraphCxx/include/OpenGraph/OGValueState.h deleted file mode 100644 index 8faffdd8..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGValueState.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// OGValueState.h -// OpenGraphCxx - -#ifndef OGValueState_h -#define OGValueState_h - -#include - -OG_ASSUME_NONNULL_BEGIN - -typedef OG_OPTIONS(uint8_t, OGValueState) { - OGValueStateNone = 0, - OGValueStateDirty = 1 << 0, - OGValueStatePending = 1 << 1, - OGValueStateUpdating = 1 << 2, - OGValueStateValueExists = 1 << 3, - OGValueStateMainThread = 1 << 4, - OGValueStateMainRef = 1 << 5, - OGValueStateRequiresMainThread = 1 << 6, - OGValueStateSelfModified = 1 << 7, -} OG_SWIFT_NAME(ValueState); - -OG_ASSUME_NONNULL_END - -#endif /* OGValueState_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGVersion.h b/Sources/OpenGraphCxx/include/OpenGraph/OGVersion.h deleted file mode 100644 index 05c1d781..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGVersion.h +++ /dev/null @@ -1,25 +0,0 @@ -// -// OGVersion.h -// OpenGraphCxx - -#ifndef OGVersion_h -#define OGVersion_h - -#include - -#define OPENGRAPH_RELEASE 2024 - -#define OPENGRAPH_RELEASE_2021 2021 -#define OPENGRAPH_RELEASE_2024 2024 - -#ifndef OPENGRAPH_RELEASE -#define OPENGRAPH_RELEASE OPENGRAPH_RELEASE_2024 -#endif - -OG_EXTERN_C_BEGIN - -OG_EXPORT const uint64_t OGVersion; - -OG_EXTERN_C_END - -#endif /* OGVersion_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGWeakAttribute.h b/Sources/OpenGraphCxx/include/OpenGraph/OGWeakAttribute.h deleted file mode 100644 index 9239dbb7..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGWeakAttribute.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// OGWeakAttribute.h -// OpenGraphCxx - -#ifndef OGWeakAttribute_hpp -#define OGWeakAttribute_hpp - -#include -#include -#include - -OG_ASSUME_NONNULL_BEGIN - -typedef struct OGWeakAttribute { - struct { - OGAttribute identifier; - uint32_t seed; - } _details; -} OGWeakAttribute OG_SWIFT_NAME(AnyWeakAttribute); - -OG_EXTERN_C_BEGIN - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGWeakAttribute OGCreateWeakAttribute(OGAttribute attribute); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGAttribute OGWeakAttributeGetAttribute(OGWeakAttribute weakAttribute); - -OG_EXPORT -OG_REFINED_FOR_SWIFT -OGWeakValue OGGraphGetWeakValue(OGWeakAttribute weakAttribute, OGValueOptions options, OGTypeID type); - -OG_EXTERN_C_END - -OG_ASSUME_NONNULL_END - -#endif /* OGWeakAttribute_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGWeakValue.h b/Sources/OpenGraphCxx/include/OpenGraph/OGWeakValue.h deleted file mode 100644 index dd8faed8..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGWeakValue.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// OGWeakValue.h -// OpenGraphCxx - -#ifndef OGWeakValue_h -#define OGWeakValue_h - -#include -#include - -OG_ASSUME_NONNULL_BEGIN - -typedef struct OGWeakValue { - const void * _Nullable value; - OGChangedValueFlags flags; -} OGWeakValue; - -OG_ASSUME_NONNULL_END - -#endif /* OGWeakValue_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OpenGraph-umbrella.h b/Sources/OpenGraphCxx/include/OpenGraph/OpenGraph-umbrella.h deleted file mode 100644 index fc00873a..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraph/OpenGraph-umbrella.h +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -OG_EXPORT double OpenGraphVersionNumber; -OG_EXPORT const unsigned char OpenGraphVersionString[]; diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Attribute/AttributeType.hpp b/Sources/OpenGraphCxx/include/OpenGraphCxx/Attribute/AttributeType.hpp deleted file mode 100644 index 9754bd2a..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Attribute/AttributeType.hpp +++ /dev/null @@ -1,16 +0,0 @@ -// -// AttributeType.hpp -// OpenGraphCxx - -#ifndef AttributeType_hpp -#define AttributeType_hpp - -#include -#include - -namespace OG { -struct AttributeType { - OGAttributeType storage; -}; -} -#endif /* AttributeType_hpp */ diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Comparison/OGComparisonPrivate.h b/Sources/OpenGraphCxx/include/OpenGraphCxx/Comparison/OGComparisonPrivate.h deleted file mode 100644 index cb3a2c1e..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Comparison/OGComparisonPrivate.h +++ /dev/null @@ -1,31 +0,0 @@ -// -// OGComparisonPrivate.h -// OpenGraphCxx -// -// Audited for 6.5.1 -// Status: Complete - -#ifndef OGComparisonPrivate_h -#define OGComparisonPrivate_h - -#include -#include -#include - -OG_ASSUME_NONNULL_BEGIN - -OG_EXTERN_C_BEGIN - -typedef struct OGComparisonStateStorage { - const void *destination; - const void *source; - OGFieldRange field_range; - OGTypeID field_type; -} OGComparisonStateStorage; - -OG_EXTERN_C_END - -OG_ASSUME_NONNULL_END - -#endif /* OGComparisonPrivate_h */ - diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Data/ClosureFunction.hpp b/Sources/OpenGraphCxx/include/OpenGraphCxx/Data/ClosureFunction.hpp deleted file mode 100644 index 08c6e949..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Data/ClosureFunction.hpp +++ /dev/null @@ -1,74 +0,0 @@ -// -// ClosureFunction.hpp -// OpenGraphCxx - -#ifndef ClosureFunction_hpp -#define ClosureFunction_hpp - -#include -#include - -OG_ASSUME_NONNULL_BEGIN - -namespace OG { -template -class ClosureFunction final { -public: - typedef const void * _Nullable Context; - typedef const ReturnType (* _Nullable Callable)(Context OG_SWIFT_CONTEXT, Args...) OG_SWIFT_CC(swift); - - OG_INLINE OG_CONSTEXPR - ClosureFunction(Callable function, Context context) OG_NOEXCEPT : - _function(function), - _context(context) { - } - - OG_INLINE OG_CONSTEXPR - ClosureFunction(std::nullptr_t) OG_NOEXCEPT : - _function(nullptr), - _context(nullptr) { - } - - OG_INLINE - ~ClosureFunction() noexcept { - } - - OG_INLINE OG_CONSTEXPR - ClosureFunction(const ClosureFunction &value) OG_NOEXCEPT : - _function(value._function), - _context(value._context) { - } - - OG_INLINE OG_CONSTEXPR - explicit operator bool() const OG_NOEXCEPT { - return _function != nullptr; - } - - OG_INLINE OG_CONSTEXPR - bool operator==(const ClosureFunction &rhs) const OG_NOEXCEPT { - return _function == rhs._function && _context == rhs._context; - } - - OG_INLINE OG_CONSTEXPR - bool operator==(std::nullptr_t) const OG_NOEXCEPT { - return _function == nullptr; - } - - OG_INLINE OG_CONSTEXPR - bool operator!=(std::nullptr_t) const OG_NOEXCEPT { - return _function != nullptr; - } - - OG_INLINE OG_CONSTEXPR - const ReturnType operator()(Args... args) const OG_NOEXCEPT { - return _function(_context, std::forward(args)...); - } -private: - Callable _function; - Context _context; -}; -} - -OG_ASSUME_NONNULL_END - -#endif /* ClosureFunction_hpp */ diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Data/ptr.hpp b/Sources/OpenGraphCxx/include/OpenGraphCxx/Data/ptr.hpp deleted file mode 100644 index dd6cf085..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Data/ptr.hpp +++ /dev/null @@ -1,104 +0,0 @@ -// -// ptr.hpp -// OpenGraphCxx -// -// Status: Complete -// Modified based Compute code - -#ifndef ptr_hpp -#define ptr_hpp - -#include -#include -#include -#include - -OG_ASSUME_NONNULL_BEGIN - -namespace OG { -namespace data { - -struct page; - -template class ptr { -public: - using element_type = T; - using difference_type = uint32_t; - -public: - OG_INLINE OG_CONSTEXPR ptr(difference_type offset = 0) : _offset(offset){}; - OG_INLINE OG_CONSTEXPR ptr(std::nullptr_t){}; - - // FIXME: this should be put into table API - OG_INLINE - element_type *_Nonnull get(vm_address_t base = shared_table().data_base()) const OG_NOEXCEPT { - assert(_offset != 0); - return reinterpret_cast(base + _offset); - } - - OG_INLINE OG_CONSTEXPR - ptr page_ptr() const OG_NOEXCEPT { return ptr(_offset & page_alignment); } - - OG_INLINE OG_CONSTEXPR - uint32_t page_index() const OG_NOEXCEPT { return (_offset >> page_mask_bits) - 1; } - - OG_INLINE OG_CONSTEXPR - difference_type page_relative_offset() const OG_NOEXCEPT { return _offset & page_mask; } - - template ptr aligned(difference_type alignment_mask = sizeof(difference_type) - 1) const { - return ptr((_offset + alignment_mask) & ~alignment_mask); - }; - - OG_INLINE OG_CONSTEXPR - operator bool() const OG_NOEXCEPT { return _offset != 0; }; - - OG_INLINE OG_CONSTEXPR - std::add_lvalue_reference_t operator*() const OG_NOEXCEPT { return *get(); }; - - OG_INLINE OG_CONSTEXPR - T *_Nonnull operator->() const OG_NOEXCEPT { return get(); }; - - OG_INLINE OG_CONSTEXPR - bool operator==(std::nullptr_t) const OG_NOEXCEPT { return _offset == 0; }; - - OG_INLINE OG_CONSTEXPR - bool operator!=(std::nullptr_t) const OG_NOEXCEPT { return _offset != 0; }; - - OG_INLINE OG_CONSTEXPR - bool operator<(difference_type offset) const OG_NOEXCEPT { return _offset < offset; }; - - OG_INLINE OG_CONSTEXPR - bool operator<=(difference_type offset) const OG_NOEXCEPT { return _offset <= offset; }; - - OG_INLINE OG_CONSTEXPR - bool operator>(difference_type offset) const OG_NOEXCEPT { return _offset > offset; }; - - OG_INLINE OG_CONSTEXPR - bool operator>=(difference_type offset) const OG_NOEXCEPT { return _offset >= offset; }; - - template - OG_INLINE OG_CONSTEXPR - ptr operator+(difference_type shift) const OG_NOEXCEPT { return ptr(_offset + shift); }; - - template - OG_INLINE OG_CONSTEXPR - ptr operator-(difference_type shift) const OG_NOEXCEPT { return ptr(_offset - shift); }; - - template - OG_INLINE OG_CONSTEXPR - difference_type operator-(const ptr &other) const OG_NOEXCEPT { - return _offset - other._offset; - }; -private: - difference_type _offset; - - template friend class ptr; - friend class table; -}; /* ptr */ - -} /* data */ -} /* OG */ - -OG_ASSUME_NONNULL_END - -#endif /* ptr_hpp */ diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Data/zone.hpp b/Sources/OpenGraphCxx/include/OpenGraphCxx/Data/zone.hpp deleted file mode 100644 index 955f4920..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Data/zone.hpp +++ /dev/null @@ -1,95 +0,0 @@ -// -// zone.hpp -// OpenGraphCxx - -#ifndef zone_hpp -#define zone_hpp - -#include -#include - -namespace OG { -namespace data { - -class zone { -public: - class info { - public: - OG_INLINE OG_CONSTEXPR - info() OG_NOEXCEPT : _value(0) {}; - - OG_INLINE OG_CONSTEXPR - info(uint32_t value) OG_NOEXCEPT : _value(value){}; - - OG_INLINE OG_CONSTEXPR - info(uint32_t zone_id, bool deleted) OG_NOEXCEPT : _value((zone_id & zone_id_mask) | (deleted ? 1 : 0)) {}; - - OG_INLINE OG_CONSTEXPR - uint32_t value() const OG_NOEXCEPT { return _value; }; - - OG_INLINE OG_CONSTEXPR - uint32_t zone_id() const OG_NOEXCEPT { return _value & zone_id_mask; }; - - OG_INLINE OG_CONSTEXPR - bool is_deleted() const OG_NOEXCEPT { return (_value & deleted) != 0; }; - - OG_INLINE OG_CONSTEXPR - info with_zone_id(uint32_t zone_id) const OG_NOEXCEPT { - return info((_value & ~zone_id_mask) | (zone_id & zone_id_mask), is_deleted()); - }; - - OG_INLINE OG_CONSTEXPR - info with_deleted(bool deleted) const OG_NOEXCEPT { - return info(zone_id(), deleted); - } - private: - enum : uint32_t { - zone_id_mask = 0x7fffffff, - deleted = 0x80000000, - }; - uint32_t _value; - }; /* info */ -public: -// zone() OG_NOEXCEPT = default; -// ~zone() OG_NOEXCEPT; - - OG_INLINE OG_CONSTEXPR - auto& malloc_buffers() const OG_NOEXCEPT { return _malloc_buffers; }; - - OG_INLINE OG_CONSTEXPR - ptr last_page() const OG_NOEXCEPT { return _last_page; }; - - OG_INLINE OG_CONSTEXPR - info info() const OG_NOEXCEPT { return _info; }; - - OG_INLINE - void clear(); - - ptr alloc_slow(uint32_t size, uint32_t alignment_mask) OG_NOEXCEPT; - - void *alloc_persistent(size_t size) OG_NOEXCEPT; - - void realloc_bytes(ptr *buffer, uint32_t size, uint32_t new_size, uint32_t alignment_mask) OG_NOEXCEPT; - -// ptr alloc_bytes(uint32_t size, uint32_t alignment_mask); - ptr alloc_bytes_recycle(uint32_t size, uint32_t alignment_mask) OG_NOEXCEPT; - - // Printing - void print() const OG_NOEXCEPT; - - void print_header() const OG_NOEXCEPT; -private: - typedef struct _bytes_info { - ptr next; - uint32_t size; - } bytes_info; - vector, 0, uint32_t> _malloc_buffers; - ptr _last_page; - ptr _free_bytes; - class info _info; -}; /* zone */ - -} /* data */ -} /* OG */ - -#endif /* zone_hpp */ diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Graph/Graph.hpp b/Sources/OpenGraphCxx/include/OpenGraphCxx/Graph/Graph.hpp deleted file mode 100644 index 43096e11..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Graph/Graph.hpp +++ /dev/null @@ -1,189 +0,0 @@ -// -// Graph.hpp -// OpenGraphCxx - - -#ifndef Graph_hpp -#define Graph_hpp - -#include -#include -#include -#include -#include - -OG_ASSUME_NONNULL_BEGIN - -#if OG_OBJC_FOUNDATION -@class NSDictionary; -#endif /* OG_OBJC_FOUNDATION */ - -namespace OG { -class Graph final { -public: - class Context final { - private: - Graph * _Nullable _graph; - const void * _Nullable _context; - OGUniqueID _id; - ClosureFunction _invalidation_callback; - ClosureFunction _update_callback; - uint64_t unknown1; - uint32_t unknown2; - uint32_t unknown3; - bool _isInvalid; - public: - static Context &from_cf(OGGraphRef graph) OG_NOEXCEPT; - Context(Graph &graph) OG_NOEXCEPT; - ~Context() OG_NOEXCEPT; - - const bool thread_is_updating() const OG_NOEXCEPT; - - OG_INLINE OG_CONSTEXPR - const bool has_graph() const OG_NOEXCEPT { - return _graph != nullptr; - } - - OG_INLINE OG_CONSTEXPR - const Graph &get_graph() const OG_NOEXCEPT { - return *_graph; - } - - OG_INLINE OG_CONSTEXPR - Graph &get_graph() OG_NOEXCEPT { - return *_graph; - } - - OG_INLINE OG_CONSTEXPR - const void * _Nullable get_context() const OG_NOEXCEPT { - return _context; - } - - OG_INLINE OG_CONSTEXPR - void set_context(const void * _Nullable context) OG_NOEXCEPT { - _context = context; - } - - OG_INLINE - void set_invalidation_callback(ClosureFunction invalidation_callback) OG_NOEXCEPT { - _invalidation_callback = invalidation_callback; - } - - OG_INLINE - void set_update_callback(ClosureFunction update_callback) OG_NOEXCEPT { - _update_callback = update_callback; - } - - OG_INLINE OG_CONSTEXPR - const bool isInvalid() const OG_NOEXCEPT { - return _isInvalid; - } - - OG_INLINE OG_CONSTEXPR - void setInvalid(bool invalid) OG_NOEXCEPT { - _isInvalid = invalid; - } - }; - #if OG_TARGET_CPU_WASM32 - static_assert(sizeof(Context) == 0x38); - #else - static_assert(sizeof(Context) == 0x50); - #endif -private: - static pthread_key_t _current_update_key; - uint64_t _counter_4; - uint32_t _counter_8; - uint64_t _counter_0; - bool _counter_9; - uint64_t _counter_5; - uint64_t _counter_1; - uint64_t _counter_2; - uint64_t _counter_10; - uint64_t _counter_3; -public: - #if OG_OBJC_FOUNDATION - static CFTypeRef description(const Graph * _Nullable graph, NSDictionary* dic); - #endif /* OG_OBJC_FOUNDATION */ - - // MARK: - pthread related - - OG_INLINE OG_CONSTEXPR - const static pthread_key_t& current_key() OG_NOEXCEPT { - return _current_update_key; - } - - Graph() OG_NOEXCEPT; - - const void value_mark_all() const OG_NOEXCEPT; - - static void all_start_profiling(uint32_t) OG_NOEXCEPT; - static void all_stop_profiling() OG_NOEXCEPT; - void start_profiling(uint32_t) OG_NOEXCEPT; - void stop_profiling() OG_NOEXCEPT; - - #if OG_OBJC_FOUNDATION - static void write_to_file(const Graph * _Nullable, const char * _Nullable, uint8_t) OG_NOEXCEPT; - #endif - - const bool thread_is_updating() const OG_NOEXCEPT; - const bool is_context_updating(const OG::Graph::Context&) const OG_NOEXCEPT; - - OG_INLINE OG_CONSTEXPR - const uint64_t get_counter_4() const OG_NOEXCEPT { - return _counter_4; - } - - OG_INLINE OG_CONSTEXPR - const uint32_t get_counter_8() const OG_NOEXCEPT { - return _counter_8; - } - - OG_INLINE OG_CONSTEXPR - const uint64_t get_counter_0() const OG_NOEXCEPT { - return _counter_0; - } - - OG_INLINE OG_CONSTEXPR - const bool get_counter_9() const OG_NOEXCEPT { - return _counter_9; - } - - OG_INLINE OG_CONSTEXPR - const uint64_t get_counter_5() const OG_NOEXCEPT { - return _counter_5; - } - - OG_INLINE OG_CONSTEXPR - const uint64_t get_counter_1() const OG_NOEXCEPT { - return _counter_1; - } - - OG_INLINE OG_CONSTEXPR - const uint64_t get_counter_2() const OG_NOEXCEPT { - return _counter_2; - } - - OG_INLINE OG_CONSTEXPR - const uint64_t get_counter_10() const OG_NOEXCEPT { - return _counter_10; - } - - OG_INLINE OG_CONSTEXPR - const uint64_t get_counter_3() const OG_NOEXCEPT { - return _counter_3; - } -}; /* Graph */ -} /* OG */ - -struct OGGraphStorage { - CFRuntimeBase base; - OG::Graph::Context context; -}; - -struct OGGraphContextStorage { - OG::Graph::Context context; -}; - -OG_ASSUME_NONNULL_END - -#endif /* Graph_hpp */ diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Graph/Subgraph.hpp b/Sources/OpenGraphCxx/include/OpenGraphCxx/Graph/Subgraph.hpp deleted file mode 100644 index 9a657d27..00000000 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Graph/Subgraph.hpp +++ /dev/null @@ -1,109 +0,0 @@ -// -// Subgraph.hpp -// OpenGraphCxx - -#ifndef Subgraph_hpp -#define Subgraph_hpp - -#include -#include -#include -#include -#include -#include - -typedef struct OG_BRIDGED_TYPE(id) OGSubgraphStorage * OGSubgraphRef; - -namespace OG { -class SubgraphObject; - -class Subgraph final { -private: - OGSubgraphRef _cf_subgraph; - OGGraphContextStorage& _context; - // TODO - bool _isInvalid; - static pthread_key_t _current_subgraph_key; -public: - // MARK: - CF related - - static Subgraph *from_cf(OGSubgraphRef cf_subgraph) OG_NOEXCEPT; - - OGSubgraphRef to_cf() const OG_NOEXCEPT { - return _cf_subgraph; - } - - // MARK: - pthread related - - OG_INLINE - const static void make_current_subgraph_key() OG_NOEXCEPT { - pthread_key_create(&_current_subgraph_key, nullptr); - } - - OG_INLINE OG_CONSTEXPR - const static pthread_key_t& current_key() OG_NOEXCEPT { - return _current_subgraph_key; - } - - OG_INLINE OG_CONSTEXPR - static Subgraph *get_current() OG_NOEXCEPT { - return (OG::Subgraph*)pthread_getspecific(OG::Subgraph::current_key()); - } - - OG_INLINE OG_CONSTEXPR - static int set_current(Subgraph *subgraph) OG_NOEXCEPT { - return pthread_setspecific(OG::Subgraph::current_key(), subgraph); - } - - // MARK: - Public API - void clear_object() const OG_NOEXCEPT; - void invalidate_and_delete_(bool) const OG_NOEXCEPT; - - void apply(OGAttributeFlags flags, OG::ClosureFunction body) const OG_NOEXCEPT; - - OGUniqueID add_observer(OG::ClosureFunction observer) const OG_NOEXCEPT; - - void begin_tree(OG::AttributeID id, OG::swift::metadata const *type, uint32_t flags) const OG_NOEXCEPT; - void add_tree_value(OG::AttributeID id, OG::swift::metadata const *type, const char* key, uint32_t flags) const OG_NOEXCEPT; - void end_tree(OG::AttributeID id) const OG_NOEXCEPT; - - // MARK: - Init and deinit - - Subgraph(SubgraphObject*, OG::Graph::Context&, OG::AttributeID); - - // MARK: - Getter and setter - - OG_INLINE OG_CONSTEXPR - const OGGraphContextRef get_context() const OG_NOEXCEPT { - return &_context; - } - - OG_INLINE OG_CONSTEXPR - OGGraphContextRef get_context() OG_NOEXCEPT { - return &_context; - } - - OG_INLINE OG_CONSTEXPR - const bool isInvalid() const OG_NOEXCEPT { - return _isInvalid; - } - - OG_INLINE OG_CONSTEXPR - void setInvalid(bool invalid) OG_NOEXCEPT { - _isInvalid = invalid; - } -}; /* Subgraph */ -} /* OG */ - -struct OGSubgraphStorage { - CFRuntimeBase base; - OG::Subgraph *subgraph; -}; - -namespace OG { -class SubgraphObject final { - OGSubgraphStorage storage; -}; -} - -#endif /* Subgraph_hpp */ diff --git a/Sources/OpenGraphCxx/include/module.modulemap b/Sources/OpenGraphCxx/include/module.modulemap deleted file mode 100644 index 4976a40e..00000000 --- a/Sources/OpenGraphCxx/include/module.modulemap +++ /dev/null @@ -1,8 +0,0 @@ -module OpenGraphCxx { - export * -} - -module OpenGraphCxx.C { - umbrella header "OpenGraph/OpenGraph-umbrella.h" - export * -} diff --git a/Sources/OpenGraphCxx/include/module.private.modulemap b/Sources/OpenGraphCxx/include/module.private.modulemap deleted file mode 100644 index 62efad57..00000000 --- a/Sources/OpenGraphCxx/include/module.private.modulemap +++ /dev/null @@ -1,58 +0,0 @@ -module OpenGraphCxx_Private { - export * -} - -module OpenGraphCxx_Private.Attribute { - requires cplusplus - umbrella "OpenGraphCxx/Attribute" - export * -} - -module OpenGraphCxx_Private.Comparison { - requires cplusplus - umbrella "OpenGraphCxx/Comparison" - export * -} - -module OpenGraphCxx_Private.Data { - requires cplusplus - umbrella "OpenGraphCxx/Data" - export * -} - -module OpenGraphCxx_Private.DebugServer { - requires cplusplus - umbrella "OpenGraphCxx/DebugServer" - export * -} - -module OpenGraphCxx_Private.Graph { - requires cplusplus - umbrella "OpenGraphCxx/Graph" - export * -} - -module OpenGraphCxx_Private.Misc { - requires cplusplus - umbrella "OpenGraphCxx/Misc" - export * -} - -module OpenGraphCxx_Private.Runtime { - requires cplusplus - umbrella "OpenGraphCxx/Runtime" - export * -} - -module OpenGraphCxx_Private.Util { - requires cplusplus - umbrella "OpenGraphCxx/Util" - export * - module * { export * } -} - -module OpenGraphCxx_Private.Vector { - requires cplusplus - umbrella "OpenGraphCxx/Vector" - export * -} diff --git a/Sources/OpenGraphShims/GraphShims.swift b/Sources/OpenGraphShims/GraphShims.swift deleted file mode 100644 index cce8aabd..00000000 --- a/Sources/OpenGraphShims/GraphShims.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// GraphShims.swift -// OpenGraphShims - -#if OPENGRAPH_ATTRIBUTEGRAPH -@_exported public import AttributeGraph -public typealias OGAttributeInfo = AGAttributeInfo -public typealias OGCachedValueOptions = AGCachedValueOptions -public typealias OGChangedValueFlags = AGChangedValueFlags -public typealias OGInputOptions = AGInputOptions -public typealias OGUniqueID = AGUniqueID -public typealias OGValue = AGValue -public typealias OGValueOptions = AGValueOptions -public let attributeGraphEnabled = true -public let swiftToolchainSupported = true -#else -@_exported import OpenGraph -public let attributeGraphEnabled = false -#if OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED -public let swiftToolchainSupported = true -#else -public let swiftToolchainSupported = false -#endif -#endif diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AnyAttributeCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Attribute/AnyAttributeCompatibilityTests.swift similarity index 97% rename from Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AnyAttributeCompatibilityTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Attribute/Attribute/AnyAttributeCompatibilityTests.swift index c11e80b4..0ca35495 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AnyAttributeCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Attribute/AnyAttributeCompatibilityTests.swift @@ -1,6 +1,6 @@ // // AnyAttributeCompatibilityTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import Testing @@ -19,7 +19,7 @@ struct AnyAttributeCompatibilityTests { // FIXME: Strange compile issue on non-ObjectiveC platform // Cannot look up associated type for imported conformance: - // (struct_type decl=_OpenGraph.(file).AnyAttribute) + // (struct_type decl=_OpenAttributeGraph.(file).AnyAttribute) // (associated_type_decl "_ObjectiveCType" access=public overridden=) // Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace. #if canImport(ObjectiveC) diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift similarity index 98% rename from Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift index a1b8b486..9405c9e9 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift @@ -1,6 +1,6 @@ // // AttributeCompatibilityTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import Testing diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/ExternalCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Attribute/ExternalCompatibilityTests.swift similarity index 94% rename from Tests/OpenGraphCompatibilityTests/Attribute/Attribute/ExternalCompatibilityTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Attribute/Attribute/ExternalCompatibilityTests.swift index 96425283..abf8cad3 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/ExternalCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Attribute/ExternalCompatibilityTests.swift @@ -1,6 +1,6 @@ // // ExternalCompatibilityTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import Testing diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/FocusCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Attribute/FocusCompatibilityTests.swift similarity index 93% rename from Tests/OpenGraphCompatibilityTests/Attribute/Attribute/FocusCompatibilityTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Attribute/Attribute/FocusCompatibilityTests.swift index c7d565a7..687045db 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/FocusCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Attribute/FocusCompatibilityTests.swift @@ -1,6 +1,6 @@ // // FocusCompatibilityTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import Testing diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/PointerOffsetCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Attribute/PointerOffsetCompatibilityTests.swift similarity index 97% rename from Tests/OpenGraphCompatibilityTests/Attribute/Attribute/PointerOffsetCompatibilityTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Attribute/Attribute/PointerOffsetCompatibilityTests.swift index ba9af6fb..6933cba5 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/PointerOffsetCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Attribute/PointerOffsetCompatibilityTests.swift @@ -1,6 +1,6 @@ // // PointerOffsetCompatibilityTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import RealModule import Testing @@ -47,7 +47,7 @@ struct PointerOffsetCompatibilityTests { #expect(invalidPointer == UnsafeMutablePointer(bitPattern: stride)) } } else { - #if OPENGRAPH_RELEASE_2024 + #if OPENATTRIBUTEGRAPH_RELEASE_2024 #expect(invalidPointer == UnsafeMutablePointer(bitPattern: 0x1)) #else #expect(invalidPointer == UnsafeMutablePointer(bitPattern: stride)) @@ -56,7 +56,7 @@ struct PointerOffsetCompatibilityTests { } - @Test(.bug("https://github.com/OpenSwiftUIProject/OpenGraph/issues/70", id: 70, "Verify fix of #70")) + @Test(.bug("https://github.com/OpenSwiftUIProject/OpenAttributeGraph/issues/70", id: 70, "Verify fix of #70")) func ofAndOffset() { struct Empty { var value: Void diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/AttributeTestBase.swift b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/AttributeTestBase.swift similarity index 100% rename from Tests/OpenGraphCompatibilityTests/Attribute/AttributeTestBase.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Attribute/AttributeTestBase.swift diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Indirect/IndirectAttributeCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Indirect/IndirectAttributeCompatibilityTests.swift similarity index 93% rename from Tests/OpenGraphCompatibilityTests/Attribute/Indirect/IndirectAttributeCompatibilityTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Attribute/Indirect/IndirectAttributeCompatibilityTests.swift index 0435cbee..a9077464 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Indirect/IndirectAttributeCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Indirect/IndirectAttributeCompatibilityTests.swift @@ -1,6 +1,6 @@ // // IndirectAttributeCompatibilityTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import Testing diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Optional/AnyOptionalAttributeCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Optional/AnyOptionalAttributeCompatibilityTests.swift similarity index 97% rename from Tests/OpenGraphCompatibilityTests/Attribute/Optional/AnyOptionalAttributeCompatibilityTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Attribute/Optional/AnyOptionalAttributeCompatibilityTests.swift index 1c7d6e00..120fb083 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Optional/AnyOptionalAttributeCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Optional/AnyOptionalAttributeCompatibilityTests.swift @@ -1,6 +1,6 @@ // // AnyOptionalAttributeCompatibilityTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import Testing diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Optional/OptionalAttributeCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Optional/OptionalAttributeCompatibilityTests.swift similarity index 96% rename from Tests/OpenGraphCompatibilityTests/Attribute/Optional/OptionalAttributeCompatibilityTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Attribute/Optional/OptionalAttributeCompatibilityTests.swift index 236b596a..c1e449ba 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Optional/OptionalAttributeCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Optional/OptionalAttributeCompatibilityTests.swift @@ -1,6 +1,6 @@ // // OptionalAttributeCompatibilityTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import Testing diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Rule/MapCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Rule/MapCompatibilityTests.swift similarity index 93% rename from Tests/OpenGraphCompatibilityTests/Attribute/Rule/MapCompatibilityTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Attribute/Rule/MapCompatibilityTests.swift index bfb74af4..7bd1ff7f 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Rule/MapCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Rule/MapCompatibilityTests.swift @@ -1,6 +1,6 @@ // // MapCompatibilityTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import Testing diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Rule/RuleCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Rule/RuleCompatibilityTests.swift similarity index 87% rename from Tests/OpenGraphCompatibilityTests/Attribute/Rule/RuleCompatibilityTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Attribute/Rule/RuleCompatibilityTests.swift index 3bd5ef9d..64922bf6 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Rule/RuleCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Rule/RuleCompatibilityTests.swift @@ -1,6 +1,6 @@ // // RuleCompatibilityTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import Testing diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Weak/AnyWeakAttributeCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Weak/AnyWeakAttributeCompatibilityTests.swift similarity index 95% rename from Tests/OpenGraphCompatibilityTests/Attribute/Weak/AnyWeakAttributeCompatibilityTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Attribute/Weak/AnyWeakAttributeCompatibilityTests.swift index f9b08a94..37403504 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Weak/AnyWeakAttributeCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Weak/AnyWeakAttributeCompatibilityTests.swift @@ -1,6 +1,6 @@ // // AnyWeakAttributeCompatibilityTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import Testing diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Weak/WeakAttributeCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Weak/WeakAttributeCompatibilityTests.swift similarity index 90% rename from Tests/OpenGraphCompatibilityTests/Attribute/Weak/WeakAttributeCompatibilityTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Attribute/Weak/WeakAttributeCompatibilityTests.swift index 4f944134..c47a8215 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Weak/WeakAttributeCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/Weak/WeakAttributeCompatibilityTests.swift @@ -1,6 +1,6 @@ // // WeakAttributeCompatibilityTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import Testing diff --git a/Tests/OpenGraphCompatibilityTests/CompareValuesCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/CompareValuesCompatibilityTests.swift similarity index 93% rename from Tests/OpenGraphCompatibilityTests/CompareValuesCompatibilityTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/CompareValuesCompatibilityTests.swift index b499a89c..29afdf26 100644 --- a/Tests/OpenGraphCompatibilityTests/CompareValuesCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/CompareValuesCompatibilityTests.swift @@ -1,10 +1,10 @@ // // CompareValuesCompatibilityTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import Testing -@Suite(.disabled(if: !compatibilityTestEnabled, "OGCompareValues is not implemented")) +@Suite(.disabled(if: !compatibilityTestEnabled, "OAGCompareValues is not implemented")) struct CompareValuesCompatibilityTests { @Test func intCompare() throws { diff --git a/Tests/OpenGraphCompatibilityTests/Data/UniqueIDCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Data/UniqueIDCompatibilityTests.swift similarity index 84% rename from Tests/OpenGraphCompatibilityTests/Data/UniqueIDCompatibilityTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Data/UniqueIDCompatibilityTests.swift index fcea36ea..a8829c9f 100644 --- a/Tests/OpenGraphCompatibilityTests/Data/UniqueIDCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Data/UniqueIDCompatibilityTests.swift @@ -1,6 +1,6 @@ // // UniqueIDCompatibilityTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import Testing diff --git a/Tests/OpenGraphCompatibilityTests/Debug/DebugServerTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Debug/DebugServerTests.swift similarity index 97% rename from Tests/OpenGraphCompatibilityTests/Debug/DebugServerTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Debug/DebugServerTests.swift index 4eecefa9..621fc8f1 100644 --- a/Tests/OpenGraphCompatibilityTests/Debug/DebugServerTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Debug/DebugServerTests.swift @@ -1,6 +1,6 @@ // // DebugServerTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests #if canImport(Darwin) import CoreFoundation diff --git a/Tests/OpenGraphCompatibilityTests/Graph/GraphCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Graph/GraphCompatibilityTests.swift similarity index 96% rename from Tests/OpenGraphCompatibilityTests/Graph/GraphCompatibilityTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Graph/GraphCompatibilityTests.swift index fbb5632f..ad3b0613 100644 --- a/Tests/OpenGraphCompatibilityTests/Graph/GraphCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Graph/GraphCompatibilityTests.swift @@ -1,6 +1,6 @@ // // GraphCompatibilityTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import Testing import Foundation @@ -20,7 +20,7 @@ struct GraphCompatibilityTests { } #if canImport(Darwin) - @Test(.disabled(if: !compatibilityTestEnabled, "Not implemented on OG")) + @Test(.disabled(if: !compatibilityTestEnabled, "Not implemented on OAG")) func graphArchiveJSON() throws { struct Graphs: Codable { var version: Int @@ -39,7 +39,7 @@ struct GraphCompatibilityTests { #expect(graphs.version == 2) } - @Test(.disabled(if: !compatibilityTestEnabled, "Not implemented on OG")) + @Test(.disabled(if: !compatibilityTestEnabled, "Not implemented on OAG")) func graphDescriptionDict() throws { let description = try #require(Graph.description( nil, @@ -52,7 +52,7 @@ struct GraphCompatibilityTests { #expect((dic["graphs"] as? NSArray)?.count == 0) } - @Test(.disabled(if: !compatibilityTestEnabled, "Not implemented on OG")) + @Test(.disabled(if: !compatibilityTestEnabled, "Not implemented on OAG")) func graphDescriptionDot() throws { let options = NSMutableDictionary() options[DescriptionOption.format] = Graph.descriptionFormatDot @@ -79,7 +79,7 @@ struct GraphCompatibilityTests { } } - @Test(.disabled(if: !compatibilityTestEnabled, "Not implemented on OG")) + @Test(.disabled(if: !compatibilityTestEnabled, "Not implemented on OAG")) func counter() { let graph = Graph() #expect(graph.mainUpdates == 0) diff --git a/Tests/OpenGraphCompatibilityTests/Graph/GraphDescriptionCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Graph/GraphDescriptionCompatibilityTests.swift similarity index 85% rename from Tests/OpenGraphCompatibilityTests/Graph/GraphDescriptionCompatibilityTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Graph/GraphDescriptionCompatibilityTests.swift index f1042294..c4014170 100644 --- a/Tests/OpenGraphCompatibilityTests/Graph/GraphDescriptionCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Graph/GraphDescriptionCompatibilityTests.swift @@ -1,6 +1,6 @@ // // GraphDescriptionCompatibilityTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import Testing diff --git a/Tests/OpenGraphCompatibilityTests/Graph/GraphTracingCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Graph/GraphTracingCompatibilityTests.swift similarity index 92% rename from Tests/OpenGraphCompatibilityTests/Graph/GraphTracingCompatibilityTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Graph/GraphTracingCompatibilityTests.swift index 0f129955..a9f71c1c 100644 --- a/Tests/OpenGraphCompatibilityTests/Graph/GraphTracingCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Graph/GraphTracingCompatibilityTests.swift @@ -1,6 +1,6 @@ // // GraphTracingCompatibilityTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import Testing diff --git a/Tests/OpenGraphCompatibilityTests/Graph/SubgraphCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Graph/SubgraphCompatibilityTests.swift similarity index 87% rename from Tests/OpenGraphCompatibilityTests/Graph/SubgraphCompatibilityTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Graph/SubgraphCompatibilityTests.swift index 35b1343d..20b44e60 100644 --- a/Tests/OpenGraphCompatibilityTests/Graph/SubgraphCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Graph/SubgraphCompatibilityTests.swift @@ -1,6 +1,6 @@ // // SubgraphCompatibilityTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import Testing @@ -9,7 +9,7 @@ import Testing struct SubgraphCompatibilityTests { @Test func shouldRecordTree() { - let key = compatibilityTestEnabled ? "AG_TREE" : "OG_TREE" + let key = compatibilityTestEnabled ? "AG_TREE" : "OAG_TREE" setenv(key, "0", 1) #expect(Subgraph.shouldRecordTree == false) diff --git a/Tests/OpenAttributeGraphCompatibilityTests/GraphShims.swift b/Tests/OpenAttributeGraphCompatibilityTests/GraphShims.swift new file mode 100644 index 00000000..2c2cdc04 --- /dev/null +++ b/Tests/OpenAttributeGraphCompatibilityTests/GraphShims.swift @@ -0,0 +1,24 @@ +// +// GraphShims.swift +// OpenAttributeGraphCompatibilityTests + +#if OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST +@_exported public import AttributeGraph +public typealias OAGAttributeInfo = AGAttributeInfo +public typealias OAGCachedValueOptions = AGCachedValueOptions +public typealias OAGChangedValueFlags = AGChangedValueFlags +public typealias OAGInputOptions = AGInputOptions +public typealias OAGUniqueID = AGUniqueID +public typealias OAGValue = AGValue +public typealias OAGValueOptions = AGValueOptions +public let compatibilityTestEnabled = true +public let swiftToolchainSupported = true +#else +@_exported import OpenAttributeGraph +let compatibilityTestEnabled = false +#if OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED +public let swiftToolchainSupported = true +#else +public let swiftToolchainSupported = false +#endif +#endif diff --git a/Tests/OpenAttributeGraphCompatibilityTests/OpenAttributeGraphTestsSupport b/Tests/OpenAttributeGraphCompatibilityTests/OpenAttributeGraphTestsSupport new file mode 120000 index 00000000..97d31df3 --- /dev/null +++ b/Tests/OpenAttributeGraphCompatibilityTests/OpenAttributeGraphTestsSupport @@ -0,0 +1 @@ +../OpenAttributeGraphTestsSupport \ No newline at end of file diff --git a/Tests/OpenAttributeGraphCompatibilityTests/README.md b/Tests/OpenAttributeGraphCompatibilityTests/README.md new file mode 100644 index 00000000..4361becf --- /dev/null +++ b/Tests/OpenAttributeGraphCompatibilityTests/README.md @@ -0,0 +1,7 @@ +## OpenAttributeGraphCompatibilityTests + +Test public API of OpenAttributeGraph and run it against with AttributeGraph on Apple Platform. + +The current supported OS +- macOS 14 (CI Supported) +- iOS 15 ~ 17 on Simulator (CI is not supported) diff --git a/Tests/OpenGraphCompatibilityTests/Runtime/MetadataCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Runtime/MetadataCompatibilityTests.swift similarity index 98% rename from Tests/OpenGraphCompatibilityTests/Runtime/MetadataCompatibilityTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Runtime/MetadataCompatibilityTests.swift index 35bc47f0..de5fa06b 100644 --- a/Tests/OpenGraphCompatibilityTests/Runtime/MetadataCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Runtime/MetadataCompatibilityTests.swift @@ -1,6 +1,6 @@ // // MetadataCompatibilityTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import Testing @@ -102,7 +102,7 @@ struct MetadataCompatibilityTests { } } - #if OPENGRAPH_SUPPORT_2024_API + #if OPENATTRIBUTEGRAPH_SUPPORT_2024_API func descriptor() { let t1 = Metadata(T1.self).descriptor let t2 = Metadata(T2.self).descriptor @@ -264,7 +264,7 @@ struct MetadataCompatibilityTests { } } - #if OPENGRAPH_SUPPORT_2024_API + #if OPENATTRIBUTEGRAPH_SUPPORT_2024_API @Test(.disabled(if: !compatibilityTestEnabled, "Metadata is not implemented")) func signature() { #expect(Metadata(T1.self).signature != Metadata(T2.self).signature) diff --git a/Tests/OpenGraphCompatibilityTests/Runtime/TupleTypeCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Runtime/TupleTypeCompatibilityTests.swift similarity index 99% rename from Tests/OpenGraphCompatibilityTests/Runtime/TupleTypeCompatibilityTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/Runtime/TupleTypeCompatibilityTests.swift index ad81905c..85fee8f8 100644 --- a/Tests/OpenGraphCompatibilityTests/Runtime/TupleTypeCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Runtime/TupleTypeCompatibilityTests.swift @@ -1,6 +1,6 @@ // // TupleTypeCompatibilityTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import Testing diff --git a/Tests/OpenGraphCompatibilityTests/VersionTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/VersionTests.swift similarity index 57% rename from Tests/OpenGraphCompatibilityTests/VersionTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/VersionTests.swift index b06e5020..bd710777 100644 --- a/Tests/OpenGraphCompatibilityTests/VersionTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/VersionTests.swift @@ -1,6 +1,6 @@ // // VersionTests.swift -// OpenGraphCompatibilityTests +// OpenAttributeGraphCompatibilityTests import Testing import Numerics @@ -9,7 +9,7 @@ struct VersionTests { @Test func versionNumber() async { await confirmation { confirm in - #if OPENGRAPH_COMPATIBILITY_TEST + #if OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST switch Int32(ATTRIBUTEGRAPH_RELEASE) { case ATTRIBUTEGRAPH_RELEASE_2021: #expect(AGVersion == 0x20014) @@ -21,14 +21,14 @@ struct VersionTests { break } #else - switch Int32(OPENGRAPH_RELEASE) { - case OPENGRAPH_RELEASE_2021: - #expect(OpenGraphVersionNumber.isApproximatelyEqual(to: 3.2)) - #expect(OGVersion == 0x20014) + switch Int32(OPENATTRIBUTEGRAPH_RELEASE) { + case OPENATTRIBUTEGRAPH_RELEASE_2021: + #expect(OpenAttributeGraphVersionNumber.isApproximatelyEqual(to: 3.2)) + #expect(OAGVersion == 0x20014) confirm() - case OPENGRAPH_RELEASE_2024: - #expect(OpenGraphVersionNumber.isApproximatelyEqual(to: 6.0)) - #expect(OGVersion == 0x2001e) + case OPENATTRIBUTEGRAPH_RELEASE_2024: + #expect(OpenAttributeGraphVersionNumber.isApproximatelyEqual(to: 6.0)) + #expect(OAGVersion == 0x2001e) confirm() default: break diff --git a/Tests/OpenGraphCxxTests/Data/PageTests.swift b/Tests/OpenAttributeGraphCxxTests/Data/PageTests.swift similarity index 55% rename from Tests/OpenGraphCxxTests/Data/PageTests.swift rename to Tests/OpenAttributeGraphCxxTests/Data/PageTests.swift index 5b128ab1..aeb4e992 100644 --- a/Tests/OpenGraphCxxTests/Data/PageTests.swift +++ b/Tests/OpenAttributeGraphCxxTests/Data/PageTests.swift @@ -1,9 +1,9 @@ // // PageTests.swift -// OpenGraphCxxTests +// OpenAttributeGraphCxxTests #if canImport(Darwin) -import OpenGraphCxx_Private.Data +import OpenAttributeGraphCxx_Private.Data import Testing struct PageTests { diff --git a/Tests/OpenGraphCxxTests/Data/TableTests.swift b/Tests/OpenAttributeGraphCxxTests/Data/TableTests.swift similarity index 63% rename from Tests/OpenGraphCxxTests/Data/TableTests.swift rename to Tests/OpenAttributeGraphCxxTests/Data/TableTests.swift index 4939a449..ce59d1a5 100644 --- a/Tests/OpenGraphCxxTests/Data/TableTests.swift +++ b/Tests/OpenAttributeGraphCxxTests/Data/TableTests.swift @@ -1,15 +1,15 @@ // // TableTests.swift -// OpenGraphCxxTests +// OpenAttributeGraphCxxTests #if canImport(Darwin) // table() is not implemented on Linux yet. -import OpenGraphCxx_Private.Data +import OpenAttributeGraphCxx_Private.Data import Testing struct TableTests { @Test func table() { - let table = OG.data.table() + let table = OAG.data.table() table.print() } } diff --git a/Tests/OpenGraphCxxTests/Data/ZoneTests.swift b/Tests/OpenAttributeGraphCxxTests/Data/ZoneTests.swift similarity index 61% rename from Tests/OpenGraphCxxTests/Data/ZoneTests.swift rename to Tests/OpenAttributeGraphCxxTests/Data/ZoneTests.swift index 6d8dbe15..2155a7e5 100644 --- a/Tests/OpenGraphCxxTests/Data/ZoneTests.swift +++ b/Tests/OpenAttributeGraphCxxTests/Data/ZoneTests.swift @@ -1,15 +1,15 @@ // // ZoneTests.swift -// OpenGraphCxxTests +// OpenAttributeGraphCxxTests #if canImport(Darwin) -import OpenGraphCxx_Private.Data +import OpenAttributeGraphCxx_Private.Data import Testing struct ZoneTests { @Test func print() { -// let zone = OG.data.zone() +// let zone = OAG.data.zone() // zone.print_header() // zone.print() } diff --git a/Tests/OpenAttributeGraphCxxTests/DebugServer/DebugClient.swift b/Tests/OpenAttributeGraphCxxTests/DebugServer/DebugClient.swift new file mode 120000 index 00000000..f1923048 --- /dev/null +++ b/Tests/OpenAttributeGraphCxxTests/DebugServer/DebugClient.swift @@ -0,0 +1 @@ +../../../Sources/OpenAttributeGraphShims/DebugClient.swift \ No newline at end of file diff --git a/Tests/OpenAttributeGraphCxxTests/DebugServer/DebugServerMessageHeader.swift b/Tests/OpenAttributeGraphCxxTests/DebugServer/DebugServerMessageHeader.swift new file mode 120000 index 00000000..e214e0fb --- /dev/null +++ b/Tests/OpenAttributeGraphCxxTests/DebugServer/DebugServerMessageHeader.swift @@ -0,0 +1 @@ +../../../Sources/OpenAttributeGraphShims/DebugServerMessageHeader.swift \ No newline at end of file diff --git a/Tests/OpenGraphCxxTests/DebugServer/DebugServerTests.swift b/Tests/OpenAttributeGraphCxxTests/DebugServer/DebugServerTests.swift similarity index 89% rename from Tests/OpenGraphCxxTests/DebugServer/DebugServerTests.swift rename to Tests/OpenAttributeGraphCxxTests/DebugServer/DebugServerTests.swift index 329d2387..4a7fcda7 100644 --- a/Tests/OpenGraphCxxTests/DebugServer/DebugServerTests.swift +++ b/Tests/OpenAttributeGraphCxxTests/DebugServer/DebugServerTests.swift @@ -1,10 +1,10 @@ // // DebugServerTests.swift -// OpenGraphCxxTests +// OpenAttributeGraphCxxTests #if canImport(Darwin) import Foundation -import OpenGraphCxx_Private.DebugServer +import OpenAttributeGraphCxx_Private.DebugServer import Testing @MainActor @@ -18,7 +18,7 @@ struct DebugServerTests { @Test func commandTest() async throws { - var debugServer = OG.DebugServer([.valid]) + var debugServer = OAG.DebugServer([.valid]) let cfURL = debugServer.copy_url() let url = try #require(cfURL) as URL let components = try #require(URLComponents(url: url, resolvingAgainstBaseURL: false)) @@ -43,7 +43,7 @@ struct DebugServerTests { let response = try #require(String(data: responseData, encoding: .utf8)) #expect(response == command.rawValue) } - debugServer.shutdown() // TODO: The shutdown should close the connection, but it does not for OGDebugServer currently. + debugServer.shutdown() // TODO: The shutdown should close the connection, but it does not for OAGDebugServer currently. client.disconnect() default: break diff --git a/Tests/OpenAttributeGraphCxxTests/README.md b/Tests/OpenAttributeGraphCxxTests/README.md new file mode 100644 index 00000000..dbd0819e --- /dev/null +++ b/Tests/OpenAttributeGraphCxxTests/README.md @@ -0,0 +1,3 @@ +## OpenAttributeGraphCxxTests + +Test internal C++ API of OpenAttributeGraphCxx diff --git a/Tests/OpenGraphShimsTests/Attribute+DebugTests.swift b/Tests/OpenAttributeGraphShimsTests/Attribute+DebugTests.swift similarity index 93% rename from Tests/OpenGraphShimsTests/Attribute+DebugTests.swift rename to Tests/OpenAttributeGraphShimsTests/Attribute+DebugTests.swift index 4aa0636b..203e46d3 100644 --- a/Tests/OpenGraphShimsTests/Attribute+DebugTests.swift +++ b/Tests/OpenAttributeGraphShimsTests/Attribute+DebugTests.swift @@ -1,14 +1,14 @@ // // Attribute+DebugTests.swift -// OpenGraphShimsTests +// OpenAttributeGraphShimsTests #if canImport(Darwin) && DEBUG import Testing -import OpenGraphShims +import OpenAttributeGraphShims @MainActor -@Suite(.disabled(if: !attributeGraphEnabled, "Subgraph is not implemented on OG"), .graphScope) +@Suite(.disabled(if: !attributeGraphEnabled, "Subgraph is not implemented on OAG"), .graphScope) struct Attribute_DebugTests { @Test func directAttribute() { diff --git a/Tests/OpenAttributeGraphShimsTests/Export.swift b/Tests/OpenAttributeGraphShimsTests/Export.swift new file mode 100644 index 00000000..426821dc --- /dev/null +++ b/Tests/OpenAttributeGraphShimsTests/Export.swift @@ -0,0 +1,5 @@ +// +// Export.swift +// OpenAttributeGraphShimsTests + +@_exported import OpenAttributeGraphShims diff --git a/Tests/OpenGraphShimsTests/MetadataDebugTests.swift b/Tests/OpenAttributeGraphShimsTests/MetadataDebugTests.swift similarity index 88% rename from Tests/OpenGraphShimsTests/MetadataDebugTests.swift rename to Tests/OpenAttributeGraphShimsTests/MetadataDebugTests.swift index ba0a6a43..99e50f6a 100644 --- a/Tests/OpenGraphShimsTests/MetadataDebugTests.swift +++ b/Tests/OpenAttributeGraphShimsTests/MetadataDebugTests.swift @@ -1,11 +1,11 @@ // // MetadataDebugTests.swift -// OpenGraphShimsTests +// OpenAttributeGraphShimsTests -@_spi(Debug) import OpenGraphShims +@_spi(Debug) import OpenAttributeGraphShims import Testing -@Suite(.disabled(if: !attributeGraphEnabled, "forEachField is not implemented for OG")) +@Suite(.disabled(if: !attributeGraphEnabled, "forEachField is not implemented for OAG")) struct MetadataDebugTests { struct Demo1 { var a: Int = .zero diff --git a/Tests/OpenAttributeGraphShimsTests/OpenAttributeGraphTestsSupport b/Tests/OpenAttributeGraphShimsTests/OpenAttributeGraphTestsSupport new file mode 120000 index 00000000..97d31df3 --- /dev/null +++ b/Tests/OpenAttributeGraphShimsTests/OpenAttributeGraphTestsSupport @@ -0,0 +1 @@ +../OpenAttributeGraphTestsSupport \ No newline at end of file diff --git a/Tests/OpenAttributeGraphShimsTests/README.md b/Tests/OpenAttributeGraphShimsTests/README.md new file mode 100644 index 00000000..61e02393 --- /dev/null +++ b/Tests/OpenAttributeGraphShimsTests/README.md @@ -0,0 +1,7 @@ +## OpenAttributeGraphShimsTests + +Test OpenAttributeGraphShims Debug API + +```swift +@_spi(Debug) import OpenAttributeGraphShims +``` diff --git a/Tests/OpenGraphTests/DummyTests.swift b/Tests/OpenAttributeGraphTests/DummyTests.swift similarity index 53% rename from Tests/OpenGraphTests/DummyTests.swift rename to Tests/OpenAttributeGraphTests/DummyTests.swift index f2b881bc..94b9c09c 100644 --- a/Tests/OpenGraphTests/DummyTests.swift +++ b/Tests/OpenAttributeGraphTests/DummyTests.swift @@ -1,8 +1,8 @@ // // DummyTests.swift -// OpenGraphTests +// OpenAttributeGraphTests -import OpenGraph +import OpenAttributeGraph import Testing struct DummyTests {} diff --git a/Tests/OpenAttributeGraphTests/README.md b/Tests/OpenAttributeGraphTests/README.md new file mode 100644 index 00000000..1b16fa74 --- /dev/null +++ b/Tests/OpenAttributeGraphTests/README.md @@ -0,0 +1,7 @@ +## OpenAttributeGraphTests + +Test internal API of OpenAttributeGraph + +```swift +@testable import OpenAttributeGraph +``` diff --git a/Tests/OpenGraphTestsSupport/AsyncSemaphore.swift b/Tests/OpenAttributeGraphTestsSupport/AsyncSemaphore.swift similarity index 100% rename from Tests/OpenGraphTestsSupport/AsyncSemaphore.swift rename to Tests/OpenAttributeGraphTestsSupport/AsyncSemaphore.swift diff --git a/Tests/OpenGraphTestsSupport/DataHelper.swift b/Tests/OpenAttributeGraphTestsSupport/DataHelper.swift similarity index 92% rename from Tests/OpenGraphTestsSupport/DataHelper.swift rename to Tests/OpenAttributeGraphTestsSupport/DataHelper.swift index ce2bc940..d7152a99 100644 --- a/Tests/OpenGraphTestsSupport/DataHelper.swift +++ b/Tests/OpenAttributeGraphTestsSupport/DataHelper.swift @@ -1,6 +1,6 @@ // // DataHelper.swift -// OpenGraphTestsSupport +// OpenAttributeGraphTestsSupport public struct Tuple { public var first: A diff --git a/Tests/OpenGraphTestsSupport/GraphEnvironmentTrait.swift b/Tests/OpenAttributeGraphTestsSupport/GraphEnvironmentTrait.swift similarity index 96% rename from Tests/OpenGraphTestsSupport/GraphEnvironmentTrait.swift rename to Tests/OpenAttributeGraphTestsSupport/GraphEnvironmentTrait.swift index 2b61892d..5a5811a7 100644 --- a/Tests/OpenGraphTestsSupport/GraphEnvironmentTrait.swift +++ b/Tests/OpenAttributeGraphTestsSupport/GraphEnvironmentTrait.swift @@ -1,6 +1,6 @@ // // GraphEnvironmentTrait.swift -// OpenGraphTestsSupport +// OpenAttributeGraphTestsSupport public import Testing diff --git a/Tests/OpenGraphCompatibilityTests/GraphShims.swift b/Tests/OpenGraphCompatibilityTests/GraphShims.swift deleted file mode 100644 index e6739333..00000000 --- a/Tests/OpenGraphCompatibilityTests/GraphShims.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// GraphShims.swift -// OpenGraphCompatibilityTests - -#if OPENGRAPH_COMPATIBILITY_TEST -@_exported public import AttributeGraph -public typealias OGAttributeInfo = AGAttributeInfo -public typealias OGCachedValueOptions = AGCachedValueOptions -public typealias OGChangedValueFlags = AGChangedValueFlags -public typealias OGInputOptions = AGInputOptions -public typealias OGUniqueID = AGUniqueID -public typealias OGValue = AGValue -public typealias OGValueOptions = AGValueOptions -public let compatibilityTestEnabled = true -public let swiftToolchainSupported = true -#else -@_exported import OpenGraph -let compatibilityTestEnabled = false -#if OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED -public let swiftToolchainSupported = true -#else -public let swiftToolchainSupported = false -#endif -#endif diff --git a/Tests/OpenGraphCompatibilityTests/OpenGraphTestsSupport b/Tests/OpenGraphCompatibilityTests/OpenGraphTestsSupport deleted file mode 120000 index d79343a8..00000000 --- a/Tests/OpenGraphCompatibilityTests/OpenGraphTestsSupport +++ /dev/null @@ -1 +0,0 @@ -../OpenGraphTestsSupport/ \ No newline at end of file diff --git a/Tests/OpenGraphCompatibilityTests/README.md b/Tests/OpenGraphCompatibilityTests/README.md deleted file mode 100644 index c9f43c50..00000000 --- a/Tests/OpenGraphCompatibilityTests/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## OpenGraphCompatibilityTests - -Test public API of OpenGraph and run it against with AttributeGraph on Apple Platform. - -The current supported OS -- macOS 14 (CI Supported) -- iOS 15 ~ 17 on Simulator (CI is not supported) diff --git a/Tests/OpenGraphCxxTests/DebugServer/DebugClient.swift b/Tests/OpenGraphCxxTests/DebugServer/DebugClient.swift deleted file mode 120000 index 14c281b3..00000000 --- a/Tests/OpenGraphCxxTests/DebugServer/DebugClient.swift +++ /dev/null @@ -1 +0,0 @@ -../../../Sources/OpenGraphShims/DebugClient.swift \ No newline at end of file diff --git a/Tests/OpenGraphCxxTests/DebugServer/DebugServerMessageHeader.swift b/Tests/OpenGraphCxxTests/DebugServer/DebugServerMessageHeader.swift deleted file mode 120000 index abce3da1..00000000 --- a/Tests/OpenGraphCxxTests/DebugServer/DebugServerMessageHeader.swift +++ /dev/null @@ -1 +0,0 @@ -../../../Sources/OpenGraphShims/DebugServerMessageHeader.swift \ No newline at end of file diff --git a/Tests/OpenGraphCxxTests/README.md b/Tests/OpenGraphCxxTests/README.md deleted file mode 100644 index ca665656..00000000 --- a/Tests/OpenGraphCxxTests/README.md +++ /dev/null @@ -1,3 +0,0 @@ -## OpenGraphCxxTests - -Test internal C++ API of OpenGraphCxx diff --git a/Tests/OpenGraphShimsTests/Export.swift b/Tests/OpenGraphShimsTests/Export.swift deleted file mode 100644 index 95a0d190..00000000 --- a/Tests/OpenGraphShimsTests/Export.swift +++ /dev/null @@ -1,5 +0,0 @@ -// -// Export.swift -// OpenGraphShimsTests - -@_exported import OpenGraphShims diff --git a/Tests/OpenGraphShimsTests/OpenGraphTestsSupport b/Tests/OpenGraphShimsTests/OpenGraphTestsSupport deleted file mode 120000 index d79343a8..00000000 --- a/Tests/OpenGraphShimsTests/OpenGraphTestsSupport +++ /dev/null @@ -1 +0,0 @@ -../OpenGraphTestsSupport/ \ No newline at end of file diff --git a/Tests/OpenGraphShimsTests/README.md b/Tests/OpenGraphShimsTests/README.md deleted file mode 100644 index 4981dc84..00000000 --- a/Tests/OpenGraphShimsTests/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## OpenGraphShimsTests - -Test OpenGraphShims Debug API - -```swift -@_spi(Debug) import OpenGraphShims -``` diff --git a/Tests/OpenGraphTests/README.md b/Tests/OpenGraphTests/README.md deleted file mode 100644 index 5f69fe9a..00000000 --- a/Tests/OpenGraphTests/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## OpenGraphTests - -Test internal API of OpenGraph - -```swift -@testable import OpenGraph -```