diff options
| author | Per Larsson <[email protected]> | 2022-03-19 10:41:08 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2022-03-19 10:41:08 +0100 |
| commit | 703c252710cdae35a35be700fade144e994777c0 (patch) | |
| tree | 03268a46ea32553c4777ee30cc617f140665938a /zencore | |
| parent | Minor cleanup. (diff) | |
| parent | Suppress C4305 in third party includes (diff) | |
| download | zen-703c252710cdae35a35be700fade144e994777c0.tar.xz zen-703c252710cdae35a35be700fade144e994777c0.zip | |
Merge branch 'main' into streamapi
Diffstat (limited to 'zencore')
| -rw-r--r-- | zencore/compactbinary.cpp | 16 | ||||
| -rw-r--r-- | zencore/include/zencore/iobuffer.h | 17 | ||||
| -rw-r--r-- | zencore/include/zencore/logging.h | 2 | ||||
| -rw-r--r-- | zencore/include/zencore/zencore.h | 9 | ||||
| -rw-r--r-- | zencore/thread.cpp | 8 |
5 files changed, 33 insertions, 19 deletions
diff --git a/zencore/compactbinary.cpp b/zencore/compactbinary.cpp index 902ec26c8..7cc6db68a 100644 --- a/zencore/compactbinary.cpp +++ b/zencore/compactbinary.cpp @@ -1754,7 +1754,7 @@ TEST_CASE("uson") SUBCASE("CbField(None|Type|Name)") { constexpr CbFieldType FieldType = CbFieldType::None | CbFieldType::HasFieldName; - constexpr const char NoneBytes[] = {char(FieldType), 4, 'N', 'a', 'm', 'e'}; + const char NoneBytes[] = {char(FieldType), 4, 'N', 'a', 'm', 'e'}; CbFieldView NoneField(NoneBytes); CHECK(NoneField.GetSize() == sizeof(NoneBytes)); @@ -1775,7 +1775,7 @@ TEST_CASE("uson") SUBCASE("CbField(None|Type)") { constexpr CbFieldType FieldType = CbFieldType::None; - constexpr const char NoneBytes[] = {char(FieldType)}; + const char NoneBytes[] = {char(FieldType)}; CbFieldView NoneField(NoneBytes); CHECK(NoneField.GetSize() == sizeof NoneBytes); @@ -1792,14 +1792,14 @@ TEST_CASE("uson") SUBCASE("CbField(None|Name)") { constexpr CbFieldType FieldType = CbFieldType::None | CbFieldType::HasFieldName; - constexpr const char NoneBytes[] = {char(FieldType), 4, 'N', 'a', 'm', 'e'}; + const char NoneBytes[] = {char(FieldType), 4, 'N', 'a', 'm', 'e'}; CbFieldView NoneField(NoneBytes + 1, FieldType); CHECK(NoneField.GetSize() == uint64_t(sizeof NoneBytes)); CHECK(NoneField.GetName().compare("Name") == 0); CHECK(NoneField.HasName() == true); CHECK(NoneField.HasValue() == false); CHECK(NoneField.GetHash() == IoHash::HashBuffer(NoneBytes, sizeof NoneBytes)); - CHECK(NoneField.GetView() == MemoryView(&NoneBytes[1], sizeof NoneBytes - 1)); + CHECK(NoneField.GetView() == MemoryView(NoneBytes + 1, sizeof NoneBytes - 1)); MemoryView SerializedView; CHECK(NoneField.TryGetSerializedView(SerializedView) == false); @@ -1810,15 +1810,15 @@ TEST_CASE("uson") SUBCASE("CbField(None|EmptyName)") { - constexpr CbFieldType FieldType = CbFieldType::None | CbFieldType::HasFieldName; - constexpr const uint8_t NoneBytes[] = {uint8_t(FieldType), 0}; - CbFieldView NoneField(NoneBytes + 1, FieldType); + constexpr CbFieldType FieldType = CbFieldType::None | CbFieldType::HasFieldName; + const uint8_t NoneBytes[] = {uint8_t(FieldType), 0}; + CbFieldView NoneField(NoneBytes + 1, FieldType); CHECK(NoneField.GetSize() == sizeof NoneBytes); CHECK(NoneField.GetName().empty() == true); CHECK(NoneField.HasName() == true); CHECK(NoneField.HasValue() == false); CHECK(NoneField.GetHash() == IoHash::HashBuffer(NoneBytes, sizeof NoneBytes)); - CHECK(NoneField.GetView() == MemoryView(&NoneBytes[1], sizeof NoneBytes - 1)); + CHECK(NoneField.GetView() == MemoryView(NoneBytes + 1, sizeof NoneBytes - 1)); MemoryView SerializedView; CHECK(NoneField.TryGetSerializedView(SerializedView) == false); } diff --git a/zencore/include/zencore/iobuffer.h b/zencore/include/zencore/iobuffer.h index 5dbbb95bf..449236127 100644 --- a/zencore/include/zencore/iobuffer.h +++ b/zencore/include/zencore/iobuffer.h @@ -27,6 +27,10 @@ enum class ZenContentType : uint8_t kCompressedBinary = 7, kUnknownContentType = 8, kHTML = 9, + kJavaScript = 10, + kCSS = 11, + kPNG = 12, + kIcon = 13, kCOUNT }; @@ -58,6 +62,15 @@ ToString(ZenContentType ContentType) return "yaml"sv; case ZenContentType::kHTML: return "html"sv; + case ZenContentType::kJavaScript: + return "javascript"sv; + case ZenContentType::kCSS: + return "css"sv; + case ZenContentType::kPNG: + return "png"sv; + case ZenContentType::kIcon: + return "icon"sv; + } } @@ -336,7 +349,7 @@ public: /** Create a buffer which references a sequence of bytes inside another buffer */ - ZENCORE_API IoBuffer(const IoBuffer& OuterBuffer, size_t Offset, size_t SizeBytes); + ZENCORE_API IoBuffer(const IoBuffer& OuterBuffer, size_t Offset, size_t SizeBytes=~0ull); /** Create a buffer which references a range of bytes which we assume will live * for the entire life time. @@ -351,7 +364,7 @@ public: ZENCORE_API IoBuffer(EFileTag, void* FileHandle, uint64_t ChunkFileOffset, uint64_t ChunkSize); ZENCORE_API IoBuffer(EBorrowedFileTag, void* FileHandle, uint64_t ChunkFileOffset, uint64_t ChunkSize); - inline operator bool() const { return !m_Core->IsNull(); } + inline explicit operator bool() const { return !m_Core->IsNull(); } inline operator MemoryView() const& { return MemoryView(m_Core->DataPointer(), m_Core->DataBytes()); } inline void MakeOwned() { return m_Core->MakeOwned(); } [[nodiscard]] inline bool IsOwned() const { return m_Core->IsOwned(); } diff --git a/zencore/include/zencore/logging.h b/zencore/include/zencore/logging.h index 74ab0f81f..7c2deeed7 100644 --- a/zencore/include/zencore/logging.h +++ b/zencore/include/zencore/logging.h @@ -54,7 +54,7 @@ struct LogCategory #define ZEN_DEFINE_LOG_CATEGORY_STATIC(Category, Name) \ static struct LogCategory##Category : public LogCategory \ { \ - LogCategory##Category() : LogCategory(Name) {} \ + LogCategory##Category() : LogCategory(Name) {} \ } Category; #define ZEN_LOG_TRACE(Category, fmtstr, ...) \ diff --git a/zencore/include/zencore/zencore.h b/zencore/include/zencore/zencore.h index bd5e5a531..60ebd0f5f 100644 --- a/zencore/include/zencore/zencore.h +++ b/zencore/include/zencore/zencore.h @@ -72,10 +72,11 @@ #ifndef ZEN_THIRD_PARTY_INCLUDES_START # if ZEN_COMPILER_MSC -# define ZEN_THIRD_PARTY_INCLUDES_START \ - __pragma(warning(push)) __pragma(warning(disable : 4668)) /* use of undefined preprocessor macro */ \ - __pragma(warning(disable : 4267)) /* '=': conversion from 'size_t' to 'US' */ \ - __pragma(warning(disable : 4127)) +# define ZEN_THIRD_PARTY_INCLUDES_START \ + __pragma(warning(push)) __pragma(warning(disable : 4668)) /* use of undefined preprocessor macro */ \ + __pragma(warning(disable : 4305)) /* 'if': truncation from 'uint32' to 'bool' */ \ + __pragma(warning(disable : 4267)) /* '=': conversion from 'size_t' to 'US' */ \ + __pragma(warning(disable : 4127)) /* conditional expression is constant */ # elif ZEN_COMPILER_CLANG # define ZEN_THIRD_PARTY_INCLUDES_START \ _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wundef\"") \ diff --git a/zencore/thread.cpp b/zencore/thread.cpp index 7b1396f5f..c2ecc8d72 100644 --- a/zencore/thread.cpp +++ b/zencore/thread.cpp @@ -75,7 +75,7 @@ SetNameInternal(DWORD thread_id, const char* name) #endif #if ZEN_PLATFORM_LINUX -const bool bNoZombieChildren = [] () { +const bool bNoZombieChildren = []() { // When a child process exits it is put into a zombie state until the parent // collects its result. This doesn't fit the Windows-like model that Zen uses // where there is a less strict familial model and no zombification. Ignoring @@ -87,7 +87,7 @@ const bool bNoZombieChildren = [] () { Action.sa_handler = SIG_IGN; sigaction(SIGCHLD, &Action, nullptr); return true; -} (); +}(); #endif void @@ -647,10 +647,10 @@ ProcessHandle::Wait(int TimeoutMs) timespec SleepTime = {0, SleepMs * 1000 * 1000}; for (int i = 0;; i += SleepMs) { -#if ZEN_PLATFORM_MAC +# if ZEN_PLATFORM_MAC int WaitState = 0; waitpid(m_Pid, &WaitState, WNOHANG | WCONTINUED | WUNTRACED); -#endif +# endif if (kill(m_Pid, 0) < 0) { |