Skip to content

Commit

Permalink
refactor: replace msvc literal extends
Browse files Browse the repository at this point in the history
  • Loading branch information
OEOTYAN committed Aug 19, 2024
1 parent ea5c339 commit 7788561
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 50 deletions.
18 changes: 9 additions & 9 deletions src-client/ll/core/gui/ImGuiAnsiColor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void ImFont_RenderAnsiText(
const float scale = size / font->FontSize;
const float line_height = font->FontSize * scale;
const bool word_wrap_enabled = (wrap_width > 0.0f);
const char* word_wrap_eol = NULL;
const char* word_wrap_eol = nullptr;

// Fast-forward to first visible line
const char* s = text_begin;
Expand Down Expand Up @@ -239,7 +239,7 @@ void ImFont_RenderAnsiText(
if (s >= word_wrap_eol) {
x = pos.x;
y += line_height;
word_wrap_eol = NULL;
word_wrap_eol = nullptr;

// Wrapping skips upcoming blanks
while (s < text_end) {
Expand Down Expand Up @@ -378,17 +378,17 @@ void ImDrawList_AddAnsiText(
const ImVec2& pos,
ImU32 col,
const char* text_begin,
const char* text_end = NULL,
const char* text_end = nullptr,
float wrap_width = 0.0f,
const ImVec4* cpu_fine_clip_rect = NULL
const ImVec4* cpu_fine_clip_rect = nullptr
) {
if ((col & IM_COL32_A_MASK) == 0) return;

if (text_end == NULL) text_end = text_begin + strlen(text_begin);
if (text_end == nullptr) text_end = text_begin + strlen(text_begin);
if (text_begin == text_end) return;

// Pull default font/size from the shared ImDrawListSharedData instance
if (font == NULL) font = drawList->_Data->Font;
if (font == nullptr) font = drawList->_Data->Font;
if (font_size == 0.0f) font_size = drawList->_Data->FontSize;

IM_ASSERT(font->ContainerAtlas->TexID == drawList->_TextureIdStack.back()); // Use high-level ImGui::PushFont()
Expand All @@ -413,7 +413,7 @@ void ImDrawList_AddAnsiText(
text_begin,
text_end,
wrap_width,
cpu_fine_clip_rect != NULL
cpu_fine_clip_rect != nullptr
);
}

Expand Down Expand Up @@ -470,9 +470,9 @@ void textAnsiUnformatted(const char* text, const char* text_end) {
if (window->SkipItems) return;

ImGuiContext& g = *GImGui;
IM_ASSERT(text != NULL);
IM_ASSERT(text != nullptr);
const char* text_begin = text;
if (text_end == NULL) text_end = text + strlen(text); // FIXME-OPT
if (text_end == nullptr) text_end = text + strlen(text); // FIXME-OPT

const ImVec2 text_pos(window->DC.CursorPos.x, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
const float wrap_pos_x = window->DC.TextWrapPos;
Expand Down
4 changes: 2 additions & 2 deletions src-test/server/TestMolang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ LL_AUTO_TYPE_INSTANCE_HOOK(
MolangQueryFunctionReturnType::Bool,
"default",
0,
~0ui64,
~0ull,
{}
);
ExpressionNode::registerQueryFunction(
Expand All @@ -46,7 +46,7 @@ LL_AUTO_TYPE_INSTANCE_HOOK(
MolangQueryFunctionReturnType::Number,
"default",
0,
~0ui64,
~0ull,
{}
);
auto parm = RenderParams();
Expand Down
16 changes: 8 additions & 8 deletions src-test/server/TestNbt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ LL_AUTO_TYPE_INSTANCE_HOOK(NbtTest, HookPriority::Normal, ServerInstance, &Serve
auto nbt = CompoundTag{
{"anull", nullptr },
{"string?", R"(streee _ _o-ix 我超, utf8 "\asfa%"*)##q)$\\"\Q34\\""'':)"_tag},
{"1num", 1 },
{"nums", 3i16 },
{"byte", 127i8 },
{"1num", 1 },
{"nums", (int16)3 },
{"byte", (int8)127 },
{"list", ListTag{5_b, ByteTag{true}, ByteTag{false}, -2_b} },
{"compound",
CompoundTag{
{"float", 0.1f},
{"long", 10000ui64},
{"long", 10000ull},
{"double", 0.3},
{"sdouble", 1.0},
} },
Expand All @@ -38,9 +38,9 @@ LL_AUTO_TYPE_INSTANCE_HOOK(NbtTest, HookPriority::Normal, ServerInstance, &Serve


nlohmann::json j{
{"num", 1 },
{"nums", 3i16 },
{"byte", 127i8}
{"num", 1 },
{"nums", (int16)3 },
{"byte", (int8)127}
};
j["some"]["new"]["json"] = 2;

Expand Down Expand Up @@ -108,7 +108,7 @@ LL_AUTO_TYPE_INSTANCE_HOOK(NbtTest, HookPriority::Normal, ServerInstance, &Serve
"{}, at: \"{}\"",
nbt2.error().message(),
std::string_view{
snbt2.data() + std::max(0i64, (int64)iter - 8i64),
snbt2.data() + std::max(0ll, (int64)iter - 8ll),
snbt2.data() + std::min(snbt2.size() - 1, iter + 8)
}
);
Expand Down
36 changes: 18 additions & 18 deletions src-test/server/customWorldGenerator/MyWorldGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@
// // v113.mRandom.mObject.mTest_OnlyUsedDeterministically = 0;
// // Core::Random::_setSeed(&v113.mRandom.mObject, (unsigned int)v12);
// // v113.mRandom.mThreadIdInitialized = 0;
// //*(_QWORD*)&v113.mRandom.mThreadId._Id = 0i64;
// //*(_QWORD*)&v113.mRandom.mThreadId._Id = 0ll;
// // LODWORD(v12) = this->mLevel->getSeed(this->mLevel);
// // Bedrock::Application::ThreadOwner<Core::Random>::_assertSameThreadID(&v113.mRandom);
// // Core::Random::_setSeed(&v113.mRandom.mObject, (unsigned int)v12);
Expand All @@ -354,10 +354,10 @@
// // if (_TSS3 == -1) {
// // if (label_305._Mypair._Myval2._Myres >= 0x10) v18 =
// (std::string*)label_305._Mypair._Myval2._Bx._Ptr;
// // v91._Mypair._Myval2._Bx._Ptr = 0i64;
// // v91._Mypair._Myval2._Mysize = 0i64;
// // v91._Mypair._Myval2._Myres = 15i64;
// // v25 = -1i64;
// // v91._Mypair._Myval2._Bx._Ptr = 0ll;
// // v91._Mypair._Myval2._Mysize = 0ll;
// // v91._Mypair._Myval2._Myres = 15ll;
// // v25 = -1ll;
// // do ++v25;
// // while (Core::Profile::Area::CHUNK_LOAD_SYSTEM_2[v25]);
// // std::string::assign(&v91, "Chunk load system", v25);
Expand Down Expand Up @@ -405,7 +405,7 @@
// // v22 = 44 * (spikes._Mypair._Myval2._Myend - Myfirst);
// // v23 = Myfirst;
// // if (v22 >= 0x1000) {
// // v22 += 39i64;
// // v22 += 39ll;
// // Myfirst = *(SpikeFeature::EndSpike**)&Myfirst[-1].mTopBoundingBox.max.y;
// // if ((unsigned __int64)((char*)v23 - (char*)Myfirst - 8) > 0x1F)
// _invalid_parameter_noinfo_noreturn();
Expand All @@ -431,10 +431,10 @@
// // if (_TSS6 == -1) {
// // if (label_323._Mypair._Myval2._Myres >= 0x10)
// // v27 = (std::string*)label_323._Mypair._Myval2._Bx._Ptr;
// // v92._Mypair._Myval2._Bx._Ptr = 0i64;
// // v92._Mypair._Myval2._Mysize = 0i64;
// // v92._Mypair._Myval2._Myres = 15i64;
// // v31 = -1i64;
// // v92._Mypair._Myval2._Bx._Ptr = 0ll;
// // v92._Mypair._Myval2._Mysize = 0ll;
// // v92._Mypair._Myval2._Myres = 15ll;
// // v31 = -1ll;
// // do ++v31;
// // while (Core::Profile::Area::CHUNK_LOAD_SYSTEM_2[v31]);
// // std::string::assign(&v92, "Chunk load system", v31);
Expand Down Expand Up @@ -471,7 +471,7 @@
// // featurePlacement.y = v29 + origin.y;
// // featurePlacement.z = (v30 & 0xF) + 8 + origin.z;
// // memset(&endIslands, 0, sizeof(endIslands));
// // Feature::Feature(&endIslands, 0i64);
// // Feature::Feature(&endIslands, 0ll);
// // endIslands.__vftable = (EndIslandFeature_vtbl*)EndIslandFeature::`vftable';
// // EndIslandFeature::place(
// // &endIslands,
Expand Down Expand Up @@ -501,10 +501,10 @@
// // if (_TSS8 == -1) {
// // if (label_338._Mypair._Myval2._Myres >= 0x10)
// // v32 = (std::string*)label_338._Mypair._Myval2._Bx._Ptr;
// // v93._Mypair._Myval2._Bx._Ptr = 0i64;
// // v93._Mypair._Myval2._Mysize = 0i64;
// // v93._Mypair._Myval2._Myres = 15i64;
// // v57 = -1i64;
// // v93._Mypair._Myval2._Bx._Ptr = 0ll;
// // v93._Mypair._Myval2._Mysize = 0ll;
// // v93._Mypair._Myval2._Myres = 15ll;
// // v57 = -1ll;
// // do ++v57;
// // while (Core::Profile::Area::CHUNK_LOAD_SYSTEM_2[v57]);
// // std::string::assign(&v93, "Chunk load system", v57);
Expand Down Expand Up @@ -549,7 +549,7 @@
// // v85.y = v38 + origin.y;
// // v85.z = v36 + origin.z;
// // v39 = BlockSource::getBlock(&source, &v85)->mLegacyBlock.ptr_;
// // if (!v39) gsl::details::terminate(0i64);
// // if (!v39) gsl::details::terminate(0ll);
// // Hash = HashedString::getHash(&v39->mNameInfo.mFullName);
// // if (Hash == HashedString::getHash(&VanillaBlockTypeIds::EndStone)) {
// // target.x = v35 + origin.x;
Expand Down Expand Up @@ -582,7 +582,7 @@
// // gatewayPos.y = v45 + v46 % 7 + 3 + origin.y;
// // gatewayPos.z = v43 + origin.z;
// // memset(&v89, 0, sizeof(v89));
// // Feature::Feature(&v89, 0i64);
// // Feature::Feature(&v89, 0ll);
// // v89.__vftable = (Feature_vtbl*)EndGatewayFeature::`vftable'; EndGatewayFeature::place(
// // (EndGatewayFeature*)&v89,
// // &source,
Expand Down Expand Up @@ -960,7 +960,7 @@
//
// void
// prepareHeights(TheEndGenerator* this, BlockVolume* box, const ChunkPos* chunkPos, bool factorInBeardsAndShavers) {
// TheEndGenerator::_prepareHeights(this, box, chunkPos, factorInBeardsAndShavers, 0i64, 0);
// TheEndGenerator::_prepareHeights(this, box, chunkPos, factorInBeardsAndShavers, 0ll, 0);
// }
//};
//
Expand Down
7 changes: 4 additions & 3 deletions src/ll/api/io/Pipe_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ static void createWinPipe(HANDLE& hRead, HANDLE& hWrite, size_t size, bool nowai
&attributes
);
SECURITY_ATTRIBUTES attributes2 = {sizeof(SECURITY_ATTRIBUTES), 0, true};
hWrite = ::CreateFile(pipeName.c_str(), GENERIC_WRITE, 0, &attributes2, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
hWrite =
::CreateFile(pipeName.c_str(), GENERIC_WRITE, 0, &attributes2, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr);

::ConnectNamedPipe(hRead, NULL);
::ConnectNamedPipe(hRead, nullptr);
}

Pipe::Pipe(size_t size, bool nowait) { createWinPipe(hRead, hWrite, size, nowait); }
Expand All @@ -39,7 +40,7 @@ std::string Pipe::read() {
DWORD cbRead{0};

// Read from the pipe.
fSuccess = ReadFile(hRead, buf, sizeof(buf), &cbRead, NULL);
fSuccess = ReadFile(hRead, buf, sizeof(buf), &cbRead, nullptr);

if (cbRead > 0) result.append(buf, cbRead);

Expand Down
4 changes: 2 additions & 2 deletions src/ll/api/io/StdoutRedirector_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ StdoutRedirector::StdoutRedirector(void* outputHandle, ProcessChannel channels)
: outputHandle(outputHandle),
m_channels(channels) {
if (m_channels & StandardOutput) {
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stdout, nullptr, _IONBF, 0);
::SetStdHandle(STD_OUTPUT_HANDLE, outputHandle);
}
if (m_channels & StandardError) {
setvbuf(stderr, NULL, _IONBF, 0);
setvbuf(stderr, nullptr, _IONBF, 0);
::SetStdHandle(STD_ERROR_HANDLE, outputHandle);
}
int fd = _open_osfhandle((intptr_t)outputHandle, _O_WRONLY | _O_U8TEXT);
Expand Down
2 changes: 1 addition & 1 deletion src/ll/api/memory/Closure.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace ll::memory {
namespace detail {
static constexpr size_t closureMagicNumber = 0x58ffffbffdffffafui64;
static constexpr size_t closureMagicNumber = 0x58ffffbffdffffafull;

LLAPI size_t getVolatileOffset(void*);
LLAPI void initNativeClosure(void* self, void* impl, size_t offset);
Expand Down
2 changes: 1 addition & 1 deletion src/ll/api/utils/ErrorUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ LLNDAPI std::system_error getLastSystemError() noexcept;

LLNDAPI std::exception_ptr createExceptionPtr(void*) noexcept;
#ifdef __cpp_lib_stacktrace
LLNDAPI std::stacktrace stacktraceFromCurrentException(size_t skip = 0, size_t maxDepth = ~0ui64);
LLNDAPI std::stacktrace stacktraceFromCurrentException(size_t skip = 0, size_t maxDepth = ~0ull);
#endif
LLNDAPI std::string makeExceptionString(std::exception_ptr ePtr) noexcept;

Expand Down
2 changes: 1 addition & 1 deletion src/ll/api/utils/HashUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace ll::inline utils::hash_utils {

template <class T>
constexpr void hashCombine(T const& v, size_t& seed) {
seed ^= v + 0x9e3779b9ULL + (seed << 6ULL) + (seed >> 2ULL);
seed ^= v + 0x9e3779b9ull + (seed << 6ull) + (seed >> 2ull);
}

[[nodiscard]] constexpr uint64 doHash(std::string_view x) {
Expand Down
2 changes: 1 addition & 1 deletion src/ll/core/CrashLogger_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "DbgHelp.h"

namespace ll::inline utils::error_utils {
std::stacktrace stacktraceFromContext(optional_ref<_CONTEXT const> context, size_t skip = 0, size_t maxDepth = ~0ui64);
std::stacktrace stacktraceFromContext(optional_ref<_CONTEXT const> context, size_t skip = 0, size_t maxDepth = ~0ull);
}

namespace ll {
Expand Down
4 changes: 2 additions & 2 deletions src/ll/core/tweak/MemoryOperators_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class StdMemoryAllocator : public ::Bedrock::Memory::IMemoryAllocator {

virtual void alignedRelease(void* ptr) { _aligned_free(ptr); }

virtual uint64 getUsableSize(void* ptr) { return ptr ? _msize(ptr) : 0ui64; }
virtual uint64 getUsableSize(void* ptr) { return ptr ? _msize(ptr) : 0ull; }

virtual void logCurrentState() {
HEAP_SUMMARY summary{.cb = sizeof(HEAP_SUMMARY)};
Expand Down Expand Up @@ -125,7 +125,7 @@ class MimallocMemoryAllocatorWithCheck : public MimallocMemoryAllocator {
if (mi_is_in_heap_region(ptr)) [[likely]] {
return mi_usable_size(ptr);
} else {
return ptr ? _msize(ptr) : 0ui64;
return ptr ? _msize(ptr) : 0ull;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/mc/deps/core/string/HashedString.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class HashedString {

[[nodiscard]] constexpr static uint64 computeHash(std::string_view str) {
if (str.empty()) return 0;
uint64 hash = 0xCBF29CE484222325ULL;
uint64 hash = 0xCBF29CE484222325ull;
for (char s : str) {
hash = s ^ (0x100000001B3ULL * hash);
hash = s ^ (0x100000001B3ull * hash);
}
return hash;
}
Expand Down

0 comments on commit 7788561

Please sign in to comment.