Skip to content

Commit

Permalink
Refactor code to remove unused files and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroAir committed Sep 24, 2024
1 parent b838cd6 commit 932ba7c
Show file tree
Hide file tree
Showing 51 changed files with 297 additions and 5,566 deletions.
2 changes: 1 addition & 1 deletion libs
Submodule libs updated 219 files
10 changes: 9 additions & 1 deletion modules/atom.io/component.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "atom/components/component.hpp"
#include "atom/components/registry.hpp"

#include "atom/function/overload.hpp"

#include "atom/io/compress.hpp"
#include "atom/io/glob.hpp"
#include "atom/io/io.hpp"
Expand Down Expand Up @@ -29,7 +31,13 @@ ATOM_MODULE(atom_io, [](Component &component) {
"Check if a pattern is recursive");
component.def("iter_dir", &iterDirectory, "Iterate a directory");
component.def("rlistdir", &rlistdir, "Recursively list a directory");
component.def<const std::string &>("glob", &glob, "Glob a list of files");
component.def("glob_s",
atom::meta::overload_cast<const std::string &>(glob),
"Glob a list of files");
component.def(
"glob_v",
atom::meta::overload_cast<const std::vector<std::string> &>(glob),
"Glob a list of files");
component.def<const std::string &>("rglob", &rglob,
"Recursively glob a list of files");
component.def("glob0", &glob0, "Glob0 a list of files");
Expand Down
10 changes: 10 additions & 0 deletions modules/atom.sysinfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ set(SOURCE_FILES
component.cpp
)

set(${PROJECT_NAME}_LIBS
loguru
atom-component
atom-sysinfo
${ZLIB_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)

# Create the module library
add_library(atom.sysinfo SHARED ${SOURCE_FILES})

target_link_libraries(atom.sysinfo ${${PROJECT_NAME}_LIBS})

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
4 changes: 2 additions & 2 deletions modules/atom.sysinfo/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ ATOM_MODULE(atom_io, [](Component &component) {
component.defType<MemoryInfo::MemorySlot>("memory_slot");
component.def_v("memory_slot_type", &MemoryInfo::MemorySlot::type,
"memory_slot", "Get memory slot type");
component.def("memory_slot_capacity", &MemoryInfo::MemorySlot::capacity,
component.def_v("memory_slot_capacity", &MemoryInfo::MemorySlot::capacity,
"memory_slot", "Get memory slot capacity");
component.def("memory_slot_clock_speed",
component.def_v("memory_slot_clock_speed",
&MemoryInfo::MemorySlot::clockSpeed, "memory_slot",
"Get memory slot clock speed");

Expand Down
1 change: 1 addition & 0 deletions src/addon/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#define pipe _pipe
#define popen _popen
#define pclose _pclose
#undef XMLDocument
// clang-format on
#else
#include <fcntl.h>
Expand Down
5 changes: 0 additions & 5 deletions src/atom/algorithm/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ auto fbase64Decode(std::span<const char> input) -> std::vector<unsigned char>;
std::string_view ciphertext, uint8_t key) -> std::string;

ATOM_INLINE constexpr auto findBase64Char(char character) -> size_t {
#pragma unroll
for (size_t index = 0; index < detail::BASE64_CHAR_COUNT; ++index) {
if (detail::BASE64_CHARS[index] == character) {
return index;
Expand Down Expand Up @@ -128,7 +127,6 @@ constexpr auto cbase64Encode(const StaticString<N> &input) {
((charArray3[2] & detail::MASK_14_BITS) >> 6);
charArray4[3] = charArray3[2] & detail::MASK_6_BITS;

#pragma unroll
for (int j = 0; j < 4; ++j) {
addCharacter(detail::BASE64_CHARS[charArray4[j]]);
}
Expand All @@ -147,7 +145,6 @@ constexpr auto cbase64Encode(const StaticString<N> &input) {
((charArray3[2] & detail::MASK_14_BITS) >> 6);
charArray4[3] = charArray3[2] & detail::MASK_6_BITS;

#pragma unroll
for (size_t j = 0; j < index % 3 + 1; ++j) {
addCharacter(detail::BASE64_CHARS[charArray4[j]]);
}
Expand Down Expand Up @@ -181,7 +178,6 @@ constexpr auto cbase64Decode(const StaticString<N> &input) {
charArray3[2] =
((charArray4[2] & detail::MASK_2_BITS) << 6) + charArray4[3];

#pragma unroll
for (index = 0; index < 3; ++index) {
addCharacter(static_cast<char>(charArray3[index]));
}
Expand All @@ -199,7 +195,6 @@ constexpr auto cbase64Decode(const StaticString<N> &input) {
charArray3[1] = ((charArray4[1] & detail::MASK_4_BITS) << 4) +
((charArray4[2] & detail::MASK_18_BITS) >> 2);

#pragma unroll
for (size_t j = 0; j < index - 1; ++j) {
addCharacter(static_cast<char>(charArray3[j]));
}
Expand Down
3 changes: 2 additions & 1 deletion src/atom/components/component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,9 @@ void Component::defBaseClass() {
template <typename Callable>
void Component::def(const std::string& name, Callable&& func,
const std::string& group, const std::string& description) {
using FuncType = std::function<std::result_of_t<Callable()>>;
m_CommandDispatcher_->def(name, group, description,
std::function(std::forward<Callable>(func)));
FuncType(std::forward<Callable>(func)));
}

template <typename Ret>
Expand Down
4 changes: 2 additions & 2 deletions src/atom/function/concept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,14 @@ concept Container = requires(T obj) {
template <typename T>
concept StringContainer = requires(T obj) {
typename T::value_type;
String<T> || Char<T>;
requires String<T> || Char<T>;
{ obj.push_back(std::declval<typename T::value_type>()) };
};

template <typename T>
concept NumberContainer = requires(T obj) {
typename T::value_type;
Number<typename T::value_type>;
requires Number<typename T::value_type>;
{ obj.push_back(std::declval<typename T::value_type>()) };
};

Expand Down
4 changes: 0 additions & 4 deletions src/atom/function/type_caster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class TypeCaster {

auto path = findConversionPath(srcInfo.value(), destInfo);
std::any result = input[i];
#pragma unroll
for (size_t j = 0; j < path.size() - 1; ++j) {
result = conversions_.at(path[j]).at(path[j + 1])(result);
}
Expand All @@ -102,7 +101,6 @@ class TypeCaster {
auto getRegisteredTypes() const -> std::vector<std::string> {
std::vector<std::string> typeNames;
typeNames.reserve(type_name_map_.size());
#pragma unroll
for (const auto& [name, info] : type_name_map_) {
typeNames.push_back(name);
}
Expand Down Expand Up @@ -143,7 +141,6 @@ class TypeCaster {
auto enumToString(EnumType value,
const std::string& enum_name) -> std::string {
const auto& enumMap = getEnumMap<EnumType>(enum_name);
#pragma unroll
for (const auto& [key, enumValue] : enumMap) {
if (enumValue == value) {
return key;
Expand Down Expand Up @@ -208,7 +205,6 @@ class TypeCaster {

auto findIt = conversions_.find(last);
if (findIt != conversions_.end()) {
#pragma unroll
for (const auto& [next_type, _] : findIt->second) {
if (visited.insert(next_type).second) {
auto newPath = currentPath;
Expand Down
2 changes: 1 addition & 1 deletion src/atom/system/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ProcessManager::ProcessManagerImpl {
int m_maxProcesses;
std::condition_variable cv;
std::vector<Process> processes;
mutable std::timed_mutex mtx;
mutable std::shared_timed_mutex mtx;

ProcessManagerImpl(int maxProcess) : m_maxProcesses(maxProcess) {}

Expand Down
5 changes: 3 additions & 2 deletions src/atom/type/string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,10 @@ class String {
*/

template <typename... Args>
static auto format(const std::string &format_str,
static auto format(std::string_view format_str,
Args &&...args) -> std::string {
return std::format(format_str, std::forward<Args>(args)...);
return std::vformat(format_str,
std::make_format_args(std::forward<Args>(args)...));
}

static constexpr size_t NPOS = std::string::npos;
Expand Down
5 changes: 0 additions & 5 deletions src/atom/web/address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ auto IPv4::toBinary() const -> std::string {
std::stringstream binaryStream;
std::istringstream iss(addressStr);
std::string segment;
#pragma unroll
while (std::getline(iss, segment, '.')) {
int num = std::stoi(segment);
binaryStream << std::bitset<K_I_PV4_SEGMENT_BITS>(
Expand All @@ -82,7 +81,6 @@ auto IPv4::ipToInteger(const std::string& ipAddress) const -> unsigned int {
std::string segment;
unsigned int result = 0;
int shift = K_I_PV4_SHIFT_START;
#pragma unroll
while (std::getline(iss, segment, '.')) {
result |= (std::stoi(segment) << shift);
shift -= K_I_PV4_SHIFT_STEP;
Expand Down Expand Up @@ -112,7 +110,6 @@ auto IPv6::isInRange(const std::string& start, const std::string& end) -> bool {
std::vector<unsigned short> startIpAddress = ipToVector(start);
std::vector<unsigned short> endIpAddress = ipToVector(end);

#pragma unroll
for (int i = 0; i < K_I_PV6_SEGMENTS; ++i) {
if (ipAddress[i] < startIpAddress[i] ||
ipAddress[i] > endIpAddress[i]) {
Expand All @@ -126,7 +123,6 @@ auto IPv6::toBinary() const -> std::string {
std::stringstream binaryStream;
std::istringstream iss(addressStr);
std::string segment;
#pragma unroll
while (std::getline(iss, segment, ':')) {
auto num = static_cast<unsigned short>(std::stoi(segment, nullptr, 16));
binaryStream << std::bitset<K_I_PV6_SEGMENT_BITS>(
Expand All @@ -150,7 +146,6 @@ auto IPv6::ipToVector(const std::string& ipAddress) const
std::istringstream iss(ipAddress);
std::string segment;
int index = 0;
#pragma unroll
while (std::getline(iss, segment, ':') && index < K_I_PV6_SEGMENTS) {
result[index++] =
static_cast<unsigned short>(std::stoi(segment, nullptr, 16));
Expand Down
3 changes: 2 additions & 1 deletion tests/atom/utils/aes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ TEST(CompressionTest, CompressDifferentData) {
TEST(CompressionTest, DecompressInvalidData) {
// Attempt to decompress invalid compressed data
std::string invalidData = "This is not compressed data.";
EXPECT_THROW(decompress(invalidData), atom::error::RuntimeError);
EXPECT_THROW(ATOM_UNUSED_RESULT(decompress(invalidData)),
atom::error::RuntimeError);
}

TEST(CompressionTest, CompressAndDecompressSpecialCharacters) {
Expand Down
25 changes: 0 additions & 25 deletions websrc/.eslintrc.cjs

This file was deleted.

33 changes: 0 additions & 33 deletions websrc/.gitignore

This file was deleted.

8 changes: 0 additions & 8 deletions websrc/.prettierrc.json

This file was deleted.

64 changes: 0 additions & 64 deletions websrc/README.md

This file was deleted.

4 changes: 0 additions & 4 deletions websrc/e2e/tsconfig.json

This file was deleted.

8 changes: 0 additions & 8 deletions websrc/e2e/vue.spec.ts

This file was deleted.

1 change: 0 additions & 1 deletion websrc/env.d.ts

This file was deleted.

Loading

0 comments on commit 932ba7c

Please sign in to comment.