From c35c796cc8dbe86b76f84d8917ad22fec5fa2c14 Mon Sep 17 00:00:00 2001 From: Kyle Date: Mon, 30 Dec 2024 02:41:00 +0800 Subject: [PATCH] Update OGVersion --- Package.resolved | 4 +- Package.swift | 2 +- Sources/OpenGraph/Export.swift | 7 ++++ Sources/OpenGraph_SPI/OGBase.h | 12 +++--- Sources/OpenGraph_SPI/OGVersion.h | 17 -------- Sources/OpenGraph_SPI/Runtime/OGTypeID.cpp | 2 +- Sources/OpenGraph_SPI/Runtime/OGTypeID.h | 3 +- Sources/OpenGraph_SPI/Version/OGVersion.c | 16 ++++++++ Sources/OpenGraph_SPI/Version/OGVersion.h | 23 +++++++++++ Sources/OpenGraph_SPI/include/OGVersion.h | 2 +- .../include/OpenGraph-umbrella.h | 13 ++----- .../VersionTests.swift | 39 +++++++++++++++++++ 12 files changed, 100 insertions(+), 40 deletions(-) delete mode 100644 Sources/OpenGraph_SPI/OGVersion.h create mode 100644 Sources/OpenGraph_SPI/Version/OGVersion.c create mode 100644 Sources/OpenGraph_SPI/Version/OGVersion.h create mode 100644 Tests/OpenGraphCompatibilityTests/VersionTests.swift diff --git a/Package.resolved b/Package.resolved index 58a8ff3e..cf245961 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "e34af969d8f4a303070ee7bea78ad5d898a415892447c83e19cdc16c141e6722", + "originHash" : "541a191769e45d8d8acb1b48a687231b967da208924053878dcedf8652ae1c99", "pins" : [ { "identity" : "darwinprivateframeworks", @@ -7,7 +7,7 @@ "location" : "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks.git", "state" : { "branch" : "main", - "revision" : "e7a96d8a5bc76c3e7e9713e084a1ffd5271e933b" + "revision" : "97476edc16f5f635fa275150012bc2facc942794" } }, { diff --git a/Package.swift b/Package.swift index e2e8ee24..09e238e9 100644 --- a/Package.swift +++ b/Package.swift @@ -138,7 +138,7 @@ let openGraphTestTarget = Target.testTarget( let openGraphCompatibilityTestTarget = Target.testTarget( name: "OpenGraphCompatibilityTests", dependencies: [ - .product(name: "RealModule", package: "swift-numerics"), + .product(name: "Numerics", package: "swift-numerics"), ], exclude: ["README.md"], cSettings: sharedCSettings, diff --git a/Sources/OpenGraph/Export.swift b/Sources/OpenGraph/Export.swift index 59b6a311..3c7bc4bf 100644 --- a/Sources/OpenGraph/Export.swift +++ b/Sources/OpenGraph/Export.swift @@ -1 +1,8 @@ @_exported public import OpenGraph_SPI + +// Align the constant define behavior +#if OPENGRAPH_RELEASE_2024 +public let OPENGRAPH_RELEASE: Int32 = 2024 +#elseif OPENGRAPH_RELEASE_2021 +public let OPENGRAPH_RELEASE: Int32 = 2021 +#endif diff --git a/Sources/OpenGraph_SPI/OGBase.h b/Sources/OpenGraph_SPI/OGBase.h index 12bda6a6..2d53aaa4 100644 --- a/Sources/OpenGraph_SPI/OGBase.h +++ b/Sources/OpenGraph_SPI/OGBase.h @@ -5,8 +5,6 @@ #ifndef OGBase_h #define OGBase_h -#include "OGVersion.h" - #if DEBUG #define OG_ASSERTION #else @@ -14,13 +12,13 @@ #endif #if __has_attribute(cold) -#define __cold __attribute__((__cold__)) +#define __cold __attribute__((__cold__)) #else #define __cold #endif #if __has_attribute(noreturn) -#define __dead2 __attribute__((__noreturn__)) +#define __dead2 __attribute__((__noreturn__)) #else #define __dead2 #endif @@ -45,11 +43,11 @@ #define OG_CONSTEXPR #endif +#include "OGSwiftSupport.h" +#include "OGTargetConditionals.h" #include -#include #include -#include "OGTargetConditionals.h" -#include "OGSwiftSupport.h" +#include #define OG_ENUM CF_ENUM #define OG_OPTIONS CF_OPTIONS diff --git a/Sources/OpenGraph_SPI/OGVersion.h b/Sources/OpenGraph_SPI/OGVersion.h deleted file mode 100644 index b074c9b4..00000000 --- a/Sources/OpenGraph_SPI/OGVersion.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// OGVersion.h -// OpenGraph - -#ifndef OGVersion_h -#define OGVersion_h - -#define OG_RELEASE_2021 2021 -#define OG_RELEASE_2022 2022 -#define OG_RELEASE_2023 2023 -#define OG_RELEASE_2024 2024 - -#ifndef OG_TARGET_RELEASE -#define OG_TARGET_RELEASE 2024 -#endif - -#endif /* OGVersion_h */ diff --git a/Sources/OpenGraph_SPI/Runtime/OGTypeID.cpp b/Sources/OpenGraph_SPI/Runtime/OGTypeID.cpp index 0d7e7481..7ff0dcac 100644 --- a/Sources/OpenGraph_SPI/Runtime/OGTypeID.cpp +++ b/Sources/OpenGraph_SPI/Runtime/OGTypeID.cpp @@ -40,7 +40,7 @@ OGTypeKind OGTypeGetKind(OGTypeID typeID) { #endif } -#if OPENGRAPH_RELEASE >= 2024 +#if OPENGRAPH_RELEASE >= OPENGRAPH_RELEASE_2024 void const* OGTypeGetSignature(OGTypeID typeID) { #ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED diff --git a/Sources/OpenGraph_SPI/Runtime/OGTypeID.h b/Sources/OpenGraph_SPI/Runtime/OGTypeID.h index f3f47c7d..908812b2 100644 --- a/Sources/OpenGraph_SPI/Runtime/OGTypeID.h +++ b/Sources/OpenGraph_SPI/Runtime/OGTypeID.h @@ -9,6 +9,7 @@ #define OGTypeID_h #include "OGBase.h" +#include "OGVersion.h" OG_ASSUME_NONNULL_BEGIN @@ -35,7 +36,7 @@ OG_EXPORT OG_REFINED_FOR_SWIFT OGTypeKind OGTypeGetKind(OGTypeID typeID) OG_SWIFT_NAME(getter:Metadata.kind(self:)); -#if OPENGRAPH_RELEASE >= 2024 +#if OPENGRAPH_RELEASE >= OPENGRAPH_RELEASE_2024 OG_EXPORT OG_REFINED_FOR_SWIFT diff --git a/Sources/OpenGraph_SPI/Version/OGVersion.c b/Sources/OpenGraph_SPI/Version/OGVersion.c new file mode 100644 index 00000000..42e3d8de --- /dev/null +++ b/Sources/OpenGraph_SPI/Version/OGVersion.c @@ -0,0 +1,16 @@ +// +// OGVersion.c +// OpenGraph + +#include "OGBase.h" +#include "OGVersion.h" + +#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/OpenGraph_SPI/Version/OGVersion.h b/Sources/OpenGraph_SPI/Version/OGVersion.h new file mode 100644 index 00000000..76745007 --- /dev/null +++ b/Sources/OpenGraph_SPI/Version/OGVersion.h @@ -0,0 +1,23 @@ +// +// OGVersion.h +// OpenGraph + +#ifndef OGVersion_h +#define OGVersion_h + +#include "OGBase.h" + +#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/OpenGraph_SPI/include/OGVersion.h b/Sources/OpenGraph_SPI/include/OGVersion.h index 8ef4f886..94624a22 120000 --- a/Sources/OpenGraph_SPI/include/OGVersion.h +++ b/Sources/OpenGraph_SPI/include/OGVersion.h @@ -1 +1 @@ -../OGVersion.h \ No newline at end of file +../Version/OGVersion.h \ No newline at end of file diff --git a/Sources/OpenGraph_SPI/include/OpenGraph-umbrella.h b/Sources/OpenGraph_SPI/include/OpenGraph-umbrella.h index cfc452b1..4adf653c 100644 --- a/Sources/OpenGraph_SPI/include/OpenGraph-umbrella.h +++ b/Sources/OpenGraph_SPI/include/OpenGraph-umbrella.h @@ -1,11 +1,3 @@ -#ifndef FOUNDATION_EXPORT -#if defined(__cplusplus) -#define FOUNDATION_EXPORT extern "C" -#else -#define FOUNDATION_EXPORT extern -#endif -#endif - #include "OGAttribute.h" #include "OGAttributeFlags.h" #include "OGAttributeInfo.h" @@ -32,7 +24,8 @@ #include "OGValue.h" #include "OGValueOptions.h" #include "OGValueState.h" +#include "OGVersion.h" #include "OGWeakAttribute.h" -FOUNDATION_EXPORT double AGAttributeVersionNumber; -FOUNDATION_EXPORT const unsigned char AGAttributeVersionString[]; +OG_EXPORT double OpenGraphVersionNumber; +OG_EXPORT const unsigned char OpenGraphVersionString[]; diff --git a/Tests/OpenGraphCompatibilityTests/VersionTests.swift b/Tests/OpenGraphCompatibilityTests/VersionTests.swift new file mode 100644 index 00000000..b06e5020 --- /dev/null +++ b/Tests/OpenGraphCompatibilityTests/VersionTests.swift @@ -0,0 +1,39 @@ +// +// VersionTests.swift +// OpenGraphCompatibilityTests + +import Testing +import Numerics + +struct VersionTests { + @Test + func versionNumber() async { + await confirmation { confirm in + #if OPENGRAPH_COMPATIBILITY_TEST + switch Int32(ATTRIBUTEGRAPH_RELEASE) { + case ATTRIBUTEGRAPH_RELEASE_2021: + #expect(AGVersion == 0x20014) + confirm() + case ATTRIBUTEGRAPH_RELEASE_2024: + #expect(AGVersion == 0x2001e) + confirm() + default: + break + } + #else + switch Int32(OPENGRAPH_RELEASE) { + case OPENGRAPH_RELEASE_2021: + #expect(OpenGraphVersionNumber.isApproximatelyEqual(to: 3.2)) + #expect(OGVersion == 0x20014) + confirm() + case OPENGRAPH_RELEASE_2024: + #expect(OpenGraphVersionNumber.isApproximatelyEqual(to: 6.0)) + #expect(OGVersion == 0x2001e) + confirm() + default: + break + } + #endif + } + } +}