Skip to content

Commit

Permalink
tools: update inspector_protocol to 2f51e05
Browse files Browse the repository at this point in the history
PR-URL: #51293
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
cola119 authored and richardlau committed Mar 25, 2024
1 parent 6b85f5c commit 6863fb8
Showing 1 changed file with 7 additions and 47 deletions.
54 changes: 7 additions & 47 deletions tools/inspector_protocol/lib/Maybe_h.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,6 @@
#ifndef {{"_".join(config.protocol.namespace)}}_Maybe_h
#define {{"_".join(config.protocol.namespace)}}_Maybe_h

// This macro allows to test for the version of the GNU C++ compiler.
// Note that this also applies to compilers that masquerade as GCC,
// for example clang and the Intel C++ compiler for Linux.
// Use like:
// #if IP_GNUC_PREREQ(4, 3, 1)
// ...
// #endif
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
#define IP_GNUC_PREREQ(major, minor, patchlevel) \
((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= \
((major)*10000 + (minor)*100 + (patchlevel)))
#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
#define IP_GNUC_PREREQ(major, minor, patchlevel) \
((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= \
((major)*10000 + (minor)*100 + (patchlevel)))
#else
#define IP_GNUC_PREREQ(major, minor, patchlevel) 0
#endif

#if defined(__mips64)
#define IP_TARGET_ARCH_MIPS64 1
#elif defined(__MIPSEB__) || defined(__MIPSEL__)
#define IP_TARGET_ARCH_MIPS 1
#endif

// Allowing the use of noexcept by removing the keyword on older compilers that
// do not support adding noexcept to default members.
#if ((IP_GNUC_PREREQ(4, 9, 0) && !defined(IP_TARGET_ARCH_MIPS) && \
!defined(IP_TARGET_ARCH_MIPS64)) || \
(defined(__clang__) && __cplusplus > 201300L))
#define IP_NOEXCEPT noexcept
#else
#define IP_NOEXCEPT
#endif

//#include "Forward.h"

{% for namespace in config.protocol.namespace %}
Expand All @@ -53,7 +18,7 @@ class Maybe {
public:
Maybe() : m_value() { }
Maybe(std::unique_ptr<T> value) : m_value(std::move(value)) { }
Maybe(Maybe&& other) IP_NOEXCEPT : m_value(std::move(other.m_value)) {}
Maybe(Maybe&& other) noexcept : m_value(std::move(other.m_value)) {}
void operator=(std::unique_ptr<T> value) { m_value = std::move(value); }
T* fromJust() const { DCHECK(m_value); return m_value.get(); }
T* fromMaybe(T* defaultValue) const { return m_value ? m_value.get() : defaultValue; }
Expand All @@ -68,7 +33,7 @@ class MaybeBase {
public:
MaybeBase() : m_isJust(false) { }
MaybeBase(T value) : m_isJust(true), m_value(value) { }
MaybeBase(MaybeBase&& other) IP_NOEXCEPT
MaybeBase(MaybeBase&& other) noexcept
: m_isJust(other.m_isJust),
m_value(std::move(other.m_value)) {}
void operator=(T value) { m_value = value; m_isJust = true; }
Expand All @@ -87,7 +52,7 @@ class Maybe<bool> : public MaybeBase<bool> {
public:
Maybe() { m_value = false; }
Maybe(bool value) : MaybeBase(value) { }
Maybe(Maybe&& other) IP_NOEXCEPT : MaybeBase(std::move(other)) {}
Maybe(Maybe&& other) noexcept : MaybeBase(std::move(other)) {}
using MaybeBase::operator=;
};

Expand All @@ -96,7 +61,7 @@ class Maybe<int> : public MaybeBase<int> {
public:
Maybe() { m_value = 0; }
Maybe(int value) : MaybeBase(value) { }
Maybe(Maybe&& other) IP_NOEXCEPT : MaybeBase(std::move(other)) {}
Maybe(Maybe&& other) noexcept : MaybeBase(std::move(other)) {}
using MaybeBase::operator=;
};

Expand All @@ -105,7 +70,7 @@ class Maybe<double> : public MaybeBase<double> {
public:
Maybe() { m_value = 0; }
Maybe(double value) : MaybeBase(value) { }
Maybe(Maybe&& other) IP_NOEXCEPT : MaybeBase(std::move(other)) {}
Maybe(Maybe&& other) noexcept : MaybeBase(std::move(other)) {}
using MaybeBase::operator=;
};

Expand All @@ -114,7 +79,7 @@ class Maybe<String> : public MaybeBase<String> {
public:
Maybe() { }
Maybe(const String& value) : MaybeBase(value) { }
Maybe(Maybe&& other) IP_NOEXCEPT : MaybeBase(std::move(other)) {}
Maybe(Maybe&& other) noexcept : MaybeBase(std::move(other)) {}
using MaybeBase::operator=;
};

Expand All @@ -123,17 +88,12 @@ class Maybe<Binary> : public MaybeBase<Binary> {
public:
Maybe() { }
Maybe(Binary value) : MaybeBase(value) { }
Maybe(Maybe&& other) IP_NOEXCEPT : MaybeBase(std::move(other)) {}
Maybe(Maybe&& other) noexcept : MaybeBase(std::move(other)) {}
using MaybeBase::operator=;
};

{% for namespace in config.protocol.namespace %}
} // namespace {{namespace}}
{% endfor %}

#undef IP_GNUC_PREREQ
#undef IP_TARGET_ARCH_MIPS64
#undef IP_TARGET_ARCH_MIPS
#undef IP_NOEXCEPT

#endif // !defined({{"_".join(config.protocol.namespace)}}_Maybe_h)

0 comments on commit 6863fb8

Please sign in to comment.