diff options
| author | Frederic L <frederic.laing.development@gmail.com> | 2018-10-30 05:03:25 +0100 | 
|---|---|---|
| committer | bunnei <bunneidev@gmail.com> | 2018-10-30 00:03:25 -0400 | 
| commit | 7a5eda59146306dedaf3e6f07f97a8c6898543dd (patch) | |
| tree | 78e07b43fb0113f95e1c8e9426d3b394b9524d4e /src/core/hle | |
| parent | adf26ae668eada321b69e52be40300110e47aa56 (diff) | |
global: Use std::optional instead of boost::optional (#1578)
* get rid of boost::optional
* Remove optional references
* Use std::reference_wrapper for optional references
* Fix clang format
* Fix clang format part 2
* Adressed feedback
* Fix clang format and MacOS build
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 8 | ||||
| -rw-r--r-- | src/core/hle/service/acc/profile_manager.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/am/am.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/nvflinger/buffer_queue.cpp | 8 | ||||
| -rw-r--r-- | src/core/hle/service/nvflinger/buffer_queue.h | 7 | ||||
| -rw-r--r-- | src/core/hle/service/nvflinger/nvflinger.cpp | 12 | ||||
| -rw-r--r-- | src/core/hle/service/vi/vi.cpp | 9 | 
7 files changed, 25 insertions, 23 deletions
| diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 59bc9e0af..dd5cd9ced 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -4,9 +4,9 @@  #include <algorithm>  #include <cinttypes> +#include <optional>  #include <vector> -#include <boost/optional.hpp>  #include <boost/range/algorithm_ext/erase.hpp>  #include "common/assert.h" @@ -94,7 +94,7 @@ void Thread::CancelWakeupTimer() {      CoreTiming::UnscheduleEventThreadsafe(kernel.ThreadWakeupCallbackEventType(), callback_handle);  } -static boost::optional<s32> GetNextProcessorId(u64 mask) { +static std::optional<s32> GetNextProcessorId(u64 mask) {      for (s32 index = 0; index < Core::NUM_CPU_CORES; ++index) {          if (mask & (1ULL << index)) {              if (!Core::System::GetInstance().Scheduler(index).GetCurrentThread()) { @@ -142,7 +142,7 @@ void Thread::ResumeFromWait() {      status = ThreadStatus::Ready; -    boost::optional<s32> new_processor_id = GetNextProcessorId(affinity_mask); +    std::optional<s32> new_processor_id = GetNextProcessorId(affinity_mask);      if (!new_processor_id) {          new_processor_id = processor_id;      } @@ -369,7 +369,7 @@ void Thread::ChangeCore(u32 core, u64 mask) {          return;      } -    boost::optional<s32> new_processor_id{GetNextProcessorId(affinity_mask)}; +    std::optional<s32> new_processor_id{GetNextProcessorId(affinity_mask)};      if (!new_processor_id) {          new_processor_id = processor_id; diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index 3cac1b4ff..c08394e4c 100644 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp @@ -195,7 +195,7 @@ std::size_t ProfileManager::GetOpenUserCount() const {  /// Checks if a user id exists in our profile manager  bool ProfileManager::UserExists(UUID uuid) const { -    return GetUserIndex(uuid) != std::nullopt; +    return GetUserIndex(uuid).has_value();  }  bool ProfileManager::UserExistsIndex(std::size_t index) const { diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 59aafd616..ac3ff9f20 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -743,7 +743,7 @@ void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) {      Account::ProfileManager profile_manager{};      const auto uuid = profile_manager.GetUser(Settings::values.current_user); -    ASSERT(uuid != std::nullopt); +    ASSERT(uuid);      params.current_user = uuid->uuid;      IPC::ResponseBuilder rb{ctx, 2, 0, 1}; diff --git a/src/core/hle/service/nvflinger/buffer_queue.cpp b/src/core/hle/service/nvflinger/buffer_queue.cpp index fd98d541d..630ebbfc7 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.cpp +++ b/src/core/hle/service/nvflinger/buffer_queue.cpp @@ -31,7 +31,7 @@ void BufferQueue::SetPreallocatedBuffer(u32 slot, const IGBPBuffer& igbp_buffer)      buffer_wait_event->Signal();  } -boost::optional<u32> BufferQueue::DequeueBuffer(u32 width, u32 height) { +std::optional<u32> BufferQueue::DequeueBuffer(u32 width, u32 height) {      auto itr = std::find_if(queue.begin(), queue.end(), [&](const Buffer& buffer) {          // Only consider free buffers. Buffers become free once again after they've been Acquired          // and Released by the compositor, see the NVFlinger::Compose method. @@ -44,7 +44,7 @@ boost::optional<u32> BufferQueue::DequeueBuffer(u32 width, u32 height) {      });      if (itr == queue.end()) { -        return boost::none; +        return {};      }      itr->status = Buffer::Status::Dequeued; @@ -70,12 +70,12 @@ void BufferQueue::QueueBuffer(u32 slot, BufferTransformFlags transform,      itr->crop_rect = crop_rect;  } -boost::optional<const BufferQueue::Buffer&> BufferQueue::AcquireBuffer() { +std::optional<std::reference_wrapper<const BufferQueue::Buffer>> BufferQueue::AcquireBuffer() {      auto itr = std::find_if(queue.begin(), queue.end(), [](const Buffer& buffer) {          return buffer.status == Buffer::Status::Queued;      });      if (itr == queue.end()) -        return boost::none; +        return {};      itr->status = Buffer::Status::Acquired;      return *itr;  } diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h index 50b767732..2fe81a560 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.h +++ b/src/core/hle/service/nvflinger/buffer_queue.h @@ -4,8 +4,9 @@  #pragma once +#include <optional>  #include <vector> -#include <boost/optional.hpp> +  #include "common/common_funcs.h"  #include "common/math_util.h"  #include "common/swap.h" @@ -73,11 +74,11 @@ public:      };      void SetPreallocatedBuffer(u32 slot, const IGBPBuffer& igbp_buffer); -    boost::optional<u32> DequeueBuffer(u32 width, u32 height); +    std::optional<u32> DequeueBuffer(u32 width, u32 height);      const IGBPBuffer& RequestBuffer(u32 slot) const;      void QueueBuffer(u32 slot, BufferTransformFlags transform,                       const MathUtil::Rectangle<int>& crop_rect); -    boost::optional<const Buffer&> AcquireBuffer(); +    std::optional<std::reference_wrapper<const Buffer>> AcquireBuffer();      void ReleaseBuffer(u32 slot);      u32 Query(QueryType type); diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index d47b6f659..214e6d1b3 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp @@ -3,7 +3,7 @@  // Refer to the license.txt file included.  #include <algorithm> -#include <boost/optional.hpp> +#include <optional>  #include "common/alignment.h"  #include "common/assert.h" @@ -134,7 +134,7 @@ void NVFlinger::Compose() {          MicroProfileFlip(); -        if (buffer == boost::none) { +        if (!buffer) {              auto& system_instance = Core::System::GetInstance();              // There was no queued buffer to draw, render previous frame @@ -143,7 +143,7 @@ void NVFlinger::Compose() {              continue;          } -        auto& igbp_buffer = buffer->igbp_buffer; +        auto& igbp_buffer = buffer->get().igbp_buffer;          // Now send the buffer to the GPU for drawing.          // TODO(Subv): Support more than just disp0. The display device selection is probably based @@ -152,10 +152,10 @@ void NVFlinger::Compose() {          ASSERT(nvdisp);          nvdisp->flip(igbp_buffer.gpu_buffer_id, igbp_buffer.offset, igbp_buffer.format, -                     igbp_buffer.width, igbp_buffer.height, igbp_buffer.stride, buffer->transform, -                     buffer->crop_rect); +                     igbp_buffer.width, igbp_buffer.height, igbp_buffer.stride, +                     buffer->get().transform, buffer->get().crop_rect); -        buffer_queue->ReleaseBuffer(buffer->slot); +        buffer_queue->ReleaseBuffer(buffer->get().slot);      }  } diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 184537daa..d764b2406 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -6,9 +6,10 @@  #include <array>  #include <cstring>  #include <memory> +#include <optional>  #include <type_traits>  #include <utility> -#include <boost/optional.hpp> +  #include "common/alignment.h"  #include "common/assert.h"  #include "common/common_funcs.h" @@ -506,9 +507,9 @@ private:              IGBPDequeueBufferRequestParcel request{ctx.ReadBuffer()};              const u32 width{request.data.width};              const u32 height{request.data.height}; -            boost::optional<u32> slot = buffer_queue->DequeueBuffer(width, height); +            std::optional<u32> slot = buffer_queue->DequeueBuffer(width, height); -            if (slot != boost::none) { +            if (slot) {                  // Buffer is available                  IGBPDequeueBufferResponseParcel response{*slot};                  ctx.WriteBuffer(response.Serialize()); @@ -520,7 +521,7 @@ private:                          Kernel::ThreadWakeupReason reason) {                          // Repeat TransactParcel DequeueBuffer when a buffer is available                          auto buffer_queue = nv_flinger->GetBufferQueue(id); -                        boost::optional<u32> slot = buffer_queue->DequeueBuffer(width, height); +                        std::optional<u32> slot = buffer_queue->DequeueBuffer(width, height);                          IGBPDequeueBufferResponseParcel response{*slot};                          ctx.WriteBuffer(response.Serialize());                          IPC::ResponseBuilder rb{ctx, 2}; | 
