Skip to content

Update OGVersion #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
}
}
}