Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
82e7d9d
ci: Add workflow trigger conditions
FrozenLemonTee Oct 5, 2025
3b05054
ci: Show test details
FrozenLemonTee Oct 5, 2025
7720132
ci: Add trigger condition
FrozenLemonTee Oct 5, 2025
aff7233
feat: Add conversion method to DWORD milliseconds
FrozenLemonTee Oct 8, 2025
8af067b
chore: Add more excluded directories
FrozenLemonTee Oct 8, 2025
0ef54e0
refactor: Optimize precompiled macro code blocks
FrozenLemonTee Oct 8, 2025
3b4bf1a
chore: Add platform setting for Visual Studio generator
FrozenLemonTee Oct 8, 2025
1d241e8
feat: Add wThread for msvc
FrozenLemonTee Oct 8, 2025
b503fbd
feat: Add wMutex for msvc
FrozenLemonTee Oct 8, 2025
5696ddf
feat: Add wCondition for msvc
FrozenLemonTee Oct 8, 2025
f89315f
refactor: Add missing platform marcos definitions
FrozenLemonTee Oct 8, 2025
9884d41
refactor: Add missing template arg for msvc
FrozenLemonTee Oct 8, 2025
05ec5cb
refactor: Use correct header to avoid architecture not defined error
FrozenLemonTee Oct 8, 2025
f8698c5
feat: Add declaration of atomic for msvc
FrozenLemonTee Oct 8, 2025
e087325
feat: Add condition tool some
FrozenLemonTee Oct 9, 2025
a555bf4
feat: Add impl of atomicImpl<false> for msvc
FrozenLemonTee Oct 9, 2025
26065a9
feat: Add alias some_t for some::type
FrozenLemonTee Oct 9, 2025
8196d1b
feat: Add impl of atomicImpl<true> for msvc
FrozenLemonTee Oct 9, 2025
61a7ee7
test: Enable big object test
FrozenLemonTee Oct 10, 2025
cf476e8
refactor: Rename to maximum
FrozenLemonTee Oct 10, 2025
1d14a42
refactor: Rename to minimum
FrozenLemonTee Oct 10, 2025
759666f
refactor: Use parentheses to avoid symbol conflicts
FrozenLemonTee Oct 10, 2025
89f4999
refactor: Use cross-platform wrapper
FrozenLemonTee Oct 10, 2025
9139174
refactor: Add or remove keywords
FrozenLemonTee Oct 10, 2025
8957956
fix: Use atomicCastBack and atomicCastTo to ensure correct conversion
FrozenLemonTee Oct 10, 2025
7bb1124
fix: Correct function signature
FrozenLemonTee Oct 10, 2025
53c432e
fix: Fix headers containing order
FrozenLemonTee Oct 10, 2025
35785ff
fix: Use full namespace
FrozenLemonTee Oct 10, 2025
51ed749
feat: Impl time::point::now for msvc
FrozenLemonTee Oct 10, 2025
3836ccb
feat: Add cross-platform wrapper for mutex.h and condition.h
FrozenLemonTee Oct 10, 2025
ee7b93a
fix: Align feature of wMutex to pMutex
FrozenLemonTee Oct 10, 2025
d747e40
fix: Fix access control permission issues
FrozenLemonTee Oct 10, 2025
937cc0b
fix: Fix template mismatch issue
FrozenLemonTee Oct 10, 2025
32c28f9
refactor: Change destructors to virtual function
FrozenLemonTee Oct 10, 2025
5947cec
fix: Fix headers containing order
FrozenLemonTee Oct 10, 2025
5fb9a82
fix: Fix API and logic of wThread
FrozenLemonTee Oct 10, 2025
2ac0072
refactor: Rename to null
FrozenLemonTee Oct 10, 2025
acb8481
fix: Fix initialization order
FrozenLemonTee Oct 10, 2025
3ac8508
refactor: Use parentheses to avoid symbol conflicts
FrozenLemonTee Oct 10, 2025
84c348a
refactor: Use std::rethrow_exception
FrozenLemonTee Oct 10, 2025
7bcd081
fix: Fix comparison logic
FrozenLemonTee Oct 10, 2025
f3bbf69
fix: Use cross-platform wrapper
FrozenLemonTee Oct 10, 2025
427bd2a
fix: Fix test assertion statements
FrozenLemonTee Oct 10, 2025
71a9eee
refactor: Add qualifiers
FrozenLemonTee Oct 10, 2025
c69c9a4
fix: Add missing header
FrozenLemonTee Oct 10, 2025
6cfb3cc
fix: Fix the definition method of callable objects
FrozenLemonTee Oct 10, 2025
45e56d1
fix: Fix the test logic of SharedFutureVoidWaitFor
FrozenLemonTee Oct 10, 2025
a1dfb3a
fix: Correct platform logic
FrozenLemonTee Oct 10, 2025
2c4c2c2
refactor: Using thread::sleep
FrozenLemonTee Oct 10, 2025
cae3249
refactor: Using compile-time type detection
FrozenLemonTee Oct 10, 2025
5b209c8
refactor: Using const lvalue reference
FrozenLemonTee Oct 10, 2025
9b0cc03
refactor: Using const lvalue reference
FrozenLemonTee Oct 10, 2025
a049e73
refactor: Adjust the initialization sequence
FrozenLemonTee Oct 10, 2025
97fb392
chore: Add MVP gdb formatter scripts
FrozenLemonTee Oct 11, 2025
dcb68f2
chore: Add new exclusive directories
FrozenLemonTee Oct 11, 2025
4371ffe
chore: Extract testing config
FrozenLemonTee Oct 11, 2025
30362a9
chore: Add all clion build directories to exclusive list
FrozenLemonTee Oct 13, 2025
cadc4e7
chore: Add register logic for all printers
FrozenLemonTee Oct 13, 2025
bda8cca
chore: Add auto-load permissions for setting up GDB
FrozenLemonTee Oct 13, 2025
404ff42
chore: Add pretty printers for auto pointers, couple and tuple
FrozenLemonTee Oct 13, 2025
df75c24
chore: Add all clion tmp directories to exclusive list
FrozenLemonTee Oct 13, 2025
58631dc
feat: Add helper functions in utils.py
FrozenLemonTee Oct 13, 2025
6f58f89
refactor: Remove redundant info
FrozenLemonTee Oct 13, 2025
a4918dc
refactor: Use helpers in utils.py
FrozenLemonTee Oct 13, 2025
95a06d4
fix: Fix show bugs in printer of autoPtr
FrozenLemonTee Oct 13, 2025
34fe818
feat: Add pretty printer for serial containers and container adaptors
FrozenLemonTee Oct 13, 2025
475f349
feat: Add helper to print address
FrozenLemonTee Oct 14, 2025
2a2bb28
refactor: Show more info in to_string
FrozenLemonTee Oct 14, 2025
24718d9
refactor: Optimize the output of the children method
FrozenLemonTee Oct 14, 2025
5f4de23
feat: Add printer for hashSet and hashMap
FrozenLemonTee Oct 14, 2025
dac53a7
fix: Properly handle reference types
FrozenLemonTee Oct 14, 2025
9f6df6b
feat: Add pretty format for treeSet and treeMap
FrozenLemonTee Oct 14, 2025
3279236
refactor: Optimize the output of the children/to_string methods
FrozenLemonTee Oct 14, 2025
3ed6372
fix: Fix the issue where ctest cannot find the tests
FrozenLemonTee Oct 14, 2025
21a8f0a
fix: Add missing headers
FrozenLemonTee Oct 14, 2025
63fdd4c
refactor: Change trigger condition of ci test
FrozenLemonTee Oct 14, 2025
8782f52
refactor: Add compiler version min require
FrozenLemonTee Oct 14, 2025
7501b3f
refactor: refactor field definitions
FrozenLemonTee Oct 16, 2025
18df248
test: Test for debug pretty printer of skipList
FrozenLemonTee Oct 16, 2025
b013844
feat: Add pretty printer for JSet and JMap
FrozenLemonTee Oct 16, 2025
ceba669
chore: Enable some options debugging using gdb
FrozenLemonTee Oct 16, 2025
e705816
refactor: Error handling in call
FrozenLemonTee Oct 16, 2025
4bb7c97
refactor: Refactor field
FrozenLemonTee Oct 16, 2025
a753cf4
feat: Add pretty printer for alternative
FrozenLemonTee Oct 16, 2025
03c9f90
refactor: Add nodiscard marks
FrozenLemonTee Oct 17, 2025
0975175
docs: Add docs for cross platforms
FrozenLemonTee Oct 17, 2025
d874167
fix: Fix logic of point::now on clang+windows
FrozenLemonTee Oct 17, 2025
59b512e
fix: Fix logic of thread::sleep on clang+windows
FrozenLemonTee Oct 17, 2025
c9b2bf3
fix: Explicitly find and link the thread APIs
FrozenLemonTee Oct 17, 2025
6e1b3b2
fix: Add missing headers
FrozenLemonTee Oct 17, 2025
5ed0793
refactor: Enable functions using Windows API on platforms Windows
FrozenLemonTee Oct 17, 2025
45061d6
docs: Add docs for original::some
FrozenLemonTee Oct 17, 2025
3f9b608
docs: Add docs for minimum environment version using the project
FrozenLemonTee Oct 17, 2025
cfbad0a
docs: Correct the version requirements in the example
FrozenLemonTee Oct 18, 2025
2b30252
docs: Add generator in description
FrozenLemonTee Oct 18, 2025
8ab5a32
refactor: Extract the minimum version
FrozenLemonTee Oct 18, 2025
fcc8f9c
fix: Cast time_t pointer for localtime_r and gmtime_r
Creativecole Oct 20, 2025
0e33c26
fix: Improve sleep function for compatibility with different platforms
Creativecole Oct 20, 2025
d790d66
fix: Add src/.DS_Store to .gitignore
Creativecole Oct 20, 2025
a6c885e
fix: Add .cache to .gitignore
Creativecole Oct 20, 2025
4e52478
fix: Resolve sleep compatibility issues across platforms
Creativecole Oct 20, 2025
f5b3dbc
fix: Cast time_t pointer to const_cast for localtime_r and gmtime_r c…
Creativecole Oct 20, 2025
1680097
chore: Remove unused pthread_time.h include
Creativecole Oct 21, 2025
b6c8254
fix: Improve sleep function for compatibility with different platforms
Creativecole Oct 21, 2025
ac491c1
feat: Add reduce/maximum/minimum/summation
FrozenLemonTee Nov 5, 2025
f82c464
feat: Add missing functions of pipeline version
FrozenLemonTee Nov 5, 2025
7b568fd
test: Add tests for reduce/maximum/minimum/summation
FrozenLemonTee Nov 5, 2025
ef50ffd
refactor: Remove redundant headers
FrozenLemonTee Nov 5, 2025
30482e5
refactor: Use toDWMilliseconds
FrozenLemonTee Nov 5, 2025
570a1ac
docs: Add docs
FrozenLemonTee Nov 5, 2025
0c73fe2
refactor: fix platform macros usages
FrozenLemonTee Nov 10, 2025
4446fd7
Merge pull request #19 from FrozenLemonTee/pr-18
FrozenLemonTee Nov 10, 2025
55a76c0
feat: Add arrayView.h
FrozenLemonTee Nov 13, 2025
fdb3153
refactor: supress warning
FrozenLemonTee Nov 13, 2025
ea506ca
feat: Add formatStrings
FrozenLemonTee Nov 13, 2025
8c60bb0
test: Add tests for arrayView and printable::formatStrings
FrozenLemonTee Nov 13, 2025
29aaad0
feat: Add constructor from raw array and add conversions between arra…
FrozenLemonTee Nov 13, 2025
1d1d4fa
test: Add tests for array
FrozenLemonTee Nov 13, 2025
3ca3dfb
test: Add tests for arrayView
FrozenLemonTee Nov 13, 2025
37859dd
feat: Add conversions between vector and arrayView
FrozenLemonTee Nov 13, 2025
5666575
test: Add tests for vector
FrozenLemonTee Nov 13, 2025
a9edaad
fix: Fix the issue of mismatched numbers of constructors and destructors
FrozenLemonTee Nov 13, 2025
c61c4f0
test: Explicitly specify the allocator
FrozenLemonTee Nov 13, 2025
e7b9213
refactor: Use reference in ranged-for loop
FrozenLemonTee Nov 13, 2025
d759701
test: Remove ub test case
FrozenLemonTee Nov 13, 2025
0b6a126
test: Larger data test
FrozenLemonTee Nov 13, 2025
566681a
docs: Add docs
FrozenLemonTee Nov 13, 2025
7dad108
Merge pull request #20 from FrozenLemonTee/dev-arrayView
FrozenLemonTee Nov 13, 2025
e4fa172
feat: Add slice
FrozenLemonTee Nov 13, 2025
03f9bd1
fix: Use difference_type
FrozenLemonTee Nov 13, 2025
d1de42a
feat: Add operator-() for iterator
FrozenLemonTee Nov 13, 2025
c436a79
docs: Update README.md
FrozenLemonTee Nov 14, 2025
405c181
test: Test full-tests.yml
FrozenLemonTee Nov 24, 2025
95b9ab0
fix: Trying to fix thread::sleep
FrozenLemonTee Nov 24, 2025
e889602
test: trying to fix thread::sleep
FrozenLemonTee Nov 24, 2025
a1c9b30
test: small changes
FrozenLemonTee Nov 24, 2025
de21714
fix: Trying to fix the accuracy issue of sleep
FrozenLemonTee Nov 24, 2025
7b1bf9d
test: Increase tolerance for timing errors during testing
FrozenLemonTee Nov 24, 2025
88adb29
Merge remote-tracking branch 'origin/test-mactest' into test-mactest
FrozenLemonTee Nov 24, 2025
75e514b
refactor: Revert sleep
FrozenLemonTee Nov 24, 2025
0539656
refactor: Increase tolerance for timing errors during testing
FrozenLemonTee Nov 24, 2025
140e12b
refactor: Increase tolerance for timing errors during testing
FrozenLemonTee Nov 24, 2025
c54d1a2
chore: Add continue-on-error tag on macos test
FrozenLemonTee Nov 24, 2025
563357d
chore: Remove test branch
FrozenLemonTee Nov 24, 2025
27426a4
chore: Release 0.1.6
FrozenLemonTee Nov 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gdbinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set unwind-on-signal on
set pagination off
python
import sys
import os
sys.path.insert(0, os.path.join(os.getcwd(), 'debug'))
import gdbinit
print("GDB pretty-printer for original initialized.")
end
2 changes: 1 addition & 1 deletion .github/workflows/basic-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name: Test Branch CI - Basic Tests

on:
push:
pull_request:
branches: [ test ]

jobs:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-docs-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:

jobs:
build-and-deploy:
if: github.repository == 'FrozenLemonTee/original'
runs-on: ubuntu-latest

steps:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/deploy-docs-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ name: Deploy Documentation - Stable
on:
push:
branches: [ master ]
tags:
- 'v*.*.*'

jobs:
build-and-deploy:
if: github.repository == 'FrozenLemonTee/original'
runs-on: ubuntu-latest

steps:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-docs-tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:

jobs:
build-and-deploy:
if: github.repository == 'FrozenLemonTee/original'
runs-on: ubuntu-latest

steps:
Expand Down
32 changes: 30 additions & 2 deletions .github/workflows/full-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:

- name: Run tests
run: |
cd build && ctest --output-on-failure
cd build && ctest --verbose --output-on-failure

windows-tests:
runs-on: windows-latest
Expand All @@ -75,4 +75,32 @@ jobs:

- name: Run tests
run: |
cd build && ctest -C ${{ matrix.build_type }} --output-on-failure
cd build && ctest --verbose -C ${{ matrix.build_type }} --output-on-failure

macos-tests:
runs-on: macos-latest
continue-on-error: true
strategy:
matrix:
build_type: [ Debug, Release ]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install dependencies
run: |
brew update
brew install cmake ninja

- name: Configure and Build
run: |
export CC=clang
export CXX=clang++

cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -G Ninja
cmake --build build --config ${{ matrix.build_type }}

- name: Run tests
run: |
cd build && ctest --verbose --output-on-failure
17 changes: 11 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
cmake-build-debug/
.idea/
test.exe
original.zip
original.rar
cmake-build-*/
**/.idea/
build/
install/
.vs/
.vscode/
out/
original/
original/
**/__pycache__/
.cache/

test.exe
original.zip
original.rar
src/.DS_Store
68 changes: 50 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,53 @@
# CMakeLists.txt Main

cmake_minimum_required(VERSION 3.31)
set(CMAKE_VERSION_MINIMUM 3.31)
cmake_minimum_required(VERSION ${CMAKE_VERSION_MINIMUM})
message(STATUS "Cmake version: ${CMAKE_VERSION} (>= ${CMAKE_VERSION_MINIMUM} ✓)")
if(CMAKE_GENERATOR MATCHES "Visual Studio" OR CMAKE_GENERATOR MATCHES "Ninja Multi-Config")
set(CMAKE_GENERATOR_PLATFORM x64 CACHE STRING "Platform" FORCE)
endif()
project(original LANGUAGES CXX)
set(ORIGINAL_VERSION 0.1.5)
set(ORIGINAL_VERSION 0.1.6)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(Threads REQUIRED)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(COMPILER_GCC_VERSION_MINIMUM 13.0)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${COMPILER_GCC_VERSION_MINIMUM})
message(FATAL_ERROR "GCC version too old. Minimum required: ${COMPILER_GCC_VERSION_MINIMUM}. Current: ${CMAKE_CXX_COMPILER_VERSION}")
else()
message(STATUS "GCC version: ${CMAKE_CXX_COMPILER_VERSION} (>= ${COMPILER_GCC_VERSION_MINIMUM} ✓)")
endif()
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(COMPILER_CLANG_VERSION_MINIMUM 20.0)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${COMPILER_CLANG_VERSION_MINIMUM})
message(FATAL_ERROR "Clang version too old. Minimum required: ${COMPILER_CLANG_VERSION_MINIMUM}. Current: ${CMAKE_CXX_COMPILER_VERSION}")
else()
message(STATUS "Clang version: ${CMAKE_CXX_COMPILER_VERSION} (>= ${COMPILER_CLANG_VERSION_MINIMUM} ✓)")
endif()
endif()
if(MSVC)
set(COMPILER_MSVC_VERSION_MINIMUM 1944)
if(MSVC_VERSION LESS ${COMPILER_MSVC_VERSION_MINIMUM})
message(FATAL_ERROR "MSVC version too old. Minimum required: ${COMPILER_MSVC_VERSION_MINIMUM}. Current: ${MSVC_VERSION}")
else()
message(STATUS "MSVC version: ${MSVC_VERSION} (>= ${COMPILER_MSVC_VERSION_MINIMUM} ✓)")
endif()
set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION "10.0" CACHE STRING "Windows Target Platform Version")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++23" HAS_CXX23_FLAG)
if(NOT HAS_CXX23_FLAG)
message(WARNING "Compiler may not fully support C++23 standard")
endif()
endif()

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type (default Release)" FORCE)
endif()
Expand All @@ -20,6 +63,7 @@ file(GLOB ORIGINAL_HEADERS
"${ORIGINAL_SRC_DIR}/vibrant/*.h"
)
add_library(original STATIC ${ORIGINAL_HEADERS} src/original.cpp)
target_link_libraries(original PUBLIC Threads::Threads)

target_include_directories(original PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
Expand Down Expand Up @@ -69,24 +113,12 @@ install(FILES
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/original
)

add_subdirectory(debug)

option(BUILD_TESTING "Build the testing directories" ON)

if (BUILD_TESTING)
include(CTest)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Zi")
else()
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -g")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -g")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
endif()
endif()

# test cases
add_subdirectory(test/other)
add_subdirectory(test/unit_test)
enable_testing()
add_subdirectory(test)
endif ()
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ Original是一个C++基础工具库,也是本人的第一个正式项目,用
## 文档
[文档-Original](https://documents-original.vercel.app/)

## 环境要求

为了编译和使用 Original,请确保开发环境满足以下最低版本要求:

- **C++ 标准**: C++23
- **CMake**: 3.31 或更高版本
- **编译器**(任选其一):
- **GCC**: 13.0 或更高版本
- **Clang**: 20.0 或更高版本
- **MSVC**(Visual Studio 2022):17.10 (版本 14.44.35207) 或更高版本

> 注意:如果使用 GCC 或 Clang,请确保支持 `-std=c++23` 标志。

## 安装

这里以项目`hello_original`为例:
Expand All @@ -21,7 +34,7 @@ Original是一个C++基础工具库,也是本人的第一个正式项目,用

配置`CMakeLists.txt`:
```cmake
cmake_minimum_required(VERSION 3.30)
cmake_minimum_required(VERSION 3.31)
project(hello_original)

set(CMAKE_CXX_STANDARD 23)
Expand Down Expand Up @@ -60,7 +73,7 @@ cmake -P install.cmake

配置`CMakeLists.txt`:
```cmake
cmake_minimum_required(VERSION 3.30)
cmake_minimum_required(VERSION 3.31)
project(hello_original)

set(CMAKE_CXX_STANDARD 23)
Expand Down Expand Up @@ -103,7 +116,7 @@ array("hello world!")

##### 容器接口:

格式化输出接口 printable,元素比较接口 comparable,堆对象深拷贝接口 cloneable,可迭代接口 iterable
格式化输出接口 printable,元素比较接口 comparable,堆对象深拷贝接口 cloneable,可迭代接口 iterable,数组视图 arrayView

##### 算法库:

Expand Down Expand Up @@ -166,6 +179,10 @@ array("hello world!")

任务包装类 taskBase/task,任务委派器 taskDelegator

##### 协程:

生成器 coroutine::generator

#### matrix

计划实现,包含张量,线性代数工具功能。
Expand Down
42 changes: 42 additions & 0 deletions debug/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# debug/CMakeLists.txt

if(CMAKE_BUILD_TYPE MATCHES "Debug")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "MinGW")
message(STATUS "[GDB CONFIG] Detected GNU/MinGW toolchain, setting up GDB auto-load permissions")

if(WIN32)
file(TO_CMAKE_PATH "$ENV{USERPROFILE}" USER_HOME)
else()
file(TO_CMAKE_PATH "$ENV{HOME}" USER_HOME)
endif()

set(GDB_GLOBAL_INIT "${USER_HOME}/.config/gdb/gdbinit")
if(NOT EXISTS "${GDB_GLOBAL_INIT}")
set(GDB_GLOBAL_INIT "${USER_HOME}/.gdbinit")
endif()

set(PROJECT_GDBINIT "${CMAKE_SOURCE_DIR}/.gdbinit")

set(GDB_CONFIG_LINES
"set auto-load local-gdbinit on
add-auto-load-safe-path ${PROJECT_GDBINIT}\n"
)

get_filename_component(GDB_CONFIG_DIR "${GDB_GLOBAL_INIT}" DIRECTORY)
file(MAKE_DIRECTORY "${GDB_CONFIG_DIR}")

if(EXISTS "${GDB_GLOBAL_INIT}")
file(READ "${GDB_GLOBAL_INIT}" EXISTING_CONTENT)
string(FIND "${EXISTING_CONTENT}" "${PROJECT_GDBINIT}" ALREADY_ADDED)
else()
set(ALREADY_ADDED -1)
endif()

if(ALREADY_ADDED EQUAL -1)
file(APPEND "${GDB_GLOBAL_INIT}" "\n# Added by Original CMake auto-config\n${GDB_CONFIG_LINES}")
message(STATUS "[GDB CONFIG] Added safe-path for ${PROJECT_GDBINIT} in ${GDB_GLOBAL_INIT}")
else()
message(STATUS "[GDB CONFIG] Safe-path already configured in ${GDB_GLOBAL_INIT}")
endif()
endif()
endif()
58 changes: 58 additions & 0 deletions debug/gdbinit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# debug/gdbinit.py

import gdb
import sys
import os
import importlib.util
import inspect


def load_printers_from_directory(pretty_printer_collection, directory):
"""Load all pretty-printer scripts from the specified directory."""
if not os.path.isdir(directory):
print(f"[WARN] Skipped non-existent directory: {directory}")
return

for file_name in os.listdir(directory):
if not file_name.endswith("_printer.py"):
continue

file_path = os.path.join(directory, file_name)
module_name = os.path.splitext(file_name)[0]

try:
spec = importlib.util.spec_from_file_location(module_name, file_path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)

printer_class = None
for name, cls in inspect.getmembers(module, inspect.isclass):
if name == "Printer":
printer_class = cls
break

if printer_class is None:
print(f"[SKIP] {module_name}: no 'Printer' class found")
continue
type_name = module_name.replace("_printer", "")
type_regex = f"^original::{type_name}(<.*>)?$"

pretty_printer_collection.add_printer(module_name, type_regex, printer_class)
print(f"Registered pretty-printer: {type_name}")

except Exception as e:
print(f"Failed to load {file_name}: {e}")


this_dir = os.path.dirname(__file__)
printers_dir = os.path.join(this_dir, "printers")
core_dir = os.path.join(printers_dir, "core")

sys.path.insert(0, printers_dir)
sys.path.insert(0, core_dir)

pp = gdb.printing.RegexpCollectionPrettyPrinter("original")
load_printers_from_directory(pp, core_dir)
gdb.printing.register_pretty_printer(None, pp)

print("GDB pretty-printers for 'original' registered successfully.")
Loading
Loading