Skip to content

Commit

Permalink
Fix compareValues implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Apr 21, 2024
1 parent 315468c commit ef5e8c1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

#include "AGBase.h"
#include "AGComparisonMode.h"
#include <stdbool.h>

AG_EXTERN_C_BEGIN
AG_EXPORT
AG_REFINED_FOR_SWIFT
bool AGCompareValues(const void *lhs, const void *rhs, const AGComparisonMode comparisonMode, const void *type);
bool AGCompareValues(const void *lhs, const void *rhs, const void *type, const AGComparisonMode comparisonMode);
AG_EXTERN_C_END

#endif /* AGCompareValues_h */
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

#include "AGBase.h"
#include "AGComparisonMode.h"
#include <stdbool.h>

AG_EXTERN_C_BEGIN
AG_EXPORT
AG_REFINED_FOR_SWIFT
bool AGCompareValues(const void *lhs, const void *rhs, const AGComparisonMode comparisonMode, const void *type);
bool AGCompareValues(const void *lhs, const void *rhs, const void *type, const AGComparisonMode comparisonMode);
AG_EXTERN_C_END

#endif /* AGCompareValues_h */
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

#include "AGBase.h"
#include "AGComparisonMode.h"
#include <stdbool.h>

AG_EXTERN_C_BEGIN
AG_EXPORT
AG_REFINED_FOR_SWIFT
bool AGCompareValues(const void *lhs, const void *rhs, const AGComparisonMode comparisonMode, const void *type);
bool AGCompareValues(const void *lhs, const void *rhs, const void *type, const AGComparisonMode comparisonMode);
AG_EXTERN_C_END

#endif /* AGCompareValues_h */
3 changes: 1 addition & 2 deletions AG/Sources/Headers/AGCompareValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

#include "AGBase.h"
#include "AGComparisonMode.h"
#include <stdbool.h>

AG_EXTERN_C_BEGIN
AG_EXPORT
AG_REFINED_FOR_SWIFT
bool AGCompareValues(const void *lhs, const void *rhs, const AGComparisonMode comparisonMode, const void *type);
bool AGCompareValues(const void *lhs, const void *rhs, const void *type, const AGComparisonMode comparisonMode);
AG_EXTERN_C_END

#endif /* AGCompareValues_h */
16 changes: 8 additions & 8 deletions Sources/OpenGraph/Runtime/CompareValues.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@
import _OpenGraph

@_silgen_name("OGCompareValues")
@inlinable
@inline(__always)
func OGCompareValues(lhs: UnsafeRawPointer,
rhs: UnsafeRawPointer,
options: OGComparisonOptions,
type: Any.Type) -> Bool
private func OGCompareValues(
lhs: UnsafeRawPointer,
rhs: UnsafeRawPointer,
type: Any.Type,
options: OGComparisonOptions
) -> Bool

public func compareValues<Value>(_ lhs: Value, _ rhs: Value, mode: OGComparisonMode = ._3) -> Bool {
withUnsafePointer(to: lhs) { p1 in
withUnsafePointer(to: rhs) { p2 in
OGCompareValues(lhs: p1, rhs: p2, options: .init(mode: mode), type: Value.self)
OGCompareValues(lhs: p1, rhs: p2, type: Value.self, options: .init(mode: mode))
}
}
}

public func compareValues<Value>(_ lhs: Value, _ rhs: Value, options: OGComparisonOptions) -> Bool {
withUnsafePointer(to: lhs) { p1 in
withUnsafePointer(to: rhs) { p2 in
OGCompareValues(lhs: p1, rhs: p2, options: options, type: Value.self)
OGCompareValues(lhs: p1, rhs: p2, type: Value.self, options: options)
}
}
}
Expand Down

0 comments on commit ef5e8c1

Please sign in to comment.