Skip to content

C++ deserialization#31

Merged
vshcryabets merged 4 commits into
masterfrom
feature/cpp-deserialization
Jun 22, 2025
Merged

C++ deserialization#31
vshcryabets merged 4 commits into
masterfrom
feature/cpp-deserialization

Conversation

@vshcryabets
Copy link
Copy Markdown
Owner

No description provided.

@vshcryabets vshcryabets requested a review from Copilot June 22, 2025 18:10
@vshcryabets vshcryabets self-assigned this Jun 22, 2025

This comment was marked as outdated.

@vshcryabets vshcryabets force-pushed the feature/cpp-deserialization branch from 6225cb2 to a417702 Compare June 22, 2025 18:12
@vshcryabets vshcryabets requested a review from Copilot June 22, 2025 18:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new deserialization component (BufferReaderImpl) under the existing L5 module, including its interface, implementation, tests, and build updates.

  • Introduces IBufferReader interface and implements BufferReaderImpl with methods for reading various integer sizes and UTF strings.
  • Adds unit tests for readUInt8/16/32/64 and readUTFString.
  • Updates CMakeLists to include the new implementation and test files.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
native/V2StyxLib/modules/l5/include/serialization/IBufferReader.h New interface declaration for buffer reading
native/V2StyxLib/modules/l5/include/serialization/BufferReaderImpl.h Declaration of BufferReaderImpl subclass
native/V2StyxLib/modules/l5/src/BufferReaderImpl.cpp Implementation of deserialization methods
native/V2StyxLib/modules/l5/test/test_BufferReaderImpl.cpp Unit tests for the new reader methods
native/V2StyxLib/modules/l5/CMakeLists.txt Build updates to include new source and test files
Comments suppressed due to low confidence (1)

native/V2StyxLib/modules/l5/test/test_BufferReaderImpl.cpp:37

  • Consider adding tests for the read(uint8_t*, Styx::Size) method and buffer overflow/error cases (e.g., out-of-range reads) to improve overall coverage.
}

if (buf == nullptr) {
throw std::invalid_argument("Buffer cannot be null");
}
position = 0;
Copy link

Copilot AI Jun 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Duplicate initialization of position (it’s already set in the initializer list); consider removing this assignment in the constructor body.

Suggested change
position = 0;

Copilot uses AI. Check for mistakes.
Comment on lines +90 to +92
for (Styx::Size i = 0; i < count; ++i) {
data[i] = buffer[position++];
}
Copy link

Copilot AI Jun 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For bulk reads, prefer std::memcpy(data, buffer + position, count); position += count; to avoid the per-byte loop and improve performance.

Suggested change
for (Styx::Size i = 0; i < count; ++i) {
data[i] = buffer[position++];
}
std::memcpy(data, buffer + position, count);
position += count;

Copilot uses AI. Check for mistakes.
Styx::Size limit;
public:
BufferReaderImpl(const StyxBuffer &buf, Styx::Size size);
virtual ~BufferReaderImpl();
Copy link

Copilot AI Jun 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The destructor is empty; you can simplify by defaulting it (~BufferReaderImpl() override = default;) to reduce boilerplate.

Suggested change
virtual ~BufferReaderImpl();
~BufferReaderImpl() override = default;

Copilot uses AI. Check for mistakes.
@vshcryabets vshcryabets merged commit 1156920 into master Jun 22, 2025
2 checks passed
@vshcryabets vshcryabets deleted the feature/cpp-deserialization branch June 22, 2025 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants