aboutsummaryrefslogtreecommitdiff
path: root/include/cru
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2024-06-24 00:06:25 +0800
committercrupest <crupest@outlook.com>2024-06-25 00:12:29 +0800
commit807c1dfe8a897f9c61bf3549ff2566917b53023b (patch)
tree8f0bfed314747ff570fa99577e8954060194ed7f /include/cru
parent2f5651cd1a1efb136179cdbcb3b29ed0cc11ca2a (diff)
downloadcru-807c1dfe8a897f9c61bf3549ff2566917b53023b.tar.gz
cru-807c1dfe8a897f9c61bf3549ff2566917b53023b.tar.bz2
cru-807c1dfe8a897f9c61bf3549ff2566917b53023b.zip
feat: fix linux build, complete PosixSpawnSubProcess.
NEED TEST: BufferStream, AutoReadStream, SubProcess.
Diffstat (limited to 'include/cru')
-rw-r--r--include/cru/common/Buffer.h4
-rw-r--r--include/cru/common/PreConfig.h2
-rw-r--r--include/cru/common/io/AutoReadStream.h9
-rw-r--r--include/cru/common/platform/unix/PosixSpawnSubProcess.h6
-rw-r--r--include/cru/ui/document/TextDocumentElement.h2
-rw-r--r--include/cru/ui/render/MeasureRequirement.h5
6 files changed, 14 insertions, 14 deletions
diff --git a/include/cru/common/Buffer.h b/include/cru/common/Buffer.h
index 2c3b7b87..bc2e2a26 100644
--- a/include/cru/common/Buffer.h
+++ b/include/cru/common/Buffer.h
@@ -91,6 +91,8 @@ class Buffer final {
Index PushBack(const std::byte* other, Index other_size,
bool use_memmove = false);
+ void PushBackCount(Index count);
+
/**
* @brief Move forward the used-begin ptr.
* @return The actual size moved forward.
@@ -146,6 +148,8 @@ class Buffer final {
void Move_(Buffer&& other) noexcept;
void Delete_() noexcept;
+ void AssertValid();
+
private:
std::byte* ptr_;
Index size_;
diff --git a/include/cru/common/PreConfig.h b/include/cru/common/PreConfig.h
index ba0f5bd8..3f26c589 100644
--- a/include/cru/common/PreConfig.h
+++ b/include/cru/common/PreConfig.h
@@ -1,3 +1,5 @@
+// IWYU pragma: always_keep
+
#pragma once
#ifdef _MSC_VER
diff --git a/include/cru/common/io/AutoReadStream.h b/include/cru/common/io/AutoReadStream.h
index 4ba4066f..2887b319 100644
--- a/include/cru/common/io/AutoReadStream.h
+++ b/include/cru/common/io/AutoReadStream.h
@@ -1,11 +1,9 @@
#pragma once
-#include "../Buffer.h"
+#include "../SelfResolvable.h"
#include "BufferStream.h"
#include "Stream.h"
-#include <condition_variable>
-#include <list>
#include <mutex>
#include <thread>
@@ -33,7 +31,8 @@ struct AutoReadStreamOptions {
* @brief A stream that wraps another stream and auto read it into a buffer in a
* background thread.
*/
-class CRU_BASE_API AutoReadStream : public Stream {
+class CRU_BASE_API AutoReadStream : public Stream,
+ public SelfResolvable<AutoReadStream> {
public:
/**
* @brief Wrap a stream and auto read it in background.
@@ -71,7 +70,5 @@ class CRU_BASE_API AutoReadStream : public Stream {
Index size_per_read_;
std::unique_ptr<BufferStream> buffer_stream_;
std::mutex buffer_stream_mutex_;
-
- std::thread background_thread_;
};
} // namespace cru::io
diff --git a/include/cru/common/platform/unix/PosixSpawnSubProcess.h b/include/cru/common/platform/unix/PosixSpawnSubProcess.h
index 249b8043..9c303700 100644
--- a/include/cru/common/platform/unix/PosixSpawnSubProcess.h
+++ b/include/cru/common/platform/unix/PosixSpawnSubProcess.h
@@ -2,7 +2,9 @@
#include "../../PreConfig.h"
-#ifdef CRU_PLATFORM_UNIX
+#ifndef CRU_PLATFORM_UNIX
+#error "This file can only be included on unix."
+#endif
#include "../../Base.h"
#include "../../SubProcess.h"
@@ -46,5 +48,3 @@ class PosixSpawnSubProcess : public PlatformSubProcessBase {
std::unique_ptr<io::AutoReadStream> stderr_buffer_stream_;
};
} // namespace cru::platform::unix
-
-#endif
diff --git a/include/cru/ui/document/TextDocumentElement.h b/include/cru/ui/document/TextDocumentElement.h
index f7205b59..93b4933b 100644
--- a/include/cru/ui/document/TextDocumentElement.h
+++ b/include/cru/ui/document/TextDocumentElement.h
@@ -13,7 +13,7 @@ struct TextStyleTag {};
using TextStyle = Bitmask<details::TextStyleTag>;
struct TextStyles {
- static constexpr TextStyle Normal;
+ static constexpr TextStyle Normal{0x0};
static constexpr TextStyle Bold{0x1};
static constexpr TextStyle Italic{0x2};
};
diff --git a/include/cru/ui/render/MeasureRequirement.h b/include/cru/ui/render/MeasureRequirement.h
index 832b936c..ace52ef6 100644
--- a/include/cru/ui/render/MeasureRequirement.h
+++ b/include/cru/ui/render/MeasureRequirement.h
@@ -24,14 +24,11 @@ class MeasureLength final {
constexpr MeasureLength() : MeasureLength(tag_not_specify) {}
constexpr MeasureLength(tag_not_specify_t) : length_(-1) {}
- constexpr MeasureLength(float length) : length_(length) {
- Expects(length >= 0);
- }
+ constexpr MeasureLength(float length) : length_(length) {}
MeasureLength(const MeasureLength& other) = default;
constexpr MeasureLength& operator=(const MeasureLength& other) = default;
constexpr MeasureLength& operator=(float length) {
- Expects(length >= 0);
length_ = length;
return *this;
}