chromium/third_party/blink/renderer/platform/bindings/enumeration_base.h

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_BINDINGS_ENUMERATION_BASE_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_BINDINGS_ENUMERATION_BASE_H_

#include <type_traits>

#include "third_party/blink/renderer/platform/platform_export.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "v8/include/v8.h"

namespace blink {

namespace bindings {

class PLATFORM_EXPORT EnumerationBase {};

}  // namespace bindings

template <typename EnumTypeClass>
typename std::enable_if_t<
    std::is_base_of<bindings::EnumerationBase, EnumTypeClass>::value,
    bool>
operator==(const EnumTypeClass& lhs, const EnumTypeClass& rhs) {}

template <typename EnumTypeClass>
typename std::enable_if_t<
    std::is_base_of<bindings::EnumerationBase, EnumTypeClass>::value,
    bool>
operator!=(const EnumTypeClass& lhs, const EnumTypeClass& rhs) {}

template <typename EnumTypeClass>
typename std::enable_if_t<
    std::is_base_of<bindings::EnumerationBase, EnumTypeClass>::value,
    bool>
operator==(const EnumTypeClass& lhs, typename EnumTypeClass::Enum rhs) {}

template <typename EnumTypeClass>
typename std::enable_if_t<
    std::is_base_of<bindings::EnumerationBase, EnumTypeClass>::value,
    bool>
operator==(typename EnumTypeClass::Enum lhs, const EnumTypeClass& rhs) {}

template <typename EnumTypeClass>
typename std::enable_if_t<
    std::is_base_of<bindings::EnumerationBase, EnumTypeClass>::value,
    bool>
operator!=(const EnumTypeClass& lhs, typename EnumTypeClass::Enum rhs) {}

template <typename EnumTypeClass>
typename std::enable_if_t<
    std::is_base_of<bindings::EnumerationBase, EnumTypeClass>::value,
    bool>
operator!=(typename EnumTypeClass::Enum lhs, const EnumTypeClass& rhs) {}

// Migration adapters
template <typename EnumTypeClass>
typename std::enable_if_t<
    std::is_base_of<bindings::EnumerationBase, EnumTypeClass>::value,
    bool>
operator==(const EnumTypeClass& lhs, const String& rhs) {}

template <typename EnumTypeClass>
typename std::enable_if_t<
    std::is_base_of<bindings::EnumerationBase, EnumTypeClass>::value,
    bool>
operator!=(const EnumTypeClass& lhs, const String& rhs) {}

template <typename EnumTypeClass>
typename std::enable_if_t<
    std::is_base_of<bindings::EnumerationBase, EnumTypeClass>::value,
    bool>
operator==(const EnumTypeClass& lhs, const AtomicString& rhs) {}

template <typename EnumTypeClass>
typename std::enable_if_t<
    std::is_base_of<bindings::EnumerationBase, EnumTypeClass>::value,
    bool>
operator==(const EnumTypeClass& lhs, const char* rhs) {}

template <typename EnumTypeClass>
typename std::enable_if_t<
    std::is_base_of<bindings::EnumerationBase, EnumTypeClass>::value,
    bool>
operator==(const char* lhs, const EnumTypeClass& rhs) {}

// TODO(crbug.com/1092328): IDLEnumAsString is an adapter between the old and
// new bindings generators.  The old bindings generator implements IDL
// enumeration with String class, however, the new bindings generator implements
// it with subclasses of EnumerationBase.  IDLEnumAsString resolves this
// difference.
inline const String& IDLEnumAsString(const String& value) {}

inline String IDLEnumAsString(const bindings::EnumerationBase& value) {}

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_BINDINGS_ENUMERATION_BASE_H_