Repository navigation
Add camel case to snake case conversion - #588
liuzicheng1987 merged 3 commits into
Conversation
Summary of ChangesHello @cacharle, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a CamelCaseToSnakeCase processor, which is a valuable addition. The refactoring to consolidate case transformation logic into a shared transform_case.hpp file is also a good improvement. I've identified a bug in the new transformation logic that results in incorrect conversions for fields starting with an uppercase letter, along with a couple of minor issues. My review includes specific suggestions to address these points.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
liuzicheng1987
left a comment
There was a problem hiding this comment.
Looks good to me.
|
@cacharle thanks for the contribution. I am merging. |
c7a9741
into
munich-data-engineering:main
|
Just realized I forgot to add anything to the doc |
|
Right...if you want to, you can open a new PR for the doc, otherwise I'll just quickly write something myself. |
…neering#731) Adds opt-in whole-enum wire-name casing transform processors (`rfl::TransformEnumNames<...>` plus aliases `EnumSnakeCaseToKebabCase`, `EnumSnakeCaseToCamelCase`, `EnumSnakeCaseToPascalCase`, `EnumCamelCaseToSnakeCase`, `EnumToLowerCase`, `EnumToUpperCase`) across read, write, `rfl::enum_to_string`, `rfl::string_to_enum`, and JSON Schema generation. Resolved wire-name tables are cached once per `(EnumType, EnumNameTransform)`. Parent: depends on `feat(enums): accept std::string_view in rfl::string_to_enum (munich-data-engineering#565)` (open upstream PR munich-data-engineering#802). Per-enum overrides/trait (`rfl::EnumNames<E>`, #106) is split into a separate child commit on top of this processor seam. Judge polish applied: - Moves non-template `apply_enum_name_transform` out-of-line into `src/rfl/TransformEnumNames.cpp` (`RFL_API`, wired via `src/reflectcpp.cpp`). - Places `enum_name_transform_v` in `include/rfl/internal/enum_name_transform_v.hpp` (mirroring `enum_names_only_v.hpp` with `std::remove_pointer_t`). - Adds `EnumCamelCaseToSnakeCase` for parity with `rfl::CamelCaseToSnakeCase` (munich-data-engineering#588). - Accepts variadic `class... Ps` on `rfl::enum_to_string` and `rfl::string_to_enum`, strips `std::remove_cvref_t<EnumType>`, and guards `config::enum_descriptions` so untransformed enums avoid static heap caches. Refs: munich-data-engineering#731 (Maintainer: "My first instinct would be a processor, but I need to give it some thought.") Downstream receipts: - NVIDIA/cuda-quantum maintains 4 hand-written `rfl::Reflector<E>` switch tables for `snake_case` -> `kebab-case` YAML enums: https://github.com/NVIDIA/cuda-quantum/blob/81ef20d9d4a1e0912a6dbc68637ece017e8fd324/cudaq/lib/Target/Yaml/TargetConfigYamlAdapters.h#L27-L75 https://github.com/NVIDIA/cuda-quantum/blob/81ef20d9d4a1e0912a6dbc68637ece017e8fd324/cudaq/lib/Target/Yaml/v2/QuakeUnmappedProfileYaml.h#L16-L53 - openmoq/moqx duplicates `enum class QuicStack` as `rfl::Literal` + switch mapper: https://github.com/openmoq/moqx/blob/60bab7f13925acbaf578670223e660d71e891547/src/config/loader/ParsedConfig.h#L291 - munich-data-engineering/sqlgen post-processes `enum_to_string` across all 4 SQL backends: https://github.com/munich-data-engineering/sqlgen/blob/265b0a174b661c5905b874f97b064aecb4cded70/src/sqlgen/sqlite/to_sql.cpp#L338-L340 - games-on-whales/wolf lowercases `enum_to_string`: https://github.com/games-on-whales/wolf/blob/ac2461f68feda41fdc7a7c8e812b9ab4b80520b7/src/moonlight-server/api/openapi.cpp#L92
…neering#731) Adds opt-in whole-enum wire-name casing transform processors (`rfl::TransformEnumNames<...>` plus aliases `EnumSnakeCaseToKebabCase`, `EnumSnakeCaseToCamelCase`, `EnumSnakeCaseToPascalCase`, `EnumCamelCaseToSnakeCase`, `EnumToLowerCase`, `EnumToUpperCase`) across read, write, `rfl::enum_to_string`, `rfl::string_to_enum`, and JSON Schema generation. Resolved wire-name tables are cached once per `(EnumType, EnumNameTransform)`. Parent: depends on `feat(enums): accept std::string_view in rfl::string_to_enum (munich-data-engineering#565)` (open upstream PR munich-data-engineering#802). Per-enum overrides/trait (`rfl::EnumNames<E>`, #106) is split into a separate child commit on top of this processor seam. Judge polish applied: - Moves non-template `apply_enum_name_transform` out-of-line into `src/rfl/TransformEnumNames.cpp` (`RFL_API`, wired via `src/reflectcpp.cpp`). - Places `enum_name_transform_v` in `include/rfl/internal/enum_name_transform_v.hpp` (mirroring `enum_names_only_v.hpp` with `std::remove_pointer_t`). - Adds `EnumCamelCaseToSnakeCase` for parity with `rfl::CamelCaseToSnakeCase` (munich-data-engineering#588). - Accepts variadic `class... Ps` on `rfl::enum_to_string` and `rfl::string_to_enum`, strips `std::remove_cvref_t<EnumType>`, and guards `config::enum_descriptions` so untransformed enums avoid static heap caches. Refs: munich-data-engineering#731 (Maintainer: "My first instinct would be a processor, but I need to give it some thought.") Downstream receipts: - NVIDIA/cuda-quantum maintains 4 hand-written `rfl::Reflector<E>` switch tables for `snake_case` -> `kebab-case` YAML enums: https://github.com/NVIDIA/cuda-quantum/blob/81ef20d9d4a1e0912a6dbc68637ece017e8fd324/cudaq/lib/Target/Yaml/TargetConfigYamlAdapters.h#L27-L75 https://github.com/NVIDIA/cuda-quantum/blob/81ef20d9d4a1e0912a6dbc68637ece017e8fd324/cudaq/lib/Target/Yaml/v2/QuakeUnmappedProfileYaml.h#L16-L53 - openmoq/moqx duplicates `enum class QuicStack` as `rfl::Literal` + switch mapper: https://github.com/openmoq/moqx/blob/60bab7f13925acbaf578670223e660d71e891547/src/config/loader/ParsedConfig.h#L291 - munich-data-engineering/sqlgen post-processes `enum_to_string` across all 4 SQL backends: https://github.com/munich-data-engineering/sqlgen/blob/265b0a174b661c5905b874f97b064aecb4cded70/src/sqlgen/sqlite/to_sql.cpp#L338-L340 - games-on-whales/wolf lowercases `enum_to_string`: https://github.com/games-on-whales/wolf/blob/ac2461f68feda41fdc7a7c8e812b9ab4b80520b7/src/moonlight-server/api/openapi.cpp#L92
…neering#731) Adds opt-in whole-enum wire-name casing transform processors (`rfl::TransformEnumNames<...>` plus aliases `EnumSnakeCaseToKebabCase`, `EnumSnakeCaseToCamelCase`, `EnumSnakeCaseToPascalCase`, `EnumCamelCaseToSnakeCase`, `EnumToLowerCase`, `EnumToUpperCase`) across read, write, `rfl::enum_to_string`, `rfl::string_to_enum`, and JSON Schema generation. Resolved wire-name tables are cached once per `(EnumType, EnumNameTransform)`. Parent: depends on `feat(enums): accept std::string_view in rfl::string_to_enum (munich-data-engineering#565)` (open upstream PR munich-data-engineering#802). Per-enum overrides/trait (`rfl::EnumNames<E>`, #106) is split into a separate child commit on top of this processor seam. Judge polish applied: - Moves non-template `apply_enum_name_transform` out-of-line into `src/rfl/TransformEnumNames.cpp` (`RFL_API`, wired via `src/reflectcpp.cpp`). - Places `enum_name_transform_v` in `include/rfl/internal/enum_name_transform_v.hpp` (mirroring `enum_names_only_v.hpp` with `std::remove_pointer_t`). - Adds `EnumCamelCaseToSnakeCase` for parity with `rfl::CamelCaseToSnakeCase` (munich-data-engineering#588). - Accepts variadic `class... Ps` on `rfl::enum_to_string` and `rfl::string_to_enum`, strips `std::remove_cvref_t<EnumType>`, and guards `config::enum_descriptions` so untransformed enums avoid static heap caches. Refs: munich-data-engineering#731 (Maintainer: "My first instinct would be a processor, but I need to give it some thought.") Downstream receipts: - NVIDIA/cuda-quantum maintains 4 hand-written `rfl::Reflector<E>` switch tables for `snake_case` -> `kebab-case` YAML enums: https://github.com/NVIDIA/cuda-quantum/blob/81ef20d9d4a1e0912a6dbc68637ece017e8fd324/cudaq/lib/Target/Yaml/TargetConfigYamlAdapters.h#L27-L75 https://github.com/NVIDIA/cuda-quantum/blob/81ef20d9d4a1e0912a6dbc68637ece017e8fd324/cudaq/lib/Target/Yaml/v2/QuakeUnmappedProfileYaml.h#L16-L53 - openmoq/moqx duplicates `enum class QuicStack` as `rfl::Literal` + switch mapper: https://github.com/openmoq/moqx/blob/60bab7f13925acbaf578670223e660d71e891547/src/config/loader/ParsedConfig.h#L291 - munich-data-engineering/sqlgen post-processes `enum_to_string` across all 4 SQL backends: https://github.com/munich-data-engineering/sqlgen/blob/265b0a174b661c5905b874f97b064aecb4cded70/src/sqlgen/sqlite/to_sql.cpp#L338-L340 - games-on-whales/wolf lowercases `enum_to_string`: https://github.com/games-on-whales/wolf/blob/ac2461f68feda41fdc7a7c8e812b9ab4b80520b7/src/moonlight-server/api/openapi.cpp#L92
Fixes part of #585