Skip to content

Commit

Permalink
Update OGVersion (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye authored Dec 30, 2024
1 parent 86fb886 commit cc85388
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 40 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"originHash" : "e34af969d8f4a303070ee7bea78ad5d898a415892447c83e19cdc16c141e6722",
"originHash" : "541a191769e45d8d8acb1b48a687231b967da208924053878dcedf8652ae1c99",
"pins" : [
{
"identity" : "darwinprivateframeworks",
"kind" : "remoteSourceControl",
"location" : "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks.git",
"state" : {
"branch" : "main",
"revision" : "e7a96d8a5bc76c3e7e9713e084a1ffd5271e933b"
"revision" : "97476edc16f5f635fa275150012bc2facc942794"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions Sources/OpenGraph/Export.swift
Original file line number Diff line number Diff line change
@@ -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
12 changes: 5 additions & 7 deletions Sources/OpenGraph_SPI/OGBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@
#ifndef OGBase_h
#define OGBase_h

#include "OGVersion.h"

#if DEBUG
#define OG_ASSERTION
#else
#undef OG_ASSERTION
#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
Expand All @@ -45,11 +43,11 @@
#define OG_CONSTEXPR
#endif

#include "OGSwiftSupport.h"
#include "OGTargetConditionals.h"
#include <CoreFoundation/CoreFoundation.h>
#include <stdint.h>
#include <stdbool.h>
#include "OGTargetConditionals.h"
#include "OGSwiftSupport.h"
#include <stdint.h>

#define OG_ENUM CF_ENUM
#define OG_OPTIONS CF_OPTIONS
Expand Down
17 changes: 0 additions & 17 deletions Sources/OpenGraph_SPI/OGVersion.h

This file was deleted.

2 changes: 1 addition & 1 deletion Sources/OpenGraph_SPI/Runtime/OGTypeID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion Sources/OpenGraph_SPI/Runtime/OGTypeID.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define OGTypeID_h

#include "OGBase.h"
#include "OGVersion.h"

OG_ASSUME_NONNULL_BEGIN

Expand All @@ -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
Expand Down
16 changes: 16 additions & 0 deletions Sources/OpenGraph_SPI/Version/OGVersion.c
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions Sources/OpenGraph_SPI/Version/OGVersion.h
Original file line number Diff line number Diff line change
@@ -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 */
2 changes: 1 addition & 1 deletion Sources/OpenGraph_SPI/include/OGVersion.h
13 changes: 3 additions & 10 deletions Sources/OpenGraph_SPI/include/OpenGraph-umbrella.h
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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[];
39 changes: 39 additions & 0 deletions Tests/OpenGraphCompatibilityTests/VersionTests.swift
Original file line number Diff line number Diff line change
@@ -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
}
}
}

0 comments on commit cc85388

Please sign in to comment.