From 809a423d7ddf0d288718050f7ec3e18fff477e78 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 20 Jan 2023 21:54:46 +0000 Subject: [PATCH] third_party/fuchsia: Add stdcompat/functional.h Add sdk/lib/stdcompat/include/lib/stdcompat/functional.h to Fuchsia Copybara rules. This is used by Sapphire. Change-Id: I275d689caaab58b59d74ccf64207dfeba8e497ef Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/126694 Reviewed-by: Wyatt Hepler Commit-Queue: Ben Lawson --- third_party/fuchsia/BUILD.bazel | 1 + third_party/fuchsia/BUILD.gn | 1 + third_party/fuchsia/CMakeLists.txt | 1 + third_party/fuchsia/copy.bara.sky | 1 + third_party/fuchsia/pigweed_adaptations.patch | 50 +++++-------------- 5 files changed, 17 insertions(+), 37 deletions(-) diff --git a/third_party/fuchsia/BUILD.bazel b/third_party/fuchsia/BUILD.bazel index 35ca6fc09d..d3d90a74fd 100644 --- a/third_party/fuchsia/BUILD.bazel +++ b/third_party/fuchsia/BUILD.bazel @@ -60,6 +60,7 @@ pw_cc_library( "repo/sdk/lib/stdcompat/include/lib/stdcompat/memory.h", ], hdrs = [ + "repo/sdk/lib/stdcompat/include/lib/stdcompat/functional.h", "repo/sdk/lib/stdcompat/include/lib/stdcompat/internal/bit.h", "repo/sdk/lib/stdcompat/include/lib/stdcompat/optional.h", "repo/sdk/lib/stdcompat/include/lib/stdcompat/type_traits.h", diff --git a/third_party/fuchsia/BUILD.gn b/third_party/fuchsia/BUILD.gn index c6fd56aa05..2773a80d15 100644 --- a/third_party/fuchsia/BUILD.gn +++ b/third_party/fuchsia/BUILD.gn @@ -68,6 +68,7 @@ pw_source_set("stdcompat") { public_configs = [ ":stdcompat_public_include_path" ] public = [ "repo/sdk/lib/stdcompat/include/lib/stdcompat/bit.h", + "repo/sdk/lib/stdcompat/include/lib/stdcompat/functional.h", "repo/sdk/lib/stdcompat/include/lib/stdcompat/memory.h", "repo/sdk/lib/stdcompat/include/lib/stdcompat/optional.h", "repo/sdk/lib/stdcompat/include/lib/stdcompat/type_traits.h", diff --git a/third_party/fuchsia/CMakeLists.txt b/third_party/fuchsia/CMakeLists.txt index c7cf222c3e..1efc5d0db9 100644 --- a/third_party/fuchsia/CMakeLists.txt +++ b/third_party/fuchsia/CMakeLists.txt @@ -34,6 +34,7 @@ pw_add_library(pw_third_party.fuchsia.fit INTERFACE pw_add_library(pw_third_party.fuchsia.stdcompat INTERFACE HEADERS repo/sdk/lib/stdcompat/include/lib/stdcompat/bit.h + repo/sdk/lib/stdcompat/include/lib/stdcompat/functional.h repo/sdk/lib/stdcompat/include/lib/stdcompat/memory.h repo/sdk/lib/stdcompat/include/lib/stdcompat/optional.h repo/sdk/lib/stdcompat/include/lib/stdcompat/type_traits.h diff --git a/third_party/fuchsia/copy.bara.sky b/third_party/fuchsia/copy.bara.sky index 49bb562fac..7d51519e8c 100644 --- a/third_party/fuchsia/copy.bara.sky +++ b/third_party/fuchsia/copy.bara.sky @@ -26,6 +26,7 @@ fuchsia_repo_files = [ "sdk/lib/fit/test/function_tests.cc", # stdcompat "sdk/lib/stdcompat/include/lib/stdcompat/bit.h", + "sdk/lib/stdcompat/include/lib/stdcompat/functional.h", "sdk/lib/stdcompat/include/lib/stdcompat/memory.h", "sdk/lib/stdcompat/include/lib/stdcompat/optional.h", "sdk/lib/stdcompat/include/lib/stdcompat/type_traits.h", diff --git a/third_party/fuchsia/pigweed_adaptations.patch b/third_party/fuchsia/pigweed_adaptations.patch index e7e9aa3b67..4f7ea5b616 100644 --- a/third_party/fuchsia/pigweed_adaptations.patch +++ b/third_party/fuchsia/pigweed_adaptations.patch @@ -1,4 +1,4 @@ -# Copyright 2022 The Pigweed Authors +# Copyright 2023 The Pigweed Authors # # Licensed under the Apache License, Version 2.0 (the "License"); you may not # use this file except in compliance with the License. You may obtain a copy of @@ -114,7 +114,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/nullable.h b/t diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h --- a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h +++ b/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h -@@ -54,6 +54,8 @@ +@@ -55,6 +55,8 @@ // // fit::result with a different "success" vluae type (or // // fit::result). @@ -123,19 +123,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi namespace fit { // Convenience type to indicate failure without elaboration. -@@ -248,7 +250,10 @@ class LIB_FIT_NODISCARD result { - - // Implicit conversion from fit::failed. This overload is only enabled when the error type E is - // fit::failed. -- constexpr result(failed_or_none) : storage_{::fit::internal::error_v, failed{}} {} -+ constexpr result(failed_or_none) : storage_ { -+ ::fit::internal::error_v, failed {} -+ } -+ {} - - // Implicit conversion from success, where T is constructible from U. - template > = true> -@@ -279,25 +284,25 @@ class LIB_FIT_NODISCARD result { +@@ -280,25 +282,25 @@ class LIB_FIT_NODISCARD result { if (is_error()) { return storage_.error_or_value.error; } @@ -165,7 +153,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi } // Moves the underlying error and returns it as an instance of fit::error, simplifying -@@ -308,7 +313,7 @@ class LIB_FIT_NODISCARD result { +@@ -309,7 +311,7 @@ class LIB_FIT_NODISCARD result { if (is_error()) { return error(std::move(storage_.error_or_value.error)); } @@ -174,7 +162,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi } // Accessors for the underlying value. -@@ -318,25 +323,25 @@ class LIB_FIT_NODISCARD result { +@@ -319,25 +321,25 @@ class LIB_FIT_NODISCARD result { if (is_ok()) { return storage_.error_or_value.value; } @@ -204,7 +192,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi } // Moves the underlying value and returns it as an instance of fit::success, simplifying -@@ -347,7 +352,7 @@ class LIB_FIT_NODISCARD result { +@@ -348,7 +350,7 @@ class LIB_FIT_NODISCARD result { if (is_ok()) { return success(std::move(storage_.error_or_value.value)); } @@ -213,7 +201,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi } // Contingent accessors for the underlying value. -@@ -376,13 +381,13 @@ class LIB_FIT_NODISCARD result { +@@ -377,13 +379,13 @@ class LIB_FIT_NODISCARD result { if (is_ok()) { return ::fit::internal::arrow_operator::forward(storage_.error_or_value.value); } @@ -229,7 +217,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi } // Accessors for the underlying value. This is a syntax sugar for value(). -@@ -405,7 +410,7 @@ class LIB_FIT_NODISCARD result { +@@ -406,7 +408,7 @@ class LIB_FIT_NODISCARD result { storage_.error_or_value.error += std::move(error.value_); return *this; } @@ -237,20 +225,8 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi + PW_ASSERT(false); } - constexpr void swap(result& other) { -@@ -453,7 +458,10 @@ class LIB_FIT_NODISCARD result { - - // Implicit conversion from fit::failure. This overload is only enabled when the error type E is - // fit::failed. -- constexpr result(failure_or_none) : storage_{::fit::internal::error_v, failed{}} {} -+ constexpr result(failure_or_none) : storage_ { -+ ::fit::internal::error_v, failed {} -+ } -+ {} - - // Implicit conversion from fit::success<>. - constexpr result(success<>) : storage_{::fit::internal::value_v} {} -@@ -478,25 +486,25 @@ class LIB_FIT_NODISCARD result { + // Maps a result to a result by transforming the error through +@@ -517,25 +519,25 @@ class LIB_FIT_NODISCARD result { if (is_error()) { return storage_.error_or_value.error; } @@ -280,7 +256,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi } // Moves the underlying error and returns it as an instance of fit::error, simplifying -@@ -507,7 +515,7 @@ class LIB_FIT_NODISCARD result { +@@ -546,7 +548,7 @@ class LIB_FIT_NODISCARD result { if (is_error()) { return error(std::move(storage_.error_or_value.error)); } @@ -289,7 +265,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi } // Augments the error value of the result with the given value. The operator E::operator+=(F) must -@@ -521,7 +529,7 @@ class LIB_FIT_NODISCARD result { +@@ -560,7 +562,7 @@ class LIB_FIT_NODISCARD result { storage_.error_or_value.error += std::move(error.value_); return *this; } @@ -297,4 +273,4 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi + PW_ASSERT(false); } - constexpr void swap(result& other) { + // Maps a result to a result by transforming the error through