//===--- KnownProtocols.def - Compiler protocol metaprogramming -*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// This file defines macros used for macro-metaprogramming with compiler-known
// protocols.
//
//===----------------------------------------------------------------------===//


/// \def PROTOCOL_WITH_NAME(Id, Name)
///
/// The enumerator value is \c KnownProtocolKind::Id. The protocol represented
/// is simply named \p Name.
#ifndef PROTOCOL_WITH_NAME
#define PROTOCOL_WITH_NAME(Id, Name)
#endif

/// \def LITERAL_CONVERTIBLE_PROTOCOL_WITH_NAME(Id, Name)
#ifndef LITERAL_CONVERTIBLE_PROTOCOL_WITH_NAME
#define LITERAL_CONVERTIBLE_PROTOCOL_WITH_NAME(Id, Name) \
    PROTOCOL_WITH_NAME(Id, Name)
#endif

/// \def BUILTIN_LITERAL_CONVERTIBLE_PROTOCOL_WITH_NAME(Id, Name)
///
/// Note that this is not a special form of LITERAL_CONVERTIBLE_PROTOCOL.
#ifndef BUILTIN_LITERAL_CONVERTIBLE_PROTOCOL_WITH_NAME
#define BUILTIN_LITERAL_CONVERTIBLE_PROTOCOL_WITH_NAME(Id, Name) \
    PROTOCOL_WITH_NAME(Id, Name)
#endif


#define PROTOCOL(name) PROTOCOL_WITH_NAME(name, #name)
#define PROTOCOL_(name) PROTOCOL_WITH_NAME(name, "_" #name)
#define LITERAL_CONVERTIBLE_PROTOCOL(name) \
    LITERAL_CONVERTIBLE_PROTOCOL_WITH_NAME(name, #name)
#define LITERAL_CONVERTIBLE_PROTOCOL_(name) \
    LITERAL_CONVERTIBLE_PROTOCOL_WITH_NAME(name, "_" #name)
#define BUILTIN_LITERAL_CONVERTIBLE_PROTOCOL_(name) \
    BUILTIN_LITERAL_CONVERTIBLE_PROTOCOL_WITH_NAME(name, "_" #name)

PROTOCOL(Sequence)
PROTOCOL(IteratorProtocol)
PROTOCOL(Boolean)
PROTOCOL(AnyObject)
PROTOCOL(RawRepresentable)
PROTOCOL(Equatable)
PROTOCOL(Hashable)
PROTOCOL(Comparable)
PROTOCOL(ErrorProtocol)
PROTOCOL(OptionSet)
PROTOCOL_(BridgedNSError)

PROTOCOL_(ObjectiveCBridgeable)
PROTOCOL_(DestructorSafeContainer)

LITERAL_CONVERTIBLE_PROTOCOL(ArrayLiteralConvertible)
LITERAL_CONVERTIBLE_PROTOCOL(BooleanLiteralConvertible)
LITERAL_CONVERTIBLE_PROTOCOL(DictionaryLiteralConvertible)
LITERAL_CONVERTIBLE_PROTOCOL(ExtendedGraphemeClusterLiteralConvertible)
LITERAL_CONVERTIBLE_PROTOCOL(FloatLiteralConvertible)
LITERAL_CONVERTIBLE_PROTOCOL(IntegerLiteralConvertible)
LITERAL_CONVERTIBLE_PROTOCOL(StringInterpolationConvertible)
LITERAL_CONVERTIBLE_PROTOCOL(StringLiteralConvertible)
LITERAL_CONVERTIBLE_PROTOCOL(NilLiteralConvertible)
LITERAL_CONVERTIBLE_PROTOCOL(UnicodeScalarLiteralConvertible)

LITERAL_CONVERTIBLE_PROTOCOL_(ColorLiteralConvertible)
LITERAL_CONVERTIBLE_PROTOCOL_(ImageLiteralConvertible)
LITERAL_CONVERTIBLE_PROTOCOL_(FileReferenceLiteralConvertible)

BUILTIN_LITERAL_CONVERTIBLE_PROTOCOL_(BuiltinBooleanLiteralConvertible)
BUILTIN_LITERAL_CONVERTIBLE_PROTOCOL_(BuiltinExtendedGraphemeClusterLiteralConvertible)
BUILTIN_LITERAL_CONVERTIBLE_PROTOCOL_(BuiltinFloatLiteralConvertible)
BUILTIN_LITERAL_CONVERTIBLE_PROTOCOL_(BuiltinIntegerLiteralConvertible)
BUILTIN_LITERAL_CONVERTIBLE_PROTOCOL_(BuiltinStringLiteralConvertible)
BUILTIN_LITERAL_CONVERTIBLE_PROTOCOL_(BuiltinUTF16StringLiteralConvertible)
BUILTIN_LITERAL_CONVERTIBLE_PROTOCOL_(BuiltinUnicodeScalarLiteralConvertible)

#undef LITERAL_CONVERTIBLE_PROTOCOL
#undef LITERAL_CONVERTIBLE_PROTOCOL_
#undef LITERAL_CONVERTIBLE_PROTOCOL_WITH_NAME
#undef BUILTIN_LITERAL_CONVERTIBLE_PROTOCOL_
#undef BUILTIN_LITERAL_CONVERTIBLE_PROTOCOL_WITH_NAME
#undef PROTOCOL
#undef PROTOCOL_
#undef PROTOCOL_WITH_NAME
