2016-11-13 19:28:36 +00:00
|
|
|
/*
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
* Copyright (C) 2016-2017 Apple Inc. All rights reserved.
|
2016-11-13 19:28:36 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
|
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
// Implementation of Library Fundamentals v3's std::expected, as described here: http://wg21.link/p0323r4
|
2016-11-13 19:28:36 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
/*
|
|
|
|
expected synopsis
|
|
|
|
|
|
|
|
namespace std {
|
|
|
|
namespace experimental {
|
|
|
|
inline namespace fundamentals_v3 {
|
|
|
|
// ?.?.4, Expected for object types
|
|
|
|
template <class T, class E>
|
|
|
|
class expected;
|
|
|
|
|
|
|
|
// ?.?.5, Expected specialization for void
|
|
|
|
template <class E>
|
|
|
|
class expected<void,E>;
|
|
|
|
|
|
|
|
// ?.?.6, unexpect tag
|
|
|
|
struct unexpect_t {
|
|
|
|
unexpect_t() = default;
|
|
|
|
};
|
|
|
|
inline constexpr unexpect_t unexpect{};
|
|
|
|
|
|
|
|
// ?.?.7, class bad_expected_access
|
|
|
|
template <class E>
|
|
|
|
class bad_expected_access;
|
|
|
|
|
|
|
|
// ?.?.8, Specialization for void.
|
|
|
|
template <>
|
|
|
|
class bad_expected_access<void>;
|
|
|
|
|
|
|
|
// ?.?.9, Expected relational operators
|
|
|
|
template <class T, class E>
|
|
|
|
constexpr bool operator==(const expected<T, E>&, const expected<T, E>&);
|
|
|
|
template <class T, class E>
|
|
|
|
constexpr bool operator!=(const expected<T, E>&, const expected<T, E>&);
|
|
|
|
|
|
|
|
// ?.?.10, Comparison with T
|
|
|
|
template <class T, class E>
|
|
|
|
constexpr bool operator==(const expected<T, E>&, const T&);
|
|
|
|
template <class T, class E>
|
|
|
|
constexpr bool operator==(const T&, const expected<T, E>&);
|
|
|
|
template <class T, class E>
|
|
|
|
constexpr bool operator!=(const expected<T, E>&, const T&);
|
|
|
|
template <class T, class E>
|
|
|
|
constexpr bool operator!=(const T&, const expected<T, E>&);
|
|
|
|
|
|
|
|
// ?.?.10, Comparison with unexpected<E>
|
|
|
|
template <class T, class E>
|
|
|
|
constexpr bool operator==(const expected<T, E>&, const unexpected<E>&);
|
|
|
|
template <class T, class E>
|
|
|
|
constexpr bool operator==(const unexpected<E>&, const expected<T, E>&);
|
|
|
|
template <class T, class E>
|
|
|
|
constexpr bool operator!=(const expected<T, E>&, const unexpected<E>&);
|
|
|
|
template <class T, class E>
|
|
|
|
constexpr bool operator!=(const unexpected<E>&, const expected<T, E>&);
|
|
|
|
|
|
|
|
// ?.?.11, Specialized algorithms
|
|
|
|
void swap(expected<T, E>&, expected<T, E>&) noexcept(see below);
|
|
|
|
|
|
|
|
template <class T, class E>
|
|
|
|
class expected
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef T value_type;
|
|
|
|
typedef E error_type;
|
|
|
|
typedef unexpected<E> unexpected_type;
|
|
|
|
|
|
|
|
template <class U>
|
|
|
|
struct rebind {
|
|
|
|
using type = expected<U, error_type>;
|
|
|
|
};
|
|
|
|
|
|
|
|
// ?.?.4.1, constructors
|
|
|
|
constexpr expected();
|
|
|
|
constexpr expected(const expected&);
|
|
|
|
constexpr expected(expected&&) noexcept(see below);
|
|
|
|
template <class U, class G>
|
|
|
|
EXPLICIT constexpr expected(const expected<U, G>&);
|
|
|
|
template <class U, class G>
|
|
|
|
EXPLICIT constexpr expected(expected<U, G>&&);
|
|
|
|
|
|
|
|
template <class U = T>
|
|
|
|
EXPLICIT constexpr expected(U&& v);
|
|
|
|
|
|
|
|
template <class... Args>
|
|
|
|
constexpr explicit expected(in_place_t, Args&&...);
|
|
|
|
template <class U, class... Args>
|
|
|
|
constexpr explicit expected(in_place_t, initializer_list<U>, Args&&...);
|
|
|
|
template <class G = E>
|
|
|
|
constexpr expected(unexpected<G> const&);
|
|
|
|
template <class G = E>
|
|
|
|
constexpr expected(unexpected<G> &&);
|
|
|
|
template <class... Args>
|
|
|
|
constexpr explicit expected(unexpect_t, Args&&...);
|
|
|
|
template <class U, class... Args>
|
|
|
|
constexpr explicit expected(unexpect_t, initializer_list<U>, Args&&...);
|
|
|
|
|
|
|
|
// ?.?.4.2, destructor
|
|
|
|
~expected();
|
|
|
|
|
|
|
|
// ?.?.4.3, assignment
|
|
|
|
expected& operator=(const expected&);
|
|
|
|
expected& operator=(expected&&) noexcept(see below);
|
|
|
|
template <class U = T> expected& operator=(U&&);
|
|
|
|
template <class G = E>
|
|
|
|
expected& operator=(const unexpected<G>&);
|
|
|
|
template <class G = E>
|
|
|
|
expected& operator=(unexpected<G>&&) noexcept(see below);
|
|
|
|
|
|
|
|
template <class... Args>
|
|
|
|
void emplace(Args&&...);
|
|
|
|
template <class U, class... Args>
|
|
|
|
void emplace(initializer_list<U>, Args&&...);
|
|
|
|
|
|
|
|
// ?.?.4.4, swap
|
|
|
|
void swap(expected&) noexcept(see below);
|
|
|
|
|
|
|
|
// ?.?.4.5, observers
|
|
|
|
constexpr const T* operator ->() const;
|
|
|
|
constexpr T* operator ->();
|
|
|
|
constexpr const T& operator *() const&;
|
|
|
|
constexpr T& operator *() &;
|
|
|
|
constexpr const T&& operator *() const &&;
|
|
|
|
constexpr T&& operator *() &&;
|
|
|
|
constexpr explicit operator bool() const noexcept;
|
|
|
|
constexpr bool has_value() const noexcept;
|
|
|
|
constexpr const T& value() const&;
|
|
|
|
constexpr T& value() &;
|
|
|
|
constexpr const T&& value() const &&;
|
|
|
|
constexpr T&& value() &&;
|
|
|
|
constexpr const E& error() const&;
|
|
|
|
constexpr E& error() &;
|
|
|
|
constexpr const E&& error() const &&;
|
|
|
|
constexpr E&& error() &&;
|
|
|
|
template <class U>
|
|
|
|
constexpr T value_or(U&&) const&;
|
|
|
|
template <class U>
|
|
|
|
T value_or(U&&) &&;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool has_val; // exposition only
|
|
|
|
union
|
|
|
|
{
|
|
|
|
value_type val; // exposition only
|
|
|
|
unexpected_type unexpect; // exposition only
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}}}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2016-11-13 19:28:36 +00:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <initializer_list>
|
|
|
|
#include <type_traits>
|
|
|
|
#include <utility>
|
|
|
|
#include <wtf/Assertions.h>
|
2017-12-04 23:34:57 +00:00
|
|
|
#include <wtf/Compiler.h>
|
2016-11-13 19:28:36 +00:00
|
|
|
#include <wtf/StdLibExtras.h>
|
2017-12-04 23:34:57 +00:00
|
|
|
#include <wtf/Unexpected.h>
|
2016-11-13 19:28:36 +00:00
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
namespace std {
|
|
|
|
namespace experimental {
|
|
|
|
inline namespace fundamentals_v3 {
|
2016-11-13 19:28:36 +00:00
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
struct unexpected_t {
|
|
|
|
unexpected_t() = default;
|
2016-11-13 19:28:36 +00:00
|
|
|
};
|
2017-12-04 23:34:57 +00:00
|
|
|
#if __cplusplus < 201703L
|
|
|
|
#define __EXPECTED_INLINE_VARIABLE static const
|
|
|
|
#else
|
|
|
|
#define __EXPECTED_INLINE_VARIABLE inline
|
|
|
|
#endif
|
2016-11-13 19:28:36 +00:00
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
__EXPECTED_INLINE_VARIABLE constexpr unexpected_t unexpect { };
|
2016-11-13 19:28:36 +00:00
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
template<class E> class bad_expected_access;
|
2016-11-13 19:28:36 +00:00
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
template<>
|
|
|
|
class bad_expected_access<void> : public std::exception {
|
|
|
|
public:
|
|
|
|
explicit bad_expected_access() { }
|
2016-11-13 19:28:36 +00:00
|
|
|
};
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
template<class E>
|
|
|
|
class bad_expected_access : public bad_expected_access<void> {
|
|
|
|
public:
|
|
|
|
explicit bad_expected_access(E val) : val(val) { }
|
2020-05-12 19:13:18 +00:00
|
|
|
const char* what() const noexcept override { return std::exception::what(); }
|
2017-12-04 23:34:57 +00:00
|
|
|
E& error() & { return val; }
|
|
|
|
const E& error() const& { return val; }
|
|
|
|
E&& error() && { return std::move(val); }
|
|
|
|
const E&& error() const&& { return std::move(val); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
E val;
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
};
|
2016-11-13 19:28:36 +00:00
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
namespace __expected_detail {
|
2016-11-13 19:28:36 +00:00
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
#if COMPILER_SUPPORTS(EXCEPTIONS)
|
|
|
|
#define __EXPECTED_THROW(__exception) (throw __exception)
|
|
|
|
#else
|
|
|
|
inline NO_RETURN_DUE_TO_CRASH void __expected_terminate() { RELEASE_ASSERT_NOT_REACHED(); }
|
|
|
|
#define __EXPECTED_THROW(...) __expected_detail::__expected_terminate()
|
|
|
|
#endif
|
2016-11-13 19:28:36 +00:00
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
__EXPECTED_INLINE_VARIABLE constexpr enum class value_tag_t { } value_tag { };
|
|
|
|
__EXPECTED_INLINE_VARIABLE constexpr enum class error_tag_t { } error_tag { };
|
2016-11-13 19:28:36 +00:00
|
|
|
|
WebAssembly JS API: improve Instance
https://bugs.webkit.org/show_bug.cgi?id=164757
Reviewed by Keith Miller.
JSTests:
An Instance's `exports` property wasn't populated with exports.
A follow-up patch will do imports.
A few things of note:
- LowLevelBinary: support 3-byte integers.
- LowLevelBinary: support proper UTF-8 2003 code points (instead of UTF-16).
* wasm/Builder.js:
* wasm/Builder_WebAssemblyBinary.js: wire up exports, stub other things out some more
(const.emitters.Export):
* wasm/LowLevelBinary.js:
(export.default.LowLevelBinary.prototype.uint24): add, used for UTF-8
(export.default.LowLevelBinary.prototype.string): support UTF-8
(export.default.LowLevelBinary.prototype.getUint24): add, used for UTF-8
(export.default.LowLevelBinary.prototype.getVaruint1): was missing
(export.default.LowLevelBinary.prototype.getString): support UTF-8
(export.default.LowLevelBinary):
* wasm/js-api/test_Instance.js: instance.exports.answer() // <-- this is where the magic of this entire patch is
(ExportedAnswerI32):
* wasm/js-api/test_basic_api.js: punt test to later
(const.c.in.constructorProperties.switch):
* wasm/self-test/test_BuilderWebAssembly.js: UTF-8
(CustomSection):
* wasm/self-test/test_LowLevelBinary_string.js: UTF-8 now works
* wasm/self-test/test_LowLevelBinary_uint16.js: was missing one value
* wasm/self-test/test_LowLevelBinary_uint24.js: Copied from JSTests/wasm/self-test/test_LowLevelBinary_uint8.js.
* wasm/self-test/test_LowLevelBinary_uint8.js: was missing one value
* wasm/self-test/test_LowLevelBinary_varuint1.js: Added.
* wasm/utilities.js: this `dump` thing was useful
(const._dump):
Source/JavaScriptCore:
An Instance's `exports` property wasn't populated with exports.
According to the spec [0], `exports` should present itself as a WebAssembly
Module Record. In order to do this we need to split JSModuleRecord into
AbstractModuleRecord (without the `link` and `evaluate` functions), and
JSModuleRecord (which implements link and evaluate). We can then have a separate
WebAssemblyModuleRecord which shares most of the implementation.
`exports` then maps function names to WebAssemblyFunction and
WebAssemblyFunctionCell, which call into the B3-generated WebAssembly code.
A follow-up patch will do imports.
A few things of note:
- Use Identifier instead of String. They get uniqued, we need them for the JSModuleNamespaceObject. This is safe because JSWebAssemblyModule creation is on the main thread.
- JSWebAssemblyInstance needs to refer to the JSWebAssemblyModule used to create it, because the module owns the code, identifiers, etc. The world would be very sad if it got GC'd.
- Instance.exports shouldn't use putWithoutTransition because it affects all Structures, whereas here each instance needs its own exports.
- Expose the compiled functions, and pipe them to the InstanceConstructor. Start moving things around to split JSModuleRecord out into JS and WebAssembly parts.
[0]: https://github.com/WebAssembly/design/blob/master/JS.md#webassemblyinstance-constructor
* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* runtime/AbstractModuleRecord.cpp: Copied from Source/JavaScriptCore/runtime/JSModuleRecord.cpp, which I split in two
(JSC::AbstractModuleRecord::AbstractModuleRecord):
(JSC::AbstractModuleRecord::destroy):
(JSC::AbstractModuleRecord::finishCreation):
(JSC::AbstractModuleRecord::visitChildren):
(JSC::AbstractModuleRecord::appendRequestedModule):
(JSC::AbstractModuleRecord::addStarExportEntry):
(JSC::AbstractModuleRecord::addImportEntry):
(JSC::AbstractModuleRecord::addExportEntry):
(JSC::identifierToJSValue):
(JSC::AbstractModuleRecord::hostResolveImportedModule):
(JSC::AbstractModuleRecord::ResolveQuery::ResolveQuery):
(JSC::AbstractModuleRecord::ResolveQuery::isEmptyValue):
(JSC::AbstractModuleRecord::ResolveQuery::isDeletedValue):
(JSC::AbstractModuleRecord::ResolveQuery::Hash::hash):
(JSC::AbstractModuleRecord::ResolveQuery::Hash::equal):
(JSC::AbstractModuleRecord::cacheResolution):
(JSC::getExportedNames):
(JSC::AbstractModuleRecord::getModuleNamespace):
(JSC::printableName):
(JSC::AbstractModuleRecord::dump):
* runtime/AbstractModuleRecord.h: Copied from Source/JavaScriptCore/runtime/JSModuleRecord.h.
(JSC::AbstractModuleRecord::ImportEntry::isNamespace):
(JSC::AbstractModuleRecord::sourceCode):
(JSC::AbstractModuleRecord::moduleKey):
(JSC::AbstractModuleRecord::requestedModules):
(JSC::AbstractModuleRecord::exportEntries):
(JSC::AbstractModuleRecord::importEntries):
(JSC::AbstractModuleRecord::starExportEntries):
(JSC::AbstractModuleRecord::declaredVariables):
(JSC::AbstractModuleRecord::lexicalVariables):
(JSC::AbstractModuleRecord::moduleEnvironment):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::webAssemblyModuleRecordStructure):
(JSC::JSGlobalObject::webAssemblyFunctionStructure):
* runtime/JSModuleEnvironment.cpp:
(JSC::JSModuleEnvironment::create):
(JSC::JSModuleEnvironment::finishCreation):
(JSC::JSModuleEnvironment::getOwnPropertySlot):
(JSC::JSModuleEnvironment::getOwnNonIndexPropertyNames):
(JSC::JSModuleEnvironment::put):
(JSC::JSModuleEnvironment::deleteProperty):
* runtime/JSModuleEnvironment.h:
(JSC::JSModuleEnvironment::create):
(JSC::JSModuleEnvironment::offsetOfModuleRecord):
(JSC::JSModuleEnvironment::allocationSize):
(JSC::JSModuleEnvironment::moduleRecord):
(JSC::JSModuleEnvironment::moduleRecordSlot):
* runtime/JSModuleNamespaceObject.cpp:
(JSC::JSModuleNamespaceObject::finishCreation):
(JSC::JSModuleNamespaceObject::getOwnPropertySlot):
* runtime/JSModuleNamespaceObject.h:
(JSC::JSModuleNamespaceObject::create):
(JSC::JSModuleNamespaceObject::moduleRecord):
* runtime/JSModuleRecord.cpp:
(JSC::JSModuleRecord::createStructure):
(JSC::JSModuleRecord::create):
(JSC::JSModuleRecord::JSModuleRecord):
(JSC::JSModuleRecord::destroy):
(JSC::JSModuleRecord::finishCreation):
(JSC::JSModuleRecord::visitChildren):
(JSC::JSModuleRecord::instantiateDeclarations):
* runtime/JSModuleRecord.h:
* runtime/JSScope.cpp:
(JSC::abstractAccess):
(JSC::JSScope::collectClosureVariablesUnderTDZ):
* runtime/VM.cpp:
(JSC::VM::VM):
* runtime/VM.h:
* wasm/JSWebAssembly.h:
* wasm/WasmFormat.h: use Identifier instead of String
* wasm/WasmModuleParser.cpp:
(JSC::Wasm::ModuleParser::parse):
(JSC::Wasm::ModuleParser::parseType):
(JSC::Wasm::ModuleParser::parseImport): fix off-by-one
(JSC::Wasm::ModuleParser::parseFunction):
(JSC::Wasm::ModuleParser::parseExport):
* wasm/WasmModuleParser.h:
(JSC::Wasm::ModuleParser::ModuleParser):
* wasm/WasmPlan.cpp:
(JSC::Wasm::Plan::run):
* wasm/js/JSWebAssemblyInstance.cpp:
(JSC::JSWebAssemblyInstance::create):
(JSC::JSWebAssemblyInstance::finishCreation):
(JSC::JSWebAssemblyInstance::visitChildren):
* wasm/js/JSWebAssemblyInstance.h:
(JSC::JSWebAssemblyInstance::module):
* wasm/js/JSWebAssemblyModule.cpp:
(JSC::JSWebAssemblyModule::create):
(JSC::JSWebAssemblyModule::finishCreation):
(JSC::JSWebAssemblyModule::visitChildren):
* wasm/js/JSWebAssemblyModule.h:
(JSC::JSWebAssemblyModule::moduleInformation):
(JSC::JSWebAssemblyModule::compiledFunctions):
(JSC::JSWebAssemblyModule::exportSymbolTable):
* wasm/js/WebAssemblyFunction.cpp: Added.
(JSC::callWebAssemblyFunction):
(JSC::WebAssemblyFunction::create):
(JSC::WebAssemblyFunction::createStructure):
(JSC::WebAssemblyFunction::WebAssemblyFunction):
(JSC::WebAssemblyFunction::visitChildren):
(JSC::WebAssemblyFunction::finishCreation):
* wasm/js/WebAssemblyFunction.h: Copied from Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.h.
(JSC::CallableWebAssemblyFunction::CallableWebAssemblyFunction):
(JSC::WebAssemblyFunction::webAssemblyFunctionCell):
* wasm/js/WebAssemblyFunctionCell.cpp: Copied from Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h.
(JSC::WebAssemblyFunctionCell::create):
(JSC::WebAssemblyFunctionCell::WebAssemblyFunctionCell):
(JSC::WebAssemblyFunctionCell::destroy):
(JSC::WebAssemblyFunctionCell::createStructure):
* wasm/js/WebAssemblyFunctionCell.h: Copied from Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h.
(JSC::WebAssemblyFunctionCell::function):
* wasm/js/WebAssemblyInstanceConstructor.cpp:
(JSC::constructJSWebAssemblyInstance):
* wasm/js/WebAssemblyModuleConstructor.cpp:
(JSC::constructJSWebAssemblyModule):
* wasm/js/WebAssemblyModuleRecord.cpp: Added.
(JSC::WebAssemblyModuleRecord::createStructure):
(JSC::WebAssemblyModuleRecord::create):
(JSC::WebAssemblyModuleRecord::WebAssemblyModuleRecord):
(JSC::WebAssemblyModuleRecord::destroy):
(JSC::WebAssemblyModuleRecord::finishCreation):
(JSC::WebAssemblyModuleRecord::visitChildren):
(JSC::WebAssemblyModuleRecord::link):
(JSC::WebAssemblyModuleRecord::evaluate):
* wasm/js/WebAssemblyModuleRecord.h: Copied from Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.h.
Source/WTF:
* wtf/Expected.h:
(WTF::ExpectedDetail::destroy): silence a warning
Canonical link: https://commits.webkit.org/182809@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209123 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-11-30 07:22:17 +00:00
|
|
|
template<class T, std::enable_if_t<std::is_trivially_destructible<T>::value>* = nullptr> void destroy(T&) { }
|
2016-11-13 19:28:36 +00:00
|
|
|
template<class T, std::enable_if_t<!std::is_trivially_destructible<T>::value && (std::is_class<T>::value || std::is_union<T>::value)>* = nullptr> void destroy(T& t) { t.~T(); }
|
|
|
|
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
template<class T, class E>
|
2017-12-04 23:34:57 +00:00
|
|
|
union constexpr_storage {
|
|
|
|
typedef T value_type;
|
|
|
|
typedef E error_type;
|
|
|
|
typedef unexpected<E> unexpected_type;
|
2016-11-13 19:28:36 +00:00
|
|
|
char dummy;
|
2017-12-04 23:34:57 +00:00
|
|
|
value_type val;
|
|
|
|
error_type err;
|
|
|
|
constexpr constexpr_storage() : dummy() { }
|
|
|
|
constexpr constexpr_storage(value_tag_t) : val() { }
|
|
|
|
constexpr constexpr_storage(error_tag_t) : err() { }
|
2019-03-26 05:53:57 +00:00
|
|
|
template<typename U = T>
|
|
|
|
constexpr constexpr_storage(value_tag_t, U&& v) : val(std::forward<U>(v)) { }
|
|
|
|
template<typename U = E>
|
|
|
|
constexpr constexpr_storage(error_tag_t, U&& e) : err(std::forward<U>(e)) { }
|
2017-12-04 23:34:57 +00:00
|
|
|
~constexpr_storage() = default;
|
2016-11-13 19:28:36 +00:00
|
|
|
};
|
|
|
|
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
template<class T, class E>
|
2017-12-04 23:34:57 +00:00
|
|
|
union storage {
|
|
|
|
typedef T value_type;
|
|
|
|
typedef E error_type;
|
|
|
|
typedef unexpected<E> unexpected_type;
|
2016-11-13 19:28:36 +00:00
|
|
|
char dummy;
|
2017-12-04 23:34:57 +00:00
|
|
|
value_type val;
|
|
|
|
error_type err;
|
|
|
|
constexpr storage() : dummy() { }
|
|
|
|
constexpr storage(value_tag_t) : val() { }
|
|
|
|
constexpr storage(error_tag_t) : err() { }
|
|
|
|
constexpr storage(value_tag_t, const value_type& val) : val(val) { }
|
|
|
|
constexpr storage(value_tag_t, value_type&& val) : val(std::forward<value_type>(val)) { }
|
|
|
|
constexpr storage(error_tag_t, const error_type& err) : err(err) { }
|
|
|
|
constexpr storage(error_tag_t, error_type&& err) : err(std::forward<error_type>(err)) { }
|
|
|
|
~storage() { }
|
2016-11-13 19:28:36 +00:00
|
|
|
};
|
|
|
|
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
template<class E>
|
2017-12-04 23:34:57 +00:00
|
|
|
union constexpr_storage<void, E> {
|
|
|
|
typedef void value_type;
|
|
|
|
typedef E error_type;
|
|
|
|
typedef unexpected<E> unexpected_type;
|
2016-11-13 19:28:36 +00:00
|
|
|
char dummy;
|
2017-12-04 23:34:57 +00:00
|
|
|
error_type err;
|
|
|
|
constexpr constexpr_storage() : dummy() { }
|
|
|
|
constexpr constexpr_storage(value_tag_t) : dummy() { }
|
|
|
|
constexpr constexpr_storage(error_tag_t) : err() { }
|
|
|
|
constexpr constexpr_storage(error_tag_t, const error_type& e) : err(e) { }
|
|
|
|
~constexpr_storage() = default;
|
2016-11-13 19:28:36 +00:00
|
|
|
};
|
|
|
|
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
template<class E>
|
2017-12-04 23:34:57 +00:00
|
|
|
union storage<void, E> {
|
|
|
|
typedef void value_type;
|
|
|
|
typedef E error_type;
|
|
|
|
typedef unexpected<E> unexpected_type;
|
2016-11-13 19:28:36 +00:00
|
|
|
char dummy;
|
2017-12-04 23:34:57 +00:00
|
|
|
error_type err;
|
|
|
|
constexpr storage() : dummy() { }
|
|
|
|
constexpr storage(value_tag_t) : dummy() { }
|
|
|
|
constexpr storage(error_tag_t) : err() { }
|
|
|
|
constexpr storage(error_tag_t, const error_type& err) : err(err) { }
|
|
|
|
constexpr storage(error_tag_t, error_type&& err) : err(std::forward<error_type>(err)) { }
|
|
|
|
~storage() { }
|
2016-11-13 19:28:36 +00:00
|
|
|
};
|
|
|
|
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
template<class T, class E>
|
2017-12-04 23:34:57 +00:00
|
|
|
struct constexpr_base {
|
|
|
|
typedef T value_type;
|
|
|
|
typedef E error_type;
|
|
|
|
typedef unexpected<E> unexpected_type;
|
|
|
|
constexpr_storage<value_type, error_type> s;
|
2016-11-13 19:28:36 +00:00
|
|
|
bool has;
|
2017-12-04 23:34:57 +00:00
|
|
|
constexpr constexpr_base() : s(), has(true) { }
|
|
|
|
constexpr constexpr_base(value_tag_t tag) : s(tag), has(true) { }
|
|
|
|
constexpr constexpr_base(error_tag_t tag) : s(tag), has(false) { }
|
2019-03-26 05:53:57 +00:00
|
|
|
template<typename U = T>
|
|
|
|
constexpr constexpr_base(value_tag_t tag, U&& val) : s(tag, std::forward<U>(val)), has(true) { }
|
|
|
|
template<typename U = E>
|
|
|
|
constexpr constexpr_base(error_tag_t tag, U&& err) : s(tag, std::forward<U>(err)), has(false) { }
|
2017-12-04 23:34:57 +00:00
|
|
|
~constexpr_base() = default;
|
2016-11-13 19:28:36 +00:00
|
|
|
};
|
|
|
|
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
template<class T, class E>
|
2017-12-04 23:34:57 +00:00
|
|
|
struct base {
|
|
|
|
typedef T value_type;
|
|
|
|
typedef E error_type;
|
|
|
|
typedef unexpected<E> unexpected_type;
|
|
|
|
storage<value_type, error_type> s;
|
2016-11-13 19:28:36 +00:00
|
|
|
bool has;
|
2017-12-04 23:34:57 +00:00
|
|
|
constexpr base() : s(), has(true) { }
|
|
|
|
constexpr base(value_tag_t tag) : s(tag), has(true) { }
|
|
|
|
constexpr base(error_tag_t tag) : s(tag), has(false) { }
|
|
|
|
constexpr base(value_tag_t tag, const value_type& val) : s(tag, val), has(true) { }
|
|
|
|
constexpr base(value_tag_t tag, value_type&& val) : s(tag, std::forward<value_type>(val)), has(true) { }
|
|
|
|
constexpr base(error_tag_t tag, const error_type& err) : s(tag, err), has(false) { }
|
|
|
|
constexpr base(error_tag_t tag, error_type&& err) : s(tag, std::forward<error_type>(err)), has(false) { }
|
|
|
|
base(const base& o)
|
2016-11-13 19:28:36 +00:00
|
|
|
: has(o.has)
|
|
|
|
{
|
|
|
|
if (has)
|
2019-03-12 06:04:22 +00:00
|
|
|
::new (std::addressof(s.val)) value_type(o.s.val);
|
2016-11-13 19:28:36 +00:00
|
|
|
else
|
2019-03-12 06:04:22 +00:00
|
|
|
::new (std::addressof(s.err)) error_type(o.s.err);
|
2016-11-13 19:28:36 +00:00
|
|
|
}
|
2017-12-04 23:34:57 +00:00
|
|
|
base(base&& o)
|
2016-11-13 19:28:36 +00:00
|
|
|
: has(o.has)
|
|
|
|
{
|
|
|
|
if (has)
|
2019-03-12 06:04:22 +00:00
|
|
|
::new (std::addressof(s.val)) value_type(std::move(o.s.val));
|
2016-11-13 19:28:36 +00:00
|
|
|
else
|
2019-03-12 06:04:22 +00:00
|
|
|
::new (std::addressof(s.err)) error_type(std::move(o.s.err));
|
2016-11-13 19:28:36 +00:00
|
|
|
}
|
2017-12-04 23:34:57 +00:00
|
|
|
~base()
|
2016-11-13 19:28:36 +00:00
|
|
|
{
|
|
|
|
if (has)
|
|
|
|
destroy(s.val);
|
|
|
|
else
|
|
|
|
destroy(s.err);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
template<class E>
|
2017-12-04 23:34:57 +00:00
|
|
|
struct constexpr_base<void, E> {
|
|
|
|
typedef void value_type;
|
|
|
|
typedef E error_type;
|
|
|
|
typedef unexpected<E> unexpected_type;
|
|
|
|
constexpr_storage<value_type, error_type> s;
|
2016-11-13 19:28:36 +00:00
|
|
|
bool has;
|
2017-12-04 23:34:57 +00:00
|
|
|
constexpr constexpr_base() : s(), has(true) { }
|
|
|
|
constexpr constexpr_base(value_tag_t tag) : s(tag), has(true) { }
|
|
|
|
constexpr constexpr_base(error_tag_t tag) : s(tag), has(false) { }
|
|
|
|
constexpr constexpr_base(error_tag_t tag, const error_type& err) : s(tag, err), has(false) { }
|
|
|
|
constexpr constexpr_base(error_tag_t tag, error_type&& err) : s(tag, std::forward<error_type>(err)), has(false) { }
|
|
|
|
~constexpr_base() = default;
|
2016-11-13 19:28:36 +00:00
|
|
|
};
|
|
|
|
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
template<class E>
|
2017-12-04 23:34:57 +00:00
|
|
|
struct base<void, E> {
|
|
|
|
typedef void value_type;
|
|
|
|
typedef E error_type;
|
|
|
|
typedef unexpected<E> unexpected_type;
|
|
|
|
storage<value_type, error_type> s;
|
2016-11-13 19:28:36 +00:00
|
|
|
bool has;
|
2017-12-04 23:34:57 +00:00
|
|
|
constexpr base() : s(), has(true) { }
|
|
|
|
constexpr base(value_tag_t tag) : s(tag), has(true) { }
|
|
|
|
constexpr base(error_tag_t tag) : s(tag), has(false) { }
|
|
|
|
constexpr base(error_tag_t tag, const error_type& err) : s(tag, err), has(false) { }
|
|
|
|
constexpr base(error_tag_t tag, error_type&& err) : s(tag, std::forward<error_type>(err)), has(false) { }
|
|
|
|
base(const base& o)
|
2016-11-13 19:28:36 +00:00
|
|
|
: has(o.has)
|
|
|
|
{
|
|
|
|
if (!has)
|
2019-03-12 06:04:22 +00:00
|
|
|
::new (std::addressof(s.err)) error_type(o.s.err);
|
2016-11-13 19:28:36 +00:00
|
|
|
}
|
2017-12-04 23:34:57 +00:00
|
|
|
base(base&& o)
|
2016-11-13 19:28:36 +00:00
|
|
|
: has(o.has)
|
|
|
|
{
|
|
|
|
if (!has)
|
2019-03-12 06:04:22 +00:00
|
|
|
::new (std::addressof(s.err)) error_type(std::move(o.s.err));
|
2016-11-13 19:28:36 +00:00
|
|
|
}
|
2017-12-04 23:34:57 +00:00
|
|
|
~base()
|
2016-11-13 19:28:36 +00:00
|
|
|
{
|
|
|
|
if (!has)
|
|
|
|
destroy(s.err);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
template<class T, class E>
|
2017-12-04 23:34:57 +00:00
|
|
|
using base_select = typename std::conditional<
|
2016-11-13 19:28:36 +00:00
|
|
|
((std::is_void<T>::value || std::is_trivially_destructible<T>::value)
|
|
|
|
&& std::is_trivially_destructible<E>::value),
|
2017-12-04 23:34:57 +00:00
|
|
|
constexpr_base<typename std::remove_const<T>::type, typename std::remove_const<E>::type>,
|
|
|
|
base<typename std::remove_const<T>::type, typename std::remove_const<E>::type>
|
2016-11-13 19:28:36 +00:00
|
|
|
>::type;
|
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
} // namespace __expected_detail
|
2016-11-13 19:28:36 +00:00
|
|
|
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
template<class T, class E>
|
2017-12-04 23:34:57 +00:00
|
|
|
class expected : private __expected_detail::base_select<T, E> {
|
2019-08-12 20:57:15 +00:00
|
|
|
WTF_MAKE_FAST_ALLOCATED;
|
2017-12-04 23:34:57 +00:00
|
|
|
typedef __expected_detail::base_select<T, E> base;
|
2016-11-13 19:28:36 +00:00
|
|
|
|
|
|
|
public:
|
2017-12-04 23:34:57 +00:00
|
|
|
typedef typename base::value_type value_type;
|
|
|
|
typedef typename base::error_type error_type;
|
|
|
|
typedef typename base::unexpected_type unexpected_type;
|
2016-11-13 19:28:36 +00:00
|
|
|
|
|
|
|
private:
|
2017-12-04 23:34:57 +00:00
|
|
|
typedef expected<value_type, error_type> type;
|
2016-11-13 19:28:36 +00:00
|
|
|
|
|
|
|
public:
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
template<class U> struct rebind {
|
2017-12-04 23:34:57 +00:00
|
|
|
using type = expected<U, error_type>;
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
};
|
2016-11-13 19:28:36 +00:00
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
constexpr expected() : base(__expected_detail::value_tag) { }
|
|
|
|
expected(const expected&) = default;
|
|
|
|
expected(expected&&) = default;
|
|
|
|
|
|
|
|
constexpr expected(const value_type& e) : base(__expected_detail::value_tag, e) { }
|
|
|
|
constexpr expected(value_type&& e) : base(__expected_detail::value_tag, std::forward<value_type>(e)) { }
|
|
|
|
template<class... Args> constexpr explicit expected(std::in_place_t, Args&&... args) : base(__expected_detail::value_tag, value_type(std::forward<Args>(args)...)) { }
|
|
|
|
// template<class U, class... Args> constexpr explicit expected(in_place_t, std::initializer_list<U>, Args&&...);
|
|
|
|
constexpr expected(const unexpected_type& u) : base(__expected_detail::error_tag, u.value()) { }
|
|
|
|
constexpr expected(unexpected_type&& u) : base(__expected_detail::error_tag, std::forward<unexpected_type>(u).value()) { }
|
|
|
|
template<class Err> constexpr expected(const unexpected<Err>& u) : base(__expected_detail::error_tag, u.value()) { }
|
|
|
|
template<class Err> constexpr expected(unexpected<Err>&& u) : base(__expected_detail::error_tag, std::forward<Err>(u.value())) { }
|
|
|
|
template<class... Args> constexpr explicit expected(unexpected_t, Args&&... args) : base(__expected_detail::value_tag, unexpected_type(std::forward<Args>(args)...)) { }
|
|
|
|
// template<class U, class... Args> constexpr explicit expected(unexpected_t, std::initializer_list<U>, Args&&...);
|
|
|
|
|
|
|
|
~expected() = default;
|
|
|
|
|
|
|
|
expected& operator=(const expected& e) { type(e).swap(*this); return *this; }
|
|
|
|
expected& operator=(expected&& e) { type(std::move(e)).swap(*this); return *this; }
|
2021-03-10 22:07:50 +00:00
|
|
|
template<class U> expected& operator=(U&& u) { type(std::forward<U>(u)).swap(*this); return *this; }
|
2017-12-04 23:34:57 +00:00
|
|
|
expected& operator=(const unexpected_type& u) { type(u).swap(*this); return *this; }
|
|
|
|
expected& operator=(unexpected_type&& u) { type(std::move(u)).swap(*this); return *this; }
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
// template<class... Args> void emplace(Args&&...);
|
|
|
|
// template<class U, class... Args> void emplace(std::initializer_list<U>, Args&&...);
|
2016-11-13 19:28:36 +00:00
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
void swap(expected& o)
|
2016-11-13 19:28:36 +00:00
|
|
|
{
|
|
|
|
using std::swap;
|
|
|
|
if (base::has && o.has)
|
|
|
|
swap(base::s.val, o.s.val);
|
|
|
|
else if (base::has && !o.has) {
|
2017-12-04 23:34:57 +00:00
|
|
|
error_type e(std::move(o.s.err));
|
|
|
|
__expected_detail::destroy(o.s.err);
|
2019-03-12 06:04:22 +00:00
|
|
|
::new (std::addressof(o.s.val)) value_type(std::move(base::s.val));
|
2017-12-04 23:34:57 +00:00
|
|
|
__expected_detail::destroy(base::s.val);
|
2019-03-12 06:04:22 +00:00
|
|
|
::new (std::addressof(base::s.err)) error_type(std::move(e));
|
2016-11-13 19:28:36 +00:00
|
|
|
swap(base::has, o.has);
|
|
|
|
} else if (!base::has && o.has) {
|
2017-12-04 23:34:57 +00:00
|
|
|
value_type v(std::move(o.s.val));
|
|
|
|
__expected_detail::destroy(o.s.val);
|
2019-03-12 06:04:22 +00:00
|
|
|
::new (std::addressof(o.s.err)) error_type(std::move(base::s.err));
|
2017-12-04 23:34:57 +00:00
|
|
|
__expected_detail::destroy(base::s.err);
|
2019-03-12 06:04:22 +00:00
|
|
|
::new (std::addressof(base::s.val)) value_type(std::move(v));
|
2016-11-13 19:28:36 +00:00
|
|
|
swap(base::has, o.has);
|
|
|
|
} else
|
|
|
|
swap(base::s.err, o.s.err);
|
|
|
|
}
|
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
constexpr const value_type* operator->() const { return &base::s.val; }
|
|
|
|
value_type* operator->() { return &base::s.val; }
|
|
|
|
constexpr const value_type& operator*() const & { return base::s.val; }
|
|
|
|
value_type& operator*() & { return base::s.val; }
|
|
|
|
constexpr const value_type&& operator*() const && { return std::move(base::s.val); }
|
2017-12-09 21:42:02 +00:00
|
|
|
constexpr value_type&& operator*() && { return std::move(base::s.val); }
|
2016-11-13 19:28:36 +00:00
|
|
|
constexpr explicit operator bool() const { return base::has; }
|
2017-12-04 23:34:57 +00:00
|
|
|
constexpr bool has_value() const { return base::has; }
|
|
|
|
constexpr const value_type& value() const & { return base::has ? base::s.val : (__EXPECTED_THROW(bad_expected_access<error_type>(base::s.err)), base::s.val); }
|
2017-12-09 21:42:02 +00:00
|
|
|
constexpr value_type& value() & { return base::has ? base::s.val : (__EXPECTED_THROW(bad_expected_access<error_type>(base::s.err)), base::s.val); }
|
2017-12-04 23:34:57 +00:00
|
|
|
constexpr const value_type&& value() const && { return std::move(base::has ? base::s.val : (__EXPECTED_THROW(bad_expected_access<error_type>(base::s.err)), base::s.val)); }
|
2017-12-09 21:42:02 +00:00
|
|
|
constexpr value_type&& value() && { return std::move(base::has ? base::s.val : (__EXPECTED_THROW(bad_expected_access<error_type>(base::s.err)), base::s.val)); }
|
2017-12-04 23:34:57 +00:00
|
|
|
constexpr const error_type& error() const & { return !base::has ? base::s.err : (__EXPECTED_THROW(bad_expected_access<void>()), base::s.err); }
|
|
|
|
error_type& error() & { return !base::has ? base::s.err : (__EXPECTED_THROW(bad_expected_access<void>()), base::s.err); }
|
2017-12-09 21:42:02 +00:00
|
|
|
constexpr error_type&& error() && { return std::move(!base::has ? base::s.err : (__EXPECTED_THROW(bad_expected_access<void>()), base::s.err)); }
|
2017-12-04 23:34:57 +00:00
|
|
|
constexpr const error_type&& error() const && { return std::move(!base::has ? base::s.err : (__EXPECTED_THROW(bad_expected_access<void>()), base::s.err)); }
|
|
|
|
template<class U> constexpr value_type value_or(U&& u) const & { return base::has ? **this : static_cast<value_type>(std::forward<U>(u)); }
|
|
|
|
template<class U> value_type value_or(U&& u) && { return base::has ? std::move(**this) : static_cast<value_type>(std::forward<U>(u)); }
|
2016-11-13 19:28:36 +00:00
|
|
|
};
|
|
|
|
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
template<class E>
|
2017-12-04 23:34:57 +00:00
|
|
|
class expected<void, E> : private __expected_detail::base_select<void, E> {
|
|
|
|
typedef __expected_detail::base_select<void, E> base;
|
2016-11-13 19:28:36 +00:00
|
|
|
|
|
|
|
public:
|
2017-12-04 23:34:57 +00:00
|
|
|
typedef typename base::value_type value_type;
|
|
|
|
typedef typename base::error_type error_type;
|
|
|
|
typedef typename base::unexpected_type unexpected_type;
|
2016-11-13 19:28:36 +00:00
|
|
|
|
|
|
|
private:
|
2017-12-04 23:34:57 +00:00
|
|
|
typedef expected<value_type, error_type> type;
|
2016-11-13 19:28:36 +00:00
|
|
|
|
|
|
|
public:
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
template<class U> struct rebind {
|
2017-12-04 23:34:57 +00:00
|
|
|
using type = expected<U, error_type>;
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
};
|
2016-11-13 19:28:36 +00:00
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
constexpr expected() : base(__expected_detail::value_tag) { }
|
|
|
|
expected(const expected&) = default;
|
|
|
|
expected(expected&&) = default;
|
|
|
|
// constexpr explicit expected(in_place_t);
|
|
|
|
constexpr expected(unexpected_type const& u) : base(__expected_detail::error_tag, u.value()) { }
|
|
|
|
constexpr expected(unexpected_type&& u) : base(__expected_detail::error_tag, std::forward<unexpected_type>(u).value()) { }
|
|
|
|
template<class Err> constexpr expected(unexpected<Err> const& u) : base(__expected_detail::error_tag, u.value()) { }
|
2016-11-13 19:28:36 +00:00
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
~expected() = default;
|
2016-11-13 19:28:36 +00:00
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
expected& operator=(const expected& e) { type(e).swap(*this); return *this; }
|
|
|
|
expected& operator=(expected&& e) { type(std::move(e)).swap(*this); return *this; }
|
|
|
|
expected& operator=(const unexpected_type& u) { type(u).swap(*this); return *this; } // Not in the current paper.
|
|
|
|
expected& operator=(unexpected_type&& u) { type(std::move(u)).swap(*this); return *this; } // Not in the current paper.
|
2016-11-13 19:28:36 +00:00
|
|
|
// void emplace();
|
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
void swap(expected& o)
|
2016-11-13 19:28:36 +00:00
|
|
|
{
|
|
|
|
using std::swap;
|
|
|
|
if (base::has && o.has) {
|
|
|
|
// Do nothing.
|
|
|
|
} else if (base::has && !o.has) {
|
2017-12-04 23:34:57 +00:00
|
|
|
error_type e(std::move(o.s.err));
|
2019-03-12 06:04:22 +00:00
|
|
|
::new (std::addressof(base::s.err)) error_type(e);
|
2016-11-13 19:28:36 +00:00
|
|
|
swap(base::has, o.has);
|
|
|
|
} else if (!base::has && o.has) {
|
2019-03-12 06:04:22 +00:00
|
|
|
::new (std::addressof(o.s.err)) error_type(std::move(base::s.err));
|
2016-11-13 19:28:36 +00:00
|
|
|
swap(base::has, o.has);
|
|
|
|
} else
|
|
|
|
swap(base::s.err, o.s.err);
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr explicit operator bool() const { return base::has; }
|
2017-12-04 23:34:57 +00:00
|
|
|
constexpr bool has_value() const { return base::has; }
|
|
|
|
void value() const { !base::has ? __EXPECTED_THROW(bad_expected_access<void>()) : void(); }
|
|
|
|
constexpr const E& error() const & { return !base::has ? base::s.err : (__EXPECTED_THROW(bad_expected_access<void>()), base::s.err); }
|
|
|
|
E& error() & { return !base::has ? base::s.err : (__EXPECTED_THROW(bad_expected_access<void>()), base::s.err); }
|
2017-12-09 21:42:02 +00:00
|
|
|
constexpr E&& error() && { return std::move(!base::has ? base::s.err : (__EXPECTED_THROW(bad_expected_access<void>()), base::s.err)); }
|
2016-11-13 19:28:36 +00:00
|
|
|
};
|
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
template<class T, class E> constexpr bool operator==(const expected<T, E>& x, const expected<T, E>& y) { return bool(x) == bool(y) && (x ? x.value() == y.value() : x.error() == y.error()); }
|
|
|
|
template<class T, class E> constexpr bool operator!=(const expected<T, E>& x, const expected<T, E>& y) { return !(x == y); }
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
template<class E> constexpr bool operator==(const expected<void, E>& x, const expected<void, E>& y) { return bool(x) == bool(y) && (x ? true : x.error() == y.error()); }
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
|
2019-03-26 05:53:57 +00:00
|
|
|
template<class T, class E> constexpr bool operator==(const expected<T, E>& x, const T& y) { return x ? *x == y : false; }
|
|
|
|
template<class T, class E> constexpr bool operator==(const T& x, const expected<T, E>& y) { return y ? x == *y : false; }
|
|
|
|
template<class T, class E> constexpr bool operator!=(const expected<T, E>& x, const T& y) { return x ? *x != y : true; }
|
|
|
|
template<class T, class E> constexpr bool operator!=(const T& x, const expected<T, E>& y) { return y ? x != *y : true; }
|
WTF: Update std::expected to match current proposal
https://bugs.webkit.org/show_bug.cgi?id=177881
Reviewed by Mark Lam.
Source/JavaScriptCore:
Update API.
* wasm/WasmB3IRGenerator.cpp:
* wasm/WasmModule.cpp:
(JSC::Wasm::makeValidationResult):
* wasm/WasmParser.h:
* wasm/WasmValidate.cpp:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
Source/WTF:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* wtf/Expected.h:
(WTF::Unexpected::Unexpected):
(WTF::Unexpected::value const):
(WTF::operator==):
(WTF::operator!=):
(WTF::makeUnexpected):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::getUnexpected const):
Tools:
The proposal is likely to be in C++20 and I've been asked to help co-champion
it. I'm therefore updating our implementation to more closely match the current
proposal, and to make sure it'll work for us if standardized.
- Rename UnexpectedType to Unexpected to match the proposal.
- Remove relational operators, only equality / inequality remains.
- Fix minor type signatures.
- Add UnexpectedType typedef.
- Uncomment rebind implementation.
- Add in-place construction tag, as well as explicit error construction tag.
- Add template unexpected constructor.
- Note that make_unexpected isn't in the proposal anymore, but we keep it because we don't have C++17 deduction guides.
- Remove hashing, which isn't in the proposal anymore.
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/194157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-04 20:54:26 +00:00
|
|
|
|
2019-03-26 05:53:57 +00:00
|
|
|
template<class T, class E> constexpr bool operator==(const expected<T, E>& x, const unexpected<E>& y) { return x ? false : x.error() == y.value(); }
|
|
|
|
template<class T, class E> constexpr bool operator==(const unexpected<E>& x, const expected<T, E>& y) { return y ? false : x.value() == y.error(); }
|
|
|
|
template<class T, class E> constexpr bool operator!=(const expected<T, E>& x, const unexpected<E>& y) { return x ? true : x.error() != y.value(); }
|
|
|
|
template<class T, class E> constexpr bool operator!=(const unexpected<E>& x, const expected<T, E>& y) { return y ? true : x.value() != y.error(); }
|
2016-11-13 19:28:36 +00:00
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
template<typename T, typename E> void swap(expected<T, E>& x, expected<T, E>& y) { x.swap(y); }
|
2016-11-13 19:28:36 +00:00
|
|
|
|
2017-12-04 23:34:57 +00:00
|
|
|
}}} // namespace std::experimental::fundamentals_v3
|
2016-11-13 19:28:36 +00:00
|
|
|
|
2018-05-04 01:00:18 +00:00
|
|
|
__EXPECTED_INLINE_VARIABLE constexpr auto& unexpect = std::experimental::unexpect;
|
2017-12-04 23:34:57 +00:00
|
|
|
template<class T, class E> using Expected = std::experimental::expected<T, E>;
|