mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
runtime: make _SwiftNativeNSError use the Hashable conformance, if available
If the Swift error wrapped in a _SwiftNativeNSError box conforms to Hashable, the box now uses the Swift's conformance to Hashable. Part of rdar://problem/27574348.
This commit is contained in:
53
stdlib/public/runtime/SwiftHashableSupport.h
Normal file
53
stdlib/public/runtime/SwiftHashableSupport.h
Normal file
@@ -0,0 +1,53 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2014 - 2016 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SWIFT_RUNTIME_SWIFT_HASHABLE_SUPPORT_H
|
||||
#define SWIFT_RUNTIME_SWIFT_HASHABLE_SUPPORT_H
|
||||
|
||||
#include "swift/Runtime/Metadata.h"
|
||||
#include <stdint.h>
|
||||
|
||||
namespace swift {
|
||||
namespace hashable_support {
|
||||
|
||||
/// The name demangles to "protocol descriptor for Swift.Hashable".
|
||||
extern "C" const ProtocolDescriptor _TMps8Hashable;
|
||||
|
||||
struct HashableWitnessTable;
|
||||
|
||||
/// Calls `Equatable.==` through a `Hashable` (not Equatable!) witness
|
||||
/// table.
|
||||
extern "C" bool swift_stdlib_Hashable_isEqual_indirect(
|
||||
const void *lhsValue, const void *rhsValue, const Metadata *type,
|
||||
const HashableWitnessTable *wt);
|
||||
|
||||
/// Calls `Hashable.hashValue.get` through a `Hashable` witness table.
|
||||
extern "C" intptr_t swift_stdlib_Hashable_hashValue_indirect(
|
||||
const void *value, const Metadata *type, const HashableWitnessTable *wt);
|
||||
|
||||
/// Find the base type that introduces the `Hashable` conformance.
|
||||
/// Because the provided type is known to conform to `Hashable`, this
|
||||
/// function always returns non-null.
|
||||
///
|
||||
/// - Precondition: `type` conforms to `Hashable` (not checked).
|
||||
const Metadata *findHashableBaseTypeOfHashableType(
|
||||
const Metadata *type);
|
||||
|
||||
/// Find the base type that introduces the `Hashable` conformance.
|
||||
/// If `type` does not conform to `Hashable`, `nullptr` is returned.
|
||||
const Metadata *findHashableBaseType(const Metadata *type);
|
||||
|
||||
} // namespace hashable_support
|
||||
} // namespace swift
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user