Skip to content

Commit

Permalink
refactor: create new pch file and fix some header include problem (#1440
Browse files Browse the repository at this point in the history
)
  • Loading branch information
RimuruChan authored Jan 18, 2024
1 parent 6895366 commit 8db100a
Show file tree
Hide file tree
Showing 66 changed files with 176 additions and 155 deletions.
16 changes: 8 additions & 8 deletions .clangd
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Diagnostics:
Suppress:
Suppress:
- "-Wmicrosoft-enum-forward-reference"
- "-Wc++11-narrowing"
- "-Wc++2b-extensions"
- "-Wmicrosoft-cast"
CompileFlags:
Add:
Add:
- "-ferror-limit=0"
- "-D__FUNCTION__=\"dummy\""
- "-Yumc/_HeaderOutputPredefine.h"
- "-FImc/_HeaderOutputPredefine.h" # clangd bug can't find pch file
Remove:
- "/Yu_HeaderOutputPredefine.h"
- "/FI_HeaderOutputPredefine.h"
- '-D__FUNCTION__="dummy"'
- "-Yusrc/ll/api/Global.h"
- "-FIsrc/ll/api/Global.h" # clangd bug can't find pch file
Remove:
- "/YuGlobal.h"
- "/FIGlobal.h"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -557,3 +557,6 @@ fabric.properties

# MkDocs
/site/

# Test
src/ll/test/include_all.cpp
10 changes: 10 additions & 0 deletions src/ll/api/Global.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

#include "mc/_HeaderOutputPredefine.h"

#include "ll/api/base/Concepts.h"
#include "ll/api/base/Containers.h"
#include "ll/api/base/Macro.h"
#include "ll/api/base/Meta.h"
#include "ll/api/base/StdInt.h"
#include "ll/api/base/ToString.h"
6 changes: 3 additions & 3 deletions src/ll/api/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include "ll/api/Logger.h"

#include "ll/api/base/ErrorInfo.h"
#include "ll/api/base/Hash.h"
#include "ll/api/io/FileUtils.h"
#include "ll/api/utils/ErrorUtils.h"
#include "ll/api/utils/HashUtils.h"
#include "ll/api/utils/StringUtils.h"
#include "ll/core/Config.h"

Expand Down Expand Up @@ -68,7 +68,7 @@ void Logger::OutputStream::print(std::string_view s) const noexcept {
try {
fmt::print(
"\x1b[31mERROR IN LOGGER API:\n{}\x1b[91m\n{}\x1b[0m\n",
error_info::makeExceptionString(std::current_exception()),
error_utils::makeExceptionString(std::current_exception()),
tou8str(s)
);
} catch (...) {
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/ll/api/command/DynamicCommand.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "ll/api/command/DynamicCommand.h"

#include "ll/api/Logger.h"
#include "ll/api/base/ErrorInfo.h"
#include "ll/api/memory/Closure.h"
#include "ll/api/utils/ErrorUtils.h"
#include "ll/core/Config.h"
#include "ll/core/LeviLamina.h"

Expand Down Expand Up @@ -97,7 +97,7 @@ auto const ParameterSizeMap = std::unordered_map<ParameterType, size_t>{

inline void OutputError(const std::string& command, const std::string& func = __builtin_FUNCTION()) {
auto lock = ll::Logger::lock();
ll::error_info::printCurrentException(logger);
ll::error_utils::printCurrentException(logger);
logger.error("In Function ({})", func);
logger.error("In Command <{}>", command);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#pragma once

#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

namespace ll {
namespace ll::inline data {
template <class T>
class DependencyGraph {
struct Data {
Expand Down Expand Up @@ -121,4 +120,4 @@ class DependencyGraph {
return {sorted, unsorted};
}
};
} // namespace ll
} // namespace ll::inline data
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "ll/api/io/FileUtils.h"
#include "ll/core/LeviLamina.h"

using namespace ll;
using namespace ll::data;

class KeyValueDB::KeyValueDBImpl {
public:
Expand Down
4 changes: 2 additions & 2 deletions src/ll/api/base/KeyValueDB.h → src/ll/api/data/KeyValueDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "ll/api/base/Macro.h"

namespace ll {
namespace ll::inline data {
class KeyValueDB {
private:
class KeyValueDBImpl;
Expand Down Expand Up @@ -40,4 +40,4 @@ class KeyValueDB {
LLNDAPI std::vector<std::string> getAllKeys() const;
};

} // namespace ll
} // namespace ll::inline data
4 changes: 2 additions & 2 deletions src/ll/api/base/Version.h → src/ll/api/data/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "ll/api/utils/StringUtils.h"

namespace ll {
namespace ll::inline data {

namespace detail {

Expand Down Expand Up @@ -301,4 +301,4 @@ namespace literals {
}
} // namespace literals

} // namespace ll
} // namespace ll::inline data
6 changes: 3 additions & 3 deletions src/ll/api/event/EventBus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#include <unordered_set>

#include "ll/api/Logger.h"
#include "ll/api/base/ErrorInfo.h"
#include "ll/api/event/EmitterBase.h"
#include "ll/api/thread/SharedRecursiveMutex.h"
#include "ll/api/utils/ErrorUtils.h"
#include "ll/core/LeviLamina.h"

namespace ll::event {
Expand Down Expand Up @@ -43,7 +43,7 @@ class CallbackStream {
l->pluginPtr.expired() ? "unknown plugin" : l->pluginPtr.lock()->getManifest().name
);
} catch (...) {}
error_info::printCurrentException(logger);
error_utils::printCurrentException(logger);
}
}
}
Expand All @@ -66,7 +66,7 @@ class CallbackStream {
pluginName
);
} catch (...) {}
error_info::printCurrentException(logger);
error_utils::printCurrentException(logger);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/ll/api/event/EventId.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "ll/api/base/Hash.h"
#include "ll/api/reflection/Reflection.h"
#include "ll/api/utils/HashUtils.h"

namespace ll::event {
class EventId {
Expand All @@ -11,7 +11,7 @@ class EventId {

[[nodiscard]] constexpr explicit EventId(std::string_view name) noexcept
: name(name),
hash(ll::hash::do_hash(name)) {}
hash(ll::hash_utils::do_hash(name)) {}

[[nodiscard]] constexpr bool operator==(EventId other) const noexcept {
return hash == other.hash && name == other.name;
Expand Down
8 changes: 4 additions & 4 deletions src/ll/api/event/filesystem/FileActionEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
#include <thread>
#include <vector>

#include "ll/api/base/ErrorInfo.h"
#include "ll/api/event/Emitter.h"
#include "ll/api/event/EventBus.h"
#include "ll/api/io/FileUtils.h"
#include "ll/api/utils/ErrorUtils.h"

#include "windows.h"

Expand Down Expand Up @@ -58,7 +58,7 @@ class FileWatcher : public Emitter<emitterFactory, FileActionEvent> {

closeEvent = CreateEventW(nullptr, TRUE, FALSE, nullptr);
if (!closeEvent) {
throw ll::error_info::getWinLastError();
throw ll::error_utils::getWinLastError();
}


Expand Down Expand Up @@ -121,7 +121,7 @@ class FileWatcher : public Emitter<emitterFactory, FileActionEvent> {
switch (WaitForMultipleObjects(2, handles.data(), FALSE, INFINITE)) {
case WAIT_OBJECT_0: {
if (!GetOverlappedResult(directoryHandle, &overlapped_buffer, &bytes_returned, TRUE)) {
throw ll::error_info::getWinLastError();
throw ll::error_utils::getWinLastError();
}
async_pending = false;

Expand Down Expand Up @@ -224,7 +224,7 @@ class FileWatcher : public Emitter<emitterFactory, FileActionEvent> {
); // file with attributes to copy

if (directory == INVALID_HANDLE_VALUE) {
throw ll::error_info::getWinLastError();
throw ll::error_utils::getWinLastError();
}
return directory;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ll/api/event/server/ServerStartedEvent.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "ll/api/event/server/ServerStartedEvent.h"
#include "ll/api/ServerInfo.h"
#include "ll/api/event/Emitter.h"
#include "ll/api/memory/Hook.h"
#include "ll/api/service/ServerInfo.h"

#include "mc/world/events/ServerInstanceEventCoordinator.h"

Expand Down
2 changes: 1 addition & 1 deletion src/ll/api/event/server/ServerStoppingEvent.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "ll/api/event/server/ServerStoppingEvent.h"
#include "ll/api/ServerInfo.h"
#include "ll/api/event/Emitter.h"
#include "ll/api/memory/Hook.h"
#include "ll/api/service/ServerInfo.h"

#include "mc/nbt/CompoundTag.h"

Expand Down
12 changes: 6 additions & 6 deletions src/ll/api/form/ModalForm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ ModalForm::ModalForm(
Callback callback
)
: impl(std::make_unique<ModalFormImpl>(
std::move(title),
std::move(content),
std::move(buttonLeft),
std::move(buttonRight),
std::move(callback)
)) {}
std::move(title),
std::move(content),
std::move(buttonLeft),
std::move(buttonRight),
std::move(callback)
)) {}

ModalForm::~ModalForm() = default;

Expand Down
2 changes: 1 addition & 1 deletion src/ll/api/i18n/I18nAPI.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "ll/api/base/Concepts.h"
#include "ll/api/base/UnorderedStringMap.h"
#include "ll/api/base/Containers.h"
#include "ll/api/io/FileUtils.h"
#include "ll/api/utils/StringUtils.h"

Expand Down
2 changes: 1 addition & 1 deletion src/ll/api/io/FileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <filesystem>

#include "ll/api/Logger.h"
#include "ll/api/ServerInfo.h"
#include "ll/api/service/ServerInfo.h"
#include "ll/api/utils/StringUtils.h"
#include "ll/core/Config.h"

Expand Down
2 changes: 1 addition & 1 deletion src/ll/api/io/FileUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <vector>

#include "ll/api/base/Macro.h"
#include "ll/api/base/Version.h"
#include "ll/api/data/Version.h"

namespace ll::inline utils::file_utils {

Expand Down
2 changes: 1 addition & 1 deletion src/ll/api/memory/Hook.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "ll/api/memory/Hook.h"
#include "ll/api/Logger.h"
#include "ll/api/ServerInfo.h"
#include "ll/api/memory/Memory.h"
#include "ll/api/service/ServerInfo.h"
#include "ll/api/utils/StacktraceUtils.h"
#include "ll/api/utils/WinUtils.h"
#include "pl/Hook.h"
Expand Down
2 changes: 1 addition & 1 deletion src/ll/api/memory/Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "pl/SymbolProvider.h"

#include "ll/api/Logger.h"
#include "ll/api/ServerInfo.h"
#include "ll/api/service/ServerInfo.h"
#include "ll/api/thread/GlobalThreadPauser.h"
#include "ll/api/utils/StringUtils.h"
#include "ll/api/utils/WinUtils.h"
Expand Down
8 changes: 4 additions & 4 deletions src/ll/api/memory/PatchHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ namespace ll::utils {

template <size_t len>
struct PatchHelper {
uchar data[len];
uchar data[len];
using ref_t = uchar (&)[len];
constexpr bool operator==(ref_t ref) const noexcept { return memcmp(data, ref, sizeof data) == 0; }
constexpr bool operator!=(ref_t ref) const noexcept { return memcmp(data, ref, sizeof data) != 0; }
constexpr bool operator==(PatchHelper const& ref) const noexcept {
constexpr bool operator==(ref_t ref) const noexcept { return memcmp(data, ref, sizeof data) == 0; }
constexpr bool operator!=(ref_t ref) const noexcept { return memcmp(data, ref, sizeof data) != 0; }
constexpr bool operator==(PatchHelper const& ref) const noexcept {
return memcmp(data, ref.data, sizeof data) == 0;
}
constexpr bool operator!=(PatchHelper const& ref) const noexcept {
Expand Down
6 changes: 3 additions & 3 deletions src/ll/api/plugin/Manifest.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include <unordered_map>
#include <unordered_set>

#include "ll/api/base/Hash.h"
#include "ll/api/base/Version.h"
#include "ll/api/data/Version.h"
#include "ll/api/utils/HashUtils.h"

namespace ll::plugin {
struct Dependency {
Expand All @@ -23,7 +23,7 @@ template <>
struct hash<ll::plugin::Dependency> {
size_t operator()(ll::plugin::Dependency const& d) const noexcept {
size_t hash = std::hash<std::string>{}(d.name);
ll::hash::hashCombine(std::hash<std::optional<std::string>>{}(d.version), hash);
ll::hash_utils::hashCombine(std::hash<std::optional<std::string>>{}(d.version), hash);
return hash;
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/ll/api/plugin/Plugin.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "ll/api/plugin/Plugin.h"

#include "ll/api/ServerInfo.h"
#include "ll/api/event/EventBus.h"
#include "ll/api/event/server/ServerStartedEvent.h"
#include "ll/api/service/Bedrock.h"
#include "ll/api/service/ServerInfo.h"

namespace ll::plugin {

Expand Down
2 changes: 1 addition & 1 deletion src/ll/api/plugin/Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <filesystem>

#include "ll/api/Logger.h"
#include "ll/api/base/UnorderedStringMap.h"
#include "ll/api/base/Containers.h"
#include "ll/api/plugin/Manifest.h"

#include "mc/common/wrapper/optional_ref.h"
Expand Down
2 changes: 1 addition & 1 deletion src/ll/api/plugin/PluginManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <string_view>
#include <vector>

#include "ll/api/base/UnorderedStringMap.h"
#include "ll/api/base/Containers.h"
#include "ll/api/plugin/Plugin.h"

namespace ll::plugin {
Expand Down
2 changes: 1 addition & 1 deletion src/ll/api/plugin/PluginManagerRegistry.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "ll/api/base/DependencyGraph.h"
#include "ll/api/base/Macro.h"
#include "ll/api/data/DependencyGraph.h"
#include "ll/api/plugin/PluginManager.h"

namespace ll::plugin {
Expand Down
4 changes: 2 additions & 2 deletions src/ll/api/schedule/Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <spanstream>

#include "ll/api/Logger.h"
#include "ll/api/base/ErrorInfo.h"
#include "ll/api/utils/ErrorUtils.h"

namespace ll::schedule {
inline namespace task {
Expand Down Expand Up @@ -42,7 +42,7 @@ void printScheduleError() noexcept {
try {
logger.error("Error in schedule thread [{}]:", std::this_thread::get_id());
} catch (...) {}
error_info::printCurrentException(logger);
error_utils::printCurrentException(logger);
}
} // namespace detail

Expand Down
Loading

0 comments on commit 8db100a

Please sign in to comment.