Skip to content

Static initialization#85

Merged
K20shores merged 3 commits intomainfrom
struct
Apr 16, 2025
Merged

Static initialization#85
K20shores merged 3 commits intomainfrom
struct

Conversation

@K20shores
Copy link
Copy Markdown
Collaborator

@K20shores K20shores commented Apr 15, 2025

This replaces the validation keys struct in both v0 and v1 with static constexpr const char* variables for keys.

When using std::string, we were running into a static initialization problem (also see the linked article in the answer for more detail). This apparently isn't a problem within the library, but attempting to use those values in the musica performance repo caused this issue to pop up here and in micm.

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 refactors the key validation mechanism by replacing the old keys struct with static constexpr const char* variables for keys, and updates all parser files (both v0 and v1) to use the new syntax.

  • Replaces old brace-initialized key structures with std::vectorstd::string initializations using static constexpr key variables.
  • Updates all usage of validation::keys. to validation:: in parser files.
  • Revises header files in v0 and v1 to reflect the new key definitions.

Reviewed Changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/v1/emission_parser.cpp Updates key references to use static constexpr variables.
src/v1/condensed_phase_photolysis_parser.cpp Updates key references and vector initializations.
src/v1/condensed_phase_arrhenius_parser.cpp Refactors key usage and error message updates for mutually exclusive options.
src/v1/branched_parser.cpp Replaces old key syntax with new static constexpr key variable usage.
src/v1/arrhenius_parser.cpp Consistent update of Arrhenius key references using new definitions.
src/v1/aqueous_equilibrium_parser.cpp Refactors key references and vector initialization.
(v0 files) All parser files updated uniformly replacing key struct access.
include/mechanism_configuration/v1/validation.hpp Removes the keys struct and defines keys as static constexpr variables.
include/mechanism_configuration/v0/validation.hpp Updates key definitions to use static constexpr const char*.

@K20shores K20shores changed the title Struct Static initialization Apr 15, 2025
Copy link
Copy Markdown
Collaborator

@mattldawson mattldawson left a comment

Choose a reason for hiding this comment

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

nice!

@K20shores K20shores merged commit da2c752 into main Apr 16, 2025
33 checks passed
@K20shores K20shores deleted the struct branch April 16, 2025 12:48
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.

4 participants