Skip to content
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

Refactor attr_lines() #47

Merged
merged 4 commits into from
Dec 6, 2024
Merged

Refactor attr_lines() #47

merged 4 commits into from
Dec 6, 2024

Conversation

ThirteenFish
Copy link
Contributor

@ThirteenFish ThirteenFish commented Nov 26, 2024

attr_lines() was generating initializers for each of the three OD types in slightly different ways. This pulls that block out into its own function so that fixes always happen to all three types, simplifies the generating a bit, and fixes a few edge cases:

  • Removed whitespace at the end of VISIBLE_STRING
  • Use '\0' instead of 0 for null in VISIBLE_STRING
  • VISIBLE_STRING would generate strings ("") instead of chars ('') as
    the array members for ODVariable and ODArray
  • _SKIP_INDEXES are always skipped, previously ODRecords were not.

Checking over our current generated configs the only difference in generated output is using '\0' instead of 0 for VISIBLE_STRINGs and removing the single space at the end of those lines.

This has also been extended to _canopennode_h_lines() and obj_lines() with no change of generated output, although the calculation of the length of OCTET_STRING was fixed in cases where we didn't use it.

`attr_lines` was generating initializers for each of the three OD types
in slightly different ways. This pulls that block out into its own
function so that fixes always happen to all three types, simplifies the
generating a bit, and fixes a few edge cases:
- Removed whitespace at the end of VISIBLE_STRING
- Use '\0' instead of 0 for null in VISIBLE_STRING
- VISIBLE_STRING would generate strings ("") instead of chars ('') as
  the array members for ODVariable and ODArray
- _SKIP_INDEXES are always skipped, previously ODRecords were not.

Checking over our current generated configs the only difference in
generated output is using '\0' instead of 0 for VISIBLE_STRINGs and
removing the single space at the end of those lines.
In 791fdd3 I had marked class Card as frozen but it turns out that
being a frozen dataclass means it can't be subclassed and in
oresat-c3-software, class Node tries to subclass from it.
@ThirteenFish ThirteenFish requested a review from ryanpdx November 26, 2024 10:04
A similar treatment to attr_lines, the ODVariable specific parts were
given their own function. This results in no change in the generated
config but:
- _SKIP_INDEXES is now always respected
- the len of OCTET_STRING for ODVaraible and ODArray looked super
  suspect, but they were never used so it didn't show up anywhere.
Similar to the previous two, this splits up `obj_lines()` and fixes the
OCTET_STRING length calculation. It wasn't used so there's no change in
generated output.

While I was there I imported the byte-array-esque OD types directly and
replaced all the instances with the shorter names.
@ThirteenFish ThirteenFish merged commit ba6118a into master Dec 6, 2024
1 check passed
@ThirteenFish ThirteenFish deleted the gen-fw-refactor branch December 6, 2024 07:01
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