-
Notifications
You must be signed in to change notification settings - Fork 32
[DRAFT] Add TRICK_ENUMERATED type #182
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -351,7 +351,8 @@ void Attribute::initialize( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case TRICK_LONG: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case TRICK_UNSIGNED_LONG: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case TRICK_LONG_LONG: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case TRICK_UNSIGNED_LONG_LONG: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case TRICK_UNSIGNED_LONG_LONG: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case TRICK_ENUMERATED: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( ( rti_encoding != ENCODING_BIG_ENDIAN ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| && ( rti_encoding != ENCODING_LITTLE_ENDIAN ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| && ( rti_encoding != ENCODING_LOGICAL_TIME ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -3361,6 +3362,7 @@ void Attribute::byteswap_buffer_copy( // RETURN: -- None. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case TRICK_ENUMERATED: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case TRICK_ENUMERATED: | |
| case TRICK_ENUMERATED: { | |
| // Swap based on the actual size of TRICK_ENUMERATED. | |
| size_t elem_size = num_bytes / length; | |
| if (elem_size == sizeof(short)) { | |
| short const *e_src = static_cast<short const *>(src); | |
| short *e_dest = static_cast<short *>(dest); | |
| for (int k = 0; k < length; ++k) { | |
| e_dest[k] = Utilities::byteswap_short(e_src[k]); | |
| } | |
| } else if (elem_size == sizeof(int)) { | |
| int const *e_src = static_cast<int const *>(src); | |
| int *e_dest = static_cast<int *>(dest); | |
| for (int k = 0; k < length; ++k) { | |
| e_dest[k] = Utilities::byteswap_int(e_src[k]); | |
| } | |
| } else if (elem_size == sizeof(long long)) { | |
| long long const *e_src = static_cast<long long const *>(src); | |
| long long *e_dest = static_cast<long long *>(dest); | |
| for (int k = 0; k < length; ++k) { | |
| e_dest[k] = Utilities::byteswap_long_long(e_src[k]); | |
| } | |
| } else { | |
| // Unknown size, just copy. | |
| memcpy(dest, src, num_bytes); | |
| } | |
| break; | |
| } |
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.
I think this is a good comment. Looking at the trick project, here is their assumption about TRICK_ENUMERATED. Not a full list, and while there appears to be some cases where the enum could be something other than int, it seems more often than not TRICK_ENUMERATED is assumed to be exclusively int.
- int: https://github.com/nasa/trick/blob/6ff28150d90f7b73bbf90f87de8b97d7be691e89/trick_source/data_products/Log/TrickBinary.cpp#L238
- int or short: https://github.com/nasa/trick/blob/6ff28150d90f7b73bbf90f87de8b97d7be691e89/trick_source/sim_services/MemoryManager/MemoryManager_clear_memory.cpp#L43
- int: https://github.com/nasa/trick/blob/6ff28150d90f7b73bbf90f87de8b97d7be691e89/trick_source/web/CivetServer/src/VariableServerVariable.cpp#L122
- int or short or char: https://github.com/nasa/trick/blob/6ff28150d90f7b73bbf90f87de8b97d7be691e89/trick_source/sim_services/MemoryManager/MemoryManager_ref_assignment.cpp#L101
- int or short: https://github.com/nasa/trick/blob/6ff28150d90f7b73bbf90f87de8b97d7be691e89/trick_source/sim_services/CheckPointAgent/ClassicCheckPointerAgent.cpp#L497
- int: https://github.com/nasa/trick/blob/6ff28150d90f7b73bbf90f87de8b97d7be691e89/trick_source/sim_services/DataRecord/DRHDF5.cpp#L116
- int: https://github.com/nasa/trick/blob/6ff28150d90f7b73bbf90f87de8b97d7be691e89/trick_source/sim_services/VariableServer/VariableReference.cpp#L485
- int and uint: https://github.com/nasa/trick/blob/6ff28150d90f7b73bbf90f87de8b97d7be691e89/trick_source/sim_services/MemoryManager/ref_to_value.c#L119
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.
[nitpick] TRICK_ENUMERATED is grouped with long/long long here, but in byteswap_buffer_copy it is grouped with TRICK_INTEGER. If the behavior is intended to mirror TRICK_INTEGER, consider grouping consistently (or add a brief comment) to avoid confusion about the expected width/semantics for TRICK_ENUMERATED in different code paths.