diff --git a/.github/workflows/compatibility_tests.yml b/.github/workflows/compatibility_tests.yml index ebd9bf7..76c8c81 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: - OPENBOX_WERROR: 1 - OPENBOX_RENDERBOX: 1 - OPENBOX_COMPATIBILITY_TEST: 1 - OPENBOX_USE_LOCAL_DEPS: 1 - OPENBOX_TARGET_RELEASE: 2024 + OPENRENDERBOX_WERROR: 1 + OPENRENDERBOX_RENDERBOX: 1 + OPENRENDERBOX_COMPATIBILITY_TEST: 1 + OPENRENDERBOX_USE_LOCAL_DEPS: 1 + OPENRENDERBOX_TARGET_RELEASE: 2024 DARWIN_PRIVATE_FRAMEWORKS_TARGET_RELEASE: 2024 GH_TOKEN: ${{ github.token }} steps: @@ -35,16 +35,16 @@ jobs: shell: bash - name: Swift version run: swift --version - - name: Run tests against Apple's RENDERBOX on macOS via SwiftPM + - name: Run tests against Apple's RenderBox on macOS via SwiftPM env: - OPENBOX_LIBRARY_EVOLUTION: 0 + OPENRENDERBOX_LIBRARY_EVOLUTION: 0 run: | swift test \ --build-path .build-compatibility-test-debug - - name: Run tests against Apple's RENDERBOX on macOS via Xcode + - name: Run tests against Apple's RenderBox on macOS via Xcode run: | xcodebuild test \ - -scheme OpenBox-Package \ + -scheme OpenRenderBox-Package \ -sdk macosx \ -destination "platform=macOS" \ -skipPackagePluginValidation \ diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index bb161b4..8487624 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: - OPENBOX_WERROR: 1 - OPENBOX_RENDERBOX: 0 - OPENBOX_COMPATIBILITY_TEST: 0 - OPENBOX_USE_LOCAL_DEPS: 1 - OPENBOX_TARGET_RELEASE: 2024 + OPENRENDERBOX_WERROR: 1 + OPENRENDERBOX_RENDERBOX: 0 + OPENRENDERBOX_COMPATIBILITY_TEST: 0 + OPENRENDERBOX_USE_LOCAL_DEPS: 1 + OPENRENDERBOX_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 OpenBox-Package \ + -scheme OpenRenderBox-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 OpenBox-Package \ + -scheme OpenRenderBox-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 5a76e22..eaa76d7 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: - OPENBOX_WERROR: 1 - OPENBOX_RENDERBOX: 0 - OPENBOX_COMPATIBILITY_TEST: 0 - OPENBOX_USE_LOCAL_DEPS: 1 - OPENBOX_TARGET_RELEASE: 2024 + OPENRENDERBOX_WERROR: 1 + OPENRENDERBOX_RENDERBOX: 0 + OPENRENDERBOX_COMPATIBILITY_TEST: 0 + OPENRENDERBOX_USE_LOCAL_DEPS: 1 + OPENRENDERBOX_TARGET_RELEASE: 2024 DARWIN_PRIVATE_FRAMEWORKS_TARGET_RELEASE: 2024 GH_TOKEN: ${{ github.token }} steps: @@ -36,7 +36,7 @@ jobs: run: swift --version - name: Build and run tests in debug mode with coverage env: - OPENBOX_LIBRARY_EVOLUTION: 0 + OPENRENDERBOX_LIBRARY_EVOLUTION: 0 run: | swift test \ -c debug \ @@ -44,11 +44,11 @@ jobs: --build-path .build-test-debug xcrun llvm-cov show \ -instr-profile=.build-test-debug/debug/codecov/default.profdata \ - .build-test-debug/debug/OPENBOXPackageTests.xctest/Contents/MacOS/OPENBOXPackageTests \ + .build-test-debug/debug/OPENRENDERBOXPackageTests.xctest/Contents/MacOS/OPENRENDERBOXPackageTests \ > coverage.txt - name: Build and run tests in release mode env: - OPENBOX_LIBRARY_EVOLUTION: 0 + OPENRENDERBOX_LIBRARY_EVOLUTION: 0 run: | swift test \ -c release \ diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 5d5a176..7c704da 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: - OPENBOX_WERROR: 1 - OPENBOX_RENDERBOX: 0 - OPENBOX_COMPATIBILITY_TEST: 0 + OPENRENDERBOX_WERROR: 1 + OPENRENDERBOX_RENDERBOX: 0 + OPENRENDERBOX_COMPATIBILITY_TEST: 0 container: swift:${{ matrix.swift_version }}-jammy steps: - uses: actions/checkout@v4 @@ -36,7 +36,7 @@ jobs: --build-path .build-test-debug llvm-cov show \ -instr-profile=.build-test-debug/debug/codecov/default.profdata \ - .build-test-debug/debug/OpenBoxPackageTests.xctest \ + .build-test-debug/debug/OpenRenderBoxPackageTests.xctest \ > coverage.txt - name: Building and running tests in release mode run: | diff --git a/.spi.yml b/.spi.yml index 3efda30..f002684 100644 --- a/.spi.yml +++ b/.spi.yml @@ -2,4 +2,4 @@ version: 1 builder: configs: - swift_version: 6.0 - documentation_targets: [OpenBox] + documentation_targets: [OpenRenderBox] diff --git a/Package.swift b/Package.swift index d55b0b1..06fa67d 100644 --- a/Package.swift +++ b/Package.swift @@ -31,9 +31,9 @@ let isSPIBuild = envEnable("SPI_BUILD") // MARK: - Env and Config let isXcodeEnv = Context.environment["__CFBundleIdentifier"] == "com.apple.dt.Xcode" -let development = envEnable("OPENBOX_DEVELOPMENT") +let development = envEnable("OPENRENDERBOX_DEVELOPMENT") -let releaseVersion = Context.environment["OPENBOX_TARGET_RELEASE"].flatMap { Int($0) } ?? 2024 +let releaseVersion = Context.environment["OPENRENDERBOX_TARGET_RELEASE"].flatMap { Int($0) } ?? 2024 let swiftBinPath = Context.environment["_"] ?? "/usr/bin/swift" let swiftBinURL = URL(fileURLWithPath: swiftBinPath) @@ -54,37 +54,37 @@ var sharedSwiftSettings: [SwiftSetting] = [ .swiftLanguageMode(.v5), ] -// MARK: - [env] OPENBOX_LIBRARY_EVOLUTION +// MARK: - [env] OPENRENDERBOX_LIBRARY_EVOLUTION -let libraryEvolutionCondition = envEnable("OPENBOX_LIBRARY_EVOLUTION", default: buildForDarwinPlatform) +let libraryEvolutionCondition = envEnable("OPENRENDERBOX_LIBRARY_EVOLUTION", default: buildForDarwinPlatform) if libraryEvolutionCondition { // NOTE: -enable-library-evolution will cause module verify failure for `swift build`. - // Either set OPENBOX_LIBRARY_EVOLUTION=0 or add `-Xswiftc -no-verify-emitted-module-interface` after `swift build` + // Either set OPENRENDERBOX_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 openBoxTarget = Target.target( - name: "OpenBox", + name: "OpenRenderBox", cSettings: sharedCSettings, cxxSettings: sharedCxxSettings ) let openBoxShimsTarget = Target.target( - name: "OpenBoxShims", + name: "OpenRenderBoxShims", swiftSettings: sharedSwiftSettings ) let openBoxTestTarget = Target.testTarget( - name: "OpenBoxTests", + name: "OpenRenderBoxTests", dependencies: [ - "OpenBox", + "OpenRenderBox", ], exclude: ["README.md"], swiftSettings: sharedSwiftSettings ) let openBoxCompatibilityTestTarget = Target.testTarget( - name: "OpenBoxCompatibilityTests", + name: "OpenRenderBoxCompatibilityTests", dependencies: [ .product(name: "RealModule", package: "swift-numerics"), ], @@ -95,7 +95,7 @@ let openBoxCompatibilityTestTarget = Target.testTarget( // MARK: - Package let libraryType: Product.Library.LibraryType? -switch Context.environment["OPENBOX_LIBRARY_TYPE"] { +switch Context.environment["OPENRENDERBOX_LIBRARY_TYPE"] { case "dynamic": libraryType = .dynamic case "static": @@ -105,10 +105,10 @@ default: } let package = Package( - name: "OpenBox", + name: "OpenRenderBox", products: [ - .library(name: "OpenBox", type: libraryType, targets: ["OpenBox"]), - .library(name: "OpenBoxShims", type: libraryType, targets: ["OpenBoxShims"]), + .library(name: "OpenRenderBox", type: libraryType, targets: ["OpenRenderBox"]), + .library(name: "OpenRenderBoxShims", type: libraryType, targets: ["OpenRenderBoxShims"]), ], dependencies: [ .package(url: "https://github.com/apple/swift-numerics", from: "1.0.2"), @@ -123,9 +123,9 @@ let package = Package( cxxLanguageStandard: .cxx20 ) -let useLocalDeps = envEnable("OPENBOX_USE_LOCAL_DEPS") +let useLocalDeps = envEnable("OPENRENDERBOX_USE_LOCAL_DEPS") -let renderBoxCondtion = envEnable("OPENBOX_RENDERBOX", default: buildForDarwinPlatform && !isSPIBuild ) +let renderBoxCondtion = envEnable("OPENRENDERBOX_RENDERBOX", default: buildForDarwinPlatform && !isSPIBuild ) if renderBoxCondtion { let privateFrameworkRepo: Package.Dependency @@ -136,7 +136,7 @@ if renderBoxCondtion { } package.dependencies.append(privateFrameworkRepo) var swiftSettings: [SwiftSetting] = (openBoxShimsTarget.swiftSettings ?? []) - swiftSettings.append(.define("OPENBOX_RENDERBOX")) + swiftSettings.append(.define("OPENRENDERBOX_RENDERBOX")) openBoxShimsTarget.swiftSettings = swiftSettings openBoxShimsTarget.dependencies.append( .product(name: "RenderBox", package: "DarwinPrivateFrameworks") @@ -149,20 +149,20 @@ if renderBoxCondtion { default: nil } } else { - openBoxShimsTarget.dependencies.append("OpenBox") + openBoxShimsTarget.dependencies.append("OpenRenderBox") } -let compatibilityTestCondition = envEnable("OPENBOX_COMPATIBILITY_TEST") +let compatibilityTestCondition = envEnable("OPENRENDERBOX_COMPATIBILITY_TEST") if compatibilityTestCondition && renderBoxCondtion { openBoxCompatibilityTestTarget.dependencies.append( .product(name: "RenderBox", package: "DarwinPrivateFrameworks") ) var swiftSettings: [SwiftSetting] = (openBoxCompatibilityTestTarget.swiftSettings ?? []) - swiftSettings.append(.define("OPENBOX_COMPATIBILITY_TEST")) + swiftSettings.append(.define("OPENRENDERBOX_COMPATIBILITY_TEST")) openBoxCompatibilityTestTarget.swiftSettings = swiftSettings } else { - openBoxCompatibilityTestTarget.dependencies.append("OpenBox") + openBoxCompatibilityTestTarget.dependencies.append("OpenRenderBox") } extension [Platform] { diff --git a/README.md b/README.md index 23d9555..7b61b38 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# OpenBox +# OpenRenderBox -[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FOpenSwiftUIProject%2FOpenBox%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/OpenSwiftUIProject/OpenBox) +[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FOpenSwiftUIProject%2FOpenRenderBox%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/OpenSwiftUIProject/OpenRenderBox) -[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FOpenSwiftUIProject%2FOpenBox%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/OpenSwiftUIProject/OpenBox) +[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FOpenSwiftUIProject%2FOpenRenderBox%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/OpenSwiftUIProject/OpenRenderBox) -[![codecov](https://codecov.io/github/OpenSwiftUIProject/OpenBox/graph/badge.svg?token=1MC561FQUR)](https://codecov.io/github/OpenSwiftUIProject/OpenBox) +[![codecov](https://codecov.io/github/OpenSwiftUIProject/OpenRenderBox/graph/badge.svg?token=1MC561FQUR)](https://codecov.io/github/OpenSwiftUIProject/OpenRenderBox) -OpenBox is an open source implementation of Apple's Private framework - RenderBox. +OpenRenderBox is an open source implementation of Apple's Private framework - RenderBox. RenderBox is a high performance rendering engine written in C++. @@ -26,10 +26,10 @@ The current suggested toolchain to build the project is Swift 6.1.2 / Xcode 16.4 | **CI Status** | |---| -|[![Compatibility tests](https://github.com/OpenSwiftUIProject/OpenBox/actions/workflows/compatibility_tests.yml/badge.svg)](https://github.com/OpenSwiftUIProject/OpenBox/actions/workflows/compatibility_tests.yml)| -|[![macOS](https://github.com/OpenSwiftUIProject/OpenBox/actions/workflows/macos.yml/badge.svg)](https://github.com/OpenSwiftUIProject/OpenBox/actions/workflows/macos.yml)| -|[![iOS](https://github.com/OpenSwiftUIProject/OpenBox/actions/workflows/ios.yml/badge.svg)](https://github.com/OpenSwiftUIProject/OpenBox/actions/workflows/ios.yml)| -|[![Ubuntu](https://github.com/OpenSwiftUIProject/OpenBox/actions/workflows/ubuntu.yml/badge.svg)](https://github.com/OpenSwiftUIProject/OpenBox/actions/workflows/ubuntu.yml)| +|[![Compatibility tests](https://github.com/OpenSwiftUIProject/OpenRenderBox/actions/workflows/compatibility_tests.yml/badge.svg)](https://github.com/OpenSwiftUIProject/OpenRenderBox/actions/workflows/compatibility_tests.yml)| +|[![macOS](https://github.com/OpenSwiftUIProject/OpenRenderBox/actions/workflows/macos.yml/badge.svg)](https://github.com/OpenSwiftUIProject/OpenRenderBox/actions/workflows/macos.yml)| +|[![iOS](https://github.com/OpenSwiftUIProject/OpenRenderBox/actions/workflows/ios.yml/badge.svg)](https://github.com/OpenSwiftUIProject/OpenRenderBox/actions/workflows/ios.yml)| +|[![Ubuntu](https://github.com/OpenSwiftUIProject/OpenRenderBox/actions/workflows/ubuntu.yml/badge.svg)](https://github.com/OpenSwiftUIProject/OpenRenderBox/actions/workflows/ubuntu.yml)| ## License diff --git a/Scripts/build.sh b/Scripts/build.sh index a2d6707..85dad82 100644 --- a/Scripts/build.sh +++ b/Scripts/build.sh @@ -5,8 +5,8 @@ filepath() { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" } -OPENBOX_ROOT="$(dirname $(dirname $(filepath $0)))" +OPENRENDERBOX_ROOT="$(dirname $(dirname $(filepath $0)))" -cd $OPENBOX_ROOT +cd $OPENRENDERBOX_ROOT swift build diff --git a/Scripts/build_swiftinterface.sh b/Scripts/build_swiftinterface.sh index 2cb307c..f713320 100755 --- a/Scripts/build_swiftinterface.sh +++ b/Scripts/build_swiftinterface.sh @@ -5,8 +5,8 @@ filepath() { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" } -OPENBOX_ROOT="$(dirname $(dirname $(filepath $0)))" +OPENRENDERBOX_ROOT="$(dirname $(dirname $(filepath $0)))" -cd $OPENBOX_ROOT +cd $OPENRENDERBOX_ROOT swift build -Xswiftc -emit-module-interface -Xswiftc -enable-library-evolution -Xswiftc -no-verify-emitted-module-interface diff --git a/Sources/OpenBox/Path/OBPath.cpp b/Sources/OpenBox/Path/OBPath.cpp deleted file mode 100644 index d325ccc..0000000 --- a/Sources/OpenBox/Path/OBPath.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// -// OBPath.cpp -// OpenBox -// -// Created by Kyle on 2025/3/25. -// - -#include "OBPath.h" - -void OBPathRetain(OBPath path) { - // TODO -} - -void OBPathRelease(OBPath path) { - // TODO -} diff --git a/Sources/OpenBox/Path/OBPathStorage.cpp b/Sources/OpenBox/Path/OBPathStorage.cpp deleted file mode 100644 index aeacfb2..0000000 --- a/Sources/OpenBox/Path/OBPathStorage.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// -// OBPathStorage.cpp -// OpenBox - -#include "OBPathStorage.h" -#include "PathStorage.hpp" -#include "../Util/assert.hpp" - -using namespace OB; - -void OBPathStorageInit(OBPathStorageRef dst, uint32_t capacity, OBPathStorageRef source) { - if (source != nullptr) { - dst->storage = OB::Path::Storage(capacity, source->storage); - } else { - dst->storage = OB::Path::Storage(capacity); - } -} - -void OBPathStorageDestroy(OBPathStorageRef storage) { - storage->storage.~Storage(); -} - -void OBPathStorageClear(OBPathStorageRef storage) { - storage->storage.clear(); -} - -// ... - -bool OBPathStorageIsEmpty(OBPathStorageRef storage) { - return storage->storage.isEmpty(); -} - -bool OBPathStorageEqualToStorage(OBPathStorageRef lhs, OBPathStorageRef rhs) { - return lhs->storage == rhs->storage; -} - -bool OBPathStorageIsSingleElement(OBPathStorageRef storage) { - return storage->storage.flags().isSingleElement(); -} - -uint32_t OBPathStorageGetBezierOrder(OBPathStorageRef storage) { - return storage->storage.flags().bezierOrder(); -} - -#if OB_TARGET_OS_DARWIN - -CGRect OBPathStorageGetBoundingRect(OBPathStorageRef storage) { - precondition_failure("TODO"); -} - -CGPathRef OBPathStorageGetCGPath(OBPathStorageRef storage) { - precondition_failure("TODO"); -} -#endif diff --git a/Sources/OpenBox/include/OBBase.h b/Sources/OpenBox/include/OBBase.h deleted file mode 100644 index c5389b6..0000000 --- a/Sources/OpenBox/include/OBBase.h +++ /dev/null @@ -1,72 +0,0 @@ -// -// OBBase.h -// OpenBox - -#ifndef OBBase_h -#define OBBase_h - -#include "OBVersion.h" - -#if DEBUG -#define OB_ASSERTION -#else -#undef OB_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 OB_NOEXCEPT noexcept -#else -#define OB_NOEXCEPT -#endif - -#if defined(__GNUC__) -#define OB_INLINE __inline__ __attribute__((always_inline)) -#elif defined(__cplusplus) -#define OB_INLINE inline -#else -#define OB_INLINE -#endif - -#if defined(__cplusplus) -#define OB_CONSTEXPR constexpr -#else -#define OB_CONSTEXPR -#endif - -#include -#include -#include -#include "OBSwiftSupport.h" -#include "OBTargetConditionals.h" - -#define OB_ENUM CF_ENUM -#define OB_CLOSED_ENUM CF_CLOSED_ENUM -#define OB_OPTIONS CF_OPTIONS -#define OB_EXTERN_C_BEGIN CF_EXTERN_C_BEGIN -#define OB_EXTERN_C_END CF_EXTERN_C_END -#define OB_ASSUME_NONNULL_BEGIN CF_ASSUME_NONNULL_BEGIN -#define OB_ASSUME_NONNULL_END CF_ASSUME_NONNULL_END -#define OB_IMPLICIT_BRIDGING_ENABLED CF_IMPLICIT_BRIDGING_ENABLED -#define OB_IMPLICIT_BRIDGING_DISABLED CF_IMPLICIT_BRIDGING_DISABLED -#define OB_EXPORT CF_EXPORT -#define OB_BRIDGED_TYPE CF_BRIDGED_TYPE - -#if TARGET_OS_DARWIN && __OBJC__ -#define OB_OBJC_FOUNDATION 1 -#else -#define OB_OBJC_FOUNDATION 0 -#endif /* TARGET_OS_DARWIN && __OBJC__ */ - -#endif /* OBBase_h */ diff --git a/Sources/OpenBox/include/OBPath.h b/Sources/OpenBox/include/OBPath.h deleted file mode 100644 index c6ee6a5..0000000 --- a/Sources/OpenBox/include/OBPath.h +++ /dev/null @@ -1,35 +0,0 @@ -// -// OBPath.h -// OpenBox - -#ifndef OBPath_h -#define OBPath_h - -#include "OBBase.h" - -OB_ASSUME_NONNULL_BEGIN - -OB_EXTERN_C_BEGIN - -typedef struct OB_BRIDGED_TYPE(id) OBPathStorage * OBPathStorageRef OB_SWIFT_NAME(OBPath.Storage); - -struct OBPathStorage; - -typedef struct OBPath { - OBPathStorageRef storage; - void *callbacks; -} OBPath; - -OB_EXPORT -OB_REFINED_FOR_SWIFT -void OBPathRetain(OBPath path) OB_SWIFT_NAME(OBPath.retain(self:)); - -OB_EXPORT -OB_REFINED_FOR_SWIFT -void OBPathRelease(OBPath path) OB_SWIFT_NAME(OBPath.release(self:)); - -OB_EXTERN_C_END - -OB_ASSUME_NONNULL_END - -#endif /* OBPath_h */ diff --git a/Sources/OpenBox/include/OBPathStorage.h b/Sources/OpenBox/include/OBPathStorage.h deleted file mode 100644 index fb05e4e..0000000 --- a/Sources/OpenBox/include/OBPathStorage.h +++ /dev/null @@ -1,65 +0,0 @@ -// -// OBPathStorage.h -// OpenBox - -#ifndef OBPathStorage_h -#define OBPathStorage_h - -#include "OBBase.h" -#include "OBPath.h" - -#if OB_TARGET_OS_DARWIN -#include -#endif - -OB_ASSUME_NONNULL_BEGIN - -OB_EXTERN_C_BEGIN - -OB_EXPORT -OB_REFINED_FOR_SWIFT -void OBPathStorageInit(OBPathStorageRef dst, uint32_t capacity, OBPathStorageRef _Nullable source); - -OB_EXPORT -OB_REFINED_FOR_SWIFT -void OBPathStorageDestroy(OBPathStorageRef storage) OB_SWIFT_NAME(OBPathStorageRef.destroy(self:)); - -OB_EXPORT -OB_REFINED_FOR_SWIFT -void OBPathStorageClear(OBPathStorageRef storage) OB_SWIFT_NAME(OBPathStorageRef.clear(self:)); - -//OB_EXPORT -//OB_REFINED_FOR_SWIFT -//void OBPathStorageAppendPath(OBPathStorage, OBPath); - -OB_EXPORT -OB_REFINED_FOR_SWIFT -bool OBPathStorageIsEmpty(OBPathStorageRef storage) OB_SWIFT_NAME(getter:OBPathStorageRef.isEmpty(self:)); - -OB_EXPORT -OB_REFINED_FOR_SWIFT -bool OBPathStorageEqualToStorage(OBPathStorageRef lhs, OBPathStorageRef rhs) OB_SWIFT_NAME(OBPathStorageRef.isEqualTo(self:_:)); - -OB_EXPORT -OB_REFINED_FOR_SWIFT -bool OBPathStorageIsSingleElement(OBPathStorageRef storage) OB_SWIFT_NAME(getter:OBPathStorageRef.isSingleElement(self:)); - -OB_EXPORT -OB_REFINED_FOR_SWIFT -uint32_t OBPathStorageGetBezierOrder(OBPathStorageRef storage) OB_SWIFT_NAME(getter:OBPathStorageRef.bezierOrder(self:)); - -#if OB_TARGET_OS_DARWIN -OB_EXPORT -OB_REFINED_FOR_SWIFT -CGRect OBPathStorageGetBoundingRect(OBPathStorageRef storage) OB_SWIFT_NAME(getter:OBPathStorageRef.boundingRect(self:)); - -OB_EXPORT -OB_REFINED_FOR_SWIFT -CGPathRef RBPathStorageGetCGPath(OBPathStorageRef storage) OB_SWIFT_NAME(getter:OBPathStorageRef.cgPath(self:)); -#endif - -OB_EXTERN_C_END - -OB_ASSUME_NONNULL_END - -#endif /* OBPathStorage_h */ diff --git a/Sources/OpenBox/include/OBSwiftSupport.h b/Sources/OpenBox/include/OBSwiftSupport.h deleted file mode 100644 index abe177f..0000000 --- a/Sources/OpenBox/include/OBSwiftSupport.h +++ /dev/null @@ -1,45 +0,0 @@ -// -// OBSwiftSupport.h -// OpenBox - -#ifndef OBSwiftSupport_h -#define OBSwiftSupport_h - -#if __has_attribute(swift_name) -#define OB_SWIFT_NAME(_name) __attribute__((swift_name(#_name))) -#else -#define OB_SWIFT_NAME -#endif - -#if __has_attribute(swift_wrapper) -#define OB_SWIFT_STRUCT __attribute__((swift_wrapper(struct))) -#else -#define OB_SWIFT_STRUCT -#endif - -#if __has_attribute(swift_private) -#define OB_REFINED_FOR_SWIFT __attribute__((swift_private)) -#else -#define OB_REFINED_FOR_SWIFT -#endif - -// MARK: - Call Convension - -#define OB_SWIFT_CC(CC) OB_SWIFT_CC_##CC -// OB_SWIFT_CC(c) is the C calling convention. -#define OB_SWIFT_CC_c - -// OB_SWIFT_CC(swift) is the Swift calling convention. -#if __has_attribute(swiftcall) -#define OB_SWIFT_CC_swift __attribute__((swiftcall)) -#define OB_SWIFT_CONTEXT __attribute__((swift_context)) -#define OB_SWIFT_ERROR_RESULT __attribute__((swift_error_result)) -#define OB_SWIFT_INDIRECT_RESULT __attribute__((swift_indirect_result)) -#else -#define OB_SWIFT_CC_swift -#define OB_SWIFT_CONTEXT -#define OB_SWIFT_ERROR_RESULT -#define OB_SWIFT_INDIRECT_RESULT -#endif - -#endif /* OBSwiftSupport_h */ diff --git a/Sources/OpenBox/include/OBTargetConditionals.h b/Sources/OpenBox/include/OBTargetConditionals.h deleted file mode 100644 index 554c764..0000000 --- a/Sources/OpenBox/include/OBTargetConditionals.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: OBTargetConditionals.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 __OPENBOXTARGETCONDITIONALS__ -#define __OPENBOXTARGETCONDITIONALS__ -/**************************************************************************************************** - - 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 OB_TARGET_OS_DARWIN 1 -#define OB_TARGET_OS_LINUX 0 -#define OB_TARGET_OS_WINDOWS 0 -#define OB_TARGET_OS_BSD 0 -#define OB_TARGET_OS_ANDROID 0 -#define OB_TARGET_OS_CYGWIN 0 -#define OB_TARGET_OS_WASI 0 -#elif __ANDROID__ -#define OB_TARGET_OS_DARWIN 0 -#define OB_TARGET_OS_LINUX 1 -#define OB_TARGET_OS_WINDOWS 0 -#define OB_TARGET_OS_BSD 0 -#define OB_TARGET_OS_ANDROID 1 -#define OB_TARGET_OS_CYGWIN 0 -#define OB_TARGET_OS_WASI 0 -#elif __linux__ -#define OB_TARGET_OS_DARWIN 0 -#define OB_TARGET_OS_LINUX 1 -#define OB_TARGET_OS_WINDOWS 0 -#define OB_TARGET_OS_BSD 0 -#define OB_TARGET_OS_ANDROID 0 -#define OB_TARGET_OS_CYGWIN 0 -#define OB_TARGET_OS_WASI 0 -#elif __CYGWIN__ -#define OB_TARGET_OS_DARWIN 0 -#define OB_TARGET_OS_LINUX 1 -#define OB_TARGET_OS_WINDOWS 0 -#define OB_TARGET_OS_BSD 0 -#define OB_TARGET_OS_ANDROID 0 -#define OB_TARGET_OS_CYGWIN 1 -#define OB_TARGET_OS_WASI 0 -#elif _WIN32 || _WIN64 -#define OB_TARGET_OS_DARWIN 0 -#define OB_TARGET_OS_LINUX 0 -#define OB_TARGET_OS_WINDOWS 1 -#define OB_TARGET_OS_BSD 0 -#define OB_TARGET_OS_ANDROID 0 -#define OB_TARGET_OS_CYGWIN 0 -#define OB_TARGET_OS_WASI 0 -#elif __unix__ -#define OB_TARGET_OS_DARWIN 0 -#define OB_TARGET_OS_LINUX 0 -#define OB_TARGET_OS_WINDOWS 0 -#define OB_TARGET_OS_BSD 1 -#define OB_TARGET_OS_ANDROID 0 -#define OB_TARGET_OS_CYGWIN 0 -#define OB_TARGET_OS_WASI 0 -#elif __wasi__ -#define OB_TARGET_OS_DARWIN 0 -#define OB_TARGET_OS_LINUX 0 -#define OB_TARGET_OS_WINDOWS 0 -#define OB_TARGET_OS_BSD 0 -#define OB_TARGET_OS_ANDROID 0 -#define OB_TARGET_OS_CYGWIN 0 -#define OB_TARGET_OS_WASI 1 -#else -#error unknown operating system -#endif - -#define OB_TARGET_OS_WIN32 OB_TARGET_OS_WINDOWS -#define OB_TARGET_OS_MAC OB_TARGET_OS_DARWIN -#define OB_TARGET_OS_OSX OB_TARGET_OS_DARWIN - -// iOS, watchOS, and tvOS are not supported -#define OB_TARGET_OS_IPHONE 0 -#define OB_TARGET_OS_IOS 0 -#define OB_TARGET_OS_WATCH 0 -#define OB_TARGET_OS_TV 0 - -#if __x86_64__ -#define OB_TARGET_CPU_PPC 0 -#define OB_TARGET_CPU_PPC64 0 -#define OB_TARGET_CPU_X86 0 -#define OB_TARGET_CPU_X86_64 1 -#define OB_TARGET_CPU_ARM 0 -#define OB_TARGET_CPU_ARM64 0 -#define OB_TARGET_CPU_MIPS 0 -#define OB_TARGET_CPU_MIPS64 0 -#define OB_TARGET_CPU_S390X 0 -#define OB_TARGET_CPU_WASM32 0 -#elif __arm64__ || __aarch64__ -#define OB_TARGET_CPU_PPC 0 -#define OB_TARGET_CPU_PPC64 0 -#define OB_TARGET_CPU_X86 0 -#define OB_TARGET_CPU_X86_64 0 -#define OB_TARGET_CPU_ARM 0 -#define OB_TARGET_CPU_ARM64 1 -#define OB_TARGET_CPU_MIPS 0 -#define OB_TARGET_CPU_MIPS64 0 -#define OB_TARGET_CPU_S390X 0 -#define OB_TARGET_CPU_WASM32 0 -#elif __mips64__ -#define OB_TARGET_CPU_PPC 0 -#define OB_TARGET_CPU_PPC64 0 -#define OB_TARGET_CPU_X86 0 -#define OB_TARGET_CPU_X86_64 0 -#define OB_TARGET_CPU_ARM 0 -#define OB_TARGET_CPU_ARM64 0 -#define OB_TARGET_CPU_MIPS 0 -#define OB_TARGET_CPU_MIPS64 1 -#define OB_TARGET_CPU_S390X 0 -#define OB_TARGET_CPU_WASM32 0 -#elif __powerpc64__ -#define OB_TARGET_CPU_PPC 0 -#define OB_TARGET_CPU_PPC64 1 -#define OB_TARGET_CPU_X86 0 -#define OB_TARGET_CPU_X86_64 0 -#define OB_TARGET_CPU_ARM 0 -#define OB_TARGET_CPU_ARM64 0 -#define OB_TARGET_CPU_MIPS 0 -#define OB_TARGET_CPU_MIPS64 0 -#define OB_TARGET_CPU_S390X 0 -#define OB_TARGET_CPU_WASM32 0 -#elif __i386__ -#define OB_TARGET_CPU_PPC 0 -#define OB_TARGET_CPU_PPC64 0 -#define OB_TARGET_CPU_X86 1 -#define OB_TARGET_CPU_X86_64 0 -#define OB_TARGET_CPU_ARM 0 -#define OB_TARGET_CPU_ARM64 0 -#define OB_TARGET_CPU_MIPS 0 -#define OB_TARGET_CPU_MIPS64 0 -#define OB_TARGET_CPU_S390X 0 -#define OB_TARGET_CPU_WASM32 0 -#elif __arm__ -#define OB_TARGET_CPU_PPC 0 -#define OB_TARGET_CPU_PPC64 0 -#define OB_TARGET_CPU_X86 0 -#define OB_TARGET_CPU_X86_64 0 -#define OB_TARGET_CPU_ARM 1 -#define OB_TARGET_CPU_ARM64 0 -#define OB_TARGET_CPU_MIPS 0 -#define OB_TARGET_CPU_MIPS64 0 -#define OB_TARGET_CPU_S390X 0 -#define OB_TARGET_CPU_WASM32 0 -#elif __mips__ -#define OB_TARGET_CPU_PPC 0 -#define OB_TARGET_CPU_PPC64 0 -#define OB_TARGET_CPU_X86 0 -#define OB_TARGET_CPU_X86_64 0 -#define OB_TARGET_CPU_ARM 0 -#define OB_TARGET_CPU_ARM64 0 -#define OB_TARGET_CPU_MIPS 1 -#define OB_TARGET_CPU_MIPS64 0 -#define OB_TARGET_CPU_S390X 0 -#define OB_TARGET_CPU_WASM32 0 -#elif __powerpc__ -#define OB_TARGET_CPU_PPC 1 -#define OB_TARGET_CPU_PPC64 0 -#define OB_TARGET_CPU_X86 0 -#define OB_TARGET_CPU_X86_64 0 -#define OB_TARGET_CPU_ARM 0 -#define OB_TARGET_CPU_ARM64 0 -#define OB_TARGET_CPU_MIPS 0 -#define OB_TARGET_CPU_MIPS64 0 -#define OB_TARGET_CPU_S390X 0 -#define OB_TARGET_CPU_WASM32 0 -#elif __s390x__ -#define OB_TARGET_CPU_PPC 0 -#define OB_TARGET_CPU_PPC64 0 -#define OB_TARGET_CPU_X86 0 -#define OB_TARGET_CPU_X86_64 0 -#define OB_TARGET_CPU_ARM 0 -#define OB_TARGET_CPU_ARM64 0 -#define OB_TARGET_CPU_MIPS 0 -#define OB_TARGET_CPU_MIPS64 0 -#define OB_TARGET_CPU_S390X 1 -#define OB_TARGET_CPU_WASM32 0 -#elif __wasm32__ -#define OB_TARGET_CPU_PPC 0 -#define OB_TARGET_CPU_PPC64 0 -#define OB_TARGET_CPU_X86 0 -#define OB_TARGET_CPU_X86_64 0 -#define OB_TARGET_CPU_ARM 0 -#define OB_TARGET_CPU_ARM64 0 -#define OB_TARGET_CPU_MIPS 0 -#define OB_TARGET_CPU_MIPS64 0 -#define OB_TARGET_CPU_S390X 0 -#define OB_TARGET_CPU_WASM32 1 -#else -#error unknown architecture -#endif - -#if __LITTLE_ENDIAN__ -#define OB_TARGET_RT_LITTLE_ENDIAN 1 -#define OB_TARGET_RT_BIG_ENDIAN 0 -#elif __BIG_ENDIAN__ -#define OB_TARGET_RT_LITTLE_ENDIAN 0 -#define OB_TARGET_RT_BIG_ENDIAN 1 -#else -#error unknown endian -#endif - -#if __LP64__ || __LLP64__ || __POINTER_WIDTH__-0 == 64 -#define OB_TARGET_RT_64_BIT 1 -#else -#define OB_TARGET_RT_64_BIT 0 -#endif - -#endif /* __OPENBOXTARGETCONDITIONALS__ */ diff --git a/Sources/OpenBox/include/OBUUID.h b/Sources/OpenBox/include/OBUUID.h deleted file mode 100644 index 481265e..0000000 --- a/Sources/OpenBox/include/OBUUID.h +++ /dev/null @@ -1,32 +0,0 @@ -// -// OBUUID.hpp -// OpenBox - -#ifndef OBUUID_hpp -#define OBUUID_hpp - -#include "OBBase.h" - -#if OB_TARGET_OS_DARWIN -#include -#endif - -typedef struct OBUUID { - uint8_t bytes[16]; -} OBUUID; - -OB_EXTERN_C_BEGIN - -#if OB_TARGET_OS_DARWIN -OB_EXPORT -OB_REFINED_FOR_SWIFT -OBUUID OBUUIDInitFromNSUUID(NSUUID *uuid) OB_SWIFT_NAME(OBUUID.init(uuid:)); -#endif - -OB_EXPORT -OB_REFINED_FOR_SWIFT -OBUUID OBUUIDInitFromHash(uint64_t words0, uint64_t words1, uint32_t words2) OB_SWIFT_NAME(OBUUID.init(_:_:_:)); - -OB_EXTERN_C_END - -#endif /* OBUUID_hpp */ diff --git a/Sources/OpenBox/include/OBVersion.h b/Sources/OpenBox/include/OBVersion.h deleted file mode 100644 index 638a9be..0000000 --- a/Sources/OpenBox/include/OBVersion.h +++ /dev/null @@ -1,14 +0,0 @@ -// -// OBVersion.h -// OpenBox - -#ifndef OBVersion_h -#define OBVersion_h - -#define OB_RELEASE_2024 2024 - -#ifndef OB_TARGET_RELEASE -#define OB_TARGET_RELEASE 2024 -#endif - -#endif /* OBVersion_h */ diff --git a/Sources/OpenBoxShims/BoxShims.swift b/Sources/OpenBoxShims/BoxShims.swift deleted file mode 100644 index 12e7ff3..0000000 --- a/Sources/OpenBoxShims/BoxShims.swift +++ /dev/null @@ -1,13 +0,0 @@ -// -// BoxShims.swift -// OpenBoxShims - -#if OPENBOX_RENDERBOX -@_exported public import RenderBox -public typealias OBUUID = RBUUID -public typealias OBPath = RBPath -public let renderBoxEnabled = true -#else -@_exported import OpenBox -public let renderBoxEnabled = false -#endif diff --git a/Sources/OpenRenderBox/Path/OBPath.cpp b/Sources/OpenRenderBox/Path/OBPath.cpp new file mode 100644 index 0000000..e7ea020 --- /dev/null +++ b/Sources/OpenRenderBox/Path/OBPath.cpp @@ -0,0 +1,16 @@ +// +// ORBPath.cpp +// OpenRenderBox +// +// Created by Kyle on 2025/3/25. +// + +#include "ORBPath.h" + +void ORBPathRetain(ORBPath path) { + // TODO +} + +void ORBPathRelease(ORBPath path) { + // TODO +} diff --git a/Sources/OpenRenderBox/Path/OBPathStorage.cpp b/Sources/OpenRenderBox/Path/OBPathStorage.cpp new file mode 100644 index 0000000..6aa178f --- /dev/null +++ b/Sources/OpenRenderBox/Path/OBPathStorage.cpp @@ -0,0 +1,54 @@ +// +// ORBPathStorage.cpp +// OpenRenderBox + +#include "ORBPathStorage.h" +#include "PathStorage.hpp" +#include "../Util/assert.hpp" + +using namespace ORB; + +void ORBPathStorageInit(ORBPathStorageRef dst, uint32_t capacity, ORBPathStorageRef source) { + if (source != nullptr) { + dst->storage = ORB::Path::Storage(capacity, source->storage); + } else { + dst->storage = ORB::Path::Storage(capacity); + } +} + +void ORBPathStorageDestroy(ORBPathStorageRef storage) { + storage->storage.~Storage(); +} + +void ORBPathStorageClear(ORBPathStorageRef storage) { + storage->storage.clear(); +} + +// ... + +bool ORBPathStorageIsEmpty(ORBPathStorageRef storage) { + return storage->storage.isEmpty(); +} + +bool ORBPathStorageEqualToStorage(ORBPathStorageRef lhs, ORBPathStorageRef rhs) { + return lhs->storage == rhs->storage; +} + +bool ORBPathStorageIsSingleElement(ORBPathStorageRef storage) { + return storage->storage.flags().isSingleElement(); +} + +uint32_t ORBPathStorageGetBezierOrder(ORBPathStorageRef storage) { + return storage->storage.flags().bezierOrder(); +} + +#if ORB_TARGET_OS_DARWIN + +CGRect ORBPathStorageGetBoundingRect(ORBPathStorageRef storage) { + precondition_failure("TODO"); +} + +CGPathRef ORBPathStorageGetCGPath(ORBPathStorageRef storage) { + precondition_failure("TODO"); +} +#endif diff --git a/Sources/OpenBox/Path/PathStorage.cpp b/Sources/OpenRenderBox/Path/PathStorage.cpp similarity index 93% rename from Sources/OpenBox/Path/PathStorage.cpp rename to Sources/OpenRenderBox/Path/PathStorage.cpp index 8dc4e86..2273755 100644 --- a/Sources/OpenBox/Path/PathStorage.cpp +++ b/Sources/OpenRenderBox/Path/PathStorage.cpp @@ -1,11 +1,11 @@ // // PathStorage.cpp -// OpenBox +// OpenRenderBox #include "PathStorage.hpp" #include "../Util/assert.hpp" -namespace OB { +namespace ORB { namespace Path { atomic_long Storage::_last_identifier; @@ -50,7 +50,7 @@ Storage::~Storage() { } } -bool Storage::operator==(const Storage &other) const OB_NOEXCEPT { +bool Storage::operator==(const Storage &other) const ORB_NOEXCEPT { // TODO return false; } @@ -60,4 +60,4 @@ void Storage::clear() { } } /* Path */ -} /* OB */ +} /* ORB */ diff --git a/Sources/OpenBox/Path/PathStorage.hpp b/Sources/OpenRenderBox/Path/PathStorage.hpp similarity index 60% rename from Sources/OpenBox/Path/PathStorage.hpp rename to Sources/OpenRenderBox/Path/PathStorage.hpp index f00b473..15b75cc 100644 --- a/Sources/OpenBox/Path/PathStorage.hpp +++ b/Sources/OpenRenderBox/Path/PathStorage.hpp @@ -1,17 +1,17 @@ // // PathStorage.hpp -// OpenBox +// OpenRenderBox #ifndef PathStorage_hpp #define PathStorage_hpp -#include "OBBase.h" +#include "ORBBase.h" #include "../Util/assert.hpp" #include -OB_ASSUME_NONNULL_BEGIN +ORB_ASSUME_NONNULL_BEGIN -namespace OB { +namespace ORB { namespace Path { struct StorageFlags { @@ -25,13 +25,13 @@ struct StorageFlags { /// [20, 32) -> capacity uint32_t value; - OB_INLINE OB_CONSTEXPR + ORB_INLINE ORB_CONSTEXPR explicit StorageFlags(uint32_t value): value(value) {} public: - OB_INLINE OB_CONSTEXPR + ORB_INLINE ORB_CONSTEXPR StorageFlags(): value(0) {} - OB_INLINE OB_CONSTEXPR + ORB_INLINE ORB_CONSTEXPR StorageFlags(bool isExternal, bool isQuadBezierOrder, bool isCubicBezierOrder, @@ -47,93 +47,93 @@ struct StorageFlags { .withCapacity(capacity)) {} - OB_INLINE OB_CONSTEXPR - bool isInline() const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + bool isInline() const ORB_NOEXCEPT { return (value & 1u) == 0; } - OB_INLINE OB_CONSTEXPR - bool isExternal() const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + bool isExternal() const ORB_NOEXCEPT { return (value & 1u) != 0; } - OB_INLINE OB_CONSTEXPR - bool isQuadBezierOrder() const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + bool isQuadBezierOrder() const ORB_NOEXCEPT { return (value & 2u) != 0; } - OB_INLINE OB_CONSTEXPR - bool isCubicBezierOrder() const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + bool isCubicBezierOrder() const ORB_NOEXCEPT { return (value & 4u) != 0; } - OB_INLINE OB_CONSTEXPR - uint32_t bezierOrder() const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + uint32_t bezierOrder() const ORB_NOEXCEPT { bool isQuad = (value & 2u) != 0; bool isCubic = (value & 4u) != 0; return isCubic ? 3u : (isQuad ? 2u : 1u); } - OB_INLINE OB_CONSTEXPR - bool isSingleElement() const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + bool isSingleElement() const ORB_NOEXCEPT { return (value & 8u) != 0; } - OB_INLINE OB_CONSTEXPR - uint32_t size() const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + uint32_t size() const ORB_NOEXCEPT { return (value >> 8u) & 0xFFFu; } - OB_INLINE OB_CONSTEXPR - uint32_t capacity() const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + uint32_t capacity() const ORB_NOEXCEPT { return (value >> 0x14); } - OB_INLINE OB_CONSTEXPR - StorageFlags withExternal(bool isExternal) const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + StorageFlags withExternal(bool isExternal) const ORB_NOEXCEPT { return StorageFlags((value & 0xFFFFFFFEu) | (isExternal ? 0x1u : 0)); } - OB_INLINE OB_CONSTEXPR - StorageFlags withQuadBezierOrder(bool isQuadBezierOrder) const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + StorageFlags withQuadBezierOrder(bool isQuadBezierOrder) const ORB_NOEXCEPT { return StorageFlags((value & 0xFFFFFFFDu) | (isQuadBezierOrder ? 0x2u : 0)); } - OB_INLINE OB_CONSTEXPR - StorageFlags withCubicBezierOrder(bool isCubicBezierOrder) const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + StorageFlags withCubicBezierOrder(bool isCubicBezierOrder) const ORB_NOEXCEPT { return StorageFlags((value & 0xFFFFFFFBu) | (isCubicBezierOrder ? 0x4u : 0)); } - OB_INLINE OB_CONSTEXPR - StorageFlags withSingleElement(bool isSingleElement) const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + StorageFlags withSingleElement(bool isSingleElement) const ORB_NOEXCEPT { return StorageFlags((value & 0xFFFFFFF7u) | (isSingleElement ? 0x8u : 0)); } - OB_INLINE OB_CONSTEXPR - StorageFlags withSize(uint32_t size) const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + StorageFlags withSize(uint32_t size) const ORB_NOEXCEPT { return StorageFlags((value & 0xFFF000FFu) | ((size & 0xFFFu) << 8)); } - OB_INLINE OB_CONSTEXPR - StorageFlags withCapacity(uint32_t capacity) const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + StorageFlags withCapacity(uint32_t capacity) const ORB_NOEXCEPT { return StorageFlags((value & 0xFFFFFFu) | ((capacity & 0xFFFu) << 0x14)); } - OB_INLINE OB_CONSTEXPR - uint32_t getIntValue() const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + uint32_t getIntValue() const ORB_NOEXCEPT { return value; } }; /* StorageFlags */ class Storage { public: - OB_INLINE OB_CONSTEXPR - const static atomic_long& last_identifier() OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + const static atomic_long& last_identifier() ORB_NOEXCEPT { return _last_identifier; } - OB_INLINE - const static uint32_t get_identifier() OB_NOEXCEPT { + ORB_INLINE + const static uint32_t get_identifier() ORB_NOEXCEPT { _last_identifier++; return _last_identifier; } @@ -152,10 +152,10 @@ class Storage { } - Storage(uint32_t capacity, const OB::Path::Storage &storage); + Storage(uint32_t capacity, const ORB::Path::Storage &storage); ~Storage(); - bool operator == (const Storage &other) const OB_NOEXCEPT; + bool operator == (const Storage &other) const ORB_NOEXCEPT; void clear(); @@ -163,33 +163,33 @@ class Storage { // push_values(unsigned char, double const*, unsigned long) // update_single_element() public: - OB_INLINE OB_CONSTEXPR - void * unknown() const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + void * unknown() const ORB_NOEXCEPT { return _unknonw; } - OB_INLINE OB_CONSTEXPR - StorageFlags flags() const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + StorageFlags flags() const ORB_NOEXCEPT { return _flags; } - OB_INLINE OB_CONSTEXPR - uint32_t identifier() const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + uint32_t identifier() const ORB_NOEXCEPT { return _identifier; } - OB_INLINE OB_CONSTEXPR - const Storage* external_storage() const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + const Storage* external_storage() const ORB_NOEXCEPT { return _external_storage; } - OB_INLINE OB_CONSTEXPR - uint64_t external_size() const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + uint64_t external_size() const ORB_NOEXCEPT { return _external_size; } - OB_INLINE OB_CONSTEXPR - const Storage* actual_storage() const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + const Storage* actual_storage() const ORB_NOEXCEPT { if (flags().isInline()) { return this; } else { @@ -197,8 +197,8 @@ class Storage { } } - OB_INLINE OB_CONSTEXPR - uint64_t actual_size() const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + uint64_t actual_size() const ORB_NOEXCEPT { if (flags().isInline()) { return flags().size(); } else { @@ -206,8 +206,8 @@ class Storage { } } - OB_INLINE OB_CONSTEXPR - bool isEmpty() const OB_NOEXCEPT { + ORB_INLINE ORB_CONSTEXPR + bool isEmpty() const ORB_NOEXCEPT { return actual_size() == 0; } private: @@ -218,12 +218,12 @@ class Storage { uint64_t _external_size; }; } /* Path */ -} /* OB */ +} /* ORB */ -struct OBPathStorage { - OB::Path::Storage storage; +struct ORBPathStorage { + ORB::Path::Storage storage; }; -OB_ASSUME_NONNULL_END +ORB_ASSUME_NONNULL_END #endif /* PathStorage_hpp */ diff --git a/Sources/OpenBox/UUID/OBUUID.mm b/Sources/OpenRenderBox/UUID/OBUUID.mm similarity index 77% rename from Sources/OpenBox/UUID/OBUUID.mm rename to Sources/OpenRenderBox/UUID/OBUUID.mm index e0e3335..7df8f25 100644 --- a/Sources/OpenBox/UUID/OBUUID.mm +++ b/Sources/OpenRenderBox/UUID/OBUUID.mm @@ -1,19 +1,19 @@ // -// OBUUID.mm -// OpenBox +// ORBUUID.mm +// OpenRenderBox -#include "OBUUID.h" +#include "ORBUUID.h" -#if OB_TARGET_OS_DARWIN -OBUUID OBUUIDInitFromNSUUID(NSUUID *uuid) { - OBUUID ob_uuid; +#if ORB_TARGET_OS_DARWIN +ORBUUID ORBUUIDInitFromNSUUID(NSUUID *uuid) { + ORBUUID ob_uuid; [uuid getUUIDBytes:ob_uuid.bytes]; return ob_uuid; } #endif -OBUUID OBUUIDInitFromHash(uint64_t words0, uint64_t words1, uint32_t words2) { - OBUUID ob_uuid; +ORBUUID ORBUUIDInitFromHash(uint64_t words0, uint64_t words1, uint32_t words2) { + ORBUUID ob_uuid; ob_uuid.bytes[0] = words0 & 0xFF; ob_uuid.bytes[1] = ((words0 >> 8) & 0x0F) | ((words2 & 0xF) << 0x4); ob_uuid.bytes[2] = (words0 >> 16) & 0xFF; diff --git a/Sources/OpenBox/Util/assert.cpp b/Sources/OpenRenderBox/Util/assert.cpp similarity index 80% rename from Sources/OpenBox/Util/assert.cpp rename to Sources/OpenRenderBox/Util/assert.cpp index b15ef8d..6c1c3c9 100644 --- a/Sources/OpenBox/Util/assert.cpp +++ b/Sources/OpenRenderBox/Util/assert.cpp @@ -1,13 +1,13 @@ // // assert.cpp -// OpenBox +// OpenRenderBox #include "assert.hpp" #include "log.hpp" char* error_message = nullptr; -namespace OB { +namespace ORB { void precondition_failure(const char *format, ...) { char* s = nullptr; va_list va; @@ -15,9 +15,9 @@ void precondition_failure(const char *format, ...) { vasprintf(&s, format, va); va_end(va); if (s != nullptr) { - #if OB_TARGET_OS_DARWIN + #if ORB_TARGET_OS_DARWIN os_log_error(error_log(), "precondition failure: %s", s); - #endif /* OB_TARGET_OS_DARWIN */ + #endif /* ORB_TARGET_OS_DARWIN */ if (error_message == nullptr) { asprintf(&error_message, "OpenGraph precondition failure: %s.\n", s); } @@ -33,11 +33,11 @@ void non_fatal_precondition_failure(const char *format, ...) { vasprintf(&s, format, va); va_end(va); if (s != nullptr) { - #if OB_TARGET_OS_DARWIN + #if ORB_TARGET_OS_DARWIN os_log_fault(error_log(), "precondition failure: %s", s); - #endif /* OB_TARGET_OS_DARWIN */ + #endif /* ORB_TARGET_OS_DARWIN */ free(s); } return; } -} /* OB */ +} /* ORB */ diff --git a/Sources/OpenBox/Util/assert.hpp b/Sources/OpenRenderBox/Util/assert.hpp similarity index 76% rename from Sources/OpenBox/Util/assert.hpp rename to Sources/OpenRenderBox/Util/assert.hpp index 991366a..e92ae7a 100644 --- a/Sources/OpenBox/Util/assert.hpp +++ b/Sources/OpenRenderBox/Util/assert.hpp @@ -1,15 +1,15 @@ // // assert.hpp -// OpenBox +// OpenRenderBox #ifndef assert_hpp #define assert_hpp -#include "OBBase.h" +#include "ORBBase.h" -namespace OB { +namespace ORB { void precondition_failure(const char *format, ...) __cold __dead2; void non_fatal_precondition_failure(const char *format, ...); -} /* OB */ +} /* ORB */ #endif /* assert_hpp */ diff --git a/Sources/OpenBox/Util/log.cpp b/Sources/OpenRenderBox/Util/log.cpp similarity index 73% rename from Sources/OpenBox/Util/log.cpp rename to Sources/OpenRenderBox/Util/log.cpp index 704292f..83687b8 100644 --- a/Sources/OpenBox/Util/log.cpp +++ b/Sources/OpenRenderBox/Util/log.cpp @@ -1,12 +1,12 @@ // // OGLog.cpp -// OpenBox +// OpenRenderBox #include "log.hpp" -#if OB_TARGET_OS_DARWIN +#if ORB_TARGET_OS_DARWIN -namespace OB { +namespace ORB { os_log_t misc_log() { static os_log_t log = os_log_create("org.openswiftuiproject.openbox", "misc"); return log; @@ -15,6 +15,6 @@ os_log_t error_log() { static os_log_t log = os_log_create("org.openswiftuiproject.openbox", "error"); return log; } -} /* OB */ +} /* ORB */ -#endif /* OB_TARGET_OS_DARWIN */ +#endif /* ORB_TARGET_OS_DARWIN */ diff --git a/Sources/OpenBox/Util/log.hpp b/Sources/OpenRenderBox/Util/log.hpp similarity index 52% rename from Sources/OpenBox/Util/log.hpp rename to Sources/OpenRenderBox/Util/log.hpp index 68adeb8..cc0decf 100644 --- a/Sources/OpenBox/Util/log.hpp +++ b/Sources/OpenRenderBox/Util/log.hpp @@ -1,21 +1,21 @@ // // log.hpp -// OpenBox +// OpenRenderBox #ifndef log_hpp #define log_hpp -#include "OBBase.h" +#include "ORBBase.h" -#if OB_TARGET_OS_DARWIN +#if ORB_TARGET_OS_DARWIN #include -namespace OB { +namespace ORB { os_log_t misc_log(); os_log_t error_log(); -} /* OB */ +} /* ORB */ -#endif /* OB_TARGET_OS_DARWIN */ +#endif /* ORB_TARGET_OS_DARWIN */ #endif /* log_hpp */ diff --git a/Sources/OpenRenderBox/include/OBBase.h b/Sources/OpenRenderBox/include/OBBase.h new file mode 100644 index 0000000..b07a47c --- /dev/null +++ b/Sources/OpenRenderBox/include/OBBase.h @@ -0,0 +1,72 @@ +// +// ORBBase.h +// OpenRenderBox + +#ifndef ORBBase_h +#define ORBBase_h + +#include "ORBVersion.h" + +#if DEBUG +#define ORB_ASSERTION +#else +#undef ORB_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 ORB_NOEXCEPT noexcept +#else +#define ORB_NOEXCEPT +#endif + +#if defined(__GNUC__) +#define ORB_INLINE __inline__ __attribute__((always_inline)) +#elif defined(__cplusplus) +#define ORB_INLINE inline +#else +#define ORB_INLINE +#endif + +#if defined(__cplusplus) +#define ORB_CONSTEXPR constexpr +#else +#define ORB_CONSTEXPR +#endif + +#include +#include +#include +#include "ORBSwiftSupport.h" +#include "ORBTargetConditionals.h" + +#define ORB_ENUM CF_ENUM +#define ORB_CLOSED_ENUM CF_CLOSED_ENUM +#define ORB_OPTIONS CF_OPTIONS +#define ORB_EXTERN_C_BEGIN CF_EXTERN_C_BEGIN +#define ORB_EXTERN_C_END CF_EXTERN_C_END +#define ORB_ASSUME_NONNULL_BEGIN CF_ASSUME_NONNULL_BEGIN +#define ORB_ASSUME_NONNULL_END CF_ASSUME_NONNULL_END +#define ORB_IMPLICIT_BRIDGING_ENABLED CF_IMPLICIT_BRIDGING_ENABLED +#define ORB_IMPLICIT_BRIDGING_DISABLED CF_IMPLICIT_BRIDGING_DISABLED +#define ORB_EXPORT CF_EXPORT +#define ORB_BRIDGED_TYPE CF_BRIDGED_TYPE + +#if TARGET_OS_DARWIN && __ORBJC__ +#define ORB_ORBJC_FOUNDATION 1 +#else +#define ORB_ORBJC_FOUNDATION 0 +#endif /* TARGET_OS_DARWIN && __ORBJC__ */ + +#endif /* ORBBase_h */ diff --git a/Sources/OpenRenderBox/include/OBPath.h b/Sources/OpenRenderBox/include/OBPath.h new file mode 100644 index 0000000..ba434ea --- /dev/null +++ b/Sources/OpenRenderBox/include/OBPath.h @@ -0,0 +1,35 @@ +// +// ORBPath.h +// OpenRenderBox + +#ifndef ORBPath_h +#define ORBPath_h + +#include "ORBBase.h" + +ORB_ASSUME_NONNULL_BEGIN + +ORB_EXTERN_C_BEGIN + +typedef struct ORB_BRIDGED_TYPE(id) ORBPathStorage * ORBPathStorageRef ORB_SWIFT_NAME(ORBPath.Storage); + +struct ORBPathStorage; + +typedef struct ORBPath { + ORBPathStorageRef storage; + void *callbacks; +} ORBPath; + +ORB_EXPORT +ORB_REFINED_FOR_SWIFT +void ORBPathRetain(ORBPath path) ORB_SWIFT_NAME(ORBPath.retain(self:)); + +ORB_EXPORT +ORB_REFINED_FOR_SWIFT +void ORBPathRelease(ORBPath path) ORB_SWIFT_NAME(ORBPath.release(self:)); + +ORB_EXTERN_C_END + +ORB_ASSUME_NONNULL_END + +#endif /* ORBPath_h */ diff --git a/Sources/OpenRenderBox/include/OBPathStorage.h b/Sources/OpenRenderBox/include/OBPathStorage.h new file mode 100644 index 0000000..1de590f --- /dev/null +++ b/Sources/OpenRenderBox/include/OBPathStorage.h @@ -0,0 +1,65 @@ +// +// ORBPathStorage.h +// OpenRenderBox + +#ifndef ORBPathStorage_h +#define ORBPathStorage_h + +#include "ORBBase.h" +#include "ORBPath.h" + +#if ORB_TARGET_OS_DARWIN +#include +#endif + +ORB_ASSUME_NONNULL_BEGIN + +ORB_EXTERN_C_BEGIN + +ORB_EXPORT +ORB_REFINED_FOR_SWIFT +void ORBPathStorageInit(ORBPathStorageRef dst, uint32_t capacity, ORBPathStorageRef _Nullable source); + +ORB_EXPORT +ORB_REFINED_FOR_SWIFT +void ORBPathStorageDestroy(ORBPathStorageRef storage) ORB_SWIFT_NAME(ORBPathStorageRef.destroy(self:)); + +ORB_EXPORT +ORB_REFINED_FOR_SWIFT +void ORBPathStorageClear(ORBPathStorageRef storage) ORB_SWIFT_NAME(ORBPathStorageRef.clear(self:)); + +//ORB_EXPORT +//ORB_REFINED_FOR_SWIFT +//void ORBPathStorageAppendPath(ORBPathStorage, ORBPath); + +ORB_EXPORT +ORB_REFINED_FOR_SWIFT +bool ORBPathStorageIsEmpty(ORBPathStorageRef storage) ORB_SWIFT_NAME(getter:ORBPathStorageRef.isEmpty(self:)); + +ORB_EXPORT +ORB_REFINED_FOR_SWIFT +bool ORBPathStorageEqualToStorage(ORBPathStorageRef lhs, ORBPathStorageRef rhs) ORB_SWIFT_NAME(ORBPathStorageRef.isEqualTo(self:_:)); + +ORB_EXPORT +ORB_REFINED_FOR_SWIFT +bool ORBPathStorageIsSingleElement(ORBPathStorageRef storage) ORB_SWIFT_NAME(getter:ORBPathStorageRef.isSingleElement(self:)); + +ORB_EXPORT +ORB_REFINED_FOR_SWIFT +uint32_t ORBPathStorageGetBezierOrder(ORBPathStorageRef storage) ORB_SWIFT_NAME(getter:ORBPathStorageRef.bezierOrder(self:)); + +#if ORB_TARGET_OS_DARWIN +ORB_EXPORT +ORB_REFINED_FOR_SWIFT +CGRect ORBPathStorageGetBoundingRect(ORBPathStorageRef storage) ORB_SWIFT_NAME(getter:ORBPathStorageRef.boundingRect(self:)); + +ORB_EXPORT +ORB_REFINED_FOR_SWIFT +CGPathRef RBPathStorageGetCGPath(ORBPathStorageRef storage) ORB_SWIFT_NAME(getter:ORBPathStorageRef.cgPath(self:)); +#endif + +ORB_EXTERN_C_END + +ORB_ASSUME_NONNULL_END + +#endif /* ORBPathStorage_h */ diff --git a/Sources/OpenRenderBox/include/OBSwiftSupport.h b/Sources/OpenRenderBox/include/OBSwiftSupport.h new file mode 100644 index 0000000..df63253 --- /dev/null +++ b/Sources/OpenRenderBox/include/OBSwiftSupport.h @@ -0,0 +1,45 @@ +// +// ORBSwiftSupport.h +// OpenRenderBox + +#ifndef ORBSwiftSupport_h +#define ORBSwiftSupport_h + +#if __has_attribute(swift_name) +#define ORB_SWIFT_NAME(_name) __attribute__((swift_name(#_name))) +#else +#define ORB_SWIFT_NAME +#endif + +#if __has_attribute(swift_wrapper) +#define ORB_SWIFT_STRUCT __attribute__((swift_wrapper(struct))) +#else +#define ORB_SWIFT_STRUCT +#endif + +#if __has_attribute(swift_private) +#define ORB_REFINED_FOR_SWIFT __attribute__((swift_private)) +#else +#define ORB_REFINED_FOR_SWIFT +#endif + +// MARK: - Call Convension + +#define ORB_SWIFT_CC(CC) ORB_SWIFT_CC_##CC +// ORB_SWIFT_CC(c) is the C calling convention. +#define ORB_SWIFT_CC_c + +// ORB_SWIFT_CC(swift) is the Swift calling convention. +#if __has_attribute(swiftcall) +#define ORB_SWIFT_CC_swift __attribute__((swiftcall)) +#define ORB_SWIFT_CONTEXT __attribute__((swift_context)) +#define ORB_SWIFT_ERROR_RESULT __attribute__((swift_error_result)) +#define ORB_SWIFT_INDIRECT_RESULT __attribute__((swift_indirect_result)) +#else +#define ORB_SWIFT_CC_swift +#define ORB_SWIFT_CONTEXT +#define ORB_SWIFT_ERROR_RESULT +#define ORB_SWIFT_INDIRECT_RESULT +#endif + +#endif /* ORBSwiftSupport_h */ diff --git a/Sources/OpenRenderBox/include/OBTargetConditionals.h b/Sources/OpenRenderBox/include/OBTargetConditionals.h new file mode 100644 index 0000000..e69e456 --- /dev/null +++ b/Sources/OpenRenderBox/include/OBTargetConditionals.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: ORBTargetConditionals.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 __OPENRENDERBOXTARGETCONDITIONALS__ +#define __OPENRENDERBOXTARGETCONDITIONALS__ +/**************************************************************************************************** + + 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 ORB_TARGET_OS_DARWIN 1 +#define ORB_TARGET_OS_LINUX 0 +#define ORB_TARGET_OS_WINDOWS 0 +#define ORB_TARGET_OS_BSD 0 +#define ORB_TARGET_OS_ANDROID 0 +#define ORB_TARGET_OS_CYGWIN 0 +#define ORB_TARGET_OS_WASI 0 +#elif __ANDROID__ +#define ORB_TARGET_OS_DARWIN 0 +#define ORB_TARGET_OS_LINUX 1 +#define ORB_TARGET_OS_WINDOWS 0 +#define ORB_TARGET_OS_BSD 0 +#define ORB_TARGET_OS_ANDROID 1 +#define ORB_TARGET_OS_CYGWIN 0 +#define ORB_TARGET_OS_WASI 0 +#elif __linux__ +#define ORB_TARGET_OS_DARWIN 0 +#define ORB_TARGET_OS_LINUX 1 +#define ORB_TARGET_OS_WINDOWS 0 +#define ORB_TARGET_OS_BSD 0 +#define ORB_TARGET_OS_ANDROID 0 +#define ORB_TARGET_OS_CYGWIN 0 +#define ORB_TARGET_OS_WASI 0 +#elif __CYGWIN__ +#define ORB_TARGET_OS_DARWIN 0 +#define ORB_TARGET_OS_LINUX 1 +#define ORB_TARGET_OS_WINDOWS 0 +#define ORB_TARGET_OS_BSD 0 +#define ORB_TARGET_OS_ANDROID 0 +#define ORB_TARGET_OS_CYGWIN 1 +#define ORB_TARGET_OS_WASI 0 +#elif _WIN32 || _WIN64 +#define ORB_TARGET_OS_DARWIN 0 +#define ORB_TARGET_OS_LINUX 0 +#define ORB_TARGET_OS_WINDOWS 1 +#define ORB_TARGET_OS_BSD 0 +#define ORB_TARGET_OS_ANDROID 0 +#define ORB_TARGET_OS_CYGWIN 0 +#define ORB_TARGET_OS_WASI 0 +#elif __unix__ +#define ORB_TARGET_OS_DARWIN 0 +#define ORB_TARGET_OS_LINUX 0 +#define ORB_TARGET_OS_WINDOWS 0 +#define ORB_TARGET_OS_BSD 1 +#define ORB_TARGET_OS_ANDROID 0 +#define ORB_TARGET_OS_CYGWIN 0 +#define ORB_TARGET_OS_WASI 0 +#elif __wasi__ +#define ORB_TARGET_OS_DARWIN 0 +#define ORB_TARGET_OS_LINUX 0 +#define ORB_TARGET_OS_WINDOWS 0 +#define ORB_TARGET_OS_BSD 0 +#define ORB_TARGET_OS_ANDROID 0 +#define ORB_TARGET_OS_CYGWIN 0 +#define ORB_TARGET_OS_WASI 1 +#else +#error unknown operating system +#endif + +#define ORB_TARGET_OS_WIN32 ORB_TARGET_OS_WINDOWS +#define ORB_TARGET_OS_MAC ORB_TARGET_OS_DARWIN +#define ORB_TARGET_OS_OSX ORB_TARGET_OS_DARWIN + +// iOS, watchOS, and tvOS are not supported +#define ORB_TARGET_OS_IPHONE 0 +#define ORB_TARGET_OS_IOS 0 +#define ORB_TARGET_OS_WATCH 0 +#define ORB_TARGET_OS_TV 0 + +#if __x86_64__ +#define ORB_TARGET_CPU_PPC 0 +#define ORB_TARGET_CPU_PPC64 0 +#define ORB_TARGET_CPU_X86 0 +#define ORB_TARGET_CPU_X86_64 1 +#define ORB_TARGET_CPU_ARM 0 +#define ORB_TARGET_CPU_ARM64 0 +#define ORB_TARGET_CPU_MIPS 0 +#define ORB_TARGET_CPU_MIPS64 0 +#define ORB_TARGET_CPU_S390X 0 +#define ORB_TARGET_CPU_WASM32 0 +#elif __arm64__ || __aarch64__ +#define ORB_TARGET_CPU_PPC 0 +#define ORB_TARGET_CPU_PPC64 0 +#define ORB_TARGET_CPU_X86 0 +#define ORB_TARGET_CPU_X86_64 0 +#define ORB_TARGET_CPU_ARM 0 +#define ORB_TARGET_CPU_ARM64 1 +#define ORB_TARGET_CPU_MIPS 0 +#define ORB_TARGET_CPU_MIPS64 0 +#define ORB_TARGET_CPU_S390X 0 +#define ORB_TARGET_CPU_WASM32 0 +#elif __mips64__ +#define ORB_TARGET_CPU_PPC 0 +#define ORB_TARGET_CPU_PPC64 0 +#define ORB_TARGET_CPU_X86 0 +#define ORB_TARGET_CPU_X86_64 0 +#define ORB_TARGET_CPU_ARM 0 +#define ORB_TARGET_CPU_ARM64 0 +#define ORB_TARGET_CPU_MIPS 0 +#define ORB_TARGET_CPU_MIPS64 1 +#define ORB_TARGET_CPU_S390X 0 +#define ORB_TARGET_CPU_WASM32 0 +#elif __powerpc64__ +#define ORB_TARGET_CPU_PPC 0 +#define ORB_TARGET_CPU_PPC64 1 +#define ORB_TARGET_CPU_X86 0 +#define ORB_TARGET_CPU_X86_64 0 +#define ORB_TARGET_CPU_ARM 0 +#define ORB_TARGET_CPU_ARM64 0 +#define ORB_TARGET_CPU_MIPS 0 +#define ORB_TARGET_CPU_MIPS64 0 +#define ORB_TARGET_CPU_S390X 0 +#define ORB_TARGET_CPU_WASM32 0 +#elif __i386__ +#define ORB_TARGET_CPU_PPC 0 +#define ORB_TARGET_CPU_PPC64 0 +#define ORB_TARGET_CPU_X86 1 +#define ORB_TARGET_CPU_X86_64 0 +#define ORB_TARGET_CPU_ARM 0 +#define ORB_TARGET_CPU_ARM64 0 +#define ORB_TARGET_CPU_MIPS 0 +#define ORB_TARGET_CPU_MIPS64 0 +#define ORB_TARGET_CPU_S390X 0 +#define ORB_TARGET_CPU_WASM32 0 +#elif __arm__ +#define ORB_TARGET_CPU_PPC 0 +#define ORB_TARGET_CPU_PPC64 0 +#define ORB_TARGET_CPU_X86 0 +#define ORB_TARGET_CPU_X86_64 0 +#define ORB_TARGET_CPU_ARM 1 +#define ORB_TARGET_CPU_ARM64 0 +#define ORB_TARGET_CPU_MIPS 0 +#define ORB_TARGET_CPU_MIPS64 0 +#define ORB_TARGET_CPU_S390X 0 +#define ORB_TARGET_CPU_WASM32 0 +#elif __mips__ +#define ORB_TARGET_CPU_PPC 0 +#define ORB_TARGET_CPU_PPC64 0 +#define ORB_TARGET_CPU_X86 0 +#define ORB_TARGET_CPU_X86_64 0 +#define ORB_TARGET_CPU_ARM 0 +#define ORB_TARGET_CPU_ARM64 0 +#define ORB_TARGET_CPU_MIPS 1 +#define ORB_TARGET_CPU_MIPS64 0 +#define ORB_TARGET_CPU_S390X 0 +#define ORB_TARGET_CPU_WASM32 0 +#elif __powerpc__ +#define ORB_TARGET_CPU_PPC 1 +#define ORB_TARGET_CPU_PPC64 0 +#define ORB_TARGET_CPU_X86 0 +#define ORB_TARGET_CPU_X86_64 0 +#define ORB_TARGET_CPU_ARM 0 +#define ORB_TARGET_CPU_ARM64 0 +#define ORB_TARGET_CPU_MIPS 0 +#define ORB_TARGET_CPU_MIPS64 0 +#define ORB_TARGET_CPU_S390X 0 +#define ORB_TARGET_CPU_WASM32 0 +#elif __s390x__ +#define ORB_TARGET_CPU_PPC 0 +#define ORB_TARGET_CPU_PPC64 0 +#define ORB_TARGET_CPU_X86 0 +#define ORB_TARGET_CPU_X86_64 0 +#define ORB_TARGET_CPU_ARM 0 +#define ORB_TARGET_CPU_ARM64 0 +#define ORB_TARGET_CPU_MIPS 0 +#define ORB_TARGET_CPU_MIPS64 0 +#define ORB_TARGET_CPU_S390X 1 +#define ORB_TARGET_CPU_WASM32 0 +#elif __wasm32__ +#define ORB_TARGET_CPU_PPC 0 +#define ORB_TARGET_CPU_PPC64 0 +#define ORB_TARGET_CPU_X86 0 +#define ORB_TARGET_CPU_X86_64 0 +#define ORB_TARGET_CPU_ARM 0 +#define ORB_TARGET_CPU_ARM64 0 +#define ORB_TARGET_CPU_MIPS 0 +#define ORB_TARGET_CPU_MIPS64 0 +#define ORB_TARGET_CPU_S390X 0 +#define ORB_TARGET_CPU_WASM32 1 +#else +#error unknown architecture +#endif + +#if __LITTLE_ENDIAN__ +#define ORB_TARGET_RT_LITTLE_ENDIAN 1 +#define ORB_TARGET_RT_BIG_ENDIAN 0 +#elif __BIG_ENDIAN__ +#define ORB_TARGET_RT_LITTLE_ENDIAN 0 +#define ORB_TARGET_RT_BIG_ENDIAN 1 +#else +#error unknown endian +#endif + +#if __LP64__ || __LLP64__ || __POINTER_WIDTH__-0 == 64 +#define ORB_TARGET_RT_64_BIT 1 +#else +#define ORB_TARGET_RT_64_BIT 0 +#endif + +#endif /* __OPENRENDERBOXTARGETCONDITIONALS__ */ diff --git a/Sources/OpenRenderBox/include/OBUUID.h b/Sources/OpenRenderBox/include/OBUUID.h new file mode 100644 index 0000000..f757023 --- /dev/null +++ b/Sources/OpenRenderBox/include/OBUUID.h @@ -0,0 +1,32 @@ +// +// ORBUUID.hpp +// OpenRenderBox + +#ifndef ORBUUID_hpp +#define ORBUUID_hpp + +#include "ORBBase.h" + +#if ORB_TARGET_OS_DARWIN +#include +#endif + +typedef struct ORBUUID { + uint8_t bytes[16]; +} ORBUUID; + +ORB_EXTERN_C_BEGIN + +#if ORB_TARGET_OS_DARWIN +ORB_EXPORT +ORB_REFINED_FOR_SWIFT +ORBUUID ORBUUIDInitFromNSUUID(NSUUID *uuid) ORB_SWIFT_NAME(ORBUUID.init(uuid:)); +#endif + +ORB_EXPORT +ORB_REFINED_FOR_SWIFT +ORBUUID ORBUUIDInitFromHash(uint64_t words0, uint64_t words1, uint32_t words2) ORB_SWIFT_NAME(ORBUUID.init(_:_:_:)); + +ORB_EXTERN_C_END + +#endif /* ORBUUID_hpp */ diff --git a/Sources/OpenRenderBox/include/OBVersion.h b/Sources/OpenRenderBox/include/OBVersion.h new file mode 100644 index 0000000..d9243d5 --- /dev/null +++ b/Sources/OpenRenderBox/include/OBVersion.h @@ -0,0 +1,14 @@ +// +// ORBVersion.h +// OpenRenderBox + +#ifndef ORBVersion_h +#define ORBVersion_h + +#define ORB_RELEASE_2024 2024 + +#ifndef ORB_TARGET_RELEASE +#define ORB_TARGET_RELEASE 2024 +#endif + +#endif /* ORBVersion_h */ diff --git a/Sources/OpenRenderBoxShims/Shims.swift b/Sources/OpenRenderBoxShims/Shims.swift new file mode 100644 index 0000000..6ec6b8a --- /dev/null +++ b/Sources/OpenRenderBoxShims/Shims.swift @@ -0,0 +1,13 @@ +// +// Shims.swift +// OpenRenderBoxShims + +#if OPENRENDERBOX_RENDERBOX +@_exported public import RenderBox +public typealias ORBUUID = RBUUID +public typealias ORBPath = RBPath +public let renderBoxEnabled = true +#else +@_exported import OpenRenderBox +public let renderBoxEnabled = false +#endif diff --git a/Tests/OpenBoxCompatibilityTests/README.md b/Tests/OpenBoxCompatibilityTests/README.md deleted file mode 100644 index e2e04a2..0000000 --- a/Tests/OpenBoxCompatibilityTests/README.md +++ /dev/null @@ -1,3 +0,0 @@ -## OpenBoxCompatibilityTests - -Test public API of OpenBox and run it against with RenderBox on Apple Platform. diff --git a/Tests/OpenBoxTests/README.md b/Tests/OpenBoxTests/README.md deleted file mode 100644 index 994cb75..0000000 --- a/Tests/OpenBoxTests/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## OPENBOXTests - -Test internal API of OPENBOX - -```swift -@testable import OPENBOX -``` diff --git a/Tests/OpenBoxCompatibilityTests/BoxShims.swift b/Tests/OpenRenderBoxCompatibilityTests/BoxShims.swift similarity index 55% rename from Tests/OpenBoxCompatibilityTests/BoxShims.swift rename to Tests/OpenRenderBoxCompatibilityTests/BoxShims.swift index cab5917..c378bdd 100644 --- a/Tests/OpenBoxCompatibilityTests/BoxShims.swift +++ b/Tests/OpenRenderBoxCompatibilityTests/BoxShims.swift @@ -1,12 +1,12 @@ // // BoxShims.swift -// OpenBoxShims +// OpenRenderBoxShims -#if OPENBOX_COMPATIBILITY_TEST +#if OPENRENDERBOX_COMPATIBILITY_TEST @_exported public import RenderBox -public typealias OBUUID = RBUUID +public typealias ORBUUID = RBUUID public let compatibilityTestEnabled = true #else -@_exported import OpenBox +@_exported import OpenRenderBox public let compatibilityTestEnabled = false #endif diff --git a/Tests/OpenRenderBoxCompatibilityTests/README.md b/Tests/OpenRenderBoxCompatibilityTests/README.md new file mode 100644 index 0000000..78e259c --- /dev/null +++ b/Tests/OpenRenderBoxCompatibilityTests/README.md @@ -0,0 +1,3 @@ +## OpenRenderBoxCompatibilityTests + +Test public API of OpenRenderBox and run it against with RenderBox on Apple Platform. diff --git a/Tests/OpenBoxCompatibilityTests/UUIDTests.swift b/Tests/OpenRenderBoxCompatibilityTests/UUIDTests.swift similarity index 94% rename from Tests/OpenBoxCompatibilityTests/UUIDTests.swift rename to Tests/OpenRenderBoxCompatibilityTests/UUIDTests.swift index 34a5cb1..93ae7ee 100644 --- a/Tests/OpenBoxCompatibilityTests/UUIDTests.swift +++ b/Tests/OpenRenderBoxCompatibilityTests/UUIDTests.swift @@ -1,6 +1,6 @@ // // UUIDTests.swift -// OpenBoxCompatibilityTests +// OpenRenderBoxCompatibilityTests import Testing import Foundation @@ -28,7 +28,7 @@ struct UUIDTests { ]) func foundationUUID(uuid: UUID, expectedBytes: [UInt8]) { #if canImport(Darwin) - let id = OBUUID(uuid: uuid) + let id = ORBUUID(uuid: uuid) let bytes = id.bytes #expect(bytes.0 == expectedBytes[0]) #expect(bytes.1 == expectedBytes[1]) @@ -83,7 +83,7 @@ struct UUIDTests { ), ]) func strongHashUUID(words: (UInt32, UInt32, UInt32, UInt32, UInt32), expectedBytes: [UInt8]) { - let id: OBUUID = OBUUID(UInt64(words.0) | UInt64(words.1) &<< 32, UInt64(words.2) | UInt64(words.3) &<< 32, words.4) + let id: ORBUUID = ORBUUID(UInt64(words.0) | UInt64(words.1) &<< 32, UInt64(words.2) | UInt64(words.3) &<< 32, words.4) let bytes = id.bytes #expect(bytes.0 == expectedBytes[0]) #expect(bytes.1 == expectedBytes[1]) diff --git a/Tests/OpenBoxTests/DummyTests.swift b/Tests/OpenRenderBoxTests/DummyTests.swift similarity index 53% rename from Tests/OpenBoxTests/DummyTests.swift rename to Tests/OpenRenderBoxTests/DummyTests.swift index b60ce10..ab9f77e 100644 --- a/Tests/OpenBoxTests/DummyTests.swift +++ b/Tests/OpenRenderBoxTests/DummyTests.swift @@ -1,8 +1,8 @@ // // DummyTests.swift -// OpenBoxTests +// OpenRenderBoxTests -@testable import OpenBox +@testable import OpenRenderBox import Testing struct DummyTests {} diff --git a/Tests/OpenRenderBoxTests/README.md b/Tests/OpenRenderBoxTests/README.md new file mode 100644 index 0000000..c3e9030 --- /dev/null +++ b/Tests/OpenRenderBoxTests/README.md @@ -0,0 +1,7 @@ +## OPENRENDERBOXTests + +Test internal API of OPENRENDERBOX + +```swift +@testable import OPENRENDERBOX +```