mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
[wpiutil] Fix dynamic struct decoding for nested structs (#7346)
After a struct-type field descriptor had offsets calculated more than once, IsBitField would return true, causing the second call to CalculateOffsets to calculate incorrect offsets.
This commit is contained in:
@@ -6,8 +6,10 @@ package edu.wpi.first.util.struct;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
/** Raw struct dynamic struct descriptor. */
|
||||
@@ -148,7 +150,7 @@ public class StructDescriptor {
|
||||
|
||||
private final String m_name;
|
||||
String m_schema;
|
||||
final List<StructDescriptor> m_references = new ArrayList<>();
|
||||
final Set<StructDescriptor> m_references = new HashSet<>();
|
||||
final List<StructFieldDescriptor> m_fields = new ArrayList<>();
|
||||
final Map<String, StructFieldDescriptor> m_fieldsByName = new HashMap<>();
|
||||
int m_size;
|
||||
|
||||
@@ -224,7 +224,7 @@ public class StructFieldDescriptor {
|
||||
* @return true if bitfield
|
||||
*/
|
||||
public boolean isBitField() {
|
||||
return m_bitShift != 0 || m_bitWidth != (m_size * 8);
|
||||
return (m_bitShift != 0 || m_bitWidth != (m_size * 8)) && m_struct == null;
|
||||
}
|
||||
|
||||
private final StructDescriptor m_parent;
|
||||
|
||||
Reference in New Issue
Block a user