-
Notifications
You must be signed in to change notification settings - Fork 61
1964 methods return size one pointers #1965
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
Merged
sharmeye
merged 8 commits into
nasa:master
from
excaliburtb:1964-methods-return-size-one-pointers
Apr 16, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
abc089d
Fixed issues pertaining to swig access and printing of pointers retur…
excaliburtb 5a6d87f
Merge remote-tracking branch 'origin/master' into 1964-methods-return…
excaliburtb a4f3725
Partially addressed MR comments
excaliburtb 4c6a8c5
Format using PR 2011 clang-format with BreakBeforeBraces: Allman
excaliburtb f455b2a
Remove ununsed skipIndex and commented code
excaliburtb cfb6939
Remove space added by clang-format
excaliburtb d907f9b
Change swig_double to use default member initialization. Removed unne…
excaliburtb 291e313
Merge remote-tracking branch 'origin/master' into 1964-methods-return…
excaliburtb 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,66 @@ | ||
| #ifndef ATTRIBUTES_UTILS_HH | ||
| #define ATTRIBUTES_UTILS_HH | ||
|
|
||
| /* | ||
| PURPOSE: ( Provides helper functions for working with ATTRIBUTES. ) | ||
| */ | ||
|
|
||
| #include "trick/attributes.h" | ||
|
|
||
| namespace Trick | ||
| { | ||
|
|
||
| class AttributesUtils | ||
| { | ||
| public: | ||
| // Compute the byte size occupied by a member - references, arrays, and pointers. | ||
| static size_t compute_member_byte_size(const ATTRIBUTES& member); | ||
|
|
||
| // Return the ATTRIBUTES entry that contains the given offset within the struct/class. | ||
| static ATTRIBUTES* find_member_by_offset(ATTRIBUTES* structAttr, size_t addrOffsetFromStruct); | ||
|
|
||
| // Count the number of fixed dimensions on an ATTRIBUTES entry. | ||
| static int count_fixed_dims(const ATTRIBUTES& member); | ||
|
|
||
| /** | ||
| * Result of traversing a structure to find an attribute at a given address offset. | ||
| * This structure contains the common information for traversal. | ||
| */ | ||
| struct TraversalResult | ||
| { | ||
| ATTRIBUTES* found_attr = nullptr; // The attribute found at the given offset, or nullptr | ||
| // if the offset falls in an anonymous/hidden member region | ||
| size_t offset_from_found_attr = 0; // Offset relative to the found attribute; for structured arrays, | ||
| // this is adjusted to the selected element base. | ||
| int array_indices[TRICK_MAX_INDEX] = { }; // Computed array indices (if applicable) | ||
| int num_computed_indices = 0; // Number of valid indices in array_indices | ||
| bool is_in_anonymous_member = false; // True if the offset falls in an anonymous or otherwise unnamed member region | ||
| }; | ||
|
|
||
| /** | ||
| * Traverse a structured type to find the attribute corresponding to a given address offset. | ||
| * This function provides the common traversal logic that can be used for the need to | ||
| * traverse structures but expecting different output formats. | ||
| * | ||
| * @param reference_offset Offset from the structure base address to the address we're looking for | ||
| * @param struct_attr ATTRIBUTES of the structure to traverse | ||
| * @param result Output parameter containing traversal results | ||
| * @return 0 if success, otherwise 1 or non-zero | ||
| */ | ||
| static int traverse_for_offset( | ||
| size_t reference_offset, | ||
| ATTRIBUTES* struct_attr, | ||
| TraversalResult& result); | ||
|
|
||
| // Given a byte offset within a member's storage, compute indices for fixed dimensions. | ||
| // Returns false if an invalid configuration is detected (e.g., divide-by-zero risk). | ||
| static bool compute_fixed_indices_for_linear_offset( | ||
| const ATTRIBUTES& member, | ||
| long offset_within_member_bytes, | ||
| int out_indices[TRICK_MAX_INDEX], | ||
| int& out_num_fixed_dims); | ||
| }; | ||
|
|
||
| } // namespace Trick | ||
|
|
||
| #endif // ATTRIBUTES_UTILS_HH |
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
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
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
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
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.