Repository navigation
Inline global constants and simplify issue lookup #1475
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
Open
agarny
wants to merge
7
commits into
cellml:main
Choose a base branch
from
agarny:issue1474
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b27612d
Inline global constants and simplify issue lookup.
agarny a19ec30
Simplified issue reference URL metadata.
agarny 0c991f8
Map the generator rules with compile-time guard.
agarny f697050
Issue: use `if constexpr` in the compile-time guard.
agarny 4d93c93
Removed compile-time rule table validation.
agarny f39f572
CMake: added Issue reference rule consistency check.
agarny 2871c9b
CMake: improved the regex processing in checkissuereferencerules.
agarny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # Copyright libCellML Contributors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # Check that ruleToInformation (in issue.cpp) has one entry for each | ||
| # Issue::ReferenceRule value (in issue.h), in declaration order, and that the | ||
| # name of each entry matches its rule. | ||
| # Usage: cmake -P checkissuereferencerules.cmake <issue.h> <issue.cpp> | ||
|
|
||
| set(_ISSUE_HEADER_FILE ${CMAKE_ARGV3}) | ||
| set(_ISSUE_SOURCE_FILE ${CMAKE_ARGV4}) | ||
|
|
||
| # Retrieve the Issue::ReferenceRule values. | ||
|
|
||
| file(READ ${_ISSUE_HEADER_FILE} _CONTENT) | ||
| string(REGEX MATCH "enum class ReferenceRule[^{]*{([^}]*)}" _MATCH "${_CONTENT}") | ||
|
|
||
| if(NOT _MATCH) | ||
| message(FATAL_ERROR "Could not find the Issue::ReferenceRule enum in '${_ISSUE_HEADER_FILE}'.") | ||
| endif() | ||
|
|
||
| string(REGEX REPLACE "//[^\n]*" "" _ENUM_BODY "${CMAKE_MATCH_1}") | ||
| string(REGEX MATCHALL "[A-Z0-9_]+" _RULES "${_ENUM_BODY}") | ||
|
|
||
| # Retrieve the ruleToInformation entries. | ||
|
|
||
| file(READ ${_ISSUE_SOURCE_FILE} _CONTENT) | ||
| string(REGEX MATCH "ruleToInformation\\[\\] = {(.*)\n};" _MATCH "${_CONTENT}") | ||
|
|
||
| if(NOT _MATCH) | ||
| message(FATAL_ERROR "Could not find the ruleToInformation table in '${_ISSUE_SOURCE_FILE}'.") | ||
| endif() | ||
|
|
||
| string(REGEX MATCHALL "{Issue::ReferenceRule::[A-Z0-9_]+, \"[A-Z0-9_]*\"" _ENTRIES "${CMAKE_MATCH_1}") | ||
|
|
||
| # Compare the two. | ||
|
|
||
| list(LENGTH _RULES _RULES_COUNT) | ||
| list(LENGTH _ENTRIES _ENTRIES_COUNT) | ||
|
|
||
| if(NOT _RULES_COUNT EQUAL _ENTRIES_COUNT) | ||
| message(FATAL_ERROR "Issue::ReferenceRule has ${_RULES_COUNT} values, but ruleToInformation has ${_ENTRIES_COUNT} entries.") | ||
| endif() | ||
|
|
||
| math(EXPR _LAST_INDEX "${_RULES_COUNT} - 1") | ||
|
|
||
| foreach(_INDEX RANGE ${_LAST_INDEX}) | ||
| list(GET _RULES ${_INDEX} _RULE) | ||
| list(GET _ENTRIES ${_INDEX} _ENTRY) | ||
| string(REGEX REPLACE "{Issue::ReferenceRule::([A-Z0-9_]+), \"([A-Z0-9_]*)\"" "\\1;\\2" _ENTRY "${_ENTRY}") | ||
| list(GET _ENTRY 0 _ENTRY_RULE) | ||
| list(LENGTH _ENTRY _ENTRY_LENGTH) | ||
|
|
||
| if(_ENTRY_LENGTH EQUAL 2) | ||
| list(GET _ENTRY 1 _ENTRY_NAME) | ||
| else() | ||
| set(_ENTRY_NAME "") | ||
| endif() | ||
|
|
||
| if(NOT _ENTRY_RULE STREQUAL _RULE) | ||
| message(FATAL_ERROR "ruleToInformation entry #${_INDEX} is for '${_ENTRY_RULE}', but Issue::ReferenceRule value #${_INDEX} is '${_RULE}'.") | ||
| endif() | ||
|
|
||
| if(_RULE STREQUAL "UNDEFINED" OR _RULE STREQUAL "UNSPECIFIED") | ||
| set(_EXPECTED_NAME "") | ||
| else() | ||
| set(_EXPECTED_NAME ${_RULE}) | ||
| endif() | ||
|
|
||
| if(NOT _ENTRY_NAME STREQUAL _EXPECTED_NAME) | ||
| message(FATAL_ERROR "ruleToInformation entry for '${_RULE}' has name '${_ENTRY_NAME}', but '${_EXPECTED_NAME}' was expected.") | ||
| endif() | ||
| endforeach() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.