Compare commits
3 Commits
98d93865f0
...
a581d9bf9d
| Author | SHA1 | Date | |
|---|---|---|---|
| a581d9bf9d | |||
| 35772fc2d1 | |||
| 6041a72f30 |
162
AGENTS.md
Normal file
162
AGENTS.md
Normal file
@@ -0,0 +1,162 @@
|
||||
# AGENTS.md - Agent Guidelines for PIP
|
||||
|
||||
This file provides guidance for agentic coding agents working on the PIP (Platform Independent Primitives) codebase.
|
||||
|
||||
## Project Overview
|
||||
|
||||
PIP is a C++ cross-platform library providing platform-independent abstractions for:
|
||||
- Core/Types: Strings, variants, containers, datetime, networks
|
||||
- Threading: Mutexes, semaphores, thread pools, timers
|
||||
- I/O: Files, serial, CAN, GPIO, SPI, Ethernet
|
||||
- Math: Vectors, matrices, FFT, quaternions
|
||||
- Crypto: MD5, SHA, BLAKE2, SipHash
|
||||
- Compression: zlib support
|
||||
- HTTP: Client and server support
|
||||
- Serialization: JSON, binary, XML
|
||||
|
||||
## Build Commands
|
||||
|
||||
### Basic Build
|
||||
```bash
|
||||
cmake -B build
|
||||
cmake --build build
|
||||
```
|
||||
|
||||
### Build with Tests
|
||||
```bash
|
||||
cmake -B build -DTESTS=ON
|
||||
cmake --build build
|
||||
```
|
||||
|
||||
### Run Tests
|
||||
```bash
|
||||
ctest --test-dir build/tests # Run all tests
|
||||
ctest --test-dir build/tests -R <regex> # Run specific tests matching regex
|
||||
ctest --test-dir build/tests -V # Verbose output
|
||||
```
|
||||
|
||||
To run a single test:
|
||||
```bash
|
||||
# Build the test executable, then run directly:
|
||||
./build/tests/pip_<test_name>_test
|
||||
# Or use ctest with specific test name
|
||||
ctest --test-dir build/tests -R "TestName"
|
||||
```
|
||||
|
||||
### Other Commands
|
||||
```bash
|
||||
cmake --build build --target clean # Clean build
|
||||
cmake --install build_pip # Install
|
||||
cmake --build build --target doc # Build documentation
|
||||
```
|
||||
|
||||
### Build Options
|
||||
```bash
|
||||
-DTESTS=ON # Build tests
|
||||
-DCOVERAGE=ON # Build with coverage
|
||||
-DICU=ON # ICU support for codepage conversion
|
||||
-DSTD_IOSTREAM=ON # std::iostream operators support
|
||||
-DINTROSPECTION=ON # Build with introspection
|
||||
-DPIP_BUILD_CRYPT=ON # Crypt module (requires libsodium)
|
||||
-DPIP_BUILD_FFTW=ON # FFT support
|
||||
```
|
||||
|
||||
## Code Style Guidelines
|
||||
|
||||
### File Organization
|
||||
- Header files: `libs/main/**/*.h`
|
||||
- Source files: `libs/main/**/*.cpp`
|
||||
- Private headers: `*_p.h`
|
||||
- Tests: `tests/<module>/`
|
||||
- Use Doxygen comments (`/*! ... */`) for documentation with `\brief`, `\param`, `\return`
|
||||
|
||||
### Naming Conventions
|
||||
- **Classes**: PascalCase with `PI` prefix (e.g., `PIString`, `PIByteArray`, `PIVariant`)
|
||||
- **Functions**: camelCase (e.g., `toAscii()`, `isEmpty()`, `append()`)
|
||||
- **Member variables**: snake_case, or just lowercase (e.g., `array_size`, `count`)
|
||||
- **Constants**: PascalCase or UPPER_SNAKE_CASE
|
||||
- **Enums**: PascalCase for enum names and values
|
||||
|
||||
### Code Formatting
|
||||
- **Indentation**: Use tabs (4 spaces equivalent) or spaces - match existing code
|
||||
- **Braces**: Opening brace on same line for functions, new line for namespaces/classes
|
||||
- **Includes**: System includes first, then project headers
|
||||
- **Use forward declarations** where possible to reduce compile times
|
||||
- **Use `nullptr`** instead of `NULL`
|
||||
|
||||
### C++ Standards
|
||||
- C++11 standard (enforced in CMakeLists.txt)
|
||||
- Use `override` keyword for virtual function overrides
|
||||
- Use `explicit` for single-argument constructors
|
||||
- Use `const` member functions where applicable
|
||||
- Use range-based `for` loops when possible
|
||||
|
||||
### Error Handling
|
||||
- Return error codes
|
||||
- DO NOT USE exceptions
|
||||
- Use `piCerr` and `piCout` for error messages
|
||||
- Check for null pointers where appropriate
|
||||
|
||||
### Module Structure
|
||||
|
||||
Each module typically has:
|
||||
1. Public header: `pip_<module>.h` or `<classname>.h`
|
||||
2. Private implementation: `<classname>.cpp` or `<classname>_p.cpp`
|
||||
3. Use `PIP_EXPORT` macro for symbols that need to be exported from the library
|
||||
|
||||
Example class structure:
|
||||
```cpp
|
||||
// header.h
|
||||
#ifndef MODULE_CLASSNAME_H
|
||||
#define MODULE_CLASSNAME_H
|
||||
|
||||
#include "pip_export.h"
|
||||
|
||||
class PIP_EXPORT ClassName {
|
||||
public:
|
||||
ClassName();
|
||||
~ClassName();
|
||||
|
||||
void doSomething();
|
||||
bool isValid() const;
|
||||
|
||||
private:
|
||||
void privateMethod();
|
||||
int data;
|
||||
};
|
||||
|
||||
#endif // MODULE_CLASSNAME_H
|
||||
|
||||
// source.cpp
|
||||
#include "header.h"
|
||||
#include "piincludes_p.h"
|
||||
|
||||
ClassName::ClassName() : data(0) {}
|
||||
```
|
||||
|
||||
### Testing
|
||||
- Use Google Test framework
|
||||
- Test files go in `tests/<module>/`
|
||||
- Use `TEST(TestSuite, TestName)` or `TEST_F(TestFixture, TestName)` for test cases
|
||||
- Use `ASSERT_*` for fatal failures, `EXPECT_*` for non-fatal
|
||||
- Test naming: `<ClassName>_<TestDescription>`
|
||||
|
||||
Example:
|
||||
```cpp
|
||||
#include "pistring.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
TEST(PIString_Tests, constructor_empty) {
|
||||
PIString str;
|
||||
ASSERT_TRUE(str.isEmpty());
|
||||
}
|
||||
```
|
||||
|
||||
### Module Dependencies
|
||||
- Main library: `libs/main/`
|
||||
- Third-party: `3rd/`
|
||||
- Utils: `utils/`
|
||||
|
||||
### Key Files
|
||||
- `CMakeLists.txt` - Main build configuration
|
||||
- `tests/CMakeLists.txt` - Test configuration
|
||||
70
plans/pivector2d.md
Normal file
70
plans/pivector2d.md
Normal file
@@ -0,0 +1,70 @@
|
||||
# План рефакторинга PIVector2D
|
||||
|
||||
## Этап 1: Выполнить наследование Row от RowConst, Col от ColConst
|
||||
|
||||
### 1.1 Переместить RowConst перед Row
|
||||
- Найти местоположение RowConst (текущая позиция ~строка 610)
|
||||
- Переместить определение RowConst перед Row (до строки ~184)
|
||||
|
||||
### 1.2 Переместить ColConst перед Col
|
||||
- Найти местоположение ColConst (текущая позиция ~строка 770)
|
||||
- Переместить определение ColConst перед Col (до строки ~402)
|
||||
|
||||
### 1.3 Изменить класс Row
|
||||
- Наследовать от RowConst: `class Row : public RowConst`
|
||||
- Убрать дублирующиеся методы (они унаследованы от RowConst):
|
||||
- size()
|
||||
- toVector()
|
||||
- operator[] (const версия)
|
||||
- data() (const версия)
|
||||
- indexOf()
|
||||
- lastIndexOf()
|
||||
- indexWhere()
|
||||
- lastIndexWhere()
|
||||
- forEach() (const версия)
|
||||
- contains()
|
||||
- entries()
|
||||
- any()
|
||||
- every()
|
||||
- Сохранить неконстантные методы:
|
||||
- operator[] (неконстантный)
|
||||
- data() (неконстантный)
|
||||
- operator=()
|
||||
- forEach() (неконстантный)
|
||||
- fill()
|
||||
|
||||
### 1.4 Изменить класс Col
|
||||
- Наследовать от ColConst: `class Col : public ColConst`
|
||||
- Аналогично убрать дублирующиеся методы
|
||||
|
||||
### 1.5 Проверить тесты
|
||||
- Запустить: `./pip_math_test --gtest_filter="*Vector2D*"`
|
||||
|
||||
---
|
||||
|
||||
## Этап 2: Заменить PIPair<ssize_t, ssize_t> на PIVector2DIndex
|
||||
|
||||
### 2.1 Создать структуру PIVector2DIndex
|
||||
```cpp
|
||||
struct PIVector2DIndex {
|
||||
ssize_t row;
|
||||
ssize_t col;
|
||||
};
|
||||
```
|
||||
|
||||
### 2.2 Обновить return types
|
||||
Методы для изменения:
|
||||
- indexOf() -> возвращает PIVector2DIndex вместо PIPair<ssize_t, ssize_t>
|
||||
- lastIndexOf()
|
||||
- indexWhere()
|
||||
- lastIndexWhere()
|
||||
|
||||
### 2.3 Обновить тесты и документацию
|
||||
|
||||
---
|
||||
|
||||
## Этап 3: Дополнительные улучшения (опционально)
|
||||
|
||||
- Добавить методы для работы с диапазонами
|
||||
- Оптимизировать методы удаления строк/столбцов
|
||||
- Добавить проверку границ в debug-режиме
|
||||
Reference in New Issue
Block a user