-
Notifications
You must be signed in to change notification settings - Fork 0
C++ type use cases will update includes #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 refactors C++ code generation to properly manage include statements when working with different data types. The key change is replacing FileData parameters with ImportsBlock parameters across multiple use cases, allowing direct management of C++ header includes based on the types being used.
- Updates type-related use cases to accept
ImportsBlockinstead ofFileDatafor more targeted include management - Adds logic to automatically add necessary C++ standard library includes (e.g.,
<vector>,<string>,<cstdint>,<optional>) when corresponding types are used - Expands test coverage to verify that includes are correctly added when types are referenced
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/enumGoldErrors.groovy | Adds a new test data class GroovyData2 with array field to exercise array type handling |
| cgen-lib/src/test/java/generators/cpp/PrepareRightValueUseCaseTest.kt | Updates tests to use ImportsBlock instead of FileData parameter |
| cgen-lib/src/test/java/generators/cpp/GetTypeNameUseCaseTest.kt | New test file verifying that type usage correctly adds required includes |
| cgen-lib/src/test/java/generators/cpp/GetArrayDataTypeUseCaseTest.kt | Updates tests to pass ImportsBlock and adds verification that <vector> include is added |
| cgen-lib/src/main/kotlin/generators/cpp/PrepareRightValueUseCase.kt | Changes signature to accept ImportsBlock instead of FileData |
| cgen-lib/src/main/kotlin/generators/cpp/GetTypeNameUseCase.kt | Adds logic to automatically add includes based on types and changes to use ImportsBlock |
| cgen-lib/src/main/kotlin/generators/cpp/GetArrayDataTypeUseCase.kt | Updates to add <vector> include when generating array types |
| cgen-lib/src/main/kotlin/generators/cpp/CppEnumGenerator.kt | Updates to pass ImportsBlock to use cases |
| cgen-lib/src/main/kotlin/generators/cpp/CppDataClassGenerator.kt | Updates to pass ImportsBlock to use cases |
| cgen-lib/src/main/kotlin/generators/cpp/CppConstantsBlockGenerator.kt | Updates to pass ImportsBlock to use cases |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| @Test | ||
| fun getArrayTypeAddvectorToImports() { |
Copilot
AI
Oct 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling: 'Addvector' should be 'AddsVector' to match camelCase naming convention.
| fun getArrayTypeAddvectorToImports() { | |
| fun getArrayTypeAddsVectorToImports() { |
| DataType.uint8Nullable, | ||
| DataType.uint16Nullable, | ||
| DataType.uint32Nullable, | ||
| DataType.uint64Nullable-> { |
Copilot
AI
Oct 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space before the arrow operator. Should be DataType.uint64Nullable -> for consistency with Kotlin style conventions.
| DataType.uint64Nullable-> { | |
| DataType.uint64Nullable -> { |
| else -> { | ||
|
|
||
| } |
Copilot
AI
Oct 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty else branch serves no purpose and reduces code clarity. Consider removing it entirely.
| else -> { | |
| } | |
| // No action needed for other types |
No description provided.