Merge remote-tracking branch 'origin/GP-862_ghidra1_UnalignedExtAlignment'

This commit is contained in:
ghidra1 2021-05-07 21:02:12 -04:00
commit 92b7728cd7
166 changed files with 6316 additions and 5486 deletions

View file

@ -344,7 +344,7 @@
<ul>
<li><I>Data Types</I>. Improved PDB composite reconstruction to attempt <code>pack(1)</code> alignment if default alignment fails. (GT-3401)</li>
<li><I>Data Types</I>. Added missing support for multi-user merge of unions and structures containing bitfields or a trailing flexible array member. (GT-3479)</li>
<li><I>Data Types</I>. Corrected structure editor save button enablement issue when editing bitfields within an unaligned structure. (GT-3519, Issue #1297)</li>
<li><I>Data Types</I>. Corrected structure editor save button enablement issue when editing bitfields within a non-packed structure. (GT-3519, Issue #1297)</li>
<li><I>Disassembly</I>. Corrected potential infinite loop with disassembler caused by branch to self with invalid delay slot instruction. (GT-3511, Issue #1486)</li>
<li><I>GUI</I>. Corrected processor manual display for Microsoft Windows users, which was not displaying processor manual and was, instead, rendering a blank page in web browser. (GT-3444)</li>
<li><I>GUI:Bitfield Editor</I>. Added field comment support to composite bitfield editor. (GT-3410)</li>
@ -393,7 +393,7 @@
<H1 align="center">Ghidra 9.1 Change History (October 2019)</H1>
<blockquote><p><u>New Features</u></p>
<ul>
<li><I>Data Types</I>. Added bit-field support to Structure and Union editor. An additional Bit-field Editor was also added for explicit bit-field placement within unaligned structures. (GT-559)</li>
<li><I>Data Types</I>. Added bit-field support to Structure and Union editor. An additional Bit-field Editor was also added for explicit bit-field placement within non-packed structures. (GT-559)</li>
<li><I>Eclipse Integration</I>. Added new GhidraSleighEditor Eclipse plugin in the installation directory under Extensions/Eclipse. (GT-113)</li>
<li><I>GUI</I>. Added method for turning off table sorting by control-clicking the only sorted table column. (GT-2763, Issue #87)</li>
<li><I>GUI</I>. Hovering on an address will now show where the byte at that address came from in the imported file. (GT-3016, Issue #154)</li>

View file

@ -7,10 +7,12 @@
li { font-family:times new roman; font-size:14pt; font-family:times new roman; font-size:14pt; margin-bottom: 8px; }
h1 { color:#000080; font-family:times new roman; font-size:28pt; font-style:italic; font-weight:bold; text-align:center; color:#000080; font-family:times new roman; }
h2 { padding-top:20px; color:#984c4c; font-family:times new roman; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left:40px; padding-top:10px; font-family:times new roman; font-family:times new roman; font-size:14pt; font-weight:bold; }
p { margin-left:40px; font-family:times new roman; font-size:14pt; }
td { font-family:times new roman; font-size:14pt; padding-left:10px; padding-right:14px; }
th { font-family:times new roman; font-size:14pt; font-weight:bold; padding-left:10px; padding-right:14px; }
code { color:black; font-family:courier new font-size: 14pt; }
table, th, td { border: 1px solid black; border-collapse: collapse; font-size:10pt; }
td { font-family:times new roman; font-size:14pt; padding-left:10px; padding-right:10px; text-align:left; vertical-align:top; }
th { font-family:times new roman; font-size:14pt; font-weight:bold; padding-left:10px; padding-right:10px; text-align:left; }
code { color:black; font-family:courier new; font-size: 12pt; }
span.code { font-family:courier new font-size: 14pt; color:#000000; }
</STYLE>
</HEAD>
@ -39,6 +41,145 @@
vulnerabilities in networks and systems.
</P>
<BR />
<H1> What's New in Ghidra 10.0</H1>
<H2>Debugger</H2>
<P>Stay tuned...
<H2>Structure/Union Changes</H2>
<P>A significant refactor of the Composite datatype interfaces and internals has been completed which affects
Structures and Unions. The intent of these changes was to provide a more unstandable API and allow an alignment
to be specified for non-packed composites (aka, composites with internal alignment disabled).</P>
<H3>Editor Changes</H3>
<P>Previously, the editor contained an <B>Align</B> checkbox which determined if packing should be performed or not.
This checkbox has been replaced by a checkbox adjacent to the <B>pack</B> choices (i.e., enable/disable packing).
Generally, this setting would be "not-checked" (i.e., disabled) when reverse-engineering the content of a
structure so that components may be placed at specific offsets. Only when there is a complete understanding
of all components, as conveyed by a source header file, should
this be enabled with the appropriate <B>pack</B> and <B>align</B> settings specified. In addition, when <B>pack</B>
is enabled it is important that the component datatypes eimit the correct alignment to ensure proper
placement during packing.</P>
<P>The <B>align</B> setting may know be used when packing is disabled with the composite adopting
the specified alignment. The default alignment for a non-packed composite is <B>1</B> which is consistent
with the current behavior in Ghidra 9.x.</P>
<H3>Composite API Changes</H3>
<P>The various pack and align methods of the <I>Composite</I> (i.e., <I>Structure</I> and <I>Union</I>)
API have been changed extensively. Since these changes were primarly intended to "cleanup" the
interface it was decided not eliminate (not depricate) the old methods. It was felt leaving them in
place would only confuse matters when attempting to understand the new interface. It is also believed that
most uses of the API generally do not utilize the pack and align settings which should minimize the
impact to existing user code.<P>
<P>The tables below convey the <I>Composite</I> API changes as they relate to the pack and align settings.</P>
<BLOCKQUOTE>
<P>
<TABLE WIDTH="100%">
<TR>
<TD COLSPAN="3" padding-top:14px; padding-bottom:14px;><CENTER><B>Composite Pack API Changes</B></CENTER></TD>
</TR><TR style="background-color:#DFDFDF;">
<TH>Old Method 9.x</TH><TH>New Method 10.0</TH><TH>Comments</TH>
</TR><TR>
<TD><CODE>setInternallyAligned(<font color="blue">boolean</font>)</CODE></TD>
<TD><CODE>setPackingEnabled(<font color="blue">boolean</font>)</CODE></TD>
<TD> </TD>
</TR><TR>
<TD><CODE>isInternallyAligned()</CODE></TD>
<TD><CODE>isPackingEnabled()</CODE></TD>
<TD>Equivalent to: <CODE>getPackingType() != DISABLED</CODE></TD>
</TR><TR>
<TD><CODE>setPackingValue(NOT_PACKING)<BR>setPackingValue(1..n)</CODE></TD>
<TD><CODE>setToDefaultPacking()<BR>setExplicitPackingValue(1..n)<BR>pack(1..n)</CODE></TD>
<TD>Packing will be enabled if not previously enabled. Old constant <CODE>NOT_PACKING</CODE> has been elliminated.</TD>
</TR><TR>
<TD><CODE>getPackingValue()</CODE></TD>
<TD><CODE>getExplicitPackingValue()</CODE></TD>
<TD>New method use does not directly map (see Javadocs). Old constant <CODE>NOT_PACKING</CODE> has been elliminated.</TD>
</TR><TR>
<TD> </TD>
<TD><CODE>hasDefaultPacking()</CODE></TD>
<TD>Equivalent to: <CODE>getPackingType() == DEFAULT</CODE></TD>
</TR><TR>
<TD> </TD>
<TD><CODE>hasExplicitPackingValue()</TD>
<TD>Equivalent to: <CODE>getPackingType() == EXPLICIT</CODE></TD>
</TR><TR>
<TD> </TD>
<TD><CODE>getPackingType()</TD>
<TD>Possible values: <CODE>DISABLED</CODE>, <CODE>DEFAULT</CODE> or <CODE>EXPLICIT</CODE></TD>
</TR><TR>
<TD><CODE>realign()</CODE></TD>
<TD><CODE>repack()</CODE></TD>
<TD>Update component sizing and placement if composite has packing enabled.
Changes to data organization (e.g., type sizes and alignments) are problematic and difficult to fully
recover from. Any attempted repair to component sizes and alignments need to be performed in
dependency order (ignoring pointer components).</TD>
</TR>
</TABLE>
<P>
<TABLE WIDTH="100%">
<TR>
<TD COLSPAN="3"><CENTER><B>Composite Align API Changes</B></CENTER><BR>
<B>NOTE!</B> The old alignment <I>set</I> methods previously forced packing to be enabled.
This is no longer the case since the alignment setting is now supported for composites
where packing is not enabled. If packing should be enabled a separate
call to a packing enablement method (see above) is required. When packing is <U>disabled</U>
the composite's computed alignment will match the specified align setting (default is
1 which is consistent with old behavior).
</TD>
</TR><TR style="background-color:#DFDFDF;">
<TH>Old Method 9.x</TH><TH>New Method 10.0</TH><TH>Comments</TH>
</TR><TR>
<TD><CODE>setToDefaultAlignment()</CODE></TD>
<TD><CODE>setToDefaultAligned()</CODE></TD>
<TD>Default alignment for a non-packed composite is 1. When packing is enabled the
default alignment is a function of the component packing.</TD>
</TR><TR>
<TD><CODE>isDefaultAligned()</CODE></TD>
<TD><CODE>isDefaultAligned()</CODE></TD>
<TD>Equivalent to: <CODE>getAlignmentType() == DEFAULT</CODE></TD>
</TR><TR>
<TD><CODE>setToMachineAlignment()</CODE></TD>
<TD><CODE>setToMachineAligned()</CODE></TD>
<TD>Non-packed composites will have an alignment which equals the machine alignment
specified by the compiler specification (data organization). Packed structures
will have an alignment which is a multiple of the machine alignment.</TD>
</TR><TR>
<TD><CODE>isMachineAligned()</CODE></TD>
<TD><CODE>isMachineAligned()</CODE></TD>
<TD>Equivalent to: <CODE>getAlignmentType() == MACHINE</CODE></TD>
</TR><TR>
<TD><CODE>setMinimumAlignment(DEFAULT_ALIGNMENT_VALUE)<BR>setMinimumAlignment(1..n)</CODE></TD>
<TD><CODE>setToDefaultAligned()<BR>setExplicitMinimumAlignment(1..n)<BR>align(1..n)</CODE></TD>
<TD>
If an explicit minimum alignment is set (1..n), non-packed composites will have an alignment
which equals this value, while packed structures
will have an alignment which is a multiple of this value.
Old constant <CODE>DEFAULT_ALIGNMENT_VALUE</CODE> has been elliminated.
</TD>
</TR><TR>
<TD><CODE>getMinimumAlignment()</CODE></TD>
<TD><CODE>getExplicitMinimumAlignment()</CODE></TD>
<TD>New method use does not directly map (see Javadocs). Old constant <CODE>DEFAULT_ALIGNMENT_VALUE</CODE> has been elliminated.</TD>
</TR><TR>
<TD></TD>
<TD><CODE>hasExplicitMinimumAlignment()</CODE></TD>
<TD>Equivalent to: <CODE>getAlignmentType() == EXPLICIT</CODE></TD>
</TR><TR>
<TD></TD>
<TD><CODE>getAlignmentType()</CODE></TD>
<TD>Possible values: <CODE>DEFAULT, MACHINE or EXPLICIT</CODE></TD>
</TR>
</TABLE>
</BLOCKQUOTE>
<BR />
<H1> What's New in Ghidra 9.2</H1>

View file

@ -80,8 +80,8 @@ public class DBTraceDataTypeManager extends DataTypeManagerDB
}
@Override
public void dataTypeChanged(DataType dataType) {
super.dataTypeChanged(dataType);
public void dataTypeChanged(DataType dataType, boolean isAutoChange) {
super.dataTypeChanged(dataType, isAutoChange);
if (!isCreatingDataType()) {
trace.getCodeManager().invalidateCache(false);
trace.getSymbolManager().invalidateCache(false);

View file

@ -203,10 +203,10 @@ src/main/help/help/topics/DataTypeEditors/images/NumElementsPrompt.png||GHIDRA||
src/main/help/help/topics/DataTypeEditors/images/Plus.png||GHIDRA||||END|
src/main/help/help/topics/DataTypeEditors/images/StructureEditBitfield.png||GHIDRA||||END|
src/main/help/help/topics/DataTypeEditors/images/StructureEditor.png||GHIDRA||||END|
src/main/help/help/topics/DataTypeEditors/images/StructureEditorAligned.png||GHIDRA||||END|
src/main/help/help/topics/DataTypeEditors/images/StructureEditorPacked.png||GHIDRA||||END|
src/main/help/help/topics/DataTypeEditors/images/StructureEditorWithFlexArray.png||GHIDRA||||END|
src/main/help/help/topics/DataTypeEditors/images/UnionEditor.png||GHIDRA||||END|
src/main/help/help/topics/DataTypeEditors/images/UnionEditorAligned.png||GHIDRA||||END|
src/main/help/help/topics/DataTypeEditors/images/UnionEditorPacked.png||GHIDRA||||END|
src/main/help/help/topics/DataTypeEditors/images/Unpackage.gif||GHIDRA||||END|
src/main/help/help/topics/DataTypeEditors/images/cstruct.png||GHIDRA||reviewed||END|
src/main/help/help/topics/DataTypeEditors/images/disk.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|

View file

@ -54,9 +54,9 @@
<UL>
<LI><I>Edit Actions</I>: The icon buttons at the top of the editor are used to modify this
structure. Each button has a different <A href="#Structure_Editor_Edit_Actions">edit
action</A> associated with it. These allow the user to: apply changes, insert Undefined
bytes, reorganize the current components, duplicate components, clear components (changes
them to Undefined bytes), delete components, create array components, and unpackage a
action</A> associated with it. These allow the user to: apply changes, insert
Undefined components, reorganize the current components, duplicate components, clear components (changes
them to <i>undefined</i> components), delete components, create array components, and unpackage a
structure or array component changing it into its component parts.<BR>
</LI>
@ -79,11 +79,9 @@
be changed by <A href="#Structure_Editor_Cycle">cycling</A> the data type.</LI>
<LI><I>Structure Information Area</I>: This is the area below the component table with the
name, description, category, size and alignment of the structure or union. The structure or
name, description, category, size, packing and alignment of the structure or union. The structure or
union being edited can be <A href="#Structure_Editor_Name">renamed</A> from here. Its <A
href="#Structure_Editor_Description">description</A> can be specified here. Also, it can be
changed between <A href="#Structure_Editor_InternallyAligned">unaligned and
aligned</A>.<BR>
href="#Structure_Editor_Description">description</A> can be specified here.<BR>
</LI>
<LI>Immediately below the structure information area is a status line where status messages
@ -146,45 +144,54 @@
<P>To change the size of the structure being edited, edit the <I>Size</I> field in the bottom
of the editor and press the <SPAN style="font-weight: bold;">Enter</SPAN> key to apply the
new size to the structure. If you are reducing the size of the structure, you will be
prompted to determine that you really want to truncate the structure.</P>
prompted to determine that you really want to truncate the structure. The ability to specify the
size is only permitted for non-packed structures. For other situations the field is read-only.</P>
</BLOCKQUOTE>
<H2><A name="Structure_Editor_ActualAlignment"></A>Alignment</H2>
<BLOCKQUOTE>
<P>At the bottom of the editor is an <SPAN style="font-style: italic;">Alignment</SPAN>
field, which indicates how the structure or union being edited will be aligned within other
data types. All unaligned structures and unions will have an alignment of 1 (byte aligned)
and will therefore not be aligned within other data types. For aligned structures and unions
the alignment value is determined based on the alignments of the individual components they
contain, whether they are <A href="#Structure_Editor_PackMaximum">packed internally</A> and
whether they have a <A href="#Structure_Editor_AlignMinimum">minimum alignment</A>
specified.<BR>
<P>At the bottom of the editor is a read-only <SPAN style="font-style: italic;">Alignment</SPAN>
field which conveys the acutal alignment of this data type.
All non-packed structures and unions (i.e., pack disabled) will have a default alignment of 1 (byte aligned)
unless a <A href="#Structure_Editor_Align">minimum alignment</A> value has been specified. For packed structures and unions
the actual alignment value is calculated based on the <A href="#Structure_Editor_Pack">pack</A> setting,
preferred alignments of the individual components,
and the minimum alignment setting. The size of a packed structure or union will always be a multiple
of this alignment value. This value is always expressed in terms of 8-bit bytes.</P>
<P>
This alignment is considered when this data type, or dirivative data type, is placed within another packed composite.
A compiler will also utilize this when placing components within memory although Ghidra does not
enforce such placement.<BR>
</P>
</BLOCKQUOTE>
<H2><A name="Structure_Editor_InternallyAligned"></A>Unaligned vs. Aligned</H2>
<H2><A name="Structure_Editor_NonPacked"></A>Packed vs. Non-Packed</H2>
<BLOCKQUOTE>
<P>In the lower right corner of the editor is an <SPAN style=
"font-style: italic;">Align</SPAN> check box. When the box is checked the structure or union
is aligned. Click the checkbox to change between aligned and unaligned. When a structure or
union is aligned, additional choices will appear that allow minimum alignment and packing to
be specified.<BR>
<P>In the lower right corner of the editor is a series of <SPAN style=
"font-style: italic;">pack</SPAN> choice buttons. The <B>disabled</B> button corresponds to a non-packed
structure or union, while the <B>default</B> or value-entry buttons enable packing.<BR>
</P>
</BLOCKQUOTE>
<BLOCKQUOTE>
<H3>Unaligned Structures</H3>
<H3>Non-Packed Structures</H3>
<BLOCKQUOTE>
<P>When a structure is unaligned, with the exception of bitfields, each component shown within
the editor immediately follows the one before it. In other words, no automatic alignment or padding occurs.
Unaligned structures may be used to position components with known data
types at specific offsets within a structure. Therefore, when editing an unaligned structure,
the structure editor attempts to prevent defined components from moving
to a different offset when performing operations like drag and drop which may consume undefined bytes. <BR>
<P>When packing is disabled for a structure all bytes are accounted for
by the displayed components. Use of <i>undefined</i> filler components as padding and reservation of space.
This differs from a packed structure which does not reveal padding in the form of components and does not provide
a means of reserving space.
Non-packed structures may be used to position components with known data
types at specific offsets within a structure whose size has been specified. When editing a non-packed structure
the editor attempts to prevent defined components from moving
to a different offset when performing operations like drag and drop which may consume undefined bytes.
The default alignment for non-packed structures is 1-byte but may be overriden by setting a specific
non-default <A href="#Structure_Editor_Align">minimum alignment</A>.
The alignment will not influence the size of a non-packed structure so it is advised
that the size always be explicity set to a multiple of the alignment value.<BR>
</P>
<DIV style="text-align: center; margin-top: 10px;">
@ -192,108 +199,114 @@
</DIV>
</BLOCKQUOTE>
<H3>Aligned Structures</H3>
<H3>Packed Structures</H3>
<BLOCKQUOTE>
<P>An aligned structure is defined similar to a structure in a C header file. The data types
are specified for each of the components, but their offsets will be automatically adjusted to
the correct alignment based on the data type and position in the structure. A default
"undefined" byte cannot be added to an aligned structure, although an "undefined1" component
can be and is treated like any other fixed-length datatype. The overall size of the structure is
determined by the components it contains and the specified pack value. The alignment and
packing behavior is determined by the effective data organization as defined by each compiler
specification (data type archives utilize a default data organization). When you select the
<B>Align</B> checkbox, the GUI displays buttons to allow an align attribute, <SPAN style=
"font-weight: bold; font-style: italic;">align( minimum )</SPAN>, to be specified. It also
allows a pack value, <SPAN style="font-style: italic;"><SPAN style=
"font-weight: bold;">pack</SPAN></SPAN> <SPAN style=
"font-weight: bold; font-style: italic;">( maximum )</SPAN>, to be specified. The following
image shows these GUI components for aligning the data type being edited.<BR>
<P>A packed structure is defined similar to a structure in a C header file and is intended
to automatically adjust component placement, size and alignment in a manner consistent
with the associated compiler specification. Data types
are specified for each of the components, but their offsets are automatically computed
based upon the pack settings and preferred alignment of each component's data type. A default
datatype (i.e., <i>undefined</i>) cannot be added to a packed structure, although other sized datatypes
(e.g., <i>undefined1</i>, <i>undefined4</i>, etc.) may be used as component place-holders and will
pack appropriately based upon their size. The overall size of the structure is
determined by the components it contains, the pack setting (default or explicit value) and the minimum alignment setting.
The default alignment and pack behavior is controlled by the effective data organization. This can
cause the same structure viewed within a program to be layed-out quite differently than within a datatype archive
which uses a default data organization.</P>
<P>The following image shows the editor state reflecting a default packed structure with
default alignment.<BR>
</P>
<DIV style="text-align: center; margin-top: 10px;">
<IMG alt="" src="images/StructureEditorAligned.png"><BR>
<IMG alt="" src="images/StructureEditorPacked.png"><BR>
</DIV>
</BLOCKQUOTE>
<H4><A name="Structure_Editor_AlignMinimum"></A>align( minimum )</H4>
<H4><A name="Structure_Editor_Align"></A>align (minimum)</H4>
<BLOCKQUOTE>
<P>This indicates the minimum alignment to be used when aligning this data type inside
another data type. Setting this to a value other than <SPAN style=
"font-weight: bold;">none</SPAN> forces this structure to be aligned within other structures
at an offset that is a multiple of the specified value. Specifying a minimum alignment also
causes the end of the structure to be padded so its size is a multiple of the minimum
alignment.<BR>
<P>This setting controls the minimum alignment to be used when computing this data type's
<A href="#Structure_Editor_ActualAlignment">actual alignment</A>.<BR>
</P>
<UL>
<LI><SPAN style="font-weight: bold;">none</SPAN> - Sets this data type to have <SPAN style=
"font-weight: bold;">no</SPAN> specified minimum alignment when aligning this data type
inside another data type. Align this data type based only on its components and their
minimum alignments and packing.<BR>
<LI><SPAN style="font-weight: bold;">default</SPAN> - Sets this data type to compute its <SPAN style=
"font-weight: bold;">default</SPAN> alignment based only on the pack setting and the alignment of
the individual components. If packing is disabled (i.e., explicit component placement by offset)
the default alignment will always be 1-byte and preferred component alignments are ignored.<BR>
</LI>
<LI><SPAN style="font-weight: bold;">machine</SPAN> - Sets this data type to have a minimum
alignment that is a multiple of the <SPAN style="font-weight: bold;">machine</SPAN>
alignment when aligning this data type inside another data type. In this case <SPAN style=
"font-weight: bold;">machine</SPAN> alignment means the largest alignment which is ever
used for any data type on the program's intended machine.<BR>
<LI>explicit value - The radio-button with a text field next to it allows you to specify an
explicit minimum alignment value. This sets the data types minimum alignment. The
computed alignment for the data type will be a multiple of this value.</LI>
<LI><SPAN style="font-weight: bold;">machine</SPAN> - Sets the minimum alignment to conform
to the machine alignment specified by the associated data organization (i.e., compiler specification).
This genrally corresponds to the largest alignment which is ever
used for any data type on the program's intended machine. If this is choosen and
the resulting alignment is larger, this is likely due to a component data type
having an alignment larger than the machine alignment.
<BR>
</LI>
<LI>by value - The bottom button with a text field next to it allows you to specify a
minimum alignment value. This sets this data type to have a minimum alignment that is a
multiple of the <SPAN style="font-weight: bold;">specified value</SPAN> when aligning this
data type inside another data type.</LI>
</UL>
<P><IMG alt="Note:" src="../../shared/note.png"> The equivalent of having <I>no C code align
attribute</I> on the structure or union is to choose <B>none</B>. The equivalent for a C code
attribute of <I>align()</I> without a value is to choose <B>machine</B> alignment. The
equivalent of <I>align(4)</I> is to specify a <B>value</B> of 4.</P>
<P><IMG alt="Note:" src="../../shared/note.png"> The equivalent of having <I>no C/C++ code aligned/alignas
attribute</I> on the structure or union is to choose <B>default</B>. The equivalent for the C code
<i>aligned</i> attribute without a value is to choose <B>machine</B> alignment. The
equivalent of <I>aligned(4)</I> or <I>alignas(4)</I> is to specify an explicit alignment <B>value</B> of 4.</P>
</BLOCKQUOTE>
<H4><A name="Structure_Editor_PackMaximum"></A>pack( maximum )</H4>
<H4><A name="Structure_Editor_Pack"></A>pack</H4>
<BLOCKQUOTE>
<P>This indicates a packing value to be used when aligning the components within this data
type. Setting this to a value other than <B>none</B> forces each component of this structure
to be packed so that its maximum alignment within the structure is no more than the pack
value. However, a component will not be packed if the data type or one of its subcomponents
data types has a minimum alignment value specified that exceeds the pack value. Packing also
affects the padding at the end of this structure so that the overall size of the structure is
the smallest possible multiple of the pack value. If the minimum alignment is greater than
the pack value, the end of the structure or union is padded based on the minimum alignment
instead.<BR>
<P>This setting controls the packing behavior of the structure or union. In general, packing should
be disabled when a complete definition is unknown and it is neccessary to reverse engineer the
component specifications. This is the initial state of a new structure with the <B>pack</B>
checkbox left unchecked. When a the specifications of a composite are known, such as from
a source header file, it may be preferred to enable packing to allow for automatic placement of
components and calculation of alignment and size. To enable packing the <B>pack</B> checkbox
should be checked and either a <B>default</B> or explicit pack value specified.<BR>
</P>
<UL>
<LI><B>none</B> - The components within this structure should align themselves in the
default way for the compiler. The components are not being packed with a reduced alignment.<BR>
<LI><B>default</B> - The components within this structure should align besed upon the
preferred alignment of each component.<BR>
</LI>
<LI>by value - The bottom button with a text field next to it allows you to specify a pack
value. The <B>specified value</B> indicates the maximum alignment to use when packing any
<LI>explicit value - The button with a text entry field next to it allows you to specify an explicit pack
value. The specified value indicates the maximum alignment to use when packing each
component.<BR>
</LI>
</UL>
<P>
When packing is enabled, the padding at the end of a structure will be adjusted to ensure
an overall size which is a multiple of the computed alignment. If an explicit pack
value is specified the, the aligned placement of components will not exceed this value.
In addition, the computed alignment will not exceed this value if a <B>default</B> is selected for the
<B>align (minimum)</B> setting. If a minimum alignment other than <B>default</B> is specified,
the computed alignment and overall size will be a multiple of the align value regardless
of the <B>pack</B> setting. The <B>align</B> setting will not influence interior component placement
as does the <B>pack</B> setting.<BR>
</P>
<P><IMG alt="Note:" src="../../shared/note.png"> The placement of bitfields may be influenced
based upon the specified pack value.<BR>
based upon the specified pack value based upon the compiler specification.<BR>
</P>
<P><IMG alt="Note:" src="../../shared/note.png"> The equivalent of having <I>no C #pragma
pack attribute</I> on the structure or union is to choose <B>none</B>. The equivalent for a C
pack attribute</I> on the structure or union is to choose <B>default</B>. The equivalent for a C
code attribute of <I>#pragma pack()</I> without a value is to specify a <B>pack value</B> of
<B>1</B>. The equivalent of <I># pragma</I> <I>pack(4)</I> is to specify a <B>pack value</B>
of 4.<BR>
</P>
</BLOCKQUOTE>
<H3>Unaligned Unions</H3>
<H3>Non-packed Unions</H3>
<BLOCKQUOTE>
<P>When a union is unaligned, the union is the size of its largest component.&nbsp; There is
no alignment padding and the alignment&nbsp; is 1 when putting an unaligned union into other
data types.<BR>
<P>When a union is not packed (i.e., pack disabled), the union is the size of its largest component.&nbsp; There is
no alignment padding and the default alignment&nbsp; is 1. As with structures, a <A href=
"#Structure_Editor_Align">minimum alignment</A> may be specified to force a specific alignment.
The alignment will not influence the size of a non-packed union so it is advised
that the size always be explicity set to a multiple of the alignment value.<BR>
</P>
<DIV style="text-align: center; margin-top: 10px;">
@ -301,21 +314,21 @@
</DIV>
</BLOCKQUOTE>
<H3>Aligned Unions</H3>
<H3>Packed Unions</H3>
<BLOCKQUOTE>
<P>&nbsp;In an aligned union the overall size is at least the size of the largest component,
but will be padded based on the alignment and packing. The <A href=
"#Structure_Editor_AlignMinimum">minimum alignment</A> is specified just as within a
<P>&nbsp;In a packed union the overall size is at least the size of the largest component,
but will be padded based on the actual computed alignment. The <A href=
"#Structure_Editor_Align">minimum alignment</A> is specified in the same manner as for a
structure and affects the alignment in the same way. The <A href=
"#Structure_Editor_PackMaximum">pack value</A> is specified in the same manner as within a
structure, but only affects the padding in the overall size of the union. All elements in a
"#Structure_Editor_Pack">pack value</A> is specified in the same manner as within a
structure, but only affects the trailing padding and overall size of the union. All elements in a
union have an offset of zero, so the pack value doesn't affect the component offsets. If both
a minimum alignment and pack value are specified, the minimum alignment will override the
pack value if it is larger.</P>
<DIV style="text-align: center; margin-top: 10px;">
<IMG alt="" src="images/UnionEditorAligned.png">
<IMG alt="" src="images/UnionEditorPacked.png">
</DIV>
</BLOCKQUOTE>
@ -334,25 +347,25 @@
bit-size is generally appended to the base-datatype for datatype specification and
presentation purposes (e.g., char:1).</li>
<li>A zero-length bitfield may be defined within a byte but its' precise bit position
is controlled by endianess alone. A zero-length bitfield has no affect within an unaligned
structure and is intended for use within aligned structures where it may impart alignment
is controlled by endianess alone. A zero-length bitfield has no affect within a non-packed
structure and is intended for use within packed structures where it may impart alignment
affects based upon compiler conventions.</li>
<li>Inserting a bitfield within an unaligned structure may cause component shifts based
<li>Inserting a bitfield within a non-packed structure may cause component shifts based
upon the specified offset and allocation unit byte size when a placement conflict occurs.</li>
<li>The start/end byte offsets may be shared with adjacent bitfield components.</li>
<li>Unoccupied bits within a partially occupied byte are not represented by any component
(similar to padding bytes within aligned structures).</li>
<li>A separate <a href="#Structure_Bitfield_Editor">Bitfield Editor</a>, for use with unaligned structures only,
(similar to padding bytes within packed structures).</li>
<li>A separate <a href="#Structure_Bitfield_Editor">Bitfield Editor</a>, for use with non-packed structures only,
must be used to precisely place a bitfield component. Adding a bitfield component via the
structure table view via datatype text entry (e.g., char:1) provides only rough placement for unaligned
structure table view via datatype text entry (e.g., char:1) provides only rough placement for non-packed
structures since additional bytes will be introduced.
The BitField Editor may be displayed using the the Add Bitfield and
Edit Bitfield popup menu actions on a selected structure component. The datatype text entry approach
must be used for all unions and aligned structures.</li>
must be used for all unions and packed structures.</li>
</ul>
</BLOCKQUOTE>
<P><IMG alt="Note:" src="../../shared/note.png">While packing of bitfields within aligned
<P><IMG alt="Note:" src="../../shared/note.png">While packing of bitfields within packed
structures is controlled by the compiler specification (e.g., data organization), bit-packing
order is currently fixed based upon endianess. Little-endian packs starting with bit-0 (lsb)
while big-endian packs starting with bit-7 (msb).</P>
@ -401,9 +414,10 @@
Insert Undefined Byte</H3>
<BLOCKQUOTE>
<P>Undefined Bytes can only be inserted into a structure that is not aligned. A single
Undefined byte is inserted before the current selection by clicking the <IMG src=
"images/Plus.png" alt=""> <B>Insert Undefined Byte</B> button.</P>
<P>Within a non-packed structure <i>undefined</i> components are inserted before the current selection by clicking the <IMG src=
"images/Plus.png" alt=""> <B>Insert Undefined Byte</B> button. Within a packed structure an <i>undefined1<i> datatype component
is inserted in a similar fashion, although in packed structures it is more appropriate to use a properly sized datatype (e.g., modify datatype
on inserted component).</P>
</BLOCKQUOTE>
<H3><A name="Structure_Editor_Move_Components_Up"></A> <IMG src="images/up.png" alt=""> Move
@ -442,9 +456,9 @@
<LI>A single copy of the component is created immediately following the selected one.</LI>
</OL>
<P>If the structure is not aligned, then there must be enough Undefined bytes following the
component to accommodate the duplicate. In an unaligned structure, Undefined bytes get
replaced by the new copy of the component.</P>
<P>If the structure is not packed (i.e., pack disabled), then there must be enough <i>undefined</i> components following the
component to accommodate the duplicate. In such a such a structure, <i>undefined</i> bytes get
consumed by the new copy of the component.</P>
</BLOCKQUOTE>
<H3><A name="Structure_Editor_Duplicate_Multiple_of_Component"></A> <IMG src=
@ -460,8 +474,8 @@
Component...</B> button.</LI>
<LI><A name="Structure_Editor_Duplicates_NumberInputDialog"></A> The number of duplicates
dialog appears. In an unaligned structure, you can only indicate as many duplicates as will
fit in place of Undefined bytes.</LI>
dialog appears. In a non-packed structure, you can only indicate as many duplicates as will
fit in place of <i>undefined</i> bytes.</LI>
</OL>
</BLOCKQUOTE>
@ -502,10 +516,10 @@
Clear Component(s)</H3>
<BLOCKQUOTE>
<P>Clearing a component changes it into Undefined byte components that take up the same
amount of space as the component being cleared. Components can be cleared in unaligned
structures, but not in unions or aligned structures. This is because the resulting Undefined
bytes are not valid components in a union or aligned structure.</P>
<P>Clearing a component changes it into an <i>undefined</i> components that take up the same
amount of space as the component being cleared. Components can only be cleared in non-packed
structures (i.e., pack disabled), but not in unions or packed structures. This is because the resulting <i>undefined</i>
components are not valid in a union or packed structure.</P>
<P>To clear components in a structure:</P>
@ -514,7 +528,7 @@
<LI>Press the <IMG src="images/erase16.png" alt=""> <B>Clear Component(s)</B> button.</LI>
<LI>Each selected component is replaced by Undefined Bytes. The number of Undefined Bytes
<LI>Each selected component is replaced by <i>undefined</i> components. The number of <i>undefined</i> components
will be equal to the length of the component being cleared.</LI>
</OL>
@ -542,8 +556,8 @@
<BLOCKQUOTE>
<OL start="4">
<LI>Specify the number of elements. For an unaligned structure, the maximum size of the
array is limited by the number of Undefined bytes following the selected component.</LI>
<LI>Specify the number of elements. For a non-packed structure (i.e., pack disabled), the maximum size of the
array is limited by the number of <i>undefined</i> components following the selected component.</LI>
<LI>Press the <B>OK</B> button.</LI>
@ -568,7 +582,7 @@
the data type of the array. The array's dimension is determined by how many of that data
type will fit in the space that was occupied by the selection. The size of the array will
be the array that can fit in the selected number of bytes. Any left over (unused) bytes at
the end of the selection will become Undefined bytes.</LI>
the end of the selection will become <i>undefined</i> components.</LI>
</OL>
</BLOCKQUOTE>
@ -621,12 +635,12 @@
</BLOCKQUOTE><BR>
</BLOCKQUOTE>
<H2><A name="Structure_Editor_Bitfield_Actions"></A>Bitfield Actions (unaligned structures)</H2>
<H2><A name="Structure_Editor_Bitfield_Actions"></A>Bitfield Actions (Non-Packed Structures)</H2>
<BLOCKQUOTE>
<P>The following bitfield actions are available when modifying unaligned structures only and are available
<P>The following bitfield actions are available when modifying non-packed structures only (i.e., pack disabled) and are available
via the popup menu based upon a selected component or table row. When working with unions and
aligned structures, bitfields may only be specified via datatype text entry specification within the
packed structures, bitfields may only be specified via datatype text entry specification within the
table view (e.g., char:1).</P>
<H3><A name="Structure_Editor_Add_Bitfield"></A>Add Bitfield</H3>
@ -671,10 +685,10 @@
<P><B><I>Name</I></B> - The field name associated with this component in the structure or
union. When specified, the field names must be unique for the components in a structure or
union. This field is editable, except on components that are Undefined bytes.</P>
union. This field is editable, except on <i>undefined</i> components.</P>
<P><B><I>Comment</I></B> - A comment associated with this component. This field is editable,
except on components that are Undefined bytes.</P>
except on <i>undefined</i> components.</P>
</BLOCKQUOTE>
<P><IMG src="../../shared/tip.png" alt="" border="0"> To rearrange the order of the component
@ -687,8 +701,7 @@
<H3><A name="Structure_Editor_Edit_Component_Field"></A> Editing Component Fields</H3>
<P>The <I>DataType</I>, <I>Name</I> and <I>Comment</I> fields are editable. However, the
<I>Name</I> and <I>Comment</I> are not editable when the component's <I>DataType</I> is an
Undefined byte.</P>
<I>Name</I> and <I>Comment</I> are not editable on <i>undefined</i> components.</P>
<P>To place an editable field into edit mode:</P>
@ -792,28 +805,29 @@
<H4><A name="EffectOfChangingDataTypeSize"></A> <U>Effect of Changing a Component's
Size</U></H4>
<P>An unaligned union's size will always be the size of its largest component. If you
<P>A non-packed union's size will always be the size of its largest component. If you
change a data type for a component and the component size changes, the union size will
change if necessary. An aligned union is padded to make its size a multiple of the union's
change if necessary. A packed union is padded to make its size a multiple of the union's
alignment.<BR>
</P>
<P>How a structure is affected by changing a component's data type depends on whether the
structure size is aligned or unaligned.</P>
structure size is packed or non-packed.</P>
<BLOCKQUOTE>
<P><B>Unaligned</B> - If the structure is <I>unaligned</I>, then the new component must
be less than or equal to the original component's size plus any Undefined byte components
that immediately follow it in the structure. In an unaligned structure, decreasing the
component size will create Undefined byte components following it to maintain the
structure size. Increasing the component size replaces Undefined bytes immediately
following the component. The last component of a structure can be always be changed which
<P><B>Non-Packed</B> - If the structure has <I>pack disabled</I>, then the new component must
be less than or equal to the original component's size plus any <i>undefined</i> components
that immediately follow it in the structure. Decreasing the
component size will create <i>undefined</i> components following it to maintain the
structure size and placement of other components. Increasing the component size replaces
<i>undefined</i> components immediately
following the component. The last component of a structure can always be changed which
can cause the structure to grow larger.<BR>
</P>
<P><B>Aligned</B> - If the structure is <I>aligned</I>, the component can change size,
which affects the structure's overall size and the alignment of individual components
that follow it.</P>
<P><B>Packed</B> - If the structure is <I>packed</I>, a component can change size or alignment,
which can affect the placement of subsequent components within a structure and/or the
overall size and alignment of both structures and unions.</P>
</BLOCKQUOTE>
</BLOCKQUOTE>
@ -859,7 +873,7 @@
</BLOCKQUOTE>
<BLOCKQUOTE>
<H3>Union or Aligned Structure<BR>
<H3>Union or Packed Structure<BR>
</H3>
<P>The first data type in a cycle group can be added to the end of a structure as a new
@ -897,13 +911,13 @@
cycle group. The data type can then be cycled to any other data type in the group.</P>
</BLOCKQUOTE>
<H3><B>Unaligned Structure</B></H3>
<H3><B>Non-Packed Structure</B></H3>
<P>Cycling is implemented similar to how it is implemented in an aligned structure. The
<P>Cycling is implemented similar to how it is implemented in a packed structure. The
only exception is that the user can only cycle to data types that will fit within the data
boundary of the current component. If Undefined bytes follow the selected component, the
Undefined bytes can be replaced by cycling the data type to a larger sized data type.
Likewise, cycling to a smaller data type will add Undefined bytes after the component being
boundary of the current component. If <i>undefined</i> components follow the selected component, the
component can be replaced by cycling the data type to a larger sized data type.
Likewise, cycling to a smaller data type will add <i>undefined</i> components after the component being
cycled. However, the last component is not restricted to a particular size.<BR>
</P>
</BLOCKQUOTE>
@ -957,8 +971,8 @@
<H2><A name="AddDataType"></A>Adding a Data Type</H2>
<BLOCKQUOTE>
<P>A data type can be added as a component by replacing Undefined bytes. When editing an
unaligned structure, there must be enough Undefined bytes for the data type to replace. A
<P>A data type can be added as a component by replacing <i>undefined</i> components. When editing a
non-packed structure, there must be enough <i>undefined</i> components for the new data type. A
data type can also be added to the end of a structure or union.</P>
<BLOCKQUOTE>
@ -997,7 +1011,7 @@
<H2><A name="InsertDataType"></A>Inserting a Data Type</H2>
<BLOCKQUOTE>
<P>In an aligned structure or a union, a data type can be inserted as a new component.</P>
<P>In a packed structure or a union, a data type can be inserted as a new component.</P>
<BLOCKQUOTE>
<H3>Drag and Drop</H3>
@ -1025,9 +1039,9 @@
<H2><A name="ReplaceDataType"></A>Replacing a Data Type</H2>
<BLOCKQUOTE>
<P>A component can have its data type replaced with a different data type. If an unaligned
structure is being edited then Undefined bytes are created or consumed as necessary to
maintain the position of other components within the structure. For unions and aligned
<P>A component can have its data type replaced with a different data type. If a non-packed
structure is being edited then <i>undefined</i> components are created or consumed as necessary to
maintain the position of other components within the structure. For unions and packed
structures, the data type simply changes for the component and the overall size is adjusted
accordingly.</P>
@ -1041,22 +1055,22 @@
component in the editor.
If the mouse pointer is a 'circle with a slash' then the data type cannot be
dropped to replace the component. This is probably because the data type being dropped
won't fit in the structure in place of the original component. If editing a union or an
aligned structure the data type should always fit and the drop is allowed. If editing an
unaligned structure, the component is replaced only if the new component will fit. (see
won't fit in the structure in place of the original component. If editing a union or
packed structure the data type will always fit and the drop is allowed (provided the datatype is allowed). If editing a
non-packed structure, the component is replaced only if the new component will fit. (see
<A href="#EffectOfChangingDataTypeSize">Effect of Changing a Component's Size</A>)</P>
<H4>Contiguous Selection of Multiple Components</H4>
<P>Drag a data type to a block of selected components.
Whether the structure is aligned or unaligned doesn't matter when dropping a data type on
Whether the structure is packed or non-packed doesn't matter when dropping a data type on
a block of selected components. This is because the new component (s) will occupy the
same space as the currently selected components.<BR>
<B>In a union</B>, all selected components will be replaced with a single component
containing the data type dropped.<BR>
<B>In a structure</B>, as many components of the dropped data type as will fit in the
selection are created to replace the selection. In an unaligned structure any left over
bytes in the selection will become Undefined bytes.</P>
selection are created to replace the selection. In a non-packed structure any left over
bytes in the selection will become <i>undefined</i> components.</P>
<P><IMG src="../../shared/note.png" alt=""> For information about drag and drop with
pointers, see <A href="#DragNDrop">Drag and Drop Basics</A>.</P>
@ -1085,9 +1099,9 @@
<B>In a union</B>, all selected components will be replaced with a single component
containing the favorite data type.<B><BR>
In a structure</B>, only favorites that will fit in place of the selection will be
enabled. Just like with drag and drop, whether the structure is aligned or unaligned
enabled. Just like with drag and drop, whether the structure is packed or non-packed
doesn't matter. The selection becomes as many of the data type as will fit and left over
bytes become Undefined bytes for an unaligned structure.</P>
bytes become <i>undefined</i> components for a non-packed structure.</P>
<P><IMG src="../../shared/note.png" alt=""> For information about Pointers as a Favorite,
see <A href="#Structure_Editor_Favorite">Favorites Basics</A>.</P>
@ -1248,14 +1262,14 @@
</U></P>
</BLOCKQUOTE>
<H2><A name="Structure_Bitfield_Editor"></A>Bitfield Editor (unaligned structures only)</H2>
<H2><A name="Structure_Bitfield_Editor"></A>Bitfield Editor (Non-Packed Structures only)</H2>
<BLOCKQUOTE>
<P>The Bitfield Editor is used by the Structure Editor when adding or modifying bitfield components
within unaligned structures to facilitate precise placement at the bit level. The Bitfield Editor
is not supported for unions and aligned structures since automated packing is performed (i.e.,
within non-packed structures to facilitate precise placement at the bit level. The Bitfield Editor
is not supported for unions and packed structures since automated packing is performed (i.e.,
bitfields are specified via datatype text entry within the structure/union table view).
While editing an unaligned structure, the Structure Editor popup menu actions <B>Add Bitfield</B>
While editing a non-packed structure, the Structure Editor popup menu actions <B>Add Bitfield</B>
and <B>Edit Bitfield</B> are used to launch the Bitfield Editor.</P>
<P>The Bitfield Editor includes a visual depiction of the storage allocation bytes and associated

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View file

@ -487,14 +487,13 @@
Archive</B></I> action.</P>
</BLOCKQUOTE>
<H3><A name="Align_All_Data_Types"></A>Aligning All Data Types In a Program or Archive</H3>
<H3><A name="Pack_All_Data_Types"></A>Pack All Data Types In a Program or Archive</H3>
<BLOCKQUOTE>
<P>Right-click on the program or data type archive where data types are to be aligned,
and select the <I><B>Align All...</B></I> action. A confirmation dialog will appear to
make sure you want to align all the structures and unions in the program or data type
archive. If you continue, all structures and unions that are unaligned will be changed to
aligned data types with no minimum alignment (the default) and no packing.</P>
<P>Right-click on the program or data type archive where structures and unions are to be packed,
and select the <I><B>Pack All...</B></I> action. A confirmation dialog will appear to
make sure you want to pack all composites in the program or data type
archive. If you continue, all non-packed composites will have default packing enabled.</P>
</BLOCKQUOTE>
<H3><A name="synchronizing"></A> <A name="Update"></A> Updating an Archive From a Source
@ -926,15 +925,14 @@
</TBODY>
</TABLE>
</BLOCKQUOTE>
<!-- disabled feature
<H3><A name="Align_Data_Type"></A>Aligning a Data Type</H3>
<BLOCKQUOTE>
<P>Right-click on the structure or union to be aligned. Select the <I><B>Align</B></I>
action. If the data type is unaligned it will be changed to an aligned data type with no
minimum alignment (the default) and no packing.</P>
<P>Right-click on the structure or union to be packed. Select the <I><B>Pack</B></I>
action. If the data type is non-packed it will be changed to be default packed.</P>
</BLOCKQUOTE>
-->
<H3><A name="Commit_To_Archive"></A>Committing Changes To Source Archive</H3>
<BLOCKQUOTE>

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -103,7 +102,7 @@ public class CreateArrayInStructureCmd implements Command {
try {
ArrayDataType adt = new ArrayDataType(dataType, numElements, dataType.getLength());
clearStruct(struct, compData.getParentOffset(), length);
if (struct.isInternallyAligned()) {
if (struct.isPackingEnabled()) {
struct.insert(index, adt, adt.getLength());
}
else {

View file

@ -1164,7 +1164,7 @@ public class DataTypeMergeManager implements MergeResolver {
updateAlignment(sourceDt, destStruct);
DataTypeManager sourceDTM = sourceDt.getDataTypeManager();
boolean aligned = sourceDt.isInternallyAligned();
boolean aligned = sourceDt.isPackingEnabled();
// Add each of the defined components back in.
DataTypeComponent[] comps = sourceDt.getDefinedComponents();
@ -1480,17 +1480,25 @@ public class DataTypeMergeManager implements MergeResolver {
private void updateAlignment(Composite sourceDt, Composite destinationDt) {
if (sourceDt.isDefaultAligned()) {
destinationDt.setToDefaultAlignment();
destinationDt.setToDefaultAligned();
}
else if (sourceDt.isMachineAligned()) {
destinationDt.setToMachineAlignment();
destinationDt.setToMachineAligned();
}
else {
destinationDt.setMinimumAlignment(sourceDt.getMinimumAlignment());
destinationDt.setExplicitMinimumAlignment(sourceDt.getExplicitMinimumAlignment());
}
if (sourceDt.isPackingEnabled()) {
if (sourceDt.hasExplicitPackingValue()) {
destinationDt.setExplicitPackingValue(sourceDt.getExplicitPackingValue());
}
else {
destinationDt.setToDefaultPacking();
}
}
else {
destinationDt.setPackingEnabled(false);
}
destinationDt.setPackingValue(sourceDt.getPackingValue());
boolean aligned = sourceDt.isInternallyAligned();
destinationDt.setInternallyAligned(aligned);
}
private void updateComposite(long sourceDtID, Composite sourceDt, Composite destDt,
@ -1860,11 +1868,15 @@ public class DataTypeMergeManager implements MergeResolver {
private boolean compositeDataTypeWasChanged(Composite c1, Composite c2) {
DataTypeManager dtm1 = c1.getDataTypeManager();
DataTypeManager dtm2 = c2.getDataTypeManager();
if (c1.isInternallyAligned() != c2.isInternallyAligned() ||
c1.isDefaultAligned() != c2.isDefaultAligned() ||
c1.isMachineAligned() != c2.isMachineAligned() ||
c1.getMinimumAlignment() != c2.getMinimumAlignment() ||
c1.getPackingValue() != c2.getPackingValue()) {
PackingType packingType = c1.getPackingType();
AlignmentType alignmentType = c1.getAlignmentType();
if ((packingType != c2.getPackingType()) || (alignmentType != c2.getAlignmentType()) ||
(packingType == PackingType.EXPLICIT &&
c1.getExplicitPackingValue() != c2.getExplicitPackingValue()) ||
(alignmentType == AlignmentType.EXPLICIT &&
c1.getExplicitMinimumAlignment() != c2.getExplicitMinimumAlignment())) {
return true;
}
@ -1877,7 +1889,7 @@ public class DataTypeMergeManager implements MergeResolver {
boolean checkOffsets = false;
if (c1 instanceof Structure) {
if (!((Structure) c1).isInternallyAligned()) {
if (!((Structure) c1).isPackingEnabled()) {
if (c1.getNumComponents() != c2.getNumComponents()) {
return true;
}
@ -2444,13 +2456,13 @@ public class DataTypeMergeManager implements MergeResolver {
}
/**
* Process fixup for unaligned structure component
* Process fixup for non-packed structure component
* @param info fixup info
* @param struct result structure
* @param dt component datatype
* @return false if component not found, else true
*/
private boolean fixUpUnalignedStructureComponent(FixUpInfo info, Structure struct,
private boolean fixUpNonPackedStructureComponent(FixUpInfo info, Structure struct,
DataType dt) {
int offset = info.index;
DataTypeComponent dtc = struct.getComponentAt(offset);
@ -2533,7 +2545,7 @@ public class DataTypeMergeManager implements MergeResolver {
boolean isFlexArrayFixup = (info.index == Integer.MAX_VALUE);
if (compDt != null) {
if (struct.isInternallyAligned() || isFlexArrayFixup) {
if (struct.isPackingEnabled() || isFlexArrayFixup) {
if (!fixUpAlignedStructureComponent(info, struct, compDt)) {
String msg =
isFlexArrayFixup ? "flex-array component" : ("component " + info.index);
@ -2544,7 +2556,7 @@ public class DataTypeMergeManager implements MergeResolver {
return true;
}
if (!fixUpUnalignedStructureComponent(info, struct, compDt)) {
if (!fixUpNonPackedStructureComponent(info, struct, compDt)) {
Msg.warn(this, "Structure Merge: Couldn't get component at offset " +
info.index + " in " + struct.getPathName());
return false;
@ -2556,7 +2568,7 @@ public class DataTypeMergeManager implements MergeResolver {
else if (isFlexArrayFixup) {
struct.clearFlexibleArrayComponent();
}
else if (struct.isInternallyAligned()) {
else if (struct.isPackingEnabled()) {
int ordinal = info.index;
int numComponents = struct.getNumComponents();
if (ordinal >= 0 && ordinal < numComponents) {
@ -2595,7 +2607,7 @@ public class DataTypeMergeManager implements MergeResolver {
* @return the number of contiguous undefined bytes or 0.
*/
private int getNumUndefinedBytes(Structure struct, int ordinal) {
if (struct.isInternallyAligned()) {
if (struct.isPackingEnabled()) {
return 0;
}
int numComponents = struct.getNumComponents();
@ -3276,7 +3288,7 @@ public class DataTypeMergeManager implements MergeResolver {
private static int getComponentFixupIndex(DataTypeComponent dtc) {
Composite composite = (Composite) dtc.getParent();
if (composite.isInternallyAligned() || (composite instanceof Union)) {
if (composite.isPackingEnabled() || (composite instanceof Union)) {
return dtc.getOrdinal();
}
return dtc.getOffset();
@ -3301,7 +3313,7 @@ public class DataTypeMergeManager implements MergeResolver {
* or components were resolved.
* @param id id of data type needed to be fixed up
* @param compID id of either component or base type
* @param index offset into unaligned structure, or ordinal into union or aligned
* @param index offset into non-packed structure, or ordinal into union or packed
* structure; or parameter/return ordinal; for other data types index is not used (specify -1).
* For structure trailing flex-array specify {@link Integer#MAX_VALUE}.
* @param resolvedDataTypes hashtable used for resolving the data type
@ -3333,7 +3345,7 @@ public class DataTypeMergeManager implements MergeResolver {
}
/**
* Find unaligned structure bitfield component at or after specified component
* Find non-packed structure bitfield component at or after specified component
* which matches this info's bitfield data.
* @param struct structure
* @param dtc structure component contained within struct
@ -3412,7 +3424,7 @@ public class DataTypeMergeManager implements MergeResolver {
/**
*
* @param index offset into unaligned structure, or ordinal into union or aligned
* @param index offset into non-packed structure, or ordinal into union or packed
* structure; for other data types, offset is not used (specify -1)
* @param resolvedDataTypes hashtable used for resolving the data type
*/
@ -3466,7 +3478,7 @@ public class DataTypeMergeManager implements MergeResolver {
}
private void cleanUpStructure(int[] indexArray, Structure dt) {
boolean aligned = dt.isInternallyAligned();
boolean aligned = dt.isPackingEnabled();
Arrays.sort(indexArray);
for (int i = indexArray.length - 1; i >= 0; i--) {
if (aligned) {

View file

@ -149,28 +149,8 @@ class DataTypePanel extends JPanel {
}
private void formatAlignment(Composite composite) {
StringBuffer alignmentBuffer = new StringBuffer();
if (!composite.isInternallyAligned()) {
alignmentBuffer.append("Unaligned");
}
else if (composite.isDefaultAligned()) {
alignmentBuffer.append("Aligned");
}
else if (composite.isMachineAligned()) {
alignmentBuffer.append("Machine aligned");
}
else {
long alignment = composite.getMinimumAlignment();
alignmentBuffer.append("align(" + alignment + ")");
}
if (composite.isInternallyAligned()) {
long packingValue = composite.getPackingValue();
if (packingValue != Composite.NOT_PACKING) {
alignmentBuffer.append(" pack(" + packingValue + ")");
}
}
insertString(alignmentBuffer.toString() + "\n\n", sourceAttrSet);
String str = CompositeDataTypeImpl.getAlignmentAndPackingString(composite);
insertString(str + "\n\n", sourceAttrSet);
}
private void insertAlignment(Composite composite) {
@ -202,7 +182,7 @@ class DataTypePanel extends JPanel {
buffer.append("[0]");
}
else if (dt instanceof BitFieldDataType &&
!((Composite) dtc.getParent()).isInternallyAligned()) {
!((Composite) dtc.getParent()).isPackingEnabled()) {
BitFieldDataType bfDt = (BitFieldDataType) dt;
buffer.append("(");
buffer.append(Integer.toString(bfDt.getBitOffset()));
@ -255,24 +235,24 @@ class DataTypePanel extends JPanel {
DataTypeComponent[] components = comp.getDefinedComponents();
DataTypeComponent flexDtc = null;
if (comp instanceof Structure) {
showComponentOffset = !comp.isInternallyAligned();
showComponentOffset = !comp.isPackingEnabled();
flexDtc = ((Structure) comp).getFlexibleArrayComponent();
}
int offsetLength = showComponentOffset ? Integer.toHexString(comp.getLength()).length() : 0;
int maxDtNameLength = 10;
int maxFieldNameLength = 1;
for (int i = 0; i < components.length; i++) {
maxDtNameLength = max(getDataTypeName(components[i]), maxDtNameLength);
maxFieldNameLength = max(components[i].getFieldName(), maxFieldNameLength);
for (DataTypeComponent component : components) {
maxDtNameLength = max(getDataTypeName(component), maxDtNameLength);
maxFieldNameLength = max(component.getFieldName(), maxFieldNameLength);
}
if (flexDtc != null) {
maxDtNameLength = max(getDataTypeName(flexDtc), maxDtNameLength);
maxFieldNameLength = max(flexDtc.getFieldName(), maxFieldNameLength);
}
for (int i = 0; i < components.length; i++) {
renderComponent(components[i], maxDtNameLength, maxFieldNameLength, offsetLength);
for (DataTypeComponent component : components) {
renderComponent(component, maxDtNameLength, maxFieldNameLength, offsetLength);
}
if (flexDtc != null) {
renderComponent(flexDtc, maxDtNameLength, maxFieldNameLength, offsetLength);
@ -293,9 +273,9 @@ class DataTypePanel extends JPanel {
String[] names = enuum.getNames();
int maxLength = 0;
for (int i = 0; i < names.length; i++) {
if (names[i].length() > maxLength) {
maxLength = names[i].length();
for (String name : names) {
if (name.length() > maxLength) {
maxLength = name.length();
}
}
long[] values = enuum.getValues();
@ -336,8 +316,8 @@ class DataTypePanel extends JPanel {
return;
}
int maxLength = 0;
for (int i = 0; i < vars.length; i++) {
String typeName = vars[i].getDataType().getDisplayName();
for (ParameterDefinition var : vars) {
String typeName = var.getDataType().getDisplayName();
if (typeName.length() > maxLength) {
maxLength = typeName.length();
}

View file

@ -69,8 +69,8 @@ public class AddBitFieldAction extends CompositeEditorTableAction {
public void adjustEnablement() {
boolean enabled = true;
CompEditorModel editorModel = (CompEditorModel) model;
// Union do not support unaligned placement of bitfields
if (!(editorModel.viewComposite instanceof Structure) || editorModel.isAligned() ||
// Union do not support non-packed placement of bitfields
if (!(editorModel.viewComposite instanceof Structure) || editorModel.isPackingEnabled() ||
editorModel.getNumSelectedRows() != 1 || editorModel.isFlexibleArraySelection()) {
enabled = false;
}

View file

@ -38,7 +38,7 @@ public class BitFieldEditorDialog extends DialogComponentProvider {
private Composite composite;
private CompositeChangeListener listener;
private BitFieldEditorPanel bitFieldEditorPanel; // for unaligned use case
private BitFieldEditorPanel bitFieldEditorPanel; // for non-packed use case
BitFieldEditorDialog(Composite composite, DataTypeManagerService dtmService, int editOrdinal,
boolean showOffsetsInHex, CompositeChangeListener listener) {
@ -290,11 +290,11 @@ public class BitFieldEditorDialog extends DialogComponentProvider {
}
private static String getCompositeType(Composite composite) {
// currently supports unaligned case only!
if (composite.isInternallyAligned()) {
throw new IllegalArgumentException("Aligned use not supported");
// currently supports non-packed case only!
if (composite.isPackingEnabled()) {
throw new IllegalArgumentException("Packed use not supported");
}
String alignmentMode = composite.isInternallyAligned() ? "Aligned" : "Unaligned";
String alignmentMode = composite.isPackingEnabled() ? "Packed" : "Non-Packed";
String type = (composite instanceof Union) ? "Union" : "Structure";
return alignmentMode + " " + type;
}
@ -309,7 +309,7 @@ public class BitFieldEditorDialog extends DialogComponentProvider {
baseDataType = ((BitFieldDataType) dtc.getDataType()).getBaseDataType();
}
}
else if (!composite.isNotYetDefined()) {
else if (!composite.isZeroLength()) {
offset = composite.getLength();
}
@ -346,7 +346,7 @@ public class BitFieldEditorDialog extends DialogComponentProvider {
// Assume a reasonable alignment in identifying aligned offset
int alignment = CompositeAlignmentHelper.getPackedAlignment(dataOrganization,
Composite.NOT_PACKING, bitfieldDt.getBaseDataType(), bitfieldDt.getBaseTypeSize());
CompositeInternal.NO_PACKING, bitfieldDtc);
int adjustedOffset = offset - (offset % alignment);

View file

@ -41,7 +41,7 @@ import resources.ResourceManager;
/**
* <code>BitFieldEditorPanel</code> provides the ability to add or modify bitfields
* within unaligned structures.
* within non-packed structures.
*/
public class BitFieldEditorPanel extends JPanel {
@ -81,9 +81,9 @@ public class BitFieldEditorPanel extends JPanel {
super();
this.composite = composite;
if (composite.isInternallyAligned()) {
if (composite.isPackingEnabled()) {
// A different bitfield editor should be used for aligned composites
throw new IllegalArgumentException("composite must be unaligned");
throw new IllegalArgumentException("composite must be non-packed");
}
setLayout(new VerticalLayout(5));
@ -169,7 +169,7 @@ public class BitFieldEditorPanel extends JPanel {
int offset = placementComponent.getAllocationOffset();
decrementButton.setEnabled(offset > 0);
int length = composite.isNotYetDefined() ? 0 : composite.getLength();
int length = composite.isZeroLength() ? 0 : composite.getLength();
incrementButton.setEnabled(offset < length);
}
}

View file

@ -157,7 +157,7 @@ public class BitFieldPlacementComponent extends JPanel implements Scrollable {
}
allocationByteOffset = 0;
allocationByteSize = 1;
if (!editUseEnabled) {
if (!editUseEnabled && composite != null) {
allocationByteSize = composite.getLength();
}
init(null);
@ -456,7 +456,7 @@ public class BitFieldPlacementComponent extends JPanel implements Scrollable {
composite.delete(editOrdinal);
int sizeChange = initialLength - composite.getLength();
if (!composite.isInternallyAligned() && editOrdinal < composite.getNumComponents()) {
if (!composite.isPackingEnabled() && editOrdinal < composite.getNumComponents()) {
// deletions cause shift which is bad - pad with defaults
for (int i = 0; i < sizeChange; i++) {
composite.insert(editOrdinal, DataType.DEFAULT);
@ -851,7 +851,7 @@ public class BitFieldPlacementComponent extends JPanel implements Scrollable {
BitFieldDataType bitfield = (BitFieldDataType) component.getDataType();
int storageSize = 8 * bitfield.getStorageSize();
rightBit = leftAdj + storageSize - bitfield.getBitOffset() - 1;
// Use effective bit-size since unaligned uses are only concerned with actual
// Use effective bit-size since non-packed uses are only concerned with actual
// bits stored (NOTE: this may cause a transition from declared to effective
// bit-size when editing a bitfield where the these bit-sizes differ).
int bitSize = bitfield.getBitSize();

View file

@ -21,7 +21,6 @@ import docking.widgets.OptionDialog;
import docking.widgets.fieldpanel.support.*;
import ghidra.program.database.data.DataTypeUtilities;
import ghidra.program.model.data.*;
import ghidra.program.model.data.Composite.AlignmentType;
import ghidra.program.model.lang.InsufficientBytesException;
import ghidra.util.*;
import ghidra.util.exception.*;
@ -232,7 +231,7 @@ public abstract class CompEditorModel extends CompositeEditorModel {
int numComps = getNumComponents();
// Make sure we don't have a selection with rows outside the table.
// This can happen due to switching between aligned and unaligned.
// This can happen due to switching between packed and non-packed.
FieldSelection allRows = new FieldSelection();
allRows.addRange(0, numComps + 1);
selection.intersect(allRows);
@ -346,30 +345,31 @@ public abstract class CompEditorModel extends CompositeEditorModel {
* and does not perform any edit notification.
*
* @param rows array with each row (component) index to delete
* @param monitor the task monitor
* @throws CancelledException if cancelled
*/
private void delete(int[] rows, TaskMonitor monitor) throws CancelledException {
private void delete(int[] rows) throws CancelledException {
int n = rows.length;
monitor.initialize(n);
int[] selectedRows = getSelectedRows();
Arrays.sort(rows);
Set<Integer> rowSet = new HashSet<>();
for (int i = n - 1; i >= 0; i--) {
monitor.checkCanceled();
monitor.setMessage("Deleting " + (n - i + 1) + " of " + n);
int rowIndex = rows[i];
int componentOrdinal = convertRowToOrdinal(rowIndex);
doDelete(componentOrdinal);
monitor.incrementProgress(1);
if (componentOrdinal < row) {
row--;
}
rowSet.add(componentOrdinal);
}
viewComposite.delete(rowSet);
// Not sure if this is the right behavior. Assuming the deleted rows were selected,
// restore the selection to be the first row that was deleted so that the UI leaves the
// user's selection close to where it was.
if (selectedRows.length > 0) {
setSelection(new int[] { selectedRows[0] });
if (rows.length > 0) {
setSelection(new int[] { rows[0] });
}
notifyCompositeChanged();
@ -409,14 +409,13 @@ public abstract class CompEditorModel extends CompositeEditorModel {
}
final int entries = endRowIndex - startRowIndex + 1;
int[] ordinals = new int[entries];
Set<Integer> ordinals = new HashSet<>();
monitor.initialize(entries);
int i = 0;
for (int rowIndex = endRowIndex; rowIndex >= startRowIndex; rowIndex--, i++) {
for (int rowIndex = endRowIndex; rowIndex >= startRowIndex; rowIndex--) {
monitor.checkCanceled();
int componentOrdinal = convertRowToOrdinal(rowIndex);
ordinals[i] = componentOrdinal;
ordinals.add(componentOrdinal);
if (componentOrdinal < row) {
row--;
}
@ -432,7 +431,7 @@ public abstract class CompEditorModel extends CompositeEditorModel {
}
@Override
public void deleteSelectedComponents(TaskMonitor monitor) throws UsrException {
public void deleteSelectedComponents() throws UsrException {
if (!isDeleteAllowed()) {
throw new UsrException("Deleting is not allowed.");
}
@ -443,7 +442,7 @@ public abstract class CompEditorModel extends CompositeEditorModel {
int[] selectedComponents = getSelectedComponentRows();
int firstRowIndex = !selection.isEmpty() ? selectedComponents[0] : getRowCount();
try {
delete(selectedComponents, monitor);
delete(selectedComponents);
}
finally {
componentEdited();
@ -1531,7 +1530,7 @@ public abstract class CompEditorModel extends CompositeEditorModel {
}
DataType dt = getComponent(rowIndex).getDataType();
int maxDups = Integer.MAX_VALUE;
// If editModel is showing undefined bytes (unaligned)
// If editModel is showing undefined bytes (non-packed)
// then constrain by number of undefined bytes that follow.
if (isShowingUndefinedBytes() && (dt != DataType.DEFAULT)) {
int numBytes = getNumUndefinedBytesAt(rowIndex + 1);
@ -1609,23 +1608,6 @@ public abstract class CompEditorModel extends CompositeEditorModel {
return rowIndex;
}
public boolean isAligned() {
return viewComposite.isInternallyAligned();
}
public void setAligned(boolean aligned) {
boolean currentViewIsAligned = viewComposite.isInternallyAligned();
if (currentViewIsAligned == aligned) {
return;
}
viewComposite.setInternallyAligned(aligned);
notifyCompositeChanged();
}
public int getPackingValue() {
return viewComposite.getPackingValue();
}
protected boolean isSizeEditable() {
return false;
}
@ -1644,69 +1626,102 @@ public abstract class CompEditorModel extends CompositeEditorModel {
hadChanges = false;
return hadChanges;
}
hadChanges = !(viewComposite.isInternallyAligned() == oldComposite.isInternallyAligned() &&
viewComposite.getPackingValue() == oldComposite.getPackingValue() &&
viewComposite.isDefaultAligned() == oldComposite.isDefaultAligned() &&
viewComposite.isMachineAligned() == oldComposite.isMachineAligned() &&
viewComposite.getMinimumAlignment() == oldComposite.getMinimumAlignment());
PackingType packingType = getPackingType();
AlignmentType alignmentType = getAlignmentType();
hadChanges = (packingType != oldComposite.getPackingType()) ||
(alignmentType != oldComposite.getAlignmentType()) ||
(packingType == PackingType.EXPLICIT &&
getExplicitPackingValue() != oldComposite.getExplicitPackingValue()) ||
(alignmentType == AlignmentType.EXPLICIT &&
getExplicitMinimumAlignment() != oldComposite.getExplicitMinimumAlignment());
return hadChanges;
}
/**
* Return the external (minimum) alignment type for the structure or union being viewed
* Return the (minimum) alignment type for the structure or union being viewed
* @return the alignment type
*/
public AlignmentType getMinimumAlignmentType() {
if (viewComposite.isDefaultAligned()) {
return AlignmentType.DEFAULT_ALIGNED;
}
if (viewComposite.isMachineAligned()) {
return AlignmentType.MACHINE_ALIGNED;
}
return AlignmentType.ALIGNED_BY_VALUE;
public AlignmentType getAlignmentType() {
return viewComposite.getAlignmentType();
}
/**
* Return the external (minimum) alignment value for the structure or union being viewed.
* @return the alignment
*/
public int getMinimumAlignment() {
if (viewComposite != null) {
return viewComposite.getMinimumAlignment();
}
return 0;
public int getExplicitMinimumAlignment() {
return viewComposite.getExplicitMinimumAlignment();
}
public void setAlignmentType(AlignmentType alignmentType) {
if (alignmentType == AlignmentType.DEFAULT_ALIGNED) {
viewComposite.setToDefaultAlignment();
public void setAlignmentType(AlignmentType alignmentType, int explicitValue) {
AlignmentType currentAlignType = getAlignmentType();
if (alignmentType == AlignmentType.DEFAULT) {
if (currentAlignType == AlignmentType.DEFAULT) {
return;
}
viewComposite.setToDefaultAligned();
}
else if (alignmentType == AlignmentType.MACHINE_ALIGNED) {
viewComposite.setToMachineAlignment();
else if (alignmentType == AlignmentType.MACHINE) {
if (currentAlignType == AlignmentType.MACHINE) {
return;
}
viewComposite.setToMachineAligned();
}
else {
int alignment = viewComposite.getMinimumAlignment();
if (alignment == 0) {
alignment = viewDTM.getDataOrganization().getAlignment(viewComposite, getLength());
if (currentAlignType == AlignmentType.EXPLICIT &&
explicitValue == viewComposite.getExplicitMinimumAlignment()) {
return;
}
viewComposite.setMinimumAlignment(alignment); // Causes the type to change, but not the value.
viewComposite.setExplicitMinimumAlignment(explicitValue);
}
if (fixSelection()) {
selectionChanged();
}
notifyCompositeChanged();
}
public abstract void setAlignment(int alignmentValue) throws InvalidInputException;
public boolean isPackingEnabled() {
return viewComposite.isPackingEnabled();
}
public void setPackingValue(int packingValue) {
int currentViewPackingValue = viewComposite.getPackingValue();
if (currentViewPackingValue == packingValue) {
return;
public PackingType getPackingType() {
return viewComposite.getPackingType();
}
public int getExplicitPackingValue() {
return viewComposite.getExplicitPackingValue();
}
public void setPackingType(PackingType packingType, int explicitValue) {
PackingType currentPacktype = getPackingType();
if (packingType == PackingType.DISABLED) {
if (currentPacktype == PackingType.DISABLED) {
return;
}
viewComposite.setPackingEnabled(false);
}
else if (packingType == PackingType.DEFAULT) {
if (currentPacktype == PackingType.DEFAULT) {
return;
}
viewComposite.setToDefaultPacking();
}
else {
if (currentPacktype == PackingType.EXPLICIT &&
explicitValue == viewComposite.getExplicitPackingValue()) {
return;
}
viewComposite.setExplicitPackingValue(explicitValue);
}
if (fixSelection()) {
selectionChanged();
}
viewComposite.setPackingValue(packingValue);
notifyCompositeChanged();
}
public int getActualAlignment() {
return viewDTM.getDataOrganization().getAlignment(viewComposite, getLength());
return viewComposite.getAlignment();
// return viewDTM.getDataOrganization().getAlignment(viewComposite, getLength());
}
}

View file

@ -35,7 +35,6 @@ import ghidra.program.model.data.*;
import ghidra.program.model.data.Enum;
import ghidra.util.*;
import ghidra.util.exception.*;
import ghidra.util.task.TaskMonitor;
/**
* Model for editing a composite data type. Specific composite data type editors
@ -546,7 +545,7 @@ public abstract class CompositeEditorModel extends CompositeViewerModel implemen
}
@Override
public void deleteSelectedComponents(TaskMonitor monitor) throws UsrException {
public void deleteSelectedComponents() throws UsrException {
if (!isDeleteAllowed()) {
throw new UsrException("Deleting is not allowed.");
}
@ -610,8 +609,8 @@ public abstract class CompositeEditorModel extends CompositeViewerModel implemen
private boolean hasCompPathNameChanges(Composite currentViewComposite, Composite oldComposite) {
// Check component data type pathnames.
DataTypeComponent[] comps = currentViewComposite.getComponents();
DataTypeComponent[] oldComps = oldComposite.getComponents();
DataTypeComponent[] comps = currentViewComposite.getDefinedComponents();
DataTypeComponent[] oldComps = oldComposite.getDefinedComponents();
if (comps.length != oldComps.length) {
return true;
}

View file

@ -153,7 +153,7 @@ public abstract class CompositeEditorPanel extends JPanel
private boolean launchBitFieldEditor(int modelColumn, int editingRow) {
if (model.viewComposite instanceof Structure &&
!model.viewComposite.isInternallyAligned() &&
!model.viewComposite.isPackingEnabled() &&
model.getDataTypeColumn() == modelColumn && editingRow < model.getNumComponents()) {
// check if we are attempting to edit a bitfield
DataTypeComponent dtComponent = model.getComponent(editingRow);

View file

@ -363,7 +363,7 @@ class CompositeViewerModel extends AbstractTableModel implements DataTypeManager
* @return this size
*/
public int getLength() {
if (viewComposite != null && !viewComposite.isNotYetDefined()) {
if (viewComposite != null && !viewComposite.isZeroLength()) {
return viewComposite.getLength();
}
return 0;
@ -1386,8 +1386,7 @@ class CompositeViewerModel extends AbstractTableModel implements DataTypeManager
protected void selectionChanged() {
updatingSelection(() -> {
for (int i = 0; i < modelListeners.size(); i++) {
CompositeViewerModelListener listener = modelListeners.get(i);
for (CompositeViewerModelListener listener : modelListeners) {
listener.selectionChanged();
}
});
@ -1411,8 +1410,7 @@ class CompositeViewerModel extends AbstractTableModel implements DataTypeManager
*/
protected <T> void notify(List<T> listeners, Consumer<T> method) {
swing(() -> {
for (int i = 0; i < listeners.size(); i++) {
T listener = listeners.get(i);
for (T listener : listeners) {
method.accept(listener);
}
});

View file

@ -52,7 +52,7 @@ public class DeleteAction extends CompositeEditorTableAction {
private void doDelete(TaskMonitor monitor) {
try {
model.deleteSelectedComponents(monitor);
model.deleteSelectedComponents();
}
catch (CancelledException e) {
// user cancelled

View file

@ -48,7 +48,7 @@ public class EditBitFieldAction extends CompositeEditorTableAction {
private DataTypeComponent getUnalignedBitFieldComponent() {
CompEditorModel editorModel = (CompEditorModel) model;
if ((editorModel.viewComposite instanceof Structure) &&
!editorModel.viewComposite.isInternallyAligned() &&
!editorModel.viewComposite.isPackingEnabled() &&
editorModel.getNumSelectedRows() == 1) {
int rowIndex = model.getSelectedRows()[0];
if (rowIndex < model.getNumComponents()) {

View file

@ -322,8 +322,7 @@ public interface EditorModel {
public void cycleDataType(CycleGroup cycleGroup);
/**
*
* @param parent
* Create array component
* @throws UsrException
*/
public void createArray() throws UsrException;
@ -331,10 +330,9 @@ public interface EditorModel {
/**
* Delete the selected components.
*
* @param monitor the task monitor
* @throws UsrException if the data type isn't allowed to be deleted.
*/
public void deleteSelectedComponents(TaskMonitor monitor) throws UsrException;
public void deleteSelectedComponents() throws UsrException;
/**
* Creates multiple duplicates of the indicated component.

View file

@ -58,7 +58,7 @@ public class InsertUndefinedAction extends CompositeEditorTableAction {
int index = model.getMinIndexSelected();
if (index >= 0) {
DataType undefinedDt =
model.viewComposite.isInternallyAligned() ? Undefined1DataType.dataType
model.viewComposite.isPackingEnabled() ? Undefined1DataType.dataType
: DataType.DEFAULT;
DataTypeInstance dti = DataTypeInstance.getDataTypeInstance(undefinedDt, -1);
model.insert(index, dti.getDataType(), dti.getLength());
@ -77,7 +77,7 @@ public class InsertUndefinedAction extends CompositeEditorTableAction {
if (model.viewComposite instanceof Structure) {
boolean isContiguousSelection = model.getSelection().getNumRanges() == 1;
DataType undefinedDt =
model.viewComposite.isInternallyAligned() ? Undefined1DataType.dataType
model.viewComposite.isPackingEnabled() ? Undefined1DataType.dataType
: DataType.DEFAULT;
enabled = isContiguousSelection &&
model.isInsertAllowed(model.getMinIndexSelected(), undefinedDt);

View file

@ -25,7 +25,6 @@ import docking.widgets.dialogs.InputDialogListener;
import docking.widgets.fieldpanel.support.FieldRange;
import docking.widgets.fieldpanel.support.FieldSelection;
import ghidra.docking.settings.SettingsImpl;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.data.*;
import ghidra.program.model.lang.InsufficientBytesException;
import ghidra.util.Msg;
@ -201,17 +200,7 @@ class StructureEditorModel extends CompEditorModel {
@Override
public int getNumComponents() {
if (viewComposite == null) {
return 0;
}
if (isShowingUndefinedBytes()) {
if (viewComposite.isNotYetDefined()) {
return 0;
}
return viewComposite.getNumComponents();
}
DataTypeComponent[] definedComponents = ((Structure) viewComposite).getDefinedComponents();
return definedComponents.length;
return viewComposite == null ? 0 : viewComposite.getNumComponents();
}
@Override
@ -252,14 +241,14 @@ class StructureEditorModel extends CompEditorModel {
@Override
protected boolean isSizeEditable() {
return !isAligned();
return !isPackingEnabled();
}
void setStructureSize(int size) {
if (viewComposite == null) {
return;
}
int currentLength = viewComposite.isNotYetDefined() ? 0 : viewComposite.getLength();
int currentLength = viewComposite.isZeroLength() ? 0 : viewComposite.getLength();
if (currentLength == size) {
return;
}
@ -449,8 +438,8 @@ class StructureEditorModel extends CompEditorModel {
DataTypeComponent comp = deleteComponentAndResidual(startIndex - 1);
try {
if (!isAligned() && comp.isBitFieldComponent()) {
// insert residual undefined bytes before inserting unaligned bitfield
if (!isPackingEnabled() && comp.isBitFieldComponent()) {
// insert residual undefined bytes before inserting non-packed bitfield
int lenChange = len - getLength();
insert(endIndex, DataType.DEFAULT, 1, lenChange, TaskMonitor.DUMMY);
}
@ -485,8 +474,8 @@ class StructureEditorModel extends CompEditorModel {
DataTypeComponent comp = deleteComponentAndResidual(endIndex + 1);
try {
if (!isAligned() && comp.isBitFieldComponent()) {
// insert residual undefined bytes before inserting unaligned bitfield
if (!isPackingEnabled() && comp.isBitFieldComponent()) {
// insert residual undefined bytes before inserting non-packed bitfield
int lenChange = len - getLength();
insert(startIndex, DataType.DEFAULT, 1, lenChange, TaskMonitor.DUMMY);
}
@ -507,7 +496,7 @@ class StructureEditorModel extends CompEditorModel {
DataTypeComponent comp = getComponent(index);
deleteComponent(index);
if (isAligned() || !comp.isBitFieldComponent() || index >= getNumComponents()) {
if (isPackingEnabled() || !comp.isBitFieldComponent() || index >= getNumComponents()) {
return comp;
}
@ -627,7 +616,7 @@ class StructureEditorModel extends CompEditorModel {
}
@Override
public void deleteSelectedComponents(TaskMonitor monitor) throws UsrException {
public void deleteSelectedComponents() throws UsrException {
if (!isDeleteAllowed()) {
throw new UsrException("Deleting is not allowed.");
}
@ -646,7 +635,7 @@ class StructureEditorModel extends CompEditorModel {
selectionChanged();
return;
}
super.deleteSelectedComponents(monitor);
super.deleteSelectedComponents();
}
@Override
@ -660,14 +649,14 @@ class StructureEditorModel extends CompEditorModel {
int rowIndex = getRow();
DataTypeComponent comp = getComponent(rowIndex);
DataType dt = comp.getDataType();
if (viewComposite.isInternallyAligned()) {
if (viewComposite.isPackingEnabled()) {
return true;
}
if (dt.equals(DataType.DEFAULT)) {
return true; // Insert an undefined and push everything down.
}
if (comp.isBitFieldComponent()) {
return false; // unable to place unaligned bitfield in a reasonable fashion
return false; // unable to place non-packed bitfield in a reasonable fashion
}
// Can always duplicate at the end.
if (isAtEnd(rowIndex) || onlyUndefinedsUntilEnd(rowIndex + 1)) {
@ -956,7 +945,7 @@ class StructureEditorModel extends CompEditorModel {
dtc.getComment());
}
else {
if (isAligned() || !(dataType instanceof BitFieldDataType)) {
if (isPackingEnabled() || !(dataType instanceof BitFieldDataType)) {
dtc = ((Structure) viewComposite).insert(rowIndex, dataType, length, name,
comment);
}
@ -1174,41 +1163,9 @@ class StructureEditorModel extends CompEditorModel {
}
}
@Override
public void setAligned(boolean aligned) {
boolean currentViewIsAligned = viewComposite.isInternallyAligned();
if (currentViewIsAligned == aligned) {
return;
}
viewComposite.setInternallyAligned(aligned);
if (fixSelection()) {
selectionChanged();
}
notifyCompositeChanged();
}
public void adjustAlignment(PluginTool tool, int minAlignment) {
int currentViewAlignment = viewComposite.getMinimumAlignment();
if (currentViewAlignment == minAlignment) {
return;
}
viewComposite.setMinimumAlignment(minAlignment);
notifyCompositeChanged();
}
@Override
public void setAlignment(int minAlignment) throws InvalidInputException {
int currentViewAlignment = viewComposite.getMinimumAlignment();
if (currentViewAlignment == minAlignment) {
return;
}
viewComposite.setMinimumAlignment(minAlignment);
notifyCompositeChanged();
}
@Override
public boolean isShowingUndefinedBytes() {
return !viewComposite.isInternallyAligned();
return !viewComposite.isPackingEnabled();
}
public void createInternalStructure(TaskMonitor monitor)
@ -1259,7 +1216,7 @@ class StructureEditorModel extends CompEditorModel {
final StructureDataType structureDataType =
new StructureDataType(originalCategoryPath, uniqueName, length, originalDTM);
// if (isAligned()) {
// if (isPackingEnabled()) {
// structureDataType.setPackingValue(getPackingValue());
// }
@ -1281,7 +1238,7 @@ class StructureEditorModel extends CompEditorModel {
length += compLength;
if (!structureDataType.isInternallyAligned() && component.isBitFieldComponent()) {
if (!structureDataType.isPackingEnabled() && component.isBitFieldComponent()) {
BitFieldDataType bitfield = (BitFieldDataType) dt;
structureDataType.insertBitFieldAt(component.getOffset() - firstDtc.getOffset(),
compLength, bitfield.getBitOffset(), bitfield.getBaseDataType(),
@ -1296,8 +1253,8 @@ class StructureEditorModel extends CompEditorModel {
lastDtc = component;
}
DataType addedDataType = createDataTypeInOriginalDTM(structureDataType);
if (viewComposite.isInternallyAligned()) {
deleteSelectedComponents(monitor);
if (viewComposite.isPackingEnabled()) {
deleteSelectedComponents();
insert(minRow, addedDataType, addedDataType.getLength());
}
else {
@ -1434,7 +1391,7 @@ class StructureEditorModel extends CompEditorModel {
DataTypeComponent dtc = struct.getComponent(i);
DataType dt = dtc.getDataType();
int compLength = dtc.getLength();
if (!isAligned()) {
if (!isPackingEnabled()) {
if (dtc.isBitFieldComponent()) {
BitFieldDataType bitfield = (BitFieldDataType) dt;
viewStruct.insertBitFieldAt(currentOffset + dtc.getOffset(), compLength,

View file

@ -40,7 +40,8 @@ import docking.widgets.fieldpanel.support.FieldSelection;
import ghidra.program.model.data.*;
import ghidra.program.model.lang.InsufficientBytesException;
import ghidra.util.exception.*;
import ghidra.util.exception.CancelledException;
import ghidra.util.exception.UsrException;
import ghidra.util.task.TaskMonitor;
class UnionEditorModel extends CompEditorModel {
@ -502,16 +503,6 @@ class UnionEditorModel extends CompEditorModel {
}
}
@Override
public void setAlignment(int minAlignment) throws InvalidInputException {
long currentViewAlignment = viewComposite.getMinimumAlignment();
if (currentViewAlignment == minAlignment) {
return;
}
viewComposite.setMinimumAlignment(minAlignment);
notifyCompositeChanged();
}
/**
* Returns the number of undefined bytes that are available in the structure
* beginning at the specified row index.

View file

@ -494,7 +494,6 @@ public class DataTypeSynchronizer {
dataType.setLastChangeTimeInSourceArchive(0); // Set timestamp so user must re-sync.
fixedSync = true;
dataTypeManager.dataTypeChanged(dataType);
}
}
if (fixedSync) {

View file

@ -152,10 +152,11 @@ public class DataTypesProvider extends ComponentProviderAdapter {
addLocalAction(new DeleteArchiveAction(plugin));
addLocalAction(new RenameAction(plugin));
addLocalAction(new EditAction(plugin));
addLocalAction(new AlignDataTypeAction(plugin));
// NOTE: it make very little sense to blindly enable packing
// addLocalAction(new PackDataTypeAction(plugin));
// addLocalAction( new PackDataTypeAction( plugin ));
// addLocalAction( new PackSizeDataTypeAction( plugin ));
addLocalAction(new AlignAllDataTypesAction(plugin));
// addLocalAction(new PackAllDataTypesAction(plugin));
// addLocalAction( new DefineDataTypeAlignmentAction( plugin ));
addLocalAction(new CreateEnumFromSelectionAction(plugin));

View file

@ -25,97 +25,62 @@ import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
import ghidra.app.plugin.core.datamgr.tree.DataTypeNode;
import ghidra.app.plugin.core.datamgr.tree.DataTypeTreeNode;
import ghidra.program.model.data.*;
import ghidra.util.HelpLocation;
import ghidra.util.Msg;
public class AlignDataTypeAction extends DockingAction {
public class Pack1DataTypeAction extends DockingAction {
private DataTypeManagerPlugin plugin;
public AlignDataTypeAction(DataTypeManagerPlugin plugin) {
super("Align Data Type", plugin.getName());
setPopupMenuData(new MenuData(new String[] { "Align" }, "Edit"));
setHelpLocation(new HelpLocation(plugin.getName(), getName()));
}
@Override
public boolean isAddToPopup(ActionContext context) {
DataTypeNode node = getSelectedDataTypeNode(context);
if (node == null) {
return false;
}
DataType dataType = node.getDataType();
if (dataType instanceof BuiltInDataType || dataType instanceof Pointer ||
dataType instanceof MissingBuiltInDataType) {
return false;
}
if (!node.isModifiable()) {
return false;
}
return true;
public Pack1DataTypeAction(DataTypeManagerPlugin plugin) {
super("Pack1 Data Type", plugin.getName());
this.plugin = plugin;
setPopupMenuData(new MenuData(new String[] { "Pack (1)" }, "Edit"));
}
@Override
public boolean isEnabledForContext(ActionContext context) {
DataTypeNode node = getSelectedDataTypeNode(context);
if (node == null) {
return false;
}
DataType dataType = node.getDataType();
if (dataType instanceof Composite) {
return !((Composite) dataType).isInternallyAligned();
}
return false;
}
private DataTypeNode getSelectedDataTypeNode(ActionContext context) {
Object contextObject = context.getContextObject();
if (!(contextObject instanceof GTree)) {
return null;
return false;
}
GTree gTree = (GTree) contextObject;
TreePath[] selectionPaths = gTree.getSelectionPaths();
if (selectionPaths.length != 1) {
return null;
return false;
}
DataTypeTreeNode node = (DataTypeTreeNode) selectionPaths[0].getLastPathComponent();
if (!(node instanceof DataTypeNode)) {
return null;
return false;
}
return (DataTypeNode) node;
setEnabled(node.isModifiable());
return true;
}
@Override
public void actionPerformed(ActionContext context) {
GTree gTree = (GTree) context.getContextObject();
TreePath[] selectionPaths = gTree.getSelectionPaths();
for (TreePath treePath : selectionPaths) {
final DataTypeNode dataTypeNode = (DataTypeNode) treePath.getLastPathComponent();
DataType dataType = dataTypeNode.getDataType();
DataTypeManager dataTypeManager = dataType.getDataTypeManager();
DataOrganization dataOrganization = dataTypeManager.getDataOrganization();
alignDataType(dataType, dataOrganization);
if (selectionPaths.length != 1) {
Msg.error(this, "Pack is only allowed on an individual data type.");
return;
}
}
private void alignDataType(DataType dataType, DataOrganization dataOrganization) {
TreePath treePath = selectionPaths[0];
final DataTypeNode dataTypeNode = (DataTypeNode) treePath.getLastPathComponent();
DataType dataType = dataTypeNode.getDataType();
DataTypeManager dataTypeManager = dataType.getDataTypeManager();
if (dataTypeManager == null) {
Msg.error(this, "Can't align data type " + dataType.getName() +
" without a data type manager.");
return;
}
if (!(dataType instanceof Structure)) {
Msg.error(this, "Can't align data type " + dataType.getName() +
". It's not a structure.");
Msg.error(this,
"Can't pack data type " + dataType.getName() + " without a data type manager.");
return;
}
int transactionID = -1;
boolean commit = false;
try {
// start a transaction
transactionID = dataTypeManager.startTransaction("align " + dataType.getName());
((Structure) dataType).setInternallyAligned(true);
transactionID = dataTypeManager.startTransaction("pack of " + dataType.getName());
packDataType(dataType);
commit = true;
}
finally {
@ -124,4 +89,13 @@ public class AlignDataTypeAction extends DockingAction {
}
}
private void packDataType(DataType dataType) {
if (!(dataType instanceof Composite)) {
Msg.error(this,
"Can't pack data type " + dataType.getName() + ". It's not a composite.");
return;
}
((Composite) dataType).pack(1);
}
}

View file

@ -29,19 +29,18 @@ import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
import ghidra.app.plugin.core.datamgr.archive.Archive;
import ghidra.app.plugin.core.datamgr.tree.*;
import ghidra.program.model.data.*;
import ghidra.util.HelpLocation;
import ghidra.util.Msg;
public class AlignAllDataTypesAction extends DockingAction {
public class PackAllDataTypesAction extends DockingAction {
private DataTypeManagerPlugin plugin;
public AlignAllDataTypesAction(DataTypeManagerPlugin plugin) {
super("Align All Data Types", plugin.getName());
public PackAllDataTypesAction(DataTypeManagerPlugin plugin) {
super("Pack All Composites", plugin.getName());
this.plugin = plugin;
setPopupMenuData(new MenuData(new String[] { "Align All..." }, "Edit"));
setHelpLocation(new HelpLocation(plugin.getName(), getName()));
setPopupMenuData(new MenuData(new String[] { "Pack All..." }, "Edit"));
// setHelpLocation(new HelpLocation(plugin.getName(), getName()));
}
@Override
@ -85,27 +84,27 @@ public class AlignAllDataTypesAction extends DockingAction {
int result =
OptionDialog.showOptionDialog(
plugin.getTool().getToolFrame(),
"Align Data Types",
"Are you sure you want to align all of the data types in " +
"Pack All Composites",
"Are you sure you want to enable packing of all non-packed composites in " +
dataTypeManager.getName() +
"?\nBoth structures and unions that are currently unaligned will become aligned.\n" +
"This could cause component offsets to change and datatype sizes to change.\n" +
"?\nAll structures and unions that are not currently packed will default packing enabled.\n" +
"This could cause component offsets to change as well as size and alignment of these data types to change.\n" +
"Do you want to continue?", "Continue", OptionDialog.WARNING_MESSAGE);
if (result == OptionDialog.CANCEL_OPTION) {
return;
}
alignDataTypes(dataTypeManager, dataOrganization);
packDataTypes(dataTypeManager, dataOrganization);
}
else {
Msg.showWarn(this, gTree, "Alignment Not Allowed",
"The archive must be modifiable to align data types.");
Msg.showWarn(this, gTree, "Modification Not Allowed",
"The archive must be modifiable to pack data types.");
}
}
}
private void alignDataTypes(DataTypeManager dataTypeManager, DataOrganization dataOrganization) {
private void packDataTypes(DataTypeManager dataTypeManager, DataOrganization dataOrganization) {
if (dataTypeManager == null) {
Msg.error(this, "Can't align data types without a data type manager.");
Msg.error(this, "Can't pack data types without a data type manager.");
return;
}
int transactionID = -1;
@ -113,9 +112,8 @@ public class AlignAllDataTypesAction extends DockingAction {
try {
// start a transaction
transactionID =
dataTypeManager.startTransaction("Align all data types in " +
dataTypeManager.getName());
alignEachStructure(dataTypeManager, dataOrganization);
dataTypeManager.startTransaction("Pack Composite Types");
packEachStructure(dataTypeManager, dataOrganization);
commit = true;
}
finally {
@ -124,12 +122,14 @@ public class AlignAllDataTypesAction extends DockingAction {
}
}
private void alignEachStructure(DataTypeManager dataTypeManager,
private void packEachStructure(DataTypeManager dataTypeManager,
DataOrganization dataOrganization) {
Iterator<? extends Composite> allComposites = dataTypeManager.getAllComposites();
while (allComposites.hasNext()) {
Composite composite = allComposites.next();
composite.setInternallyAligned(true);
if (!composite.isPackingEnabled()) {
composite.setPackingEnabled(true);
}
}
}

View file

@ -26,81 +26,101 @@ import ghidra.app.plugin.core.datamgr.tree.DataTypeNode;
import ghidra.app.plugin.core.datamgr.tree.DataTypeTreeNode;
import ghidra.program.model.data.*;
import ghidra.util.Msg;
import ghidra.util.exception.InvalidInputException;
public class PackDataTypeAction extends DockingAction {
private DataTypeManagerPlugin plugin;
public PackDataTypeAction(DataTypeManagerPlugin plugin) {
super("Pack Data Type", plugin.getName());
this.plugin = plugin;
setPopupMenuData(new MenuData(new String[] { "Pack" }, "Edit"));
setPopupMenuData(new MenuData(new String[] { "Pack (default)" }, "Edit"));
// setHelpLocation(new HelpLocation(plugin.getName(), getName()));
}
@Override
public boolean isAddToPopup(ActionContext context) {
DataTypeNode node = getSelectedDataTypeNode(context);
if (node == null) {
return false;
}
DataType dataType = node.getDataType();
if (dataType instanceof BuiltInDataType || dataType instanceof Pointer ||
dataType instanceof MissingBuiltInDataType) {
return false;
}
if (!node.isModifiable()) {
return false;
}
return true;
}
@Override
public boolean isEnabledForContext(ActionContext context) {
DataTypeNode node = getSelectedDataTypeNode(context);
if (node == null) {
return false;
}
DataType dataType = node.getDataType();
if (dataType instanceof Composite) {
return !((Composite) dataType).isPackingEnabled();
}
return false;
}
private DataTypeNode getSelectedDataTypeNode(ActionContext context) {
Object contextObject = context.getContextObject();
if (!(contextObject instanceof GTree)) {
return false;
return null;
}
GTree gTree = (GTree) contextObject;
TreePath[] selectionPaths = gTree.getSelectionPaths();
if (selectionPaths.length != 1) {
return false;
return null;
}
DataTypeTreeNode node = (DataTypeTreeNode) selectionPaths[0].getLastPathComponent();
if (!(node instanceof DataTypeNode)) {
return false;
return null;
}
setEnabled(node.isModifiable());
return true;
return (DataTypeNode) node;
}
@Override
public void actionPerformed(ActionContext context) {
GTree gTree = (GTree) context.getContextObject();
TreePath[] selectionPaths = gTree.getSelectionPaths();
if (selectionPaths.length != 1) {
Msg.error(this, "Pack is only allowed on an individual data type.");
return;
for (TreePath treePath : selectionPaths) {
final DataTypeNode dataTypeNode = (DataTypeNode) treePath.getLastPathComponent();
DataType dataType = dataTypeNode.getDataType();
DataTypeManager dataTypeManager = dataType.getDataTypeManager();
DataOrganization dataOrganization = dataTypeManager.getDataOrganization();
alignDataType(dataType, dataOrganization);
}
TreePath treePath = selectionPaths[0];
final DataTypeNode dataTypeNode = (DataTypeNode) treePath.getLastPathComponent();
DataType dataType = dataTypeNode.getDataType();
}
private void alignDataType(DataType dataType, DataOrganization dataOrganization) {
DataTypeManager dataTypeManager = dataType.getDataTypeManager();
if (dataTypeManager == null) {
Msg.error(this,
"Can't pack data type " + dataType.getName() + " without a data type manager.");
Msg.error(this, "Can't align data type " + dataType.getName() +
" without a data type manager.");
return;
}
if (!(dataType instanceof Structure)) {
Msg.error(this, "Can't align data type " + dataType.getName() +
". It's not a structure.");
return;
}
int transactionID = -1;
boolean commit = false;
try {
// start a transaction
transactionID = dataTypeManager.startTransaction("pack of " + dataType.getName());
packDataType(dataType);
transactionID = dataTypeManager.startTransaction("align " + dataType.getName());
((Structure) dataType).setPackingEnabled(true);
commit = true;
}
catch (InvalidInputException iie) {
// TODO Auto-generated catch block
iie.printStackTrace();
}
finally {
// commit the changes
dataTypeManager.endTransaction(transactionID, commit);
}
}
private void packDataType(DataType dataType) throws InvalidInputException {
if (!(dataType instanceof Structure)) {
Msg.error(this,
"Can't pack data type " + dataType.getName() + ". It's not a structure.");
return;
}
((Structure) dataType).pack(1);
}
}

View file

@ -27,7 +27,6 @@ import ghidra.app.plugin.core.datamgr.tree.DataTypeNode;
import ghidra.app.plugin.core.datamgr.tree.DataTypeTreeNode;
import ghidra.program.model.data.*;
import ghidra.util.Msg;
import ghidra.util.exception.InvalidInputException;
public class PackSizeDataTypeAction extends DockingAction {
@ -73,7 +72,8 @@ public class PackSizeDataTypeAction extends DockingAction {
return;
}
NumberInputDialog numberInputDialog = new NumberInputDialog("pack alignment", 0, 0, 16);
NumberInputDialog numberInputDialog =
new NumberInputDialog("explicit pack value", 0, 0, 16);
if (!numberInputDialog.show()) {
return;
}
@ -88,9 +88,8 @@ public class PackSizeDataTypeAction extends DockingAction {
packDataType(dataType, packSize);
commit = true;
}
catch (InvalidInputException iie) {
// TODO Auto-generated catch block
iie.printStackTrace();
catch (IllegalArgumentException iie) {
Msg.showError(this, null, "Invalid Pack Value", iie.getMessage());
}
finally {
// commit the changes
@ -98,13 +97,13 @@ public class PackSizeDataTypeAction extends DockingAction {
}
}
private void packDataType(DataType dataType, int packSize) throws InvalidInputException {
if (!(dataType instanceof Structure)) {
private void packDataType(DataType dataType, int packSize) throws IllegalArgumentException {
if (!(dataType instanceof Composite)) {
Msg.error(this,
"Can't pack data type " + dataType.getName() + ". It's not a structure.");
"Can't pack data type " + dataType.getName() + ". It's not a composite.");
return;
}
((Structure) dataType).pack(packSize);
((Composite) dataType).pack(packSize);
}
}

View file

@ -463,25 +463,25 @@ public class DataTypeEditorManager
return editorOptionMgr.showUnionNumbersInHex();
}
public void createNewStructure(Category category, boolean isInternallyAligned) {
public void createNewStructure(Category category, boolean isPacked) {
String newName = getUniqueName(category, "struct");
DataTypeManager dataTypeManager = category.getDataTypeManager();
SourceArchive sourceArchive = dataTypeManager.getLocalSourceArchive();
StructureDataType structureDataType =
new StructureDataType(category.getCategoryPath(), newName, 0, dataTypeManager);
structureDataType.setSourceArchive(sourceArchive);
structureDataType.setInternallyAligned(isInternallyAligned);
structureDataType.setPackingEnabled(isPacked);
edit(structureDataType);
}
public void createNewUnion(Category category, boolean isInternallyAligned) {
public void createNewUnion(Category category, boolean isPacked) {
String newName = getUniqueName(category, "union");
DataTypeManager dataTypeManager = category.getDataTypeManager();
SourceArchive sourceArchive = dataTypeManager.getLocalSourceArchive();
UnionDataType unionDataType =
new UnionDataType(category.getCategoryPath(), newName, dataTypeManager);
unionDataType.setSourceArchive(sourceArchive);
unionDataType.setInternallyAligned(isInternallyAligned);
unionDataType.setPackingEnabled(isPacked);
edit(unionDataType);
}

View file

@ -101,7 +101,7 @@ public class DataTypePreviewPlugin extends ProgramPlugin {
model = new DTPPTableModel();
table = new DTPPTable(model);
component = new DTPPScrollPane(table);
dataTypeManager = new LayeredDataTypeManager();
dataTypeManager = new LayeredDataTypeManager(activeProgram);
addDataType(new ByteDataType());
addDataType(new WordDataType());
@ -177,27 +177,29 @@ public class DataTypePreviewPlugin extends ProgramPlugin {
private void updateModel() {
LayeredDataTypeManager newDtm = new LayeredDataTypeManager(activeProgram);
int transactionId = newDtm.startTransaction("add datatypes");
try {
Iterator<DataType> allDataTypes = dataTypeManager.getAllDataTypes();
while (allDataTypes.hasNext()) {
newDtm.resolve(allDataTypes.next(), null);
}
}
finally {
newDtm.endTransaction(transactionId, true);
}
// NOTE: data types do not respond to switching the data organization object
// since this is cached internal to the data type at time of construction.
// We must purge old datatypes and have them re-instantiated by the
// datatype manager
List<DataTypePath> dtPaths = getModelDataTypePaths();
model.removeAll();
dataTypeManager.invalidate();
int transactionId = dataTypeManager.startTransaction("realign");
try {
Iterator<Composite> allComposites = dataTypeManager.getAllComposites();
while (allComposites.hasNext()) {
Composite composite = allComposites.next();
if (composite.isInternallyAligned()) {
composite.realign();
}
}
}
finally {
dataTypeManager.endTransaction(transactionId, true);
}
LayeredDataTypeManager oldDtm = dataTypeManager;
dataTypeManager = newDtm;
oldDtm.close();
for (DataTypePath dtPath : dtPaths) {
DataType dataType = dataTypeManager.getDataType(dtPath);
@ -538,14 +540,11 @@ public class DataTypePreviewPlugin extends ProgramPlugin {
}
private void add(Composite c, DataTypeComponentPreview parent) {
DataTypeComponent[] comps = c.getComponents();
DataTypeComponent[] comps = c.getDefinedComponents();
for (DataTypeComponent element : comps) {
DataTypeComponentPreview preview = new DataTypeComponentPreview(c, element);
preview.setParent(parent);
DataType dataType = element.getDataType();
if (dataType == DataType.DEFAULT) {
continue;
}
if (dataType instanceof Composite) {
add((Composite) element.getDataType(), preview);
}
@ -714,21 +713,22 @@ public class DataTypePreviewPlugin extends ProgramPlugin {
private class LayeredDataTypeManager extends StandAloneDataTypeManager {
public LayeredDataTypeManager() {
DataOrganization layeredDataOrganization1;
public LayeredDataTypeManager(Program program) {
super("DataTypePreviewer");
this.layeredDataOrganization1 =
program != null ? program.getDataTypeManager().getDataOrganization() : null;
}
@Override
public DataOrganization getDataOrganization() {
if (currentProgram != null) {
return currentProgram.getDataTypeManager().getDataOrganization();
if (layeredDataOrganization1 == null) {
return super.getDataOrganization();
}
return super.getDataOrganization();
}
void invalidate() {
invalidateCache();
return layeredDataOrganization1;
}
}
}

View file

@ -15,8 +15,9 @@
*/
package ghidra.app.plugin.core.stackeditor;
import java.util.Collections;
import java.util.Comparator;
import java.util.*;
import javax.help.UnsupportedOperationException;
import ghidra.program.model.data.*;
import ghidra.util.exception.AssertException;
@ -54,6 +55,49 @@ public abstract class BiDirectionDataType extends StructureDataType
this.splitOffset = splitOffset;
}
@Override
public int getAlignment() {
throw new UnsupportedOperationException(
"BiDirectionDataType.getAlignment() not implemented.");
}
@Override
public boolean repack(boolean notify) {
throw new AssertException();
}
@Override
public void setToDefaultAligned() {
// ignore
}
@Override
public void setToMachineAligned() {
// ignore
}
@Override
public void setPackingEnabled(boolean aligned) {
// ignore
}
@Override
public void setExplicitPackingValue(int packingValue) {
// ignore
}
@Override
public void setExplicitMinimumAlignment(int minimumAlignment) {
// ignore
}
@Override
public DataTypeComponent setFlexibleArrayComponent(DataType flexType, String name,
String comment) {
throw new UnsupportedOperationException(
"BiDirectionDataType.setFlexibleArrayComponent() not implemented.");
}
protected DataTypeComponent getDefinedComponentAt(int offset) {
if (offset < splitOffset - negativeLength || offset >= splitOffset + positiveLength) {
return null;
@ -108,20 +152,15 @@ public abstract class BiDirectionDataType extends StructureDataType
return positiveLength;
}
@Override
public int getLength() {
return structLength;
}
@Override
public void delete(int index) {
if (index < 0 || index >= numComponents) {
throw new ArrayIndexOutOfBoundsException(index);
throw new IndexOutOfBoundsException(index);
}
DataTypeComponent comp = getComponent(index);
int offset = comp.getOffset();
int length = comp.getLength();
int idx = Collections.binarySearch(components, new Integer(index), ordinalComparator);
int idx = Collections.binarySearch(components, index, ordinalComparator);
if (idx >= 0) {
DataTypeComponent dtc = components.remove(idx);
dtc.getDataType().removeParent(this);
@ -137,7 +176,7 @@ public abstract class BiDirectionDataType extends StructureDataType
}
@Override
public void delete(int[] ordinals) {
public void delete(Set<Integer> ordinals) {
for (int ordinal : ordinals) {
delete(ordinal);
}
@ -173,6 +212,7 @@ public abstract class BiDirectionDataType extends StructureDataType
}
}
structLength += deltaLength;
// nonpackedAlignedStructLength = -1;
}
/*
@ -198,7 +238,7 @@ public abstract class BiDirectionDataType extends StructureDataType
protected DataTypeComponent getDefinedComponent(int ordinal) {
if (ordinal < 0 || ordinal >= numComponents) {
throw new ArrayIndexOutOfBoundsException(ordinal);
throw new IndexOutOfBoundsException(ordinal);
}
int idx = Collections.binarySearch(components, new Integer(ordinal), ordinalComparator);
if (idx >= 0) {
@ -210,7 +250,7 @@ public abstract class BiDirectionDataType extends StructureDataType
@Override
public DataTypeComponent getComponent(int ordinal) {
if (ordinal < 0 || ordinal >= numComponents) {
throw new ArrayIndexOutOfBoundsException(ordinal);
throw new IndexOutOfBoundsException(ordinal);
}
int idx = Collections.binarySearch(components, new Integer(ordinal), ordinalComparator);
if (idx >= 0) {
@ -255,12 +295,14 @@ public abstract class BiDirectionDataType extends StructureDataType
numComponents += deltaLength;
positiveLength += deltaLength;
structLength += deltaLength;
// nonpackedAlignedStructLength = -1;
}
if (nextOffset < splitOffset - negativeLength) {
int deltaLength = splitOffset - nextOffset - negativeLength;
numComponents += deltaLength;
negativeLength += deltaLength;
structLength += deltaLength;
// nonpackedAlignedStructLength = -1;
}
checkAncestry(dataType);
dataType = dataType.clone(getDataTypeManager());
@ -319,6 +361,7 @@ public abstract class BiDirectionDataType extends StructureDataType
numComponents++;
positiveLength += length;
structLength += length;
// nonpackedAlignedStructLength = -1;
notifySizeChanged();
return dtc;
}
@ -341,6 +384,7 @@ public abstract class BiDirectionDataType extends StructureDataType
numComponents++;
negativeLength += length;
structLength += length;
// nonpackedAlignedStructLength = -1;
notifySizeChanged();
return dtc;
}
@ -367,39 +411,14 @@ public abstract class BiDirectionDataType extends StructureDataType
}
numComponents += absAmount;
structLength += absAmount;
// nonpackedAlignedStructLength = -1;
notifySizeChanged();
}
@Override
public DataTypeComponent insert(int index, DataType dataType, int length, String newName,
String comment) {
throw new AssertException("BiDirectionDataType.insert() not implemented.");
// if (index < 0 || index > numComponents) {
// throw new ArrayIndexOutOfBoundsException(index);
// }
// if (index == numComponents) {
// return add(dataType, length, newName, comment);
// }
// validateDataType(dataType);
//
// dataType = resolve(dataType);
// checkAncestry(dataType);
//
// int idx = Collections.binarySearch(components, new Integer(index), ordinalComparator);
// if (idx < 0) {
// idx = -idx -1;
// }
// if (dataType == DataType.DEFAULT) {
// shiftOffsets(idx, 1, 1);
// return getComponent(index);
// }
// int offset = ((DataTypeComponent)getComponent(index)).getOffset();
// DataTypeComponent dtc = new DataTypeComponentImpl(dataType,this, length,index,
// offset, newName, comment);
// shiftOffsets(idx, 1, dtc.getLength());
// components.add(idx, dtc);
// sizeChanged();
// return dtc;
throw new UnsupportedOperationException("BiDirectionDataType.insert() not implemented.");
}
protected void insertAtOffset(int offset, int numBytes) {
@ -441,6 +460,7 @@ public abstract class BiDirectionDataType extends StructureDataType
}
numComponents += numBytes;
structLength += numBytes;
// nonpackedAlignedStructLength = -1;
notifySizeChanged();
}
@ -479,7 +499,7 @@ public abstract class BiDirectionDataType extends StructureDataType
if ((splitOffset != biDir.getSplitOffset()) ||
(negativeLength != biDir.getNegativeLength()) ||
(positiveLength != biDir.getPositiveLength()) ||
(structLength != biDir.getLength())) {
(getLength() != biDir.getLength())) {
return false;
}
DataTypeComponent[] myComps = getDefinedComponents();
@ -499,72 +519,13 @@ public abstract class BiDirectionDataType extends StructureDataType
@Override
public void dataTypeSizeChanged(DataType dt) {
throw new AssertException("BiDirectionDataType.dataTypeSizeChanged() not implemented.");
// int n = components.size();
// boolean didChange = false;
// for(int i=0;i<n;i++) {
// DataTypeComponentImpl dtc = (DataTypeComponentImpl)components.get(i);
// if (dtc.getDataType() == dt) {
// int dtLen = dt.getLength();
// int dtcLen = dtc.getLength();
// if (dtLen < dtcLen) {
// dtc.setLength(dtLen);
// shiftOffsets(i+1, dtcLen-dtLen, 0);
// didChange = true;
// }
// else if (dtLen > dtcLen) {
// int consumed = consumeBytesAfter(i, dtLen-dtcLen);
// if (consumed > 0) {
// shiftOffsets(i+1, 0-consumed, 0);
// didChange = true;
// }
// }
// }
// }
// if (didChange & dtMgr != null) {
// dtMgr.dataTypeChanged(this);
// }
// ignore
}
/**
*
* @param index the index of the defined component that is consuming the bytes.
* @param numBytes the number of undefined bytes to consume
* @return the number of bytes actually consumed
*/
// private int consumeBytesAfter(int index, int numBytes) {
// throw new AssertException("BiDirectionDataType.consumeBytesAfter() not implemented.");
// DataTypeComponentImpl thisDtc = (DataTypeComponentImpl)components.get(index);
// int thisLen = thisDtc.getLength();
// int nextOffset = thisDtc.getOffset()+thisLen;
// int available = structLength-nextOffset;
// if (index+1 < components.size()) {
// DataTypeComponent nextDtc = (DataTypeComponent)components.get(index+1);
// available = nextDtc.getOffset() - nextOffset;
// }
// else {
// available = structLength-nextOffset;
// }
// if (numBytes <= available) {
// thisDtc.setLength(thisLen + numBytes);
// return numBytes;
// }
// else {
// thisDtc.setLength(thisLen + available);
// return available;
// }
// }
// private boolean hasRoom(int index, int offset, int length) {
// if (offset+length > this.positiveLength) {
// return false;
// }
// if (index+1 < components.size()) {
// DataTypeComponent nextDtc = (DataTypeComponent)components.get(index+1);
// return offset+length <= nextDtc.getOffset();
// }
// return true;
// }
@Override
public void dataTypeAlignmentChanged(DataType dt) {
// ignore
}
@Override
public abstract BiDirectionDataType clone(DataTypeManager dtm);
@ -572,7 +533,7 @@ public abstract class BiDirectionDataType extends StructureDataType
@Override
public void clearComponent(int index) {
if (index < 0 || index >= numComponents) {
throw new ArrayIndexOutOfBoundsException(index);
throw new IndexOutOfBoundsException(index);
}
int idx = Collections.binarySearch(components, new Integer(index), ordinalComparator);
if (idx >= 0) {
@ -589,81 +550,20 @@ public abstract class BiDirectionDataType extends StructureDataType
}
public void replaceWith(Structure struct) {
throw new AssertException("BiDirectionDataType.replaceWith() not implemented.");
// int oldLength = structLength;
// doReplaceWith(struct);
// if (oldLength != structLength) {
// sizeChanged();
// }
// else if (dtMgr != null) {
// dtMgr.dataTypeChanged(this);
// }
throw new UnsupportedOperationException(
"BiDirectionDataType.replaceWith() not implemented.");
}
// private void doReplaceWith(Structure struct) {
// throw new AssertException("BiDirectionDataType.doReplaceWith() not implemented.");
// components.clear();
// structLength = struct.getLength();
// numComponents = structLength;
//
// DataTypeComponent[] components = struct.getDefinedComponents();
// for(int i=0;i<components.length;i++) {
// DataTypeComponent dtc = components[i];
// DataType dt = dtc.getDataType();
// validateDataType(dt);
// dt = resolve(dt);
// replaceAtOffset(dtc.getOffset(), dt, dtc.getLength(),
// dtc.getFieldName(), dtc.getComment());
// }
// }
@Override
public void dataTypeDeleted(DataType dt) {
throw new AssertException("BiDirectionDataType.dataTypeDeleted() not implemented.");
// boolean didChange = false;
// int n = components.size();
// for(int i=n-1;i>=0;i--) {
// DataTypeComponentImpl dtc = (DataTypeComponentImpl)components.get(i);
// if (dtc.getDataType() == dt) {
// components.remove(i);
// shiftOffsets(i, dtc.getLength()-1, 0);
// didChange = true;
// }
// }
// if (didChange && dtMgr != null) {
// dtMgr.dataTypeChanged(this);
// }
throw new UnsupportedOperationException(
"BiDirectionDataType.dataTypeDeleted() not implemented.");
}
@Override
public void dataTypeReplaced(DataType oldDt, DataType newDt) {
throw new AssertException("BiDirectionDataType.dataTypeReplaced() not implemented.");
// int n = components.size();
// boolean didChange = false;
// for(int i=0;i<n;i++) {
// DataTypeComponentImpl dtc = (DataTypeComponentImpl)components.get(i);
// if (dtc.getDataType() == oldDt) {
// int dtLen = oldDt.getLength();
// int dtcLen = dtc.getLength();
// dtc.setDataType(newDt);
// if (dtLen < dtcLen) {
// dtc.setLength(dtLen);
// shiftOffsets(i+1, dtcLen-dtLen, 0);
// didChange = true;
// }
// else if (dtLen > dtcLen) {
// int consumed = consumeBytesAfter(i, dtLen-dtcLen);
// if (consumed > 0) {
// shiftOffsets(i+1, 0-consumed, 0);
// didChange = true;
// }
// }
// }
// }
// if (didChange & dtMgr != null) {
// dtMgr.dataTypeChanged(this);
// }
throw new UnsupportedOperationException(
"BiDirectionDataType.dataTypeReplaced() not implemented.");
}
@Override
@ -682,9 +582,9 @@ public abstract class BiDirectionDataType extends StructureDataType
@Override
public DataTypeComponent replace(int index, DataType dataType, int length, String newName,
String comment) throws ArrayIndexOutOfBoundsException, IllegalArgumentException {
String comment) throws IndexOutOfBoundsException, IllegalArgumentException {
if (index < 0 || index >= numComponents) {
throw new ArrayIndexOutOfBoundsException(index);
throw new IndexOutOfBoundsException(index);
}
validateDataType(dataType);
checkAncestry(dataType);

View file

@ -68,8 +68,7 @@ public class StackFrameDataType extends BiDirectionDataType {
this.returnAddressOffset = stackDt.returnAddressOffset;
this.stack = stackDt.stack;
this.defaultSettings = stackDt.defaultSettings;
for (int i = 0; i < stackDt.components.size(); i++) {
DataTypeComponent dtc = stackDt.components.get(i);
for (DataTypeComponentImpl dtc : stackDt.components) {
replaceAtOffset(dtc.getOffset(), dtc.getDataType(), dtc.getLength(), dtc.getFieldName(),
dtc.getComment());
}
@ -216,7 +215,7 @@ public class StackFrameDataType extends BiDirectionDataType {
* @see ghidra.program.model.listing.StackFrame#getFrameSize()
*/
public int getFrameSize() {
return structLength;
return getLength();
}
/* (non-Javadoc)
@ -261,8 +260,9 @@ public class StackFrameDataType extends BiDirectionDataType {
}
private boolean adjustStackFrameSize(int newSize, int oldSize, boolean isNegative) {
if (newSize < 0)
if (newSize < 0) {
return false;
}
int delta = newSize - oldSize;
if (delta == 0) {

View file

@ -82,8 +82,7 @@ class DWARFDataTypeConflictHandler extends DataTypeConflictHandler {
* @return true if empty or default and false otherwise
*/
private boolean isCompositeDefault(Composite composite) {
return composite.isNotYetDefined()
|| ((composite instanceof Structure) && ((Structure) composite).getNumDefinedComponents() == 0);
return composite.isNotYetDefined() || (composite.getNumDefinedComponents() == 0);
}
private boolean isCompositePart(Composite full, Composite part, Set<Long> visitedDataTypes) {

View file

@ -85,8 +85,10 @@ public class MSDataTypeUtils {
CategoryPath categoryPath, String structureName, int packValue) {
StructureDataType struct =
new StructureDataType(categoryPath, structureName, 0, dataTypeManager);
struct.setInternallyAligned(true);
struct.setPackingValue(packValue);
struct.setPackingEnabled(true);
if (packValue > 0) {
struct.setExplicitPackingValue(packValue);
}
return struct;
}

View file

@ -15,7 +15,7 @@
*/
package ghidra.app.util.html;
import static ghidra.util.HTMLUtilities.friendlyEncodeHTML;
import static ghidra.util.HTMLUtilities.*;
import java.awt.Color;
import java.util.*;
@ -77,7 +77,7 @@ public class CompositeDataTypeHTMLRepresentation extends HTMLDataTypeRepresentat
}
protected List<String> buildWarnings(Composite comp) {
if (!comp.isNotYetDefined()) {
if (!comp.isZeroLength()) {
return Collections.emptyList();
}
List<String> list = new ArrayList<>();
@ -87,7 +87,7 @@ public class CompositeDataTypeHTMLRepresentation extends HTMLDataTypeRepresentat
@Override
protected TextLine buildFooterText(DataType dataType) {
if (dataType.isNotYetDefined()) {
if (dataType.isZeroLength()) {
return new TextLine("0");
}
return super.buildFooterText(dataType);
@ -95,44 +95,24 @@ public class CompositeDataTypeHTMLRepresentation extends HTMLDataTypeRepresentat
protected List<ValidatableLine> buildAlignmentText(Composite dataType) {
List<ValidatableLine> list = new ArrayList<>();
if (!dataType.isInternallyAligned()) {
list.add(new TextLine("unaligned"));
String alignStr = CompositeDataTypeImpl.getMinAlignmentString(dataType);
if (alignStr != null && alignStr.length() != 0) {
list.add(new TextLine(alignStr));
}
else if (dataType.isDefaultAligned()) {
list.add(new TextLine("align()"));
}
else if (dataType.isMachineAligned()) {
list.add(new TextLine("align(machine)"));
}
else {
long alignment = dataType.getMinimumAlignment();
list.add(new TextLine("align(" + alignment + ")"));
}
TextLine packingText = buildPackingText(dataType);
if (packingText != null) {
list.add(packingText);
String packStr = CompositeDataTypeImpl.getPackingString(dataType);
if (packStr != null && packStr.length() != 0) {
list.add(new TextLine(packStr));
}
return list;
}
protected TextLine buildPackingText(Composite dataType) {
if (!dataType.isInternallyAligned()) {
return null;
}
long packingValue = dataType.getPackingValue();
if (packingValue == Composite.NOT_PACKING) {
return null;
}
return new TextLine(" pack(" + packingValue + ")");
}
protected TextLine buildAlignmentValueText(Composite composite) {
return new TextLine("" + composite.getAlignment());
}
private List<ValidatableLine> buildContent(Composite comp) {
List<ValidatableLine> list = new ArrayList<>();
if (comp.isNotYetDefined()) {
if (comp.isZeroLength()) {
return list;
}

View file

@ -70,7 +70,7 @@ public class TypeDefDataTypeHTMLRepresentation extends HTMLDataTypeRepresentatio
protected List<String> buildWarnings() {
DataType baseType = typeDef.getBaseDataType();
if (!(baseType instanceof Composite) || !baseType.isNotYetDefined()) {
if (!(baseType instanceof Composite) || !baseType.isZeroLength()) {
return Collections.emptyList();
}
List<String> list = new ArrayList<>();
@ -81,7 +81,7 @@ public class TypeDefDataTypeHTMLRepresentation extends HTMLDataTypeRepresentatio
@Override
protected TextLine buildFooterText(DataType dataType) {
if (dataType.isNotYetDefined()) {
if (dataType.isZeroLength()) {
return new TextLine("0");
}
return super.buildFooterText(dataType);

View file

@ -292,7 +292,7 @@ public class BytesFieldFactory extends FieldFactory {
return null; // e.g., union
}
Structure struct = (Structure) baseDataType;
if (!struct.isInternallyAligned()) {
if (!struct.isPackingEnabled()) {
return null;
}

View file

@ -623,7 +623,7 @@ public class DataTypesXmlMgr {
XmlAttributes attrs = new XmlAttributes();
attrs.addAttribute("NAME", struct.getDisplayName());
attrs.addAttribute("NAMESPACE", struct.getCategoryPath().getPath());
attrs.addAttribute("SIZE", struct.isNotYetDefined() ? 0 : struct.getLength(), true);
attrs.addAttribute("SIZE", struct.isZeroLength() ? 0 : struct.getLength(), true);
writer.startElement("STRUCTURE", attrs);
writeRegularComment(writer, struct.getDescription());
DataTypeComponent[] members = struct.getComponents();
@ -637,7 +637,7 @@ public class DataTypesXmlMgr {
XmlAttributes attrs = new XmlAttributes();
attrs.addAttribute("NAME", union.getDisplayName());
attrs.addAttribute("NAMESPACE", union.getCategoryPath().getPath());
attrs.addAttribute("SIZE", union.isNotYetDefined() ? 0 : union.getLength(), true);
attrs.addAttribute("SIZE", union.isZeroLength() ? 0 : union.getLength(), true);
writer.startElement("UNION", attrs);
writeRegularComment(writer, union.getDescription());
DataTypeComponent[] members = union.getComponents();
@ -649,7 +649,7 @@ public class DataTypesXmlMgr {
private void writerMember(XmlWriter writer, DataTypeComponent member) {
XmlAttributes attrs = new XmlAttributes();
// TODO: how should we output bitfields (aligned/unaligned) and flex array
// TODO: how should we output bitfields (packed/non-packed) and flex array
attrs.addAttribute("OFFSET", member.getOffset(), true);
attrs.addAttribute("DATATYPE", member.getDataType().getDisplayName());
attrs.addAttribute("DATATYPE_NAMESPACE", member.getDataType().getCategoryPath().getPath());

View file

@ -1675,17 +1675,25 @@ Composite StructOrUnion() : {Composite comp;}
(
<STRUCT> ( DeclSpec() )* { comp = new StructureDataType(ANONYMOUS_STRUCT_PREFIX + cnt++, 0);
// Always set the packing, because by default structures should be aligned
// setting 0 turns off packing, but sets structures to be aligned
comp.setPackingValue(this.packSize);
// Always set the packing, because by default structures should be aligned
if (packSize > 0) {
comp.setExplicitPackingValue(packSize);
}
else {
comp.setPackingEnabled(true); // ensure default packing enabled
}
}
|
<UNION> ( DeclSpec() )* { comp = new UnionDataType(ANONYMOUS_UNION_PREFIX + cnt++);
// Always set the packing, because by default structures should be aligned
// setting 0 turns off packing, but sets structures to be aligned.
comp.setPackingValue(this.packSize);
if (packSize > 0) {
comp.setExplicitPackingValue(packSize);
}
else {
comp.setPackingEnabled(true); // ensure default packing enabled
}
}
)
{

View file

@ -604,7 +604,7 @@ public class DataTypeMerge3Test extends AbstractDataTypeMergeTest {
executeMerge();
chooseOption(DataTypeMergeManager.OPTION_MY);// choose My Bar
chooseOption(DataTypeMergeManager.OPTION_MY);// choose My Bar // TODO: I see no reason for a conflict !
setErrorsExpected(true);
@ -2201,7 +2201,7 @@ public class DataTypeMerge3Test extends AbstractDataTypeMergeTest {
(Union) dtm.getDataType(new CategoryPath("/Category1/Category2"), "CoolUnion");
//@formatter:off
assertEquals("/Category1/Category2/CoolUnion\n" +
"Unaligned\n" +
"pack(disabled)\n" +
"Union CoolUnion {\n" +
" 0 qword 8 null \"\"\n" +
" 0 byte:4(4) 1 BF1 \"my bf1\"\n" +

View file

@ -27,7 +27,7 @@ import ghidra.program.database.ProgramModifierListener;
import ghidra.program.model.data.*;
import ghidra.util.InvalidNameException;
import ghidra.util.exception.DuplicateNameException;
import ghidra.util.task.TaskMonitorAdapter;
import ghidra.util.task.TaskMonitor;
/**
* More data type merge tests.
@ -502,7 +502,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
int transactionID = program.startTransaction("test");
Structure foo = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Foo");
try {
dtm.remove(foo, TaskMonitorAdapter.DUMMY_MONITOR);
dtm.remove(foo, TaskMonitor.DUMMY);
commit = true;
}
finally {
@ -709,7 +709,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
// delete Bar from Foo
fs.delete(3);
// add Foo to Bar
dtm.remove(bs, TaskMonitorAdapter.DUMMY_MONITOR);
dtm.remove(bs, TaskMonitor.DUMMY);
// Add s1, s2, s3
Structure s1 = new StructureDataType(new CategoryPath("/MISC"), "S1", 0);
@ -809,7 +809,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
// delete Bar from Foo
foo.delete(3);
// remove Bar from the data type manager
dtm.remove(bar, TaskMonitorAdapter.DUMMY_MONITOR);
dtm.remove(bar, TaskMonitor.DUMMY);
// Add s1, s2, s3
Structure s1 = new StructureDataType(new CategoryPath("/MISC"), "S1", 0);
@ -920,7 +920,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
// delete Bar from Foo
fs.delete(3);
// remove Bar from the data type manager
dtm.remove(bs, TaskMonitorAdapter.DUMMY_MONITOR);
dtm.remove(bs, TaskMonitor.DUMMY);
// Add s1, s2, s3
Structure s1 = new StructureDataType(new CategoryPath("/MISC"), "S1", 0);
@ -1034,7 +1034,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
Structure fs = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Foo");
try {
// delete Foo from the data type manager
dtm.remove(fs, TaskMonitorAdapter.DUMMY_MONITOR);
dtm.remove(fs, TaskMonitor.DUMMY);
commit = true;
}
finally {
@ -1051,7 +1051,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
dtm.getDataType(new CategoryPath("/MISC"), "Bar");
try {
// delete Foo from the data type manager
dtm.remove(foo, TaskMonitorAdapter.DUMMY_MONITOR);
dtm.remove(foo, TaskMonitor.DUMMY);
// Add s1, s2, s3
Structure s1 = new StructureDataType(new CategoryPath("/MISC"), "S1", 0);
@ -1129,7 +1129,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
Structure fs = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Foo");
try {
// delete Foo from the data type manager
dtm.remove(fs, TaskMonitorAdapter.DUMMY_MONITOR);
dtm.remove(fs, TaskMonitor.DUMMY);
commit = true;
}
finally {
@ -1146,7 +1146,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
dtm.getDataType(new CategoryPath("/MISC"), "Bar");
try {
// delete Foo from the data type manager
dtm.remove(foo, TaskMonitorAdapter.DUMMY_MONITOR);
dtm.remove(foo, TaskMonitor.DUMMY);
// Add s1, s2, s3
Structure s1 = new StructureDataType(new CategoryPath("/MISC"), "S1", 0);
@ -1318,7 +1318,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
Structure bar = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Bar");
try {
// remove Bar from the data type manager
dtm.remove(bar, TaskMonitorAdapter.DUMMY_MONITOR);
dtm.remove(bar, TaskMonitor.DUMMY);
commit = true;
}
finally {
@ -1441,7 +1441,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
Structure bar = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Bar");
try {
// remove Bar from the data type manager
dtm.remove(bar, TaskMonitorAdapter.DUMMY_MONITOR);
dtm.remove(bar, TaskMonitor.DUMMY);
commit = true;
}
finally {
@ -1555,7 +1555,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
Structure bar = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Bar");
try {
// remove Bar from the data type manager
dtm.remove(bar, TaskMonitorAdapter.DUMMY_MONITOR);
dtm.remove(bar, TaskMonitor.DUMMY);
commit = true;
}
finally {
@ -1643,7 +1643,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
Structure bar = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Bar");
try {
// remove Bar from the data type manager
dtm.remove(bar, TaskMonitorAdapter.DUMMY_MONITOR);
dtm.remove(bar, TaskMonitor.DUMMY);
commit = true;
}
finally {
@ -1750,7 +1750,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
Structure bar = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Bar");
try {
// remove Bar from the data type manager
dtm.remove(bar, TaskMonitorAdapter.DUMMY_MONITOR);
dtm.remove(bar, TaskMonitor.DUMMY);
commit = true;
}
finally {
@ -1844,7 +1844,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
Structure bar = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Bar");
try {
// remove Bar from the data type manager
dtm.remove(bar, TaskMonitorAdapter.DUMMY_MONITOR);
dtm.remove(bar, TaskMonitor.DUMMY);
commit = true;
}
finally {
@ -1943,7 +1943,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
Structure bar = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Bar");
try {
// remove Bar from the data type manager
dtm.remove(bar, TaskMonitorAdapter.DUMMY_MONITOR);
dtm.remove(bar, TaskMonitor.DUMMY);
commit = true;
}
finally {

View file

@ -21,7 +21,7 @@ import org.junit.Test;
import ghidra.program.database.*;
import ghidra.program.model.data.*;
import ghidra.util.task.TaskMonitorAdapter;
import ghidra.util.task.TaskMonitor;
/**
* Data type merge tests for aligned data types.
@ -31,9 +31,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
private void setupStructureMachineAlignedVsValue() throws Exception {
mtf.initialize("notepad", new OriginalProgramModifierListener() {
/* (non-Javadoc)
* @see ghidra.framework.data.OriginalProgramModifierListener#modifyOriginal(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyOriginal(ProgramDB program) throws Exception {
boolean commit = false;
@ -45,7 +43,8 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
assertEquals(15, s.getLength());
assertEquals(1, s.getAlignment());
s.setInternallyAligned(true);
s.setToDefaultPacking();
// Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset());
@ -60,9 +59,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
}
}
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyLatest(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyLatest(ProgramDB program) throws Exception {
boolean commit = false;
@ -72,7 +68,8 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try {
Structure s = (Structure) dtm.getDataType(
new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
s.setToMachineAlignment();
s.setToMachineAligned();
// Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset());
@ -87,9 +84,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
}
}
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyPrivate(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyPrivate(ProgramDB program) throws Exception {
boolean commit = false;
@ -99,7 +93,8 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try {
Structure s = (Structure) dtm.getDataType(
new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
s.setMinimumAlignment(4);
s.setExplicitMinimumAlignment(4);
// Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset());
@ -129,11 +124,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager();
Category c = dtm.getCategory(new CategoryPath("/Category1/Category2/Category3"));
Structure s = (Structure) c.getDataType("IntStruct");
assertEquals(true, s.isInternallyAligned());
assertEquals(false, s.isDefaultAligned());
assertEquals(true, s.isMachineAligned());
assertEquals(8, s.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
assertTrue(s.hasDefaultPacking());
assertTrue(s.isMachineAligned());
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset());
assertEquals(4, s.getComponent(2).getOffset());
@ -155,11 +148,10 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager();
Category c = dtm.getCategory(new CategoryPath("/Category1/Category2/Category3"));
Structure s = (Structure) c.getDataType("IntStruct");
assertEquals(true, s.isInternallyAligned());
assertEquals(false, s.isDefaultAligned());
assertEquals(false, s.isMachineAligned());
assertEquals(4, s.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
assertTrue(s.hasDefaultPacking());
assertTrue(s.hasExplicitMinimumAlignment());
assertEquals(4, s.getExplicitMinimumAlignment());
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset());
assertEquals(4, s.getComponent(2).getOffset());
@ -181,11 +173,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager();
Category c = dtm.getCategory(new CategoryPath("/Category1/Category2/Category3"));
Structure s = (Structure) c.getDataType("IntStruct");
assertEquals(true, s.isInternallyAligned());
assertEquals(true, s.isDefaultAligned());
assertEquals(false, s.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, s.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
assertTrue(s.hasDefaultPacking());
assertTrue(s.isDefaultAligned());
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset());
assertEquals(4, s.getComponent(2).getOffset());
@ -197,9 +187,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
private void setupStructurePack1VsPack2() throws Exception {
mtf.initialize("notepad", new OriginalProgramModifierListener() {
/* (non-Javadoc)
* @see ghidra.framework.data.OriginalProgramModifierListener#modifyOriginal(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyOriginal(ProgramDB program) throws Exception {
boolean commit = false;
@ -211,7 +199,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
assertEquals(15, s.getLength());
assertEquals(1, s.getAlignment());
s.setInternallyAligned(true);
s.setToDefaultPacking();
// Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset());
@ -220,7 +208,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(8, s.getComponent(3).getOffset());
assertEquals(16, s.getLength());
assertEquals(4, s.getAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
commit = true;
}
finally {
@ -228,9 +216,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
}
}
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyLatest(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyLatest(ProgramDB program) throws Exception {
boolean commit = false;
@ -240,7 +225,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try {
Structure s = (Structure) dtm.getDataType(
new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
s.setPackingValue(1);
s.pack(1);
// Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset());
@ -249,7 +234,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(7, s.getComponent(3).getOffset());
assertEquals(15, s.getLength());
assertEquals(1, s.getAlignment());
assertEquals(1, s.getPackingValue());
commit = true;
}
finally {
@ -257,9 +242,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
}
}
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyPrivate(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyPrivate(ProgramDB program) throws Exception {
boolean commit = false;
@ -269,7 +251,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try {
Structure s = (Structure) dtm.getDataType(
new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
s.setPackingValue(2);
s.pack(2);
// Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset());
@ -278,7 +260,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(8, s.getComponent(3).getOffset());
assertEquals(16, s.getLength());
assertEquals(2, s.getAlignment());
assertEquals(2, s.getPackingValue());
commit = true;
}
finally {
@ -302,11 +284,10 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Structure s =
(Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"),
"IntStruct");
assertEquals(true, s.isInternallyAligned());
assertEquals(true, s.isDefaultAligned());
assertEquals(false, s.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, s.getMinimumAlignment());
assertEquals(1, s.getPackingValue());
assertTrue(s.hasExplicitPackingValue());
assertEquals(1, s.getExplicitPackingValue());
assertTrue(s.isDefaultAligned());
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(1, s.getComponent(1).getOffset());
assertEquals(3, s.getComponent(2).getOffset());
@ -329,11 +310,10 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Structure s =
(Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"),
"IntStruct");
assertEquals(true, s.isInternallyAligned());
assertEquals(true, s.isDefaultAligned());
assertEquals(false, s.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, s.getMinimumAlignment());
assertEquals(2, s.getPackingValue());
assertTrue(s.hasExplicitPackingValue());
assertEquals(2, s.getExplicitPackingValue());
assertTrue(s.isDefaultAligned());
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset());
assertEquals(4, s.getComponent(2).getOffset());
@ -355,11 +335,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager();
Category c = dtm.getCategory(new CategoryPath("/Category1/Category2/Category3"));
Structure s = (Structure) c.getDataType("IntStruct");
assertEquals(true, s.isInternallyAligned());
assertEquals(true, s.isDefaultAligned());
assertEquals(false, s.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, s.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
assertTrue(s.hasDefaultPacking());
assertTrue(s.isDefaultAligned());
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset());
assertEquals(4, s.getComponent(2).getOffset());
@ -371,9 +349,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
private void setupStructureMinAlignVsPack() throws Exception {
mtf.initialize("notepad", new OriginalProgramModifierListener() {
/* (non-Javadoc)
* @see ghidra.framework.data.OriginalProgramModifierListener#modifyOriginal(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyOriginal(ProgramDB program) throws Exception {
boolean commit = false;
@ -385,7 +361,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
assertEquals(15, s.getLength());
assertEquals(1, s.getAlignment());
s.setInternallyAligned(true);
s.setToDefaultPacking();
// Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset());
@ -394,7 +370,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(8, s.getComponent(3).getOffset());
assertEquals(16, s.getLength());
assertEquals(4, s.getAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
commit = true;
}
finally {
@ -402,9 +378,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
}
}
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyLatest(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyLatest(ProgramDB program) throws Exception {
boolean commit = false;
@ -414,7 +387,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try {
Structure s = (Structure) dtm.getDataType(
new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
s.setToMachineAlignment();
s.setToMachineAligned();
// Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset());
@ -430,9 +403,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
}
}
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyPrivate(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyPrivate(ProgramDB program) throws Exception {
boolean commit = false;
@ -442,7 +412,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try {
Structure s = (Structure) dtm.getDataType(
new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
s.setPackingValue(1);
s.pack(1);
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(1, s.getComponent(1).getOffset());
@ -450,7 +420,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(7, s.getComponent(3).getOffset());
assertEquals(15, s.getLength());
assertEquals(1, s.getAlignment());
assertEquals(1, s.getPackingValue());
commit = true;
}
finally {
@ -474,11 +444,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Structure s =
(Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"),
"IntStruct");
assertEquals(true, s.isInternallyAligned());
assertEquals(false, s.isDefaultAligned());
assertEquals(true, s.isMachineAligned());
assertEquals(8, s.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
assertTrue(s.hasDefaultPacking());
assertTrue(s.isMachineAligned());
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset());
assertEquals(4, s.getComponent(2).getOffset());
@ -501,11 +469,10 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Structure s =
(Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"),
"IntStruct");
assertEquals(true, s.isInternallyAligned());
assertEquals(true, s.isDefaultAligned());
assertEquals(false, s.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, s.getMinimumAlignment());
assertEquals(1, s.getPackingValue());
assertTrue(s.hasExplicitPackingValue());
assertEquals(1, s.getExplicitPackingValue());
assertTrue(s.isDefaultAligned());
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(1, s.getComponent(1).getOffset());
assertEquals(3, s.getComponent(2).getOffset());
@ -517,9 +484,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
private void setupStructureAddVsAlign() throws Exception {
mtf.initialize("notepad", new ProgramModifierListener() {
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyLatest(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyLatest(ProgramDB program) throws Exception {
boolean commit = false;
@ -534,6 +499,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
s.add(new IntegerDataType());
// Offsets change to 0,2,4,8.
assertFalse(s.isPackingEnabled());
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(1, s.getComponent(1).getOffset());
assertEquals(3, s.getComponent(2).getOffset());
@ -541,7 +507,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(15, s.getComponent(4).getOffset());
assertEquals(19, s.getLength());
assertEquals(1, s.getAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
commit = true;
}
finally {
@ -549,9 +514,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
}
}
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyPrivate(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyPrivate(ProgramDB program) throws Exception {
boolean commit = false;
@ -563,7 +525,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
assertEquals(15, s.getLength());
assertEquals(1, s.getAlignment());
s.setInternallyAligned(true);
s.setToDefaultPacking();
// Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset());
@ -572,7 +534,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(8, s.getComponent(3).getOffset());
assertEquals(16, s.getLength());
assertEquals(4, s.getAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
commit = true;
}
finally {
@ -596,11 +558,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Structure s =
(Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"),
"IntStruct");
assertEquals(false, s.isInternallyAligned());
assertEquals(true, s.isDefaultAligned());
assertEquals(false, s.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, s.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
assertFalse(s.isPackingEnabled());
assertTrue(s.isDefaultAligned());
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(1, s.getComponent(1).getOffset());
assertEquals(3, s.getComponent(2).getOffset());
@ -624,11 +584,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Structure s =
(Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"),
"IntStruct");
assertEquals(true, s.isInternallyAligned());
assertEquals(true, s.isDefaultAligned());
assertEquals(false, s.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, s.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
assertTrue(s.hasDefaultPacking());
assertTrue(s.isDefaultAligned());
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset());
assertEquals(4, s.getComponent(2).getOffset());
@ -640,9 +598,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
private void setupStructureFieldNameVsPack() throws Exception {
mtf.initialize("notepad", new OriginalProgramModifierListener() {
/* (non-Javadoc)
* @see ghidra.framework.data.OriginalProgramModifierListener#modifyOriginal(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyOriginal(ProgramDB program) throws Exception {
boolean commit = false;
@ -654,7 +610,8 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
assertEquals(15, s.getLength());
assertEquals(1, s.getAlignment());
s.setInternallyAligned(true);
s.setToDefaultPacking();
// Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset());
@ -669,9 +626,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
}
}
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyLatest(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyLatest(ProgramDB program) throws Exception {
boolean commit = false;
@ -685,6 +639,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(4, s.getAlignment());
s.getComponent(1).setFieldName("MyComponentOne");
assertTrue(s.hasDefaultPacking());
assertTrue(s.isDefaultAligned());
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset());
assertEquals("MyComponentOne", s.getComponent(1).getFieldName());
@ -692,7 +649,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(8, s.getComponent(3).getOffset());
assertEquals(16, s.getLength());
assertEquals(4, s.getAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
commit = true;
}
finally {
@ -700,9 +657,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
}
}
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyPrivate(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyPrivate(ProgramDB program) throws Exception {
boolean commit = false;
@ -714,7 +668,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
assertEquals(16, s.getLength());
assertEquals(4, s.getAlignment());
s.setPackingValue(1);
s.pack(1);
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(1, s.getComponent(1).getOffset());
@ -722,7 +676,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(7, s.getComponent(3).getOffset());
assertEquals(15, s.getLength());
assertEquals(1, s.getAlignment());
assertEquals(1, s.getPackingValue());
commit = true;
}
finally {
@ -746,11 +700,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Structure s =
(Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"),
"IntStruct");
assertEquals(true, s.isInternallyAligned());
assertEquals(true, s.isDefaultAligned());
assertEquals(false, s.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, s.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
assertTrue(s.hasDefaultPacking());
assertTrue(s.isDefaultAligned());
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset());
assertEquals(4, s.getComponent(2).getOffset());
@ -773,11 +725,10 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Structure s =
(Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"),
"IntStruct");
assertEquals(true, s.isInternallyAligned());
assertEquals(true, s.isDefaultAligned());
assertEquals(false, s.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, s.getMinimumAlignment());
assertEquals(1, s.getPackingValue());
assertTrue(s.hasExplicitPackingValue());
assertEquals(1, s.getExplicitPackingValue());
assertTrue(s.isDefaultAligned());
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(1, s.getComponent(1).getOffset());
assertEquals(3, s.getComponent(2).getOffset());
@ -789,9 +740,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
private void setupStructureRemoveVsPack() throws Exception {
mtf.initialize("notepad", new OriginalProgramModifierListener() {
/* (non-Javadoc)
* @see ghidra.framework.data.OriginalProgramModifierListener#modifyOriginal(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyOriginal(ProgramDB program) throws Exception {
boolean commit = false;
@ -803,7 +752,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
assertEquals(15, s.getLength());
assertEquals(1, s.getAlignment());
s.setInternallyAligned(true);
s.setToDefaultPacking();
// Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset());
@ -812,7 +761,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(8, s.getComponent(3).getOffset());
assertEquals(16, s.getLength());
assertEquals(4, s.getAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
commit = true;
}
finally {
@ -820,9 +769,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
}
}
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyLatest(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyLatest(ProgramDB program) throws Exception {
boolean commit = false;
@ -832,7 +778,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try {
Structure s = (Structure) dtm.getDataType(
new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
dtm.remove(s, TaskMonitorAdapter.DUMMY_MONITOR);
dtm.remove(s, TaskMonitor.DUMMY);
// Offsets change to 0,2,4,8.
Structure intStruct = (Structure) dtm.getDataType(
@ -845,9 +791,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
}
}
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyPrivate(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyPrivate(ProgramDB program) throws Exception {
boolean commit = false;
@ -857,7 +800,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try {
Structure s = (Structure) dtm.getDataType(
new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
s.setPackingValue(1);
s.pack(1);
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(1, s.getComponent(1).getOffset());
@ -865,7 +808,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(7, s.getComponent(3).getOffset());
assertEquals(15, s.getLength());
assertEquals(1, s.getAlignment());
assertEquals(1, s.getPackingValue());
commit = true;
}
finally {
@ -906,11 +849,10 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Structure s =
(Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"),
"IntStruct");
assertEquals(true, s.isInternallyAligned());
assertEquals(true, s.isDefaultAligned());
assertEquals(false, s.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, s.getMinimumAlignment());
assertEquals(1, s.getPackingValue());
assertTrue(s.hasExplicitPackingValue());
assertEquals(1, s.getExplicitPackingValue());
assertTrue(s.isDefaultAligned());
assertEquals(0, s.getComponent(0).getOffset());
assertEquals(1, s.getComponent(1).getOffset());
assertEquals(3, s.getComponent(2).getOffset());
@ -922,9 +864,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
private void setupStructureInUnionAndViceVersa() throws Exception {
mtf.initialize("notepad", new OriginalProgramModifierListener() {
/* (non-Javadoc)
* @see ghidra.framework.data.OriginalProgramModifierListener#modifyOriginal(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyOriginal(ProgramDB program) throws Exception {
boolean commit = false;
@ -934,11 +874,11 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try {
Structure s = (Structure) dtm.getDataType(
new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
s.setInternallyAligned(true);
s.setPackingEnabled(true);
Union union = (Union) dtm.getDataType(new CategoryPath("/Category1/Category2"),
"CoolUnion");
union.setInternallyAligned(true);
union.setPackingEnabled(true);
commit = true;
}
@ -947,9 +887,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
}
}
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyLatest(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyLatest(ProgramDB program) throws Exception {
boolean commit = false;
@ -975,9 +912,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
}
}
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyPrivate(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyPrivate(ProgramDB program) throws Exception {
boolean commit = false;
@ -1019,11 +953,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Structure intStruct =
(Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"),
"IntStruct");
assertEquals(true, intStruct.isInternallyAligned());
assertEquals(true, intStruct.isDefaultAligned());
assertEquals(false, intStruct.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, intStruct.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, intStruct.getPackingValue());
assertTrue(intStruct.hasDefaultPacking());
assertTrue(intStruct.isDefaultAligned());
assertEquals(5, intStruct.getNumComponents());
assertEquals(0, intStruct.getComponent(0).getOffset());
assertEquals(2, intStruct.getComponent(1).getOffset());
@ -1036,11 +968,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Union coolUnion =
(Union) dtm.getDataType(new CategoryPath("/Category1/Category2"), "CoolUnion");
assertEquals(true, coolUnion.isInternallyAligned());
assertEquals(true, coolUnion.isDefaultAligned());
assertEquals(false, coolUnion.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, coolUnion.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, coolUnion.getPackingValue());
assertTrue(coolUnion.hasDefaultPacking());
assertTrue(coolUnion.isDefaultAligned());
assertEquals(6, coolUnion.getNumComponents());
assertEquals("qword", coolUnion.getComponent(0).getDataType().getDisplayName());
assertEquals("word", coolUnion.getComponent(1).getDataType().getDisplayName());
@ -1061,9 +991,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
public void setupUnionMachineAlignedVsValue() throws Exception {
mtf.initialize("notepad", new OriginalProgramModifierListener() {
/* (non-Javadoc)
* @see ghidra.framework.data.OriginalProgramModifierListener#modifyOriginal(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyOriginal(ProgramDB program) throws Exception {
boolean commit = false;
@ -1075,7 +1003,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
"CoolUnion");
assertEquals(96, union.getLength());
assertEquals(1, union.getAlignment());
union.setInternallyAligned(true);
union.setPackingEnabled(true);
assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).getLength());
@ -1091,9 +1019,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
}
}
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyLatest(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyLatest(ProgramDB program) throws Exception {
boolean commit = false;
@ -1103,7 +1028,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try {
Union union = (Union) dtm.getDataType(new CategoryPath("/Category1/Category2"),
"CoolUnion");
union.setToMachineAlignment();
union.setToMachineAligned();
assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).getLength());
@ -1119,9 +1044,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
}
}
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyPrivate(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyPrivate(ProgramDB program) throws Exception {
boolean commit = false;
@ -1131,7 +1053,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try {
Union union = (Union) dtm.getDataType(new CategoryPath("/Category1/Category2"),
"CoolUnion");
union.setMinimumAlignment(4);
union.setExplicitMinimumAlignment(4);
assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).getLength());
@ -1162,11 +1084,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager();
Category c = dtm.getCategory(new CategoryPath("/Category1/Category2"));
Union union = (Union) c.getDataType("CoolUnion");
assertEquals(true, union.isInternallyAligned());
assertEquals(false, union.isDefaultAligned());
assertEquals(true, union.isMachineAligned());
assertEquals(8, union.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, union.getPackingValue());
assertTrue(union.hasDefaultPacking());
assertTrue(union.isMachineAligned());
assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).getLength());
assertEquals(4, union.getComponent(2).getLength());
@ -1189,11 +1109,10 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager();
Category c = dtm.getCategory(new CategoryPath("/Category1/Category2"));
Union union = (Union) c.getDataType("CoolUnion");
assertEquals(true, union.isInternallyAligned());
assertEquals(false, union.isDefaultAligned());
assertEquals(false, union.isMachineAligned());
assertEquals(4, union.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, union.getPackingValue());
assertTrue(union.hasDefaultPacking());
assertTrue(union.hasExplicitMinimumAlignment());
assertEquals(4, union.getExplicitMinimumAlignment());
assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).getLength());
assertEquals(4, union.getComponent(2).getLength());
@ -1216,11 +1135,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager();
Category c = dtm.getCategory(new CategoryPath("/Category1/Category2"));
Union union = (Union) c.getDataType("CoolUnion");
assertEquals(true, union.isInternallyAligned());
assertEquals(true, union.isDefaultAligned());
assertEquals(false, union.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, union.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, union.getPackingValue());
assertTrue(union.hasDefaultPacking());
assertTrue(union.isDefaultAligned());
assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).getLength());
assertEquals(4, union.getComponent(2).getLength());
@ -1233,9 +1150,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
public void setupUnionPack1VsPack2() throws Exception {
mtf.initialize("notepad", new OriginalProgramModifierListener() {
/* (non-Javadoc)
* @see ghidra.framework.data.OriginalProgramModifierListener#modifyOriginal(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyOriginal(ProgramDB program) throws Exception {
boolean commit = false;
@ -1247,7 +1162,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
"CoolUnion");
assertEquals(96, union.getLength());
assertEquals(1, union.getAlignment());
union.setInternallyAligned(true);
union.setPackingEnabled(true);
assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).getLength());
@ -1263,9 +1178,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
}
}
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyLatest(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyLatest(ProgramDB program) throws Exception {
boolean commit = false;
@ -1275,7 +1187,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try {
Union union = (Union) dtm.getDataType(new CategoryPath("/Category1/Category2"),
"CoolUnion");
union.setPackingValue(1);
union.pack(1);
assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).getLength());
@ -1291,9 +1203,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
}
}
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyPrivate(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyPrivate(ProgramDB program) throws Exception {
boolean commit = false;
@ -1303,7 +1212,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try {
Union union = (Union) dtm.getDataType(new CategoryPath("/Category1/Category2"),
"CoolUnion");
union.setPackingValue(2);
union.pack(2);
assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).getLength());
@ -1334,11 +1243,10 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager();
Category c = dtm.getCategory(new CategoryPath("/Category1/Category2"));
Union union = (Union) c.getDataType("CoolUnion");
assertEquals(true, union.isInternallyAligned());
assertEquals(true, union.isDefaultAligned());
assertEquals(false, union.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, union.getMinimumAlignment());
assertEquals(1, union.getPackingValue());
assertTrue(union.hasExplicitPackingValue());
assertEquals(1, union.getExplicitPackingValue());
assertTrue(union.isDefaultAligned());
assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).getLength());
assertEquals(4, union.getComponent(2).getLength());
@ -1361,11 +1269,10 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager();
Category c = dtm.getCategory(new CategoryPath("/Category1/Category2"));
Union union = (Union) c.getDataType("CoolUnion");
assertEquals(true, union.isInternallyAligned());
assertEquals(true, union.isDefaultAligned());
assertEquals(false, union.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, union.getMinimumAlignment());
assertEquals(2, union.getPackingValue());
assertTrue(union.hasExplicitPackingValue());
assertEquals(2, union.getExplicitPackingValue());
assertTrue(union.isDefaultAligned());
assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).getLength());
assertEquals(4, union.getComponent(2).getLength());
@ -1388,11 +1295,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager();
Category c = dtm.getCategory(new CategoryPath("/Category1/Category2"));
Union union = (Union) c.getDataType("CoolUnion");
assertEquals(true, union.isInternallyAligned());
assertEquals(true, union.isDefaultAligned());
assertEquals(false, union.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, union.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, union.getPackingValue());
assertTrue(union.hasDefaultPacking());
assertTrue(union.isDefaultAligned());
assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).getLength());
assertEquals(4, union.getComponent(2).getLength());
@ -1416,9 +1321,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
struct2.add(new StringDataType(), 4);
mtf.initialize("notepad", new ProgramModifierListener() {
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyLatest(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyLatest(ProgramDB program) throws Exception {
boolean commit = false;
@ -1444,12 +1347,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertTrue(new PointerDataType(new FloatDataType()).isEquivalent(
s.getComponent(0).getDataType()));
assertTrue(new FloatDataType().isEquivalent(s.getComponent(1).getDataType()));
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
}
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyPrivate(ghidra.program.database.ProgramDB)
*/
@Override
public void modifyPrivate(ProgramDB program) throws Exception {
boolean commit = false;
@ -1474,7 +1374,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(4, s.getComponent(1).getLength());
assertTrue(new CharDataType().isEquivalent(s.getComponent(0).getDataType()));
assertTrue(new StringDataType().isEquivalent(s.getComponent(1).getDataType()));
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
}
});
@ -1495,7 +1394,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertTrue(new PointerDataType(new FloatDataType()).isEquivalent(
s1.getComponent(0).getDataType()));
assertTrue(new FloatDataType().isEquivalent(s1.getComponent(1).getDataType()));
assertEquals(Composite.NOT_PACKING, s1.getPackingValue());
Structure s2 =
(Structure) dtm.getDataType(new CategoryPath("/Category1"), "ABCStructure.conflict");
@ -1508,6 +1406,5 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(4, s2.getComponent(1).getLength());
assertTrue(new CharDataType().isEquivalent(s2.getComponent(0).getDataType()));
assertTrue(new StringDataType().isEquivalent(s2.getComponent(1).getDataType()));
assertEquals(Composite.NOT_PACKING, s2.getPackingValue());
}
}

View file

@ -60,7 +60,7 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
Structure inner = new StructureDataType("inner", 0);
inner.add(new ByteDataType());
inner.add(new WordDataType());
inner.setInternallyAligned(true);
inner.setPackingEnabled(true);
try {
Category rootCategory = dtm.getCategory(rootPath);
@ -103,7 +103,7 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
Structure outer = new StructureDataType("outer", 0);
outer.add(new ByteDataType());
outer.add(inner);
outer.setInternallyAligned(true);
outer.setPackingEnabled(true);
int transactionID = program.startTransaction("create outer struct, modify inner");
try {
@ -134,14 +134,14 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
waitForCompletion();
DataTypeManager dtm = resultProgram.getDataTypeManager();
Structure inner = (Structure) dtm.getDataType(rootPath, "inner");
StructureInternal inner = (StructureInternal) dtm.getDataType(rootPath, "inner");
assertNull(inner);
Structure outer = (Structure) dtm.getDataType(rootPath, "outer");
StructureInternal outer = (StructureInternal) dtm.getDataType(rootPath, "outer");
assertNotNull(outer);
assertEquals(true, outer.isInternallyAligned());
assertEquals(true, outer.isPackingEnabled());
assertEquals(true, outer.isDefaultAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, outer.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, outer.getPackingValue());
assertEquals(CompositeInternal.DEFAULT_ALIGNMENT, outer.getStoredMinimumAlignment());
assertEquals(CompositeInternal.DEFAULT_PACKING, outer.getStoredPackingValue());
assertEquals(1, outer.getNumComponents());
assertTrue(new ByteDataType().isEquivalent(outer.getComponent(0).getDataType()));
assertEquals(1, outer.getLength());
@ -162,24 +162,24 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
waitForCompletion();
DataTypeManager dtm = resultProgram.getDataTypeManager();
Structure inner = (Structure) dtm.getDataType(rootPath, "inner");
StructureInternal inner = (StructureInternal) dtm.getDataType(rootPath, "inner");
assertNotNull(inner);
assertEquals(true, inner.isInternallyAligned());
assertEquals(true, inner.isPackingEnabled());
assertEquals(true, inner.isDefaultAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, inner.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, inner.getPackingValue());
assertEquals(CompositeInternal.DEFAULT_ALIGNMENT, inner.getStoredMinimumAlignment());
assertEquals(CompositeInternal.DEFAULT_PACKING, inner.getStoredPackingValue());
assertEquals(2, inner.getNumComponents());
assertTrue(new CharDataType().isEquivalent(inner.getComponent(0).getDataType()));
assertTrue(new WordDataType().isEquivalent(inner.getComponent(1).getDataType()));
assertEquals(4, inner.getLength());
assertEquals(2, inner.getAlignment());
Structure outer = (Structure) dtm.getDataType(rootPath, "outer");
StructureInternal outer = (StructureInternal) dtm.getDataType(rootPath, "outer");
assertNotNull(outer);
assertEquals(true, outer.isInternallyAligned());
assertEquals(true, outer.isPackingEnabled());
assertEquals(true, outer.isDefaultAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, outer.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, outer.getPackingValue());
assertEquals(CompositeInternal.DEFAULT_ALIGNMENT, outer.getStoredMinimumAlignment());
assertEquals(CompositeInternal.DEFAULT_PACKING, outer.getStoredPackingValue());
assertEquals(2, outer.getNumComponents());
assertTrue(new ByteDataType().isEquivalent(outer.getComponent(0).getDataType()));
assertEquals(inner, outer.getComponent(1).getDataType());
@ -220,7 +220,7 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
Structure inner = new StructureDataType("inner", 0);
inner.add(new ByteDataType());
inner.add(new WordDataType());
inner.setInternallyAligned(true);
inner.setPackingEnabled(true);
try {
Category rootCategory = dtm.getCategory(rootPath);
@ -263,7 +263,7 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
Structure outer = new StructureDataType("outer", 0);
outer.add(new ByteDataType());
outer.add(inner);
outer.setInternallyAligned(true);
outer.setPackingEnabled(true);
int transactionID =
program.startTransaction("create outer struct, don't modify inner");
@ -283,14 +283,14 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
waitForCompletion();
DataTypeManager dtm = resultProgram.getDataTypeManager();
Structure inner = (Structure) dtm.getDataType(rootPath, "inner");
StructureInternal inner = (StructureInternal) dtm.getDataType(rootPath, "inner");
assertNull(inner);
Structure outer = (Structure) dtm.getDataType(rootPath, "outer");
StructureInternal outer = (StructureInternal) dtm.getDataType(rootPath, "outer");
assertNotNull(outer);
assertEquals(true, outer.isInternallyAligned());
assertEquals(true, outer.isPackingEnabled());
assertEquals(true, outer.isDefaultAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, outer.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, outer.getPackingValue());
assertEquals(CompositeInternal.DEFAULT_ALIGNMENT, outer.getStoredMinimumAlignment());
assertEquals(CompositeInternal.DEFAULT_PACKING, outer.getStoredPackingValue());
assertEquals(1, outer.getNumComponents());
assertTrue(new ByteDataType().isEquivalent(outer.getComponent(0).getDataType()));
assertEquals(1, outer.getLength());
@ -335,7 +335,7 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
Structure inner = new StructureDataType("inner", 0);
inner.add(new ByteDataType());
inner.add(new WordDataType());
inner.setInternallyAligned(true);
inner.setPackingEnabled(true);
try {
Category rootCategory = dtm.getCategory(rootPath);
@ -378,7 +378,7 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
Structure other = new StructureDataType("other", 0);
other.add(new ByteDataType());
other.add(new PointerDataType(new VoidDataType()));
other.setInternallyAligned(true);
other.setPackingEnabled(true);
Structure outer = new StructureDataType("outer", 0);
outer.add(new ByteDataType());
@ -386,7 +386,7 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
outer.add(new FloatDataType());
outer.add(other);
outer.add(new ByteDataType());
outer.setInternallyAligned(true);
outer.setPackingEnabled(true);
int transactionID = program.startTransaction(
"create outer struct with other structure after inner");
@ -407,15 +407,15 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager();
Structure inner = (Structure) dtm.getDataType(rootPath, "inner");
StructureInternal inner = (StructureInternal) dtm.getDataType(rootPath, "inner");
assertNull(inner);
Structure other = (Structure) dtm.getDataType(rootPath, "other");
StructureInternal other = (StructureInternal) dtm.getDataType(rootPath, "other");
assertNotNull(other);
assertEquals(true, other.isInternallyAligned());
assertEquals(true, other.isPackingEnabled());
assertEquals(true, other.isDefaultAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, other.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, other.getPackingValue());
assertEquals(CompositeInternal.DEFAULT_ALIGNMENT, other.getStoredMinimumAlignment());
assertEquals(CompositeInternal.DEFAULT_PACKING, other.getStoredPackingValue());
assertEquals(2, other.getNumComponents());
assertTrue(new ByteDataType().isEquivalent(other.getComponent(0).getDataType()));
assertTrue(new PointerDataType(new VoidDataType()).isEquivalent(
@ -423,12 +423,12 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
assertEquals(8, other.getLength());
assertEquals(4, other.getAlignment());
Structure outer = (Structure) dtm.getDataType(rootPath, "outer");
StructureInternal outer = (StructureInternal) dtm.getDataType(rootPath, "outer");
assertNotNull(outer);
assertEquals(true, outer.isInternallyAligned());
assertEquals(true, outer.isPackingEnabled());
assertEquals(true, outer.isDefaultAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, outer.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, outer.getPackingValue());
assertEquals(CompositeInternal.DEFAULT_ALIGNMENT, outer.getStoredMinimumAlignment());
assertEquals(CompositeInternal.DEFAULT_PACKING, outer.getStoredPackingValue());
assertEquals(4, outer.getNumComponents());
assertTrue(new ByteDataType().isEquivalent(outer.getComponent(0).getDataType()));
assertTrue(new FloatDataType().isEquivalent(outer.getComponent(1).getDataType()));

View file

@ -90,12 +90,12 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTest
struct.add(CharDataType.dataType);
struct.add(IntegerDataType.dataType);
struct.add(CharDataType.dataType);
struct.setInternallyAligned(true);
struct.setPackingEnabled(true);
builder.applyDataType("0x1001100", struct);
builder.setBytes("0x1001200", "01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f");
struct = new StructureDataType("struct2", 12);
struct.setInternallyAligned(false);
struct.setPackingEnabled(false);
struct.insertAtOffset(0, CharDataType.dataType, -1);
struct.insertAtOffset(4, IntegerDataType.dataType, -1);
struct.insertAtOffset(8, CharDataType.dataType, -1);
@ -486,7 +486,7 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTest
showTool(tool);
loadProgram();
// turn alignment bytes option on but it has no impact on displayed bytes for unaligned structure
// turn alignment bytes option on but it has no impact on displayed bytes for non-packed structure
Options options = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_FIELDS);
options.setBoolean("Bytes Field.Display Structure Alignment Bytes", true);

View file

@ -47,7 +47,6 @@ import ghidra.framework.plugintool.util.PluginException;
import ghidra.program.database.ProgramBuilder;
import ghidra.program.model.data.*;
import ghidra.program.model.data.Composite;
import ghidra.program.model.data.Composite.AlignmentType;
import ghidra.program.model.data.Enum;
import ghidra.program.model.listing.Program;
import ghidra.test.AbstractGhidraHeadedIntegrationTest;
@ -213,8 +212,7 @@ public abstract class AbstractEditorTest extends AbstractGhidraHeadedIntegration
}
protected CycleGroupAction getCycleGroup(DataType dt) {
for (int cycleIndex = 0; cycleIndex < cycles.size(); cycleIndex++) {
CycleGroupAction action = cycles.get(cycleIndex);
for (CycleGroupAction action : cycles) {
CycleGroup group = action.getCycleGroup();
DataType[] types = group.getDataTypes();
for (DataType type : types) {
@ -227,8 +225,7 @@ public abstract class AbstractEditorTest extends AbstractGhidraHeadedIntegration
}
protected FavoritesAction getFavorite(String name) {
for (int favIndex = 0; favIndex < favorites.size(); favIndex++) {
FavoritesAction action = favorites.get(favIndex);
for (FavoritesAction action : favorites) {
if (action.getDataType().getDisplayName().equals(name)) {
return action;
}
@ -332,13 +329,17 @@ public abstract class AbstractEditorTest extends AbstractGhidraHeadedIntegration
}
protected void invoke(final DockingActionIf action) {
invoke(action, true);
}
protected void invoke(final DockingActionIf action, boolean wait) {
assertNotNull(action);
boolean isEnabled = runSwing(() -> action.isEnabled());
if (!isEnabled) {
Msg.debug(this, "Calling actionPerformed() on a disabled action: " + action.getName(),
ReflectionUtilities.createJavaFilteredThrowable());
}
runSwing(() -> action.actionPerformed(new ActionContext()), false);
runSwing(() -> action.actionPerformed(new ActionContext()), wait);
waitForSwing();
}
@ -811,20 +812,30 @@ public abstract class AbstractEditorTest extends AbstractGhidraHeadedIntegration
actionEnablement);
}
protected void assertIsInternallyAligned(boolean aligned) {
assertEquals(aligned, ((CompEditorModel) model).isAligned());
protected void assertIsPackingEnabled(boolean aligned) {
assertEquals(aligned, ((CompEditorModel) model).isPackingEnabled());
}
protected void assertPackingValue(int value) {
assertEquals(value, ((CompEditorModel) model).getPackingValue());
protected void assertDefaultPacked() {
assertEquals(PackingType.DEFAULT, ((CompEditorModel) model).getPackingType());
}
protected void assertMinimumAlignmentType(AlignmentType alignmentType) {
assertEquals(alignmentType, ((CompEditorModel) model).getMinimumAlignmentType());
protected void assertPacked(int pack) {
assertEquals(PackingType.EXPLICIT, ((CompEditorModel) model).getPackingType());
assertEquals(pack, ((CompEditorModel) model).getExplicitPackingValue());
}
protected void assertMinimumAlignmentValue(int value) {
assertEquals(value, ((CompEditorModel) model).getMinimumAlignment());
protected void assertIsDefaultAligned() {
assertEquals(AlignmentType.DEFAULT, ((CompEditorModel) model).getAlignmentType());
}
protected void assertIsMachineAligned() {
assertEquals(AlignmentType.MACHINE, ((CompEditorModel) model).getAlignmentType());
}
protected void assertExplicitAlignment(int alignment) {
assertEquals(AlignmentType.EXPLICIT, ((CompEditorModel) model).getAlignmentType());
assertEquals(alignment, ((CompEditorModel) model).getExplicitMinimumAlignment());
}
protected void assertActualAlignment(int value) {

View file

@ -28,7 +28,7 @@ public abstract class AbstractStructureEditorLockedActionsTest extends AbstractS
try {
DataTypeManager dataTypeManager = cat.getDataTypeManager();
if (dt.getDataTypeManager() != dataTypeManager) {
dt = (Structure) dt.clone(dataTypeManager);
dt = dt.clone(dataTypeManager);
}
CategoryPath categoryPath = cat.getCategoryPath();
if (!dt.getCategoryPath().equals(categoryPath)) {

View file

@ -60,7 +60,7 @@ public abstract class AbstractStructureEditorTest extends AbstractEditorTest {
try {
DataTypeManager dataTypeManager = cat.getDataTypeManager();
if (dt.getDataTypeManager() != dataTypeManager) {
dt = (Structure) dt.clone(dataTypeManager);
dt = dt.clone(dataTypeManager);
}
CategoryPath categoryPath = cat.getCategoryPath();
if (!dt.getCategoryPath().equals(categoryPath)) {
@ -81,6 +81,7 @@ public abstract class AbstractStructureEditorTest extends AbstractEditorTest {
installProvider(new StructureEditorProvider(plugin, structDt, showInHex));
model = provider.getModel();
});
waitForSwing();
getActions();
structureModel = (StructureEditorModel) model;
}

View file

@ -23,7 +23,6 @@ import javax.swing.JTextField;
import org.junit.Test;
import ghidra.program.model.data.*;
import ghidra.program.model.data.Composite.AlignmentType;
import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.Library;
import ghidra.program.model.symbol.ExternalLocation;
@ -32,7 +31,7 @@ import ghidra.program.model.symbol.SourceType;
public class StructureEditorAlignmentTest extends AbstractStructureEditorTest {
@Test
public void testUnalignedStructure() {
public void testNonPackedStructure() {
init(emptyStructure, pgmRootCat, false);
assertTrue(structureModel.hasChanges());// initial unsaved empty structure
@ -44,10 +43,8 @@ public class StructureEditorAlignmentTest extends AbstractStructureEditorTest {
structureModel.getOriginalCategoryPath().getPath());
assertEquals(0, structureModel.getNumComponents());// no components
assertEquals(1, structureModel.getRowCount());// blank row
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertLength(0);
assertActualAlignment(1);
assertEquals(0, structureModel.getNumSelectedComponentRows());
@ -102,7 +99,9 @@ public class StructureEditorAlignmentTest extends AbstractStructureEditorTest {
assertLength(10);
assertActualAlignment(1);
pressButtonByName(getPanel(), "Internally Aligned");
pressButtonByName(getPanel(), "Packing Enablement"); // toggle -> enable packing
assertIsPackingEnabled(true);
assertDefaultPacked();
assertEquals(3, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
@ -115,7 +114,7 @@ public class StructureEditorAlignmentTest extends AbstractStructureEditorTest {
@Test
public void testEnablementDefaultAlignedStructure() throws Exception {
emptyStructure.setInternallyAligned(true);
emptyStructure.setPackingEnabled(true);
init(emptyStructure, pgmRootCat, false);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
@ -159,8 +158,12 @@ public class StructureEditorAlignmentTest extends AbstractStructureEditorTest {
waitForSwing();
pressButtonByName(getPanel(), "Internally Aligned");
pressButtonByName(getPanel(), "Machine Minimum Alignment");
pressButtonByName(getPanel(), "Packing Enablement"); // toggle -> enable packing
assertIsPackingEnabled(true);
assertDefaultPacked();
pressButtonByName(getPanel(), "Machine Alignment");
assertIsMachineAligned();
assertEquals(3, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
@ -184,19 +187,24 @@ public class StructureEditorAlignmentTest extends AbstractStructureEditorTest {
waitForSwing();
pressButtonByName(editorPanel, "Internally Aligned");
pressButtonByName(getPanel(), "Packing Enablement"); // toggle -> enable packing
assertIsPackingEnabled(true);
assertDefaultPacked();
JTextField minAlignField =
(JTextField) getInstanceField("minAlignValueTextField", editorPanel);
(JTextField) getInstanceField("explicitAlignTextField", editorPanel);
assertNotNull(minAlignField);
JRadioButton byValueMinAlignButton =
(JRadioButton) getInstanceField("byValueMinAlignButton", editorPanel);
assertNotNull(byValueMinAlignButton);
pressButton(byValueMinAlignButton);
assertEquals("4", minAlignField.getText());
JRadioButton explicitAlignButton =
(JRadioButton) getInstanceField("explicitAlignButton", editorPanel);
assertNotNull(explicitAlignButton);
pressButton(explicitAlignButton);
assertEquals("8", minAlignField.getText()); // toy.cspec machine alignment is default value
assertEquals(false, structureModel.viewComposite.isDefaultAligned());
assertEquals(false, structureModel.viewComposite.isMachineAligned());
assertEquals(4, structureModel.getMinimumAlignment());
assertEquals(8, structureModel.getExplicitMinimumAlignment());
assertActualAlignment(8);
assertEquals(3, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
@ -204,7 +212,7 @@ public class StructureEditorAlignmentTest extends AbstractStructureEditorTest {
checkRow(1, 4, 4, "float", new FloatDataType(), "", "");
checkRow(2, 8, 5, "char[5]", arrayDt, "", "");
assertLength(16);
assertActualAlignment(4);
assertActualAlignment(8);
}
@Test
@ -232,10 +240,10 @@ public class StructureEditorAlignmentTest extends AbstractStructureEditorTest {
checkByValueAlignedStructure(16, 16, 16);
}
public void checkByValueAlignedStructure(int value, int alignment, int length)
public void checkByValueAlignedStructure(int minAlignment, int alignment, int length)
throws Exception {
emptyStructure.setInternallyAligned(true);
emptyStructure.setMinimumAlignment(value);
emptyStructure.setPackingEnabled(true);
emptyStructure.setExplicitMinimumAlignment(minAlignment);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyStructure.add(new ByteDataType());
@ -245,19 +253,20 @@ public class StructureEditorAlignmentTest extends AbstractStructureEditorTest {
init(emptyStructure, pgmRootCat, false);
CompEditorPanel editorPanel = (CompEditorPanel) getPanel();
JRadioButton byValueMinAlignButton =
(JRadioButton) getInstanceField("byValueMinAlignButton", editorPanel);
assertNotNull(byValueMinAlignButton);
assertEquals(true, byValueMinAlignButton.isSelected());
JRadioButton explicitAlignButton =
(JRadioButton) getInstanceField("explicitAlignButton", editorPanel);
assertNotNull(explicitAlignButton);
assertEquals(true, explicitAlignButton.isSelected());
JTextField minAlignField =
(JTextField) getInstanceField("minAlignValueTextField", editorPanel);
(JTextField) getInstanceField("explicitAlignTextField", editorPanel);
assertNotNull(minAlignField);
assertEquals("" + value, minAlignField.getText());
assertEquals("" + minAlignment, minAlignField.getText());
assertEquals(false, structureModel.viewComposite.isDefaultAligned());
assertEquals(false, structureModel.viewComposite.isMachineAligned());
assertEquals(value, structureModel.getMinimumAlignment());
assertExplicitAlignment(minAlignment);
assertEquals(3, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
@ -270,9 +279,9 @@ public class StructureEditorAlignmentTest extends AbstractStructureEditorTest {
@Test
public void testDefaultAlignedPacked1Structure() throws Exception {
int value = 1;
emptyStructure.setInternallyAligned(true);
emptyStructure.setPackingValue(value);
int pack = 1;
emptyStructure.setPackingEnabled(true);
emptyStructure.pack(pack);
init(emptyStructure, pgmRootCat, false);
CompEditorPanel editorPanel = (CompEditorPanel) getPanel();
@ -283,17 +292,18 @@ public class StructureEditorAlignmentTest extends AbstractStructureEditorTest {
addDataType(arrayDt);
JRadioButton byValuePackingButton =
(JRadioButton) findComponentByName(editorPanel, "By Value Packing");
(JRadioButton) findComponentByName(editorPanel, "Explicit Packing");
assertNotNull(byValuePackingButton);
JTextField packingValueField =
(JTextField) findComponentByName(editorPanel, "Packing Value");
assertNotNull(packingValueField);
assertEquals(true, byValuePackingButton.isSelected());
assertEquals("" + value, packingValueField.getText());
assertEquals(Integer.toString(pack), packingValueField.getText());
assertEquals(true, structureModel.viewComposite.isDefaultAligned());
assertEquals(false, structureModel.viewComposite.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, structureModel.getMinimumAlignment());
assertIsDefaultAligned();
assertEquals(3, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
@ -306,7 +316,6 @@ public class StructureEditorAlignmentTest extends AbstractStructureEditorTest {
@Test
public void testAlignedEditToFunctionDefinitionDataType() throws Exception {
int value = 1;
startTransaction("addExternal");
ExternalLocation extLoc = program.getExternalManager().addExtFunction(Library.UNKNOWN,
@ -321,8 +330,8 @@ public class StructureEditorAlignmentTest extends AbstractStructureEditorTest {
boolean commit = false;
txId = program.startTransaction("Modify Program");
try {
simpleStructure.setInternallyAligned(true);
simpleStructure.setPackingValue(value);
simpleStructure.setPackingEnabled(true);
simpleStructure.pack(1);
programDTM = program.getListing().getDataTypeManager();
functionDefinition =
@ -358,7 +367,7 @@ public class StructureEditorAlignmentTest extends AbstractStructureEditorTest {
}
@Test
public void testSelectionOnGoFromUnalignedToAlignedStructure() throws Exception {
public void testSelectionOnGoFromNonPackedToDefaultPackedStructure() throws Exception {
init(emptyStructure, pgmRootCat, false);
CompEditorPanel editorPanel = (CompEditorPanel) getPanel();
@ -372,10 +381,8 @@ public class StructureEditorAlignmentTest extends AbstractStructureEditorTest {
structureModel.getOriginalCategoryPath().getPath());
assertEquals(0, structureModel.getNumComponents());// no components
assertEquals(1, structureModel.getRowCount());// blank row
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertLength(0);
assertActualAlignment(1);
assertEquals(0, structureModel.getNumSelectedComponentRows());
@ -388,7 +395,9 @@ public class StructureEditorAlignmentTest extends AbstractStructureEditorTest {
checkSelection(new int[] { 3 });
pressButtonByName(editorPanel, "Internally Aligned");
pressButtonByName(getPanel(), "Packing Enablement"); // toggle -> enable packing
assertIsPackingEnabled(true);
assertDefaultPacked();
assertEquals(0, structureModel.getNumComponents());
assertEquals(1, structureModel.getRowCount());
@ -397,368 +406,383 @@ public class StructureEditorAlignmentTest extends AbstractStructureEditorTest {
checkSelection(new int[] { 0 });
}
// public void testTurnOffAlignmentInStructure() throws Exception {
// emptyStructure.setInternallyAligned(true);
// emptyStructure.setMinimumAlignment(8);
//
// DataType arrayDt = new ArrayDataType(new AsciiDataType(), 5, 1);
// emptyStructure.add(new ByteDataType());
// emptyStructure.add(new FloatDataType());
// emptyStructure.add(arrayDt);
//
// init(emptyStructure, pgmRootCat, false);
//
// JRadioButton byValueButton = (JRadioButton)findComponentByName(getPanel(), "By Value Minimum Alignment");
// assertEquals(true, byValueButton.isSelected());
// JTextField minAlignField = (JTextField)findComponentByName(getPanel(), "Minimum Alignment Value");
// assertEquals("8", minAlignField.getText());
//
// assertEquals(false, structureModel.viewComposite.isDefaultAligned());
// assertEquals(false, structureModel.viewComposite.isMachineAligned());
// assertEquals(8, structureModel.getMinimumAlignment());
//
// assertEquals(3, structureModel.getNumComponents());
// assertEquals(4, structureModel.getRowCount());
// checkRow(0, 1, "db", new ByteDataType(), "", "");
// checkRow(1, 4, "float", new FloatDataType(), "", "");
// checkRow(2, 5, "char[5]", arrayDt, "", "");
// assertLength(8);
// assertActualAlignment(8);
// assertEquals(true, structureModel.isAligned());
//
// pressButtonByName(getPanel(), "Internally Aligned");
//
// assertEquals(false, structureModel.isAligned());
// assertEquals(true, structureModel.viewComposite.isDefaultAligned());
// assertEquals(false, structureModel.viewComposite.isMachineAligned());
// assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, structureModel.getMinimumAlignment());
//
// assertEquals(3, structureModel.getNumComponents());
// assertEquals(4, structureModel.getRowCount());
// checkRow(0, 1, "db", new ByteDataType(), "", "");
// checkRow(1, 4, "float", new FloatDataType(), "", "");
// checkRow(2, 5, "char[5]", arrayDt, "", "");
// assertLength(5);
// assertActualAlignment(1);
// }
//
// public void testInsertUnaligned1() throws Exception {
// emptyStructure.setInternallyAligned(false);
//
// DataType arrayDt = new ArrayDataType(new AsciiDataType(), 5, 1);
// emptyStructure.add(new ByteDataType());
// emptyStructure.add(new FloatDataType());
// emptyStructure.add(arrayDt);
//
// init(emptyStructure, pgmRootCat, false);
//
// assertEquals(3, structureModel.getNumComponents());
// assertEquals(4, structureModel.getRowCount());
// checkRow(0, 1, "db", new ByteDataType(), "", "");
// checkRow(1, 4, "float", new FloatDataType(), "", "");
// checkRow(2, 5, "char[5]", arrayDt, "", "");
// assertLength(5);
// assertActualAlignment(1);
//
// DataType asciiDt = model.getOriginalDataTypeManager().findDataType("/char");
// assertNotNull(asciiDt);
// insertAtPoint(asciiDt,0,0);
//
// assertEquals(4, structureModel.getNumComponents());
// assertEquals(5, structureModel.getRowCount());
// checkRow(0, 1, "ch", asciiDt, "", "");
// checkRow(1, 1, "db", new ByteDataType(), "", "");
// checkRow(2, 4, "float", new FloatDataType(), "", "");
// checkRow(3, 5, "char[5]", arrayDt, "", "");
// assertLength(5);
// assertActualAlignment(1);
// }
//
// public void testInsertUnaligned2() throws Exception {
// emptyStructure.setInternallyAligned(false);
//
// DataType arrayDt = new ArrayDataType(new AsciiDataType(), 5, 1);
// emptyStructure.add(new ByteDataType());
// emptyStructure.add(new FloatDataType());
// emptyStructure.add(arrayDt);
//
// init(emptyStructure, pgmRootCat, false);
//
// assertEquals(3, structureModel.getNumComponents());
// assertEquals(4, structureModel.getRowCount());
// checkRow(0, 1, "db", new ByteDataType(), "", "");
// checkRow(1, 4, "float", new FloatDataType(), "", "");
// checkRow(2, 5, "char[5]", arrayDt, "", "");
// assertLength(5);
// assertActualAlignment(1);
//
// DataType asciiDt = model.getOriginalDataTypeManager().findDataType("/char");
// assertNotNull(asciiDt);
// insertAtPoint(asciiDt,2,3);
//
// assertEquals(4, structureModel.getNumComponents());
// assertEquals(5, structureModel.getRowCount());
// checkRow(0, 1, "db", new ByteDataType(), "", "");
// checkRow(1, 4, "float", new FloatDataType(), "", "");
// checkRow(2, 1, "ch", asciiDt, "", "");
// checkRow(3, 5, "char[5]", arrayDt, "", "");
// assertLength(5);
// assertActualAlignment(1);
// }
//
// public void testInsertUnaligned3() throws Exception {
// emptyStructure.setInternallyAligned(false);
//
// DataType arrayDt = new ArrayDataType(new AsciiDataType(), 5, 1);
// emptyStructure.add(new ByteDataType());
// emptyStructure.add(new FloatDataType());
// emptyStructure.add(arrayDt);
//
// init(emptyStructure, pgmRootCat, false);
//
// assertEquals(3, structureModel.getNumComponents());
// assertEquals(4, structureModel.getRowCount());
// checkRow(0, 1, "db", new ByteDataType(), "", "");
// checkRow(1, 4, "float", new FloatDataType(), "", "");
// checkRow(2, 5, "char[5]", arrayDt, "", "");
// assertLength(5);
// assertActualAlignment(1);
//
// DataType doubleDt = model.getOriginalDataTypeManager().findDataType("/double");
// assertNotNull(doubleDt);
// insertAtPoint(doubleDt,3,3);
//
// assertEquals(4, structureModel.getNumComponents());
// assertEquals(5, structureModel.getRowCount());
// checkRow(0, 1, "db", new ByteDataType(), "", "");
// checkRow(1, 4, "float", new FloatDataType(), "", "");
// checkRow(2, 5, "char[5]", arrayDt, "", "");
// checkRow(3, 8, "double", doubleDt, "", "");
// assertLength(8);
// assertActualAlignment(1);
// }
//
// public void testReplaceUnaligned1() throws Exception {
// emptyStructure.setInternallyAligned(false);
//
// DataType arrayDt = new ArrayDataType(new AsciiDataType(), 5, 1);
// emptyStructure.add(new ByteDataType());
// emptyStructure.add(new FloatDataType());
// emptyStructure.add(arrayDt);
//
// init(emptyStructure, pgmRootCat, false);
//
// assertEquals(3, structureModel.getNumComponents());
// assertEquals(4, structureModel.getRowCount());
// checkRow(0, 1, "db", new ByteDataType(), "", "");
// checkRow(1, 4, "float", new FloatDataType(), "", "");
// checkRow(2, 5, "char[5]", arrayDt, "", "");
// assertLength(5);
// assertActualAlignment(1);
//
// DataType asciiDt = model.getOriginalDataTypeManager().findDataType("/char");
// assertNotNull(asciiDt);
// addAtPoint(asciiDt,2,3);
//
// assertEquals(3, structureModel.getNumComponents());
// assertEquals(4, structureModel.getRowCount());
// checkRow(0, 1, "db", new ByteDataType(), "", "");
// checkRow(1, 4, "float", new FloatDataType(), "", "");
// checkRow(2, 1, "ch", asciiDt, "", "");
// assertLength(4);
// assertActualAlignment(1);
// }
//
// public void testReplaceUnaligned2() throws Exception {
// emptyStructure.setInternallyAligned(false);
//
// DataType arrayDt = new ArrayDataType(new AsciiDataType(), 5, 1);
// emptyStructure.add(new ByteDataType());
// emptyStructure.add(new FloatDataType());
// emptyStructure.add(arrayDt);
//
// init(emptyStructure, pgmRootCat, false);
//
// assertEquals(3, structureModel.getNumComponents());
// assertEquals(4, structureModel.getRowCount());
// checkRow(0, 1, "db", new ByteDataType(), "", "");
// checkRow(1, 4, "float", new FloatDataType(), "", "");
// checkRow(2, 5, "char[5]", arrayDt, "", "");
// assertLength(5);
// assertActualAlignment(1);
//
// DataType doubleDt = model.getOriginalDataTypeManager().findDataType("/double");
// assertNotNull(doubleDt);
// addAtPoint(doubleDt,3,3);
//
// assertEquals(4, structureModel.getNumComponents());
// assertEquals(5, structureModel.getRowCount());
// checkRow(0, 1, "db", new ByteDataType(), "", "");
// checkRow(1, 4, "float", new FloatDataType(), "", "");
// checkRow(2, 5, "char[5]", arrayDt, "", "");
// checkRow(3, 8, "double", doubleDt, "", "");
// assertLength(8);
// assertActualAlignment(1);
// }
//
// public void testInsertAligned1() throws Exception {
// emptyStructure.setInternallyAligned(true);
//
// DataType arrayDt = new ArrayDataType(new AsciiDataType(), 5, 1);
// emptyStructure.add(new ByteDataType());
// emptyStructure.add(new FloatDataType());
// emptyStructure.add(arrayDt);
//
// init(emptyStructure, pgmRootCat, false);
//
// assertEquals(3, structureModel.getNumComponents());
// assertEquals(4, structureModel.getRowCount());
// checkRow(0, 1, "db", new ByteDataType(), "", "");
// checkRow(1, 4, "float", new FloatDataType(), "", "");
// checkRow(2, 5, "char[5]", arrayDt, "", "");
// assertLength(8);
// assertActualAlignment(4);
//
// DataType asciiDt = model.getOriginalDataTypeManager().findDataType("/char");
// assertNotNull(asciiDt);
// insertAtPoint(asciiDt,0,0);
//
// assertEquals(4, structureModel.getNumComponents());
// assertEquals(5, structureModel.getRowCount());
// checkRow(0, 1, "ch", asciiDt, "", "");
// checkRow(1, 1, "db", new ByteDataType(), "", "");
// checkRow(2, 4, "float", new FloatDataType(), "", "");
// checkRow(3, 5, "char[5]", arrayDt, "", "");
// assertLength(8);
// assertActualAlignment(4);
// }
//
// public void testInsertAligned2() throws Exception {
// emptyStructure.setInternallyAligned(true);
//
// DataType arrayDt = new ArrayDataType(new AsciiDataType(), 5, 1);
// emptyStructure.add(new ByteDataType());
// emptyStructure.add(new FloatDataType());
// emptyStructure.add(arrayDt);
//
// init(emptyStructure, pgmRootCat, false);
//
// assertEquals(3, structureModel.getNumComponents());
// assertEquals(4, structureModel.getRowCount());
// checkRow(0, 1, "db", new ByteDataType(), "", "");
// checkRow(1, 4, "float", new FloatDataType(), "", "");
// checkRow(2, 5, "char[5]", arrayDt, "", "");
// assertLength(8);
// assertActualAlignment(4);
//
// DataType asciiDt = model.getOriginalDataTypeManager().findDataType("/char");
// assertNotNull(asciiDt);
// insertAtPoint(asciiDt,2,3);
//
// assertEquals(4, structureModel.getNumComponents());
// assertEquals(5, structureModel.getRowCount());
// checkRow(0, 1, "db", new ByteDataType(), "", "");
// checkRow(1, 4, "float", new FloatDataType(), "", "");
// checkRow(2, 1, "ch", asciiDt, "", "");
// checkRow(3, 5, "char[5]", arrayDt, "", "");
// assertLength(8);
// assertActualAlignment(4);
// }
//
// public void testInsertAligned3() throws Exception {
// emptyStructure.setInternallyAligned(true);
//
// DataType arrayDt = new ArrayDataType(new AsciiDataType(), 5, 1);
// emptyStructure.add(new ByteDataType());
// emptyStructure.add(new FloatDataType());
// emptyStructure.add(arrayDt);
//
// init(emptyStructure, pgmRootCat, false);
//
// assertEquals(3, structureModel.getNumComponents());
// assertEquals(4, structureModel.getRowCount());
// checkRow(0, 1, "db", new ByteDataType(), "", "");
// checkRow(1, 4, "float", new FloatDataType(), "", "");
// checkRow(2, 5, "char[5]", arrayDt, "", "");
// assertLength(8);
// assertActualAlignment(4);
//
// DataType doubleDt = model.getOriginalDataTypeManager().findDataType("/double");
// assertNotNull(doubleDt);
// insertAtPoint(doubleDt,3,3);
//
// assertEquals(4, structureModel.getNumComponents());
// assertEquals(5, structureModel.getRowCount());
// checkRow(0, 1, "db", new ByteDataType(), "", "");
// checkRow(1, 4, "float", new FloatDataType(), "", "");
// checkRow(2, 5, "char[5]", arrayDt, "", "");
// checkRow(3, 8, "double", doubleDt, "", "");
// assertLength(8);
// assertActualAlignment(8);
// }
//
// public void testReplaceAligned1() throws Exception {
// emptyStructure.setInternallyAligned(true);
//
// DataType arrayDt = new ArrayDataType(new AsciiDataType(), 5, 1);
// emptyStructure.add(new ByteDataType());
// emptyStructure.add(new FloatDataType());
// emptyStructure.add(arrayDt);
//
// init(emptyStructure, pgmRootCat, false);
//
// assertEquals(3, structureModel.getNumComponents());
// assertEquals(4, structureModel.getRowCount());
// checkRow(0, 1, "db", new ByteDataType(), "", "");
// checkRow(1, 4, "float", new FloatDataType(), "", "");
// checkRow(2, 5, "char[5]", arrayDt, "", "");
// assertLength(8);
// assertActualAlignment(4);
//
// DataType asciiDt = model.getOriginalDataTypeManager().findDataType("/char");
// assertNotNull(asciiDt);
// addAtPoint(asciiDt,2,3);
//
// assertEquals(3, structureModel.getNumComponents());
// assertEquals(4, structureModel.getRowCount());
// checkRow(0, 1, "db", new ByteDataType(), "", "");
// checkRow(1, 4, "float", new FloatDataType(), "", "");
// checkRow(2, 1, "ch", asciiDt, "", "");
// assertLength(4);
// assertActualAlignment(4);
// }
//
// public void testReplaceAligned2() throws Exception {
// emptyStructure.setInternallyAligned(true);
//
// DataType arrayDt = new ArrayDataType(new AsciiDataType(), 5, 1);
// emptyStructure.add(new ByteDataType());
// emptyStructure.add(new FloatDataType());
// emptyStructure.add(arrayDt);
//
// init(emptyStructure, pgmRootCat, false);
//
// assertEquals(3, structureModel.getNumComponents());
// assertEquals(4, structureModel.getRowCount());
// checkRow(0, 1, "db", new ByteDataType(), "", "");
// checkRow(1, 4, "float", new FloatDataType(), "", "");
// checkRow(2, 5, "char[5]", arrayDt, "", "");
// assertLength(8);
// assertActualAlignment(4);
//
// DataType doubleDt = model.getOriginalDataTypeManager().findDataType("/double");
// assertNotNull(doubleDt);
// addAtPoint(doubleDt,3,3);
//
// assertEquals(4, structureModel.getNumComponents());
// assertEquals(5, structureModel.getRowCount());
// checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
// checkRow(1, 1, 4, "float", new FloatDataType(), "", "");
// checkRow(2, 5, 5, "char[5]", arrayDt, "", "");
// checkRow(3, 10, 8, "double", doubleDt, "", "");
// assertLength(18);
// assertActualAlignment(8);
// }
@Test
public void testTurnOffAlignmentInStructure() throws Exception {
emptyStructure.setPackingEnabled(true);
emptyStructure.setExplicitMinimumAlignment(8);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyStructure.add(new ByteDataType());
emptyStructure.add(new FloatDataType());
emptyStructure.add(arrayDt);
init(emptyStructure, pgmRootCat, false);
CompEditorPanel editorPanel = (CompEditorPanel) getPanel();
JRadioButton byValueButton =
(JRadioButton) findComponentByName(getPanel(), "Explicit Alignment");
assertEquals(true, byValueButton.isSelected());
JTextField minAlignField =
(JTextField) findComponentByName(getPanel(), "Explicit Alignment Value");
assertEquals("8", minAlignField.getText());
assertEquals(false, structureModel.viewComposite.isDefaultAligned());
assertEquals(false, structureModel.viewComposite.isMachineAligned());
assertEquals(8, structureModel.getExplicitMinimumAlignment());
assertEquals(3, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
checkRow(1, 4, 4, "float", new FloatDataType(), "", "");
checkRow(2, 8, 5, "char[5]", arrayDt, "", "");
assertLength(16);
assertActualAlignment(8);
assertEquals(true, structureModel.isPackingEnabled());
pressButtonByName(editorPanel, "Packing Enablement"); // toggle -> disable packing
assertEquals(false, structureModel.isPackingEnabled());
assertEquals(true, structureModel.viewComposite.isDefaultAligned());
assertEquals(false, structureModel.viewComposite.isMachineAligned());
assertEquals(false, structureModel.viewComposite.hasExplicitMinimumAlignment());
assertEquals(9, structureModel.getNumComponents());
assertEquals(10, structureModel.getRowCount());
checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
checkRow(4, 4, 4, "float", new FloatDataType(), "", "");
checkRow(5, 8, 5, "char[5]", arrayDt, "", "");
assertLength(16);
assertActualAlignment(1);
}
@Test
public void testInsertUnaligned1() throws Exception {
emptyStructure.setPackingEnabled(false);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyStructure.add(new ByteDataType());
emptyStructure.add(new FloatDataType());
emptyStructure.add(arrayDt);
init(emptyStructure, pgmRootCat, false);
assertEquals(3, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
checkRow(1, 1, 4, "float", new FloatDataType(), "", "");
checkRow(2, 5, 5, "char[5]", arrayDt, "", "");
assertLength(10);
assertActualAlignment(1);
DataType asciiDt = model.getOriginalDataTypeManager().getDataType("/char");
assertNotNull(asciiDt);
insertAtPoint(asciiDt, 0, 0);
assertEquals(4, structureModel.getNumComponents());
assertEquals(5, structureModel.getRowCount());
checkRow(0, 0, 1, "char", asciiDt, "", "");
checkRow(1, 1, 1, "db", new ByteDataType(), "", "");
checkRow(2, 2, 4, "float", new FloatDataType(), "", "");
checkRow(3, 6, 5, "char[5]", arrayDt, "", "");
assertLength(11);
assertActualAlignment(1);
}
@Test
public void testInsertUnaligned2() throws Exception {
emptyStructure.setPackingEnabled(false);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyStructure.add(new ByteDataType());
emptyStructure.add(new FloatDataType());
emptyStructure.add(arrayDt);
init(emptyStructure, pgmRootCat, false);
assertEquals(3, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
checkRow(1, 1, 4, "float", new FloatDataType(), "", "");
checkRow(2, 5, 5, "char[5]", arrayDt, "", "");
assertLength(10);
assertActualAlignment(1);
DataType asciiDt = model.getOriginalDataTypeManager().getDataType("/char");
assertNotNull(asciiDt);
insertAtPoint(asciiDt, 2, 3);
assertEquals(4, structureModel.getNumComponents());
assertEquals(5, structureModel.getRowCount());
checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
checkRow(1, 1, 4, "float", new FloatDataType(), "", "");
checkRow(2, 5, 1, "char", asciiDt, "", "");
checkRow(3, 6, 5, "char[5]", arrayDt, "", "");
assertLength(11);
assertActualAlignment(1);
}
@Test
public void testInsertUnaligned3() throws Exception {
emptyStructure.setPackingEnabled(false);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyStructure.add(new ByteDataType());
emptyStructure.add(new FloatDataType());
emptyStructure.add(arrayDt);
init(emptyStructure, pgmRootCat, false);
assertEquals(3, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
checkRow(1, 1, 4, "float", new FloatDataType(), "", "");
checkRow(2, 5, 5, "char[5]", arrayDt, "", "");
assertLength(10);
assertActualAlignment(1);
DataType doubleDt = model.getOriginalDataTypeManager().getDataType("/double");
assertNotNull(doubleDt);
insertAtPoint(doubleDt, 3, 3);
assertEquals(4, structureModel.getNumComponents());
assertEquals(5, structureModel.getRowCount());
checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
checkRow(1, 1, 4, "float", new FloatDataType(), "", "");
checkRow(2, 5, 5, "char[5]", arrayDt, "", "");
checkRow(3, 10, 8, "double", doubleDt, "", "");
assertLength(18);
assertActualAlignment(1);
}
@Test
public void testReplaceUnaligned1() throws Exception {
emptyStructure.setPackingEnabled(false);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyStructure.add(new ByteDataType());
emptyStructure.add(new FloatDataType());
emptyStructure.add(arrayDt);
init(emptyStructure, pgmRootCat, false);
assertEquals(3, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
checkRow(1, 1, 4, "float", new FloatDataType(), "", "");
checkRow(2, 5, 5, "char[5]", arrayDt, "", "");
assertLength(10);
assertActualAlignment(1);
DataType asciiDt = model.getOriginalDataTypeManager().getDataType("/char");
assertNotNull(asciiDt);
addAtPoint(asciiDt, 2, 3);
assertEquals(3, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
checkRow(1, 1, 4, "float", new FloatDataType(), "", "");
checkRow(2, 5, 1, "char", asciiDt, "", "");
assertLength(6);
assertActualAlignment(1);
}
@Test
public void testReplaceUnaligned2() throws Exception {
emptyStructure.setPackingEnabled(false);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyStructure.add(new ByteDataType());
emptyStructure.add(new FloatDataType());
emptyStructure.add(arrayDt);
init(emptyStructure, pgmRootCat, false);
assertEquals(3, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
checkRow(1, 1, 4, "float", new FloatDataType(), "", "");
checkRow(2, 5, 5, "char[5]", arrayDt, "", "");
assertLength(10);
assertActualAlignment(1);
DataType doubleDt = model.getOriginalDataTypeManager().getDataType("/double");
assertNotNull(doubleDt);
addAtPoint(doubleDt, 3, 3);
assertEquals(4, structureModel.getNumComponents());
assertEquals(5, structureModel.getRowCount());
checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
checkRow(1, 1, 4, "float", new FloatDataType(), "", "");
checkRow(2, 5, 5, "char[5]", arrayDt, "", "");
checkRow(3, 10, 8, "double", doubleDt, "", "");
assertLength(18);
assertActualAlignment(1);
}
@Test
public void testInsertAligned1() throws Exception {
emptyStructure.setPackingEnabled(true);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyStructure.add(new ByteDataType());
emptyStructure.add(new FloatDataType());
emptyStructure.add(arrayDt);
init(emptyStructure, pgmRootCat, false);
assertEquals(3, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
checkRow(1, 4, 4, "float", new FloatDataType(), "", "");
checkRow(2, 8, 5, "char[5]", arrayDt, "", "");
assertLength(16);
assertActualAlignment(4);
DataType asciiDt = model.getOriginalDataTypeManager().getDataType("/char");
assertNotNull(asciiDt);
insertAtPoint(asciiDt, 0, 0);
assertEquals(4, structureModel.getNumComponents());
assertEquals(5, structureModel.getRowCount());
checkRow(0, 0, 1, "char", asciiDt, "", "");
checkRow(1, 1, 1, "db", new ByteDataType(), "", "");
checkRow(2, 4, 4, "float", new FloatDataType(), "", "");
checkRow(3, 8, 5, "char[5]", arrayDt, "", "");
assertLength(16);
assertActualAlignment(4);
}
@Test
public void testInsertAligned2() throws Exception {
emptyStructure.setPackingEnabled(true);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyStructure.add(new ByteDataType());
emptyStructure.add(new FloatDataType());
emptyStructure.add(arrayDt);
init(emptyStructure, pgmRootCat, false);
assertEquals(3, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
checkRow(1, 4, 4, "float", new FloatDataType(), "", "");
checkRow(2, 8, 5, "char[5]", arrayDt, "", "");
assertLength(16);
assertActualAlignment(4);
DataType asciiDt = model.getOriginalDataTypeManager().getDataType("/char");
assertNotNull(asciiDt);
insertAtPoint(asciiDt, 2, 3);
assertEquals(4, structureModel.getNumComponents());
assertEquals(5, structureModel.getRowCount());
checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
checkRow(1, 4, 4, "float", new FloatDataType(), "", "");
checkRow(2, 8, 1, "char", asciiDt, "", "");
checkRow(3, 9, 5, "char[5]", arrayDt, "", "");
assertLength(16);
assertActualAlignment(4);
}
@Test
public void testInsertAligned3() throws Exception {
emptyStructure.setPackingEnabled(true);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyStructure.add(new ByteDataType());
emptyStructure.add(new FloatDataType());
emptyStructure.add(arrayDt);
init(emptyStructure, pgmRootCat, false);
assertEquals(3, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
checkRow(1, 4, 4, "float", new FloatDataType(), "", "");
checkRow(2, 8, 5, "char[5]", arrayDt, "", "");
assertLength(16);
assertActualAlignment(4);
DataType doubleDt = model.getOriginalDataTypeManager().getDataType("/double");
assertNotNull(doubleDt);
insertAtPoint(doubleDt, 3, 3);
assertEquals(4, structureModel.getNumComponents());
assertEquals(5, structureModel.getRowCount());
checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
checkRow(1, 4, 4, "float", new FloatDataType(), "", "");
checkRow(2, 8, 5, "char[5]", arrayDt, "", "");
checkRow(3, 16, 8, "double", doubleDt, "", ""); // alignment is 4
assertLength(24);
assertActualAlignment(4);
}
@Test
public void testReplaceAligned1() throws Exception {
emptyStructure.setPackingEnabled(true);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyStructure.add(new ByteDataType());
emptyStructure.add(new FloatDataType());
emptyStructure.add(arrayDt);
init(emptyStructure, pgmRootCat, false);
assertEquals(3, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
checkRow(1, 4, 4, "float", new FloatDataType(), "", "");
checkRow(2, 8, 5, "char[5]", arrayDt, "", "");
assertLength(16);
assertActualAlignment(4);
DataType asciiDt = model.getOriginalDataTypeManager().getDataType("/char");
assertNotNull(asciiDt);
addAtPoint(asciiDt, 2, 3);
assertEquals(3, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
checkRow(1, 4, 4, "float", new FloatDataType(), "", "");
checkRow(2, 8, 1, "char", asciiDt, "", "");
assertLength(12);
assertActualAlignment(4);
}
@Test
public void testReplaceAligned2() throws Exception {
emptyStructure.setPackingEnabled(true);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyStructure.add(new ByteDataType());
emptyStructure.add(new FloatDataType());
emptyStructure.add(arrayDt);
init(emptyStructure, pgmRootCat, false);
assertEquals(3, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
checkRow(1, 4, 4, "float", new FloatDataType(), "", "");
checkRow(2, 8, 5, "char[5]", arrayDt, "", "");
assertLength(16);
assertActualAlignment(4);
DataType doubleDt = model.getOriginalDataTypeManager().getDataType("/double");
assertNotNull(doubleDt);
addAtPoint(doubleDt, 3, 3); // same as insert on last row
assertEquals(4, structureModel.getNumComponents());
assertEquals(5, structureModel.getRowCount());
checkRow(0, 0, 1, "db", new ByteDataType(), "", "");
checkRow(1, 4, 4, "float", new FloatDataType(), "", "");
checkRow(2, 8, 5, "char[5]", arrayDt, "", "");
checkRow(3, 16, 8, "double", doubleDt, "", "");
assertLength(24);
assertActualAlignment(4);
}
////////////////////////////

View file

@ -23,10 +23,15 @@ import javax.swing.JTextField;
import org.junit.Test;
import ghidra.program.model.data.*;
import ghidra.program.model.data.Composite.AlignmentType;
public class StructureEditorFlexAlignmentTest extends AbstractStructureEditorTest {
// NOTE: The trailing flexable array may be assigned an incorrect offset
// when packing is enabled and the minimum alignment is specified. In such cases,
// the flex array may be less than the overall structure length. Currently, it is
// assumed the trailing flex array will have an offset equal to the overall
// structure length.
@Test
public void testUnalignedStructure() {
init(emptyStructure, pgmRootCat, false);
@ -40,10 +45,8 @@ public class StructureEditorFlexAlignmentTest extends AbstractStructureEditorTes
structureModel.getOriginalCategoryPath().getPath());
assertEquals(0, structureModel.getNumComponents());// no components
assertEquals(1, structureModel.getRowCount());// blank row
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertLength(0);
assertActualAlignment(1);
assertEquals(0, structureModel.getNumSelectedComponentRows());
@ -83,7 +86,9 @@ public class StructureEditorFlexAlignmentTest extends AbstractStructureEditorTes
assertLength(2);
assertActualAlignment(1);
pressButtonByName(getPanel(), "Internally Aligned");
pressButtonByName(getPanel(), "Packing Enablement"); // toggle -> enable packing
assertIsPackingEnabled(true);
assertDefaultPacked();
assertEquals(2, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
@ -105,8 +110,12 @@ public class StructureEditorFlexAlignmentTest extends AbstractStructureEditorTes
waitForSwing();
pressButtonByName(getPanel(), "Internally Aligned");
pressButtonByName(getPanel(), "Machine Minimum Alignment");
pressButtonByName(getPanel(), "Packing Enablement"); // toggle -> enable packing
assertIsPackingEnabled(true);
assertDefaultPacked();
pressButtonByName(getPanel(), "Machine Alignment");
assertIsMachineAligned();
assertEquals(2, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
@ -130,19 +139,22 @@ public class StructureEditorFlexAlignmentTest extends AbstractStructureEditorTes
waitForSwing();
pressButtonByName(editorPanel, "Internally Aligned");
pressButtonByName(getPanel(), "Packing Enablement"); // toggle -> enable packing
assertIsPackingEnabled(true);
assertDefaultPacked();
JTextField minAlignField =
(JTextField) getInstanceField("minAlignValueTextField", editorPanel);
(JTextField) getInstanceField("explicitAlignTextField", editorPanel);
assertNotNull(minAlignField);
JRadioButton byValueMinAlignButton =
(JRadioButton) getInstanceField("byValueMinAlignButton", editorPanel);
assertNotNull(byValueMinAlignButton);
pressButton(byValueMinAlignButton);
assertEquals("4", minAlignField.getText());
JRadioButton explicitAlignButton =
(JRadioButton) getInstanceField("explicitAlignButton", editorPanel);
assertNotNull(explicitAlignButton);
pressButton(explicitAlignButton);
assertEquals("8", minAlignField.getText()); // toy.cspec machine alignment is default value
assertEquals(false, structureModel.viewComposite.isDefaultAligned());
assertEquals(false, structureModel.viewComposite.isMachineAligned());
assertEquals(4, structureModel.getMinimumAlignment());
assertEquals(8, structureModel.getExplicitMinimumAlignment());
assertEquals(2, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
@ -151,9 +163,9 @@ public class StructureEditorFlexAlignmentTest extends AbstractStructureEditorTes
checkRow(0, 0, 1, "db", ByteDataType.dataType, "", "");
checkRow(1, 1, 1, "char", CharDataType.dataType, "", "");
checkBlankRow(2);
checkRow(3, 4, 0, "ddw[0]", DWordDataType.dataType, "", "");
assertLength(4);
assertActualAlignment(4);
checkRow(3, 8, 0, "ddw[0]", DWordDataType.dataType, "", "");
assertLength(8);
assertActualAlignment(8);
}
@Test
@ -183,8 +195,8 @@ public class StructureEditorFlexAlignmentTest extends AbstractStructureEditorTes
public void checkByValueAlignedStructure(int value, int alignment, int length)
throws Exception {
emptyStructure.setInternallyAligned(true);
emptyStructure.setMinimumAlignment(value);
emptyStructure.setPackingEnabled(true);
emptyStructure.setExplicitMinimumAlignment(value);
emptyStructure.add(ByteDataType.dataType);
emptyStructure.add(CharDataType.dataType);
@ -193,19 +205,19 @@ public class StructureEditorFlexAlignmentTest extends AbstractStructureEditorTes
init(emptyStructure, pgmRootCat, false);
CompEditorPanel editorPanel = (CompEditorPanel) getPanel();
JRadioButton byValueMinAlignButton =
(JRadioButton) getInstanceField("byValueMinAlignButton", editorPanel);
assertNotNull(byValueMinAlignButton);
assertEquals(true, byValueMinAlignButton.isSelected());
JRadioButton explicitAlignButton =
(JRadioButton) getInstanceField("explicitAlignButton", editorPanel);
assertNotNull(explicitAlignButton);
assertEquals(true, explicitAlignButton.isSelected());
JTextField minAlignField =
(JTextField) getInstanceField("minAlignValueTextField", editorPanel);
(JTextField) getInstanceField("explicitAlignTextField", editorPanel);
assertNotNull(minAlignField);
assertEquals("" + value, minAlignField.getText());
assertEquals(false, structureModel.viewComposite.isDefaultAligned());
assertEquals(false, structureModel.viewComposite.isMachineAligned());
assertEquals(value, structureModel.getMinimumAlignment());
assertEquals(value, structureModel.getExplicitMinimumAlignment());
assertEquals(2, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());
@ -220,8 +232,8 @@ public class StructureEditorFlexAlignmentTest extends AbstractStructureEditorTes
@Test
public void testDefaultAlignedPacked1Structure() throws Exception {
int value = 1;
emptyStructure.setInternallyAligned(true);
emptyStructure.setPackingValue(value);
emptyStructure.setPackingEnabled(true);
emptyStructure.setExplicitPackingValue(value);
init(emptyStructure, pgmRootCat, false);
CompEditorPanel editorPanel = (CompEditorPanel) getPanel();
@ -231,17 +243,17 @@ public class StructureEditorFlexAlignmentTest extends AbstractStructureEditorTes
addFlexDataType(DWordDataType.dataType, null, null);
JRadioButton byValuePackingButton =
(JRadioButton) findComponentByName(editorPanel, "By Value Packing");
(JRadioButton) findComponentByName(editorPanel, "Explicit Packing");
assertNotNull(byValuePackingButton);
JTextField packingValueField =
(JTextField) findComponentByName(editorPanel, "Packing Value");
assertNotNull(packingValueField);
assertEquals(true, byValuePackingButton.isSelected());
assertEquals("" + value, packingValueField.getText());
assertEquals(Integer.toString(value), packingValueField.getText());
assertEquals(true, structureModel.viewComposite.isDefaultAligned());
assertEquals(false, structureModel.viewComposite.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, structureModel.getMinimumAlignment());
assertEquals(false, structureModel.viewComposite.hasExplicitMinimumAlignment());
assertEquals(2, structureModel.getNumComponents());
assertEquals(4, structureModel.getRowCount());

View file

@ -243,7 +243,7 @@ public class StructureEditorLockedActions2Test extends AbstractStructureEditorLo
DataType dt2 = getDataType(2);
DataType dt7 = getDataType(7);
invoke(duplicateMultipleAction);
invoke(duplicateMultipleAction, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
badInput(dialog, 3);
@ -270,7 +270,7 @@ public class StructureEditorLockedActions2Test extends AbstractStructureEditorLo
boolean commit = false;
txId = program.startTransaction("Modify Program");
try {
simpleStructure.setInternallyAligned(true);
simpleStructure.setPackingEnabled(true);
commit = true;
}
finally {
@ -288,7 +288,7 @@ public class StructureEditorLockedActions2Test extends AbstractStructureEditorLo
DataType originalDt4 = getDataType(4);
// Make selected components into internal structure.
invoke(createInternalStructureAction);
invoke(createInternalStructureAction, false);
// Specify name for structure.
JDialog inputDialog = waitForJDialog("Specify the Structure's Name");
@ -331,7 +331,7 @@ public class StructureEditorLockedActions2Test extends AbstractStructureEditorLo
DataType originalDt4 = getDataType(4);
// Make selected components into internal structure.
invoke(createInternalStructureAction);
invoke(createInternalStructureAction, false);
// Specify name for structure.
JDialog inputDialog = waitForJDialog("Specify the Structure's Name");
@ -365,7 +365,7 @@ public class StructureEditorLockedActions2Test extends AbstractStructureEditorLo
DataType originalDt4 = getDataType(4);
// Make selected components into internal structure.
invoke(createInternalStructureAction);
invoke(createInternalStructureAction, false);
// Specify name for structure.
JDialog inputDialog = waitForJDialog("Specify the Structure's Name");

View file

@ -47,7 +47,7 @@ public class StructureEditorLockedActions3Test extends AbstractStructureEditorLo
DataType originalDt4 = getDataType(4);
// Make selected components into internal structure.
invoke(createInternalStructureAction);
invoke(createInternalStructureAction, false);
// Specify name for structure.
InputDialog inputDialog = waitForDialogComponent(InputDialog.class);
@ -173,7 +173,7 @@ public class StructureEditorLockedActions3Test extends AbstractStructureEditorLo
assertEquals(29, getModel().getLength());
assertEquals(8, getModel().getNumComponents());
setSelection(new int[] { 4 });
invoke(fav);
invoke(fav, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 8);
@ -213,7 +213,7 @@ public class StructureEditorLockedActions3Test extends AbstractStructureEditorLo
// setSelection(new int[] {1});
// DataType dt1 = getDataType(1);
// assertTrue(getDataType(1).isEquivalent(new WordDataType()));
// invoke(pointerAction);
// invoke(pointerAction, false);
// dialog = (NumberInputDialog)env.waitForDialogComponent(NumberInputDialog.class, 1000);
// assertNotNull(dialog);
// cancelInput(dialog, 2);
@ -259,7 +259,7 @@ public class StructureEditorLockedActions3Test extends AbstractStructureEditorLo
// DataType dt1 = getDataType(1);
// assertTrue(getDataType(1).isEquivalent(new StringDataType()));
// assertEquals(5, getModel().getComponent(1).getLength());
// invoke(pointerAction);
// invoke(pointerAction, false);
// dialog = (NumberInputDialog)env.waitForDialogComponent(NumberInputDialog.class, 1000);
// assertNotNull(dialog);
// okInput(dialog, 8);
@ -299,7 +299,7 @@ public class StructureEditorLockedActions3Test extends AbstractStructureEditorLo
//
// setSelection(new int[] {10});
// DataType dt10 = getDataType(10);
// invoke(pointerAction);
// invoke(pointerAction, false);
// dialog = (NumberInputDialog)env.waitForDialogComponent(NumberInputDialog.class, 1000);
// assertNotNull(dialog);
// okInput(dialog, 2);
@ -321,7 +321,7 @@ public class StructureEditorLockedActions3Test extends AbstractStructureEditorLo
//
// setSelection(new int[] {15});
// DataType dt15 = getDataType(15);
// invoke(pointerAction);
// invoke(pointerAction, false);
// dialog = (NumberInputDialog)env.waitForDialogComponent(NumberInputDialog.class, 1000);
// assertNotNull(dialog);
// okInput(dialog, 4);

View file

@ -36,7 +36,7 @@ public class StructureEditorLockedActions4Test extends AbstractStructureEditorLo
DataType dt8 = getDataType(8);
// Make array of 7 bytes
invoke(arrayAction);
invoke(arrayAction, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
assertEquals("Enter Number", dialog.getTitle());
@ -65,7 +65,7 @@ public class StructureEditorLockedActions4Test extends AbstractStructureEditorLo
checkSelection(new int[] { 1 });
// Make array of 5 quadwords
invoke(arrayAction);
invoke(arrayAction, false);
waitForPostedSwingRunnables();
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
@ -109,7 +109,7 @@ public class StructureEditorLockedActions4Test extends AbstractStructureEditorLo
assertEquals(getLength(16), dt16Len);
assertEquals(getDataType(16), dt16);
invoke(action);
invoke(action, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
badInput(dialog, 20);
@ -126,7 +126,7 @@ public class StructureEditorLockedActions4Test extends AbstractStructureEditorLo
assertEquals(getLength(2), dt16Len);
assertEquals(getDataType(2), dt16);
invoke(action);
invoke(action, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 10);
@ -180,7 +180,7 @@ public class StructureEditorLockedActions4Test extends AbstractStructureEditorLo
assertEquals(getLength(8), dt8Len);
assertEquals(getDataType(8), dt8);
invoke(action);
invoke(action, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 7);
@ -194,7 +194,7 @@ public class StructureEditorLockedActions4Test extends AbstractStructureEditorLo
assertEquals(getLength(2), dt8Len);
assertEquals(getDataType(2), dt8);
invoke(action);
invoke(action, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 6);
@ -241,7 +241,7 @@ public class StructureEditorLockedActions4Test extends AbstractStructureEditorLo
assertEquals(1, getLength(1));
assertEquals(getDataType(1), dt1);
invoke(action);
invoke(action, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
badInput(dialog, 7);
@ -255,7 +255,7 @@ public class StructureEditorLockedActions4Test extends AbstractStructureEditorLo
assertEquals(1, getLength(1));
assertEquals(getDataType(1), dt1);
invoke(action);
invoke(action, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
badInput(dialog, 10);

View file

@ -523,7 +523,7 @@ public class StructureEditorLockedCellEditTest extends AbstractStructureEditorTe
public void testEditDataTypeNotSelf() throws Exception {
Structure testStruct = new StructureDataType("testStruct", 20);
testStruct.setInternallyAligned(false);
testStruct.setPackingEnabled(false);
DataTypeManager dtm = program.getDataTypeManager();
txId = program.startTransaction("Add testStruct");

View file

@ -46,7 +46,7 @@ public class StructureEditorUnlockedActions1Test
assertEquals(getDataType(3), DataType.DEFAULT);
assertEquals(getDataType(4), dt3);
invoke(action);
invoke(action, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 2);
@ -60,7 +60,7 @@ public class StructureEditorUnlockedActions1Test
assertEquals(getDataType(3), dt3);
setSelection(new int[] { 2 });
invoke(action);
invoke(action, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 2);

View file

@ -165,7 +165,7 @@ public class StructureEditorUnlockedActions2Test
assertEquals(getDataType(3), DataType.DEFAULT);
assertEquals(getDataType(4), dt3);
invoke(action);
invoke(action, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 2);
@ -179,7 +179,7 @@ public class StructureEditorUnlockedActions2Test
assertEquals(getDataType(3), dt3);
setSelection(new int[] { 2 });
invoke(action);
invoke(action, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 2);

View file

@ -44,7 +44,7 @@ public class StructureEditorUnlockedActions3Test
DataType dt2 = getDataType(2);// word
DataType dt7 = getDataType(7);// SimpleUnion
invoke(duplicateMultipleAction);
invoke(duplicateMultipleAction, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 2);
@ -73,7 +73,7 @@ public class StructureEditorUnlockedActions3Test
DataType dt0 = getDataType(0);
DataType dt1 = getDataType(1);
invoke(duplicateMultipleAction);
invoke(duplicateMultipleAction, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 2);

View file

@ -26,7 +26,6 @@ import org.junit.Test;
import docking.widgets.dialogs.NumberInputDialog;
import ghidra.program.model.data.*;
import ghidra.util.exception.UsrException;
import ghidra.util.task.TaskMonitor;
public class StructureEditorUnlockedActions4Test
extends AbstractStructureEditorUnlockedActionsTest {
@ -56,7 +55,7 @@ public class StructureEditorUnlockedActions4Test
invoke(applyAction);
assertTrue(complexStructure.isEquivalent(model.viewComposite));
assertEquals(1, complexStructure.getLength());
assertTrue(complexStructure.isNotYetDefined());
assertTrue(complexStructure.isZeroLength());
}
@Test
@ -74,7 +73,7 @@ public class StructureEditorUnlockedActions4Test
assertEquals(2, model.getComponent(5).getLength());
// Make array of 3 pointers
invoke(arrayAction);
invoke(arrayAction, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 3);
@ -222,7 +221,7 @@ public class StructureEditorUnlockedActions4Test
runSwing(() -> {
try {
model.clearSelectedComponents();
model.deleteSelectedComponents(TaskMonitor.DUMMY);
model.deleteSelectedComponents();
}
catch (UsrException e) {
failWithException("Unexpected error", e);

View file

@ -87,6 +87,7 @@ public class StructureEditorUnlockedActions5Test
invoke(applyAction);
assertTrue(simpleStructure.isEquivalent(model.viewComposite));
assertTrue(simpleStructure.isNotYetDefined());
assertTrue(simpleStructure.isZeroLength());
assertTrue(viewCopy.isEquivalent(model.viewComposite));
// Is now allowed
// assertEquals(
@ -132,7 +133,7 @@ public class StructureEditorUnlockedActions5Test
assertTrue(dt2 instanceof WordDataType);
// Cancel the array dialog
invoke(arrayAction);
invoke(arrayAction, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
cancelInput(dialog);
@ -163,7 +164,7 @@ public class StructureEditorUnlockedActions5Test
assertEquals(getDataType(3), DataType.DEFAULT);
assertEquals(getDataType(4), dt3);
invoke(action);
invoke(action, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
cancelInput(dialog);

View file

@ -43,7 +43,7 @@ public class StructureEditorUnlockedActions6Test
assertTrue(dt15 instanceof Array);
// Make array of 2 arrays
invoke(arrayAction);
invoke(arrayAction, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 2);
@ -70,7 +70,7 @@ public class StructureEditorUnlockedActions6Test
assertEquals("dword", dt3.getDisplayName());
// Make array of 5 quadwords
invoke(arrayAction);
invoke(arrayAction, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 5);
@ -88,6 +88,7 @@ public class StructureEditorUnlockedActions6Test
init(emptyStructure, pgmRootCat);
int originalLength = 0;
assertTrue(emptyStructure.isNotYetDefined());
assertTrue(emptyStructure.isZeroLength());
int newLength = 5;
assertEquals(originalLength, model.getLength());
@ -151,7 +152,7 @@ public class StructureEditorUnlockedActions6Test
assertEquals(0, model.getLength());
assertEquals(0, model.getNumComponents());
invoke(fav);
invoke(fav, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 7);

View file

@ -15,8 +15,7 @@
*/
package ghidra.app.plugin.core.compositeeditor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import org.junit.Assert;
import org.junit.Test;
@ -32,7 +31,7 @@ public class StructureEditorUnlockedEnablementTest extends AbstractStructureEdit
try {
DataTypeManager dataTypeManager = cat.getDataTypeManager();
if (dt.getDataTypeManager() != dataTypeManager) {
dt = (Structure) dt.clone(dataTypeManager);
dt = dt.clone(dataTypeManager);
}
CategoryPath categoryPath = cat.getCategoryPath();
if (!dt.getCategoryPath().equals(categoryPath)) {
@ -336,7 +335,7 @@ public class StructureEditorUnlockedEnablementTest extends AbstractStructureEdit
assertEquals("word", getDataType(3).getDisplayName());
assertTrue(!editBitFieldAction.isEnabled());
structureModel.setAligned(true);
structureModel.setPackingType(PackingType.DEFAULT, 0);
// Edit Bitfield action not enabled for Aligned mode
setSelection(new int[] { 1 });

View file

@ -26,8 +26,6 @@ import org.junit.Test;
import docking.widgets.dialogs.NumberInputDialog;
import ghidra.program.model.data.*;
import ghidra.program.model.data.Composite.AlignmentType;
import ghidra.util.task.TaskMonitor;
public class UnionEditorActions1Test extends AbstractUnionEditorTest {
@ -44,10 +42,8 @@ public class UnionEditorActions1Test extends AbstractUnionEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 0 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(emptyUnion.getName(), model.getCompositeName());
@ -83,10 +79,8 @@ public class UnionEditorActions1Test extends AbstractUnionEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { model.getNumComponents() });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(8);
assertEquals(simpleUnion.getName(), model.getCompositeName());
@ -283,8 +277,8 @@ public class UnionEditorActions1Test extends AbstractUnionEditorTest {
assertEquals(0, model.getLength());
assertEquals(0, model.getNumComponents());
invoke(fav);
dialog = env.waitForDialogComponent(NumberInputDialog.class, 1000);
invoke(fav, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 7);
dialog = null;
@ -377,8 +371,8 @@ public class UnionEditorActions1Test extends AbstractUnionEditorTest {
assertTrue(getDataType(2).isEquivalent(new CharDataType()));
assertEquals(getDataType(3), dt3);
invoke(action);
dialog = env.waitForDialogComponent(NumberInputDialog.class, 1000);
invoke(action, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
cancelInput(dialog);
dialog = null;
@ -668,7 +662,7 @@ public class UnionEditorActions1Test extends AbstractUnionEditorTest {
DataType dt3 = getDataType(3);
// Cancel the array dialog
invoke(arrayAction);
invoke(arrayAction, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
cancelInput(dialog);
@ -766,7 +760,7 @@ public class UnionEditorActions1Test extends AbstractUnionEditorTest {
init(complexUnion, pgmTestCat, false);
setSelection(new int[] { 3, 4 });
model.deleteSelectedComponents(TaskMonitor.DUMMY);
model.deleteSelectedComponents();
DataType viewCopy = model.viewComposite.clone(null);
assertFalse(complexUnion.isEquivalent(model.viewComposite));

View file

@ -46,8 +46,8 @@ public class UnionEditorActions2Test extends AbstractUnionEditorTest {
assertTrue(getDataType(2).isEquivalent(new CharDataType()));
assertEquals(getDataType(3), dt3);
invoke(action);
dialog = env.waitForDialogComponent(NumberInputDialog.class, 1000);
invoke(action, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 7);
dialog = null;
@ -59,8 +59,8 @@ public class UnionEditorActions2Test extends AbstractUnionEditorTest {
assertTrue(getDataType(2).isEquivalent(new StringDataType()));
assertEquals(getDataType(3), dt3);
invoke(action);
dialog = env.waitForDialogComponent(NumberInputDialog.class, 1000);
invoke(action, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 10);
dialog = null;

View file

@ -35,8 +35,8 @@ public class UnionEditorActions3Test extends AbstractUnionEditorTest {
DataType dt11 = getDataType(11);
// Make array of 2 arrays
invoke(arrayAction);
dialog = env.waitForDialogComponent(NumberInputDialog.class, 1000);
invoke(arrayAction, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 2);
dialog = null;
@ -58,8 +58,8 @@ public class UnionEditorActions3Test extends AbstractUnionEditorTest {
DataType dt3 = getDataType(3);
// Make array of 5 quadwords
invoke(arrayAction);
dialog = env.waitForDialogComponent(NumberInputDialog.class, 1000);
invoke(arrayAction, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 5);
dialog = null;

View file

@ -36,8 +36,8 @@ public class UnionEditorActions4Test extends AbstractUnionEditorTest {
assertEquals(2, model.getComponent(4).getLength());
// Make array of 3 pointers
invoke(arrayAction);
dialog = env.waitForDialogComponent(NumberInputDialog.class, 1000);
invoke(arrayAction, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 3);
dialog = null;
@ -59,8 +59,8 @@ public class UnionEditorActions4Test extends AbstractUnionEditorTest {
DataType dt2 = getDataType(2);
DataType dt3 = getDataType(3);
invoke(duplicateMultipleAction);
dialog = env.waitForDialogComponent(NumberInputDialog.class, 1000);
invoke(duplicateMultipleAction, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 5);
dialog = null;

View file

@ -23,7 +23,6 @@ import javax.swing.JTextField;
import org.junit.Test;
import ghidra.program.model.data.*;
import ghidra.program.model.data.Composite.AlignmentType;
public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
@ -40,10 +39,8 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
unionModel.getOriginalCategoryPath().getPath());
assertEquals(0, unionModel.getNumComponents());// no components
assertEquals(1, unionModel.getRowCount());// blank row
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertLength(0);
assertActualAlignment(1);
assertEquals(0, unionModel.getNumSelectedComponentRows());
@ -88,7 +85,9 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
addDataType(new FloatDataType());
addDataType(arrayDt);
pressButtonByName(getPanel(), "Internally Aligned");
pressButtonByName(getPanel(), "Packing Enablement"); // toggle -> enable packing
assertIsPackingEnabled(true);
assertDefaultPacked();
assertEquals(true, unionModel.viewComposite.isDefaultAligned());
assertEquals(3, unionModel.getNumComponents());
@ -102,7 +101,7 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
@Test
public void testEnablementDefaultAlignedUnion() throws Exception {
emptyUnion.setInternallyAligned(true);
emptyUnion.setPackingEnabled(true);
init(emptyUnion, pgmRootCat, false);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
@ -112,16 +111,16 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
// Check enablement.
CompositeEditorTableAction[] pActions = provider.getActions();
for (int i = 0; i < pActions.length; i++) {
if ((pActions[i] instanceof FavoritesAction) ||
(pActions[i] instanceof CycleGroupAction) ||
(pActions[i] instanceof EditFieldAction) ||
(pActions[i] instanceof PointerAction) ||
(pActions[i] instanceof HexNumbersAction) || (pActions[i] instanceof ApplyAction)) {
checkEnablement(pActions[i], true);
for (CompositeEditorTableAction pAction : pActions) {
if ((pAction instanceof FavoritesAction) ||
(pAction instanceof CycleGroupAction) ||
(pAction instanceof EditFieldAction) ||
(pAction instanceof PointerAction) ||
(pAction instanceof HexNumbersAction) || (pAction instanceof ApplyAction)) {
checkEnablement(pAction, true);
}
else {
checkEnablement(pActions[i], false);
checkEnablement(pAction, false);
}
}
@ -144,8 +143,11 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
addDataType(new FloatDataType());
addDataType(arrayDt);
pressButtonByName(getPanel(), "Internally Aligned");
pressButtonByName(getPanel(), "Machine Minimum Alignment");
pressButtonByName(getPanel(), "Packing Enablement"); // toggle -> enable packing
assertIsPackingEnabled(true);
assertDefaultPacked();
pressButtonByName(getPanel(), "Machine Alignment");
assertEquals(true, unionModel.viewComposite.isMachineAligned());
assertEquals(3, unionModel.getNumComponents());
@ -166,16 +168,19 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
addDataType(new FloatDataType());
addDataType(arrayDt);
pressButtonByName(getPanel(), "Internally Aligned");
pressButtonByName(getPanel(), "By Value Minimum Alignment");
pressButtonByName(getPanel(), "Packing Enablement"); // toggle -> enable packing
assertIsPackingEnabled(true);
assertDefaultPacked();
pressButtonByName(getPanel(), "Explicit Alignment");
JTextField minAlignField =
(JTextField) findComponentByName(getPanel(), "Minimum Alignment Value");
assertEquals("4", minAlignField.getText());
(JTextField) findComponentByName(getPanel(), "Explicit Alignment Value");
assertEquals("8", minAlignField.getText()); // toy.cspec machine alignment is default value
assertEquals(false, unionModel.viewComposite.isDefaultAligned());
assertEquals(false, unionModel.viewComposite.isMachineAligned());
assertEquals(4, unionModel.getMinimumAlignment());
assertEquals(8, unionModel.getExplicitMinimumAlignment());
assertEquals(3, unionModel.getNumComponents());
assertEquals(4, unionModel.getRowCount());
@ -183,7 +188,7 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
checkRow(1, 4, "float", new FloatDataType(), "", "");
checkRow(2, 5, "char[5]", arrayDt, "", "");
assertLength(8);
assertActualAlignment(4);
assertActualAlignment(8);
}
@Test
@ -211,9 +216,9 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
checkByValueAlignedUnion(16, 16, 16);
}
public void checkByValueAlignedUnion(int value, int alignment, int length) throws Exception {
emptyUnion.setInternallyAligned(true);
emptyUnion.setMinimumAlignment(value);
public void checkByValueAlignedUnion(int minAlignment, int alignment, int length) throws Exception {
emptyUnion.setPackingEnabled(true);
emptyUnion.setExplicitMinimumAlignment(minAlignment);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyUnion.add(new ByteDataType());
@ -223,15 +228,15 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
init(emptyUnion, pgmRootCat, false);
JRadioButton byValueButton =
(JRadioButton) findComponentByName(getPanel(), "By Value Minimum Alignment");
(JRadioButton) findComponentByName(getPanel(), "Explicit Alignment");
assertEquals(true, byValueButton.isSelected());
JTextField minAlignField =
(JTextField) findComponentByName(getPanel(), "Minimum Alignment Value");
assertEquals("" + value, minAlignField.getText());
(JTextField) findComponentByName(getPanel(), "Explicit Alignment Value");
assertEquals("" + minAlignment, minAlignField.getText());
assertEquals(false, unionModel.viewComposite.isDefaultAligned());
assertEquals(false, unionModel.viewComposite.isMachineAligned());
assertEquals(value, unionModel.getMinimumAlignment());
assertEquals(minAlignment, unionModel.getExplicitMinimumAlignment());
assertEquals(3, unionModel.getNumComponents());
assertEquals(4, unionModel.getRowCount());
@ -244,8 +249,8 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
@Test
public void testTurnOffAlignmentInUnion() throws Exception {
emptyUnion.setInternallyAligned(true);
emptyUnion.setMinimumAlignment(8);
emptyUnion.setPackingEnabled(true);
emptyUnion.setExplicitMinimumAlignment(8);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyUnion.add(new ByteDataType());
@ -255,15 +260,15 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
init(emptyUnion, pgmRootCat, false);
JRadioButton byValueButton =
(JRadioButton) findComponentByName(getPanel(), "By Value Minimum Alignment");
(JRadioButton) findComponentByName(getPanel(), "Explicit Alignment");
assertEquals(true, byValueButton.isSelected());
JTextField minAlignField =
(JTextField) findComponentByName(getPanel(), "Minimum Alignment Value");
(JTextField) findComponentByName(getPanel(), "Explicit Alignment Value");
assertEquals("8", minAlignField.getText());
assertEquals(false, unionModel.viewComposite.isDefaultAligned());
assertEquals(false, unionModel.viewComposite.isMachineAligned());
assertEquals(8, unionModel.getMinimumAlignment());
assertEquals(8, unionModel.getExplicitMinimumAlignment());
assertEquals(3, unionModel.getNumComponents());
assertEquals(4, unionModel.getRowCount());
@ -272,14 +277,14 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
checkRow(2, 5, "char[5]", arrayDt, "", "");
assertLength(8);
assertActualAlignment(8);
assertEquals(true, unionModel.isAligned());
assertEquals(true, unionModel.isPackingEnabled());
pressButtonByName(getPanel(), "Internally Aligned");
pressButtonByName(getPanel(), "Packing Enablement"); // toggle -> disable packing
assertEquals(false, unionModel.isAligned());
assertEquals(false, unionModel.isPackingEnabled());
assertEquals(true, unionModel.viewComposite.isDefaultAligned());
assertEquals(false, unionModel.viewComposite.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, unionModel.getMinimumAlignment());
assertEquals(false, unionModel.viewComposite.hasExplicitMinimumAlignment());
assertEquals(3, unionModel.getNumComponents());
assertEquals(4, unionModel.getRowCount());
@ -292,7 +297,7 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
@Test
public void testInsertUnaligned1() throws Exception {
emptyUnion.setInternallyAligned(false);
emptyUnion.setPackingEnabled(false);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyUnion.add(new ByteDataType());
@ -325,7 +330,7 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
@Test
public void testInsertUnaligned2() throws Exception {
emptyUnion.setInternallyAligned(false);
emptyUnion.setPackingEnabled(false);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyUnion.add(new ByteDataType());
@ -358,7 +363,7 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
@Test
public void testInsertUnaligned3() throws Exception {
emptyUnion.setInternallyAligned(false);
emptyUnion.setPackingEnabled(false);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyUnion.add(new ByteDataType());
@ -391,7 +396,7 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
@Test
public void testReplaceUnaligned1() throws Exception {
emptyUnion.setInternallyAligned(false);
emptyUnion.setPackingEnabled(false);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyUnion.add(new ByteDataType());
@ -423,7 +428,7 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
@Test
public void testReplaceUnaligned2() throws Exception {
emptyUnion.setInternallyAligned(false);
emptyUnion.setPackingEnabled(false);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyUnion.add(new ByteDataType());
@ -456,7 +461,7 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
@Test
public void testInsertAligned1() throws Exception {
emptyUnion.setInternallyAligned(true);
emptyUnion.setPackingEnabled(true);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyUnion.add(new ByteDataType());
@ -489,7 +494,7 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
@Test
public void testInsertAligned2() throws Exception {
emptyUnion.setInternallyAligned(true);
emptyUnion.setPackingEnabled(true);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyUnion.add(new ByteDataType());
@ -522,7 +527,7 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
@Test
public void testInsertAligned3() throws Exception {
emptyUnion.setInternallyAligned(true);
emptyUnion.setPackingEnabled(true);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyUnion.add(new ByteDataType());
@ -555,7 +560,7 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
@Test
public void testReplaceAligned1() throws Exception {
emptyUnion.setInternallyAligned(true);
emptyUnion.setPackingEnabled(true);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyUnion.add(new ByteDataType());
@ -587,7 +592,7 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest {
@Test
public void testReplaceAligned2() throws Exception {
emptyUnion.setInternallyAligned(true);
emptyUnion.setPackingEnabled(true);
DataType arrayDt = new ArrayDataType(new CharDataType(), 5, 1);
emptyUnion.add(new ByteDataType());

View file

@ -63,7 +63,7 @@ public class UnionEditorDnDTest extends AbstractUnionEditorTest {
assertNotNull(dt4);
addAtPoint(dt4, 3, 0);
dialog = env.waitForDialogComponent(NumberInputDialog.class, 1000);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 25);
dialog = null;
@ -106,7 +106,7 @@ public class UnionEditorDnDTest extends AbstractUnionEditorTest {
DataType dt4 = model.getOriginalDataTypeManager().getDataType("/string");
assertNotNull(dt4);
insertAtPoint(dt4, 0, 0);
dialog = env.waitForDialogComponent(NumberInputDialog.class, 1000);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 25);
dialog = null;

View file

@ -25,11 +25,9 @@ import org.junit.Assert;
import org.junit.Test;
import ghidra.program.model.data.*;
import ghidra.program.model.data.Composite.AlignmentType;
import ghidra.util.exception.DuplicateNameException;
import ghidra.util.exception.UsrException;
import ghidra.util.task.TaskMonitor;
import ghidra.util.task.TaskMonitorAdapter;
public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
@ -40,7 +38,7 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
try {
DataTypeManager dataTypeManager = cat.getDataTypeManager();
if (dt.getDataTypeManager() != dataTypeManager) {
dt = (Union) dt.clone(dataTypeManager);
dt = dt.clone(dataTypeManager);
}
CategoryPath categoryPath = cat.getCategoryPath();
if (!dt.getCategoryPath().equals(categoryPath)) {
@ -61,10 +59,8 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
installProvider(new UnionEditorProvider(plugin, unionDt, showInHex));
model = provider.getModel();
});
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
startTransaction("Modify Program");
}
@ -86,7 +82,7 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
init(complexUnion, pgmTestCat, false);
assertEquals("/aa/bb", getDataType(20).getCategoryPath().getPath());
pgmTestCat.moveCategory(pgmBbCat, TaskMonitorAdapter.DUMMY_MONITOR);
pgmTestCat.moveCategory(pgmBbCat, TaskMonitor.DUMMY);
waitForSwing();
assertEquals("/testCat/bb", getDataType(20).getCategoryPath().getPath());
}
@ -101,7 +97,7 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
init(simpleUnion, pgmBbCat, false);
assertEquals(pgmBbCat.getCategoryPathName(), model.getOriginalCategoryPath().getPath());
pgmTestCat.moveCategory(pgmBbCat, TaskMonitorAdapter.DUMMY_MONITOR);
pgmTestCat.moveCategory(pgmBbCat, TaskMonitor.DUMMY);
waitForSwing();
assertTrue(model.getOriginalCategoryPath().getPath().startsWith(
pgmTestCat.getCategoryPathName()));
@ -142,9 +138,9 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
DataType dt18 = getDataType(18).clone(programDTM);
DataType dt20 = getDataType(20).clone(programDTM);
SwingUtilities.invokeLater(() -> {
programDTM.remove(complexUnion, TaskMonitorAdapter.DUMMY_MONITOR);
programDTM.remove(complexUnion, TaskMonitor.DUMMY);
programDTM.getCategory(pgmRootCat.getCategoryPath()).removeCategory("Temp",
TaskMonitorAdapter.DUMMY_MONITOR);
TaskMonitor.DUMMY);
});
waitForSwing();
@ -250,7 +246,7 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
DataType origCopy = complexUnion.clone(null);
// Verify the Reload Union Editor? dialog is displayed.
dialog = env.waitForWindow("Reload Union Editor?", 1000);
dialog = waitForWindow("Reload Union Editor?");
assertNotNull(dialog);
pressButtonByText(dialog, "Yes");
dialog.dispose();
@ -287,7 +283,7 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
waitForSwing();
// Verify the Reload Union Editor? dialog is displayed.
dialog = env.waitForWindow("Reload Union Editor?", 1000);
dialog = waitForWindow("Reload Union Editor?");
assertNotNull(dialog);
pressButtonByText(dialog, "No");
dialog.dispose();
@ -374,7 +370,7 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
assertEquals(21, model.getNumComponents());
SwingUtilities.invokeLater(() -> complexUnion.getDataTypeManager().remove(
simpleStructure, TaskMonitorAdapter.DUMMY_MONITOR));
simpleStructure, TaskMonitor.DUMMY));
waitForSwing();
assertEquals(15, model.getNumComponents());
}
@ -400,7 +396,7 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
assertTrue(simpleUnion.isEquivalent(getDataType(0)));
SwingUtilities.invokeLater(() -> simpleUnion.getDataTypeManager().remove(simpleUnion,
TaskMonitorAdapter.DUMMY_MONITOR));
TaskMonitor.DUMMY));
waitForSwing();
assertEquals(0, model.getNumComponents());
}

View file

@ -20,7 +20,6 @@ import static org.junit.Assert.*;
import org.junit.Test;
import ghidra.program.model.data.*;
import ghidra.program.model.data.Composite.AlignmentType;
public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
@ -39,10 +38,8 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 0 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(emptyStructure.getName(), model.getCompositeName());
@ -55,12 +52,10 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
DataType dt = pgmRootCat.getDataType(emptyStructure.getName());
assertNotNull(dt);
assertTrue(dt.isNotYetDefined());
assertTrue(dt.isZeroLength());
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(emptyStructure.getName(), model.getCompositeName());
@ -76,7 +71,7 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
DataType dt = pgmBbCat.getDataType(simpleStructure.getName());
assertNotNull(dt);
assertFalse(dt.isNotYetDefined());
assertFalse(dt.isZeroLength());
assertEquals(8, model.getNumComponents());
assertEquals(9, model.getRowCount());
@ -87,10 +82,8 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 8 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(29);
assertEquals(simpleStructure.getName(), model.getCompositeName());
@ -110,10 +103,8 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 0 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(simpleStructure.getName(), model.getCompositeName());
@ -125,16 +116,14 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
invoke(applyAction);
assertTrue(simpleStructure.isEquivalent(model.viewComposite));
assertTrue(simpleStructure.isNotYetDefined());
assertTrue(simpleStructure.isZeroLength());
dt = pgmBbCat.getDataType(simpleStructure.getName());
assertNotNull(dt);
assertTrue(dt.isNotYetDefined());
assertTrue(dt.isZeroLength());
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(simpleStructure.getName(), model.getCompositeName());
@ -179,7 +168,7 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
DataType dt = pgmTestCat.getDataType(innerStructure.getName());
assertNotNull(dt);
assertFalse(dt.isNotYetDefined());
assertFalse(dt.isZeroLength());
assertEquals(1, model.getNumComponents());
assertEquals(2, model.getRowCount());
@ -190,10 +179,8 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 1 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(1);
assertEquals(innerStructure.getName(), model.getCompositeName());
@ -213,10 +200,8 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 0 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(innerStructure.getName(), model.getCompositeName());
@ -229,12 +214,10 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
dt = pgmTestCat.getDataType(innerStructure.getName());
assertNotNull(dt);
assertTrue(dt.isNotYetDefined());
assertTrue(dt.isZeroLength());
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(innerStructure.getName(), model.getCompositeName());
@ -280,7 +263,7 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
DataType dt = pgmTestCat.getDataType(innerStructure.getName());
assertNotNull(dt);
assertFalse(dt.isNotYetDefined());
assertFalse(dt.isZeroLength());
assertEquals(1, model.getNumComponents());
assertEquals(2, model.getRowCount());
@ -291,10 +274,8 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 1 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(1);
assertEquals(innerStructure.getName(), model.getCompositeName());
@ -314,10 +295,8 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 0 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(innerStructure.getName(), model.getCompositeName());
@ -330,15 +309,13 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
dt = pgmTestCat.getDataType(innerStructure.getName());
assertNotNull(dt);
assertTrue(dt.isNotYetDefined());
assertTrue(dt.isZeroLength());
assertTrue(innerStructure.isEquivalent(model.viewComposite));
assertTrue(innerStructure.isNotYetDefined());
assertTrue(innerStructure.isZeroLength());
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(innerStructure.getName(), model.getCompositeName());
@ -373,13 +350,13 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
}
assertNotNull(innerStructure);
assertNotNull(innerTypedef);
assertTrue(!innerTypedef.isNotYetDefined());
assertTrue(!innerTypedef.isZeroLength());
init(innerStructure, pgmTestCat, false);
DataType dt = pgmTestCat.getDataType(innerStructure.getName());
assertNotNull(dt);
assertFalse(dt.isNotYetDefined());
assertFalse(dt.isZeroLength());
assertEquals(1, model.getNumComponents());
assertEquals(2, model.getRowCount());
@ -390,10 +367,8 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 1 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(1);
assertEquals(innerStructure.getName(), model.getCompositeName());
@ -413,10 +388,8 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 0 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(innerStructure.getName(), model.getCompositeName());
@ -429,15 +402,13 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
dt = pgmTestCat.getDataType(innerStructure.getName());
assertNotNull(dt);
assertTrue(dt.isNotYetDefined());
assertTrue(dt.isZeroLength());
assertTrue(innerStructure.isEquivalent(model.viewComposite));
assertTrue(innerStructure.isNotYetDefined());
assertTrue(innerStructure.isZeroLength());
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(innerStructure.getName(), model.getCompositeName());
@ -446,7 +417,7 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
assertEquals(false, applyAction.isEnabled());
// assertStatus("/testCat/innerStructure is contained in /testCat/innerStructureTypedef and can't be changed to a zero size data type.");
assertTrue(innerTypedef.isNotYetDefined());
assertTrue(innerTypedef.isZeroLength());
assertEquals(1, innerTypedef.getLength());
}
@ -481,7 +452,7 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
DataType dt = pgmTestCat.getDataType(innerStructure.getName());
assertNotNull(dt);
assertFalse(dt.isNotYetDefined());
assertFalse(dt.isZeroLength());
assertEquals(1, model.getNumComponents());
assertEquals(2, model.getRowCount());
@ -492,10 +463,8 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 1 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(2);
assertEquals(innerStructure.getName(), model.getCompositeName());
@ -515,10 +484,8 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 0 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(innerStructure.getName(), model.getCompositeName());
@ -531,15 +498,13 @@ public class ZeroSizeStructureTest extends AbstractStructureEditorTest {
dt = pgmTestCat.getDataType(innerStructure.getName());
assertNotNull(dt);
assertTrue(dt.isNotYetDefined());
assertTrue(dt.isZeroLength());
assertTrue(innerStructure.isEquivalent(model.viewComposite));
assertTrue(innerStructure.isNotYetDefined());
assertTrue(innerStructure.isZeroLength());
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(innerStructure.getName(), model.getCompositeName());

View file

@ -20,7 +20,6 @@ import static org.junit.Assert.*;
import org.junit.Test;
import ghidra.program.model.data.*;
import ghidra.program.model.data.Composite.AlignmentType;
public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
@ -39,10 +38,8 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 0 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(emptyUnion.getName(), model.getCompositeName());
@ -55,12 +52,10 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
DataType dt = pgmRootCat.getDataType(emptyUnion.getName());
assertNotNull(dt);
assertTrue(dt.isNotYetDefined());
assertTrue(dt.isZeroLength());
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(emptyUnion.getName(), model.getCompositeName());
@ -76,7 +71,7 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
DataType dt = pgmBbCat.getDataType(simpleUnion.getName());
assertNotNull(dt);
assertFalse(dt.isNotYetDefined());
assertFalse(dt.isZeroLength());
assertEquals(7, model.getNumComponents());
assertEquals(8, model.getRowCount());
@ -87,10 +82,8 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 7 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(8);
assertEquals(simpleUnion.getName(), model.getCompositeName());
@ -110,10 +103,8 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 0 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(simpleUnion.getName(), model.getCompositeName());
@ -125,18 +116,16 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
invoke(applyAction);
assertTrue(simpleUnion.isEquivalent(model.viewComposite));
assertTrue(simpleUnion.isNotYetDefined());
assertTrue(simpleUnion.isZeroLength());
dt = pgmBbCat.getDataType(simpleUnion.getName());
assertNotNull(dt);
assertTrue(dt.isNotYetDefined());
assertTrue(dt.isZeroLength());
assertTrue(simpleUnion.isEquivalent(model.viewComposite));
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(simpleUnion.getName(), model.getCompositeName());
@ -179,7 +168,7 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
DataType dt = pgmTestCat.getDataType(innerUnion.getName());
assertNotNull(dt);
assertFalse(dt.isNotYetDefined());
assertFalse(dt.isZeroLength());
assertEquals(1, model.getNumComponents());
assertEquals(2, model.getRowCount());
@ -190,10 +179,8 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 1 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(1);
assertEquals(innerUnion.getName(), model.getCompositeName());
@ -213,10 +200,8 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 0 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(innerUnion.getName(), model.getCompositeName());
@ -229,12 +214,10 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
dt = pgmTestCat.getDataType(innerUnion.getName());
assertNotNull(dt);
assertTrue(dt.isNotYetDefined());
assertTrue(dt.isZeroLength());
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(innerUnion.getName(), model.getCompositeName());
@ -278,7 +261,7 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
DataType dt = pgmTestCat.getDataType(innerUnion.getName());
assertNotNull(dt);
assertFalse(dt.isNotYetDefined());
assertFalse(dt.isZeroLength());
assertEquals(1, model.getNumComponents());
assertEquals(2, model.getRowCount());
@ -289,10 +272,8 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 1 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(1);
assertEquals(innerUnion.getName(), model.getCompositeName());
@ -312,10 +293,8 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 0 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(innerUnion.getName(), model.getCompositeName());
@ -328,15 +307,13 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
dt = pgmTestCat.getDataType(innerUnion.getName());
assertNotNull(dt);
assertTrue(dt.isNotYetDefined());
assertTrue(dt.isZeroLength());
assertTrue(innerUnion.isEquivalent(model.viewComposite));
assertTrue(innerUnion.isNotYetDefined());
assertTrue(innerUnion.isZeroLength());
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(innerUnion.getName(), model.getCompositeName());
@ -374,7 +351,7 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
DataType dt = pgmTestCat.getDataType(innerUnion.getName());
assertNotNull(dt);
assertFalse(dt.isNotYetDefined());
assertFalse(dt.isZeroLength());
assertEquals(1, model.getNumComponents());
assertEquals(2, model.getRowCount());
@ -385,10 +362,8 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 1 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(1);
assertEquals(innerUnion.getName(), model.getCompositeName());
@ -408,10 +383,8 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 0 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(innerUnion.getName(), model.getCompositeName());
@ -424,15 +397,13 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
dt = pgmTestCat.getDataType(innerUnion.getName());
assertNotNull(dt);
assertTrue(dt.isNotYetDefined());
assertTrue(dt.isZeroLength());
assertTrue(innerUnion.isEquivalent(model.viewComposite));
assertTrue(innerUnion.isNotYetDefined());
assertTrue(innerUnion.isZeroLength());
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(innerUnion.getName(), model.getCompositeName());
@ -470,7 +441,7 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
DataType dt = pgmTestCat.getDataType(innerUnion.getName());
assertNotNull(dt);
assertFalse(dt.isNotYetDefined());
assertFalse(dt.isZeroLength());
assertEquals(1, model.getNumComponents());
assertEquals(2, model.getRowCount());
@ -481,10 +452,8 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 1 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(1);
assertEquals(innerUnion.getName(), model.getCompositeName());
@ -504,10 +473,8 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
assertEquals(0, model.getNumSelectedComponentRows());
assertEquals(1, model.getNumSelectedRows());
checkSelection(new int[] { 0 });
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(innerUnion.getName(), model.getCompositeName());
@ -520,15 +487,13 @@ public class ZeroSizeUnionTest extends AbstractUnionEditorTest {
dt = pgmTestCat.getDataType(innerUnion.getName());
assertNotNull(dt);
assertTrue(dt.isNotYetDefined());
assertTrue(dt.isZeroLength());
assertTrue(innerUnion.isEquivalent(model.viewComposite));
assertTrue(innerUnion.isNotYetDefined());
assertTrue(innerUnion.isZeroLength());
assertIsInternallyAligned(false);
assertPackingValue(Composite.NOT_PACKING);
assertMinimumAlignmentType(AlignmentType.DEFAULT_ALIGNED);
assertMinimumAlignmentValue(Composite.DEFAULT_ALIGNMENT_VALUE);
assertIsPackingEnabled(false);
assertIsDefaultAligned();
assertActualAlignment(1);
assertLength(0);
assertEquals(innerUnion.getName(), model.getCompositeName());

View file

@ -774,14 +774,14 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
enumm.add("One", 1);
Structure structX = new StructureDataType("StructX", 0);
structX.setInternallyAligned(true);
structX.setPackingEnabled(true);
structX.add(new ByteDataType());
structX.add(enumm);
structX.add(new ByteDataType());
category.addDataType(structX, DataTypeConflictHandler.DEFAULT_HANDLER);
Structure structY = new StructureDataType("StructY", 0);
structY.setInternallyAligned(false);
structY.setPackingEnabled(false);
structY.add(new ByteDataType());
structY.add(enumm);
category.addDataType(structY, DataTypeConflictHandler.DEFAULT_HANDLER);
@ -815,7 +815,7 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
assertEquals(intValue, 4);
Structure structX = (Structure) category.getDataType("StructX");
assertTrue(structX.isInternallyAligned());
assertTrue(structX.isPackingEnabled());
assertEquals(3, structX.getNumComponents());
assertEquals(1, structX.getComponent(0).getLength());
assertEquals(4, structX.getComponent(1).getLength());
@ -823,7 +823,7 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
assertEquals(12, structX.getLength());
Structure structY = (Structure) category.getDataType("StructY");
assertFalse(structY.isInternallyAligned());
assertFalse(structY.isPackingEnabled());
assertEquals(2, structY.getNumComponents());
assertEquals(1, structY.getComponent(0).getLength());
assertEquals(4, structY.getComponent(1).getLength());
@ -846,14 +846,14 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
enumm.setDescription("ABCD");
Structure structX = new StructureDataType("StructX", 0);
structX.setInternallyAligned(true);
structX.setPackingEnabled(true);
structX.add(new ByteDataType());
structX.add(enumm);
structX.add(new ByteDataType());
category.addDataType(structX, DataTypeConflictHandler.DEFAULT_HANDLER);
Structure structY = new StructureDataType("StructY", 0);
structY.setInternallyAligned(false);
structY.setPackingEnabled(false);
structY.add(new ByteDataType());
structY.add(enumm);
category.addDataType(structY, DataTypeConflictHandler.DEFAULT_HANDLER);
@ -926,7 +926,7 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
assertEquals(1, value1);
Structure structX = (Structure) category.getDataType("StructX");
assertTrue(structX.isInternallyAligned());
assertTrue(structX.isPackingEnabled());
assertEquals(3, structX.getNumComponents());
assertEquals(1, structX.getComponent(0).getLength());
assertEquals(4, structX.getComponent(1).getLength());
@ -934,7 +934,7 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
assertEquals(12, structX.getLength());
Structure structY = (Structure) category.getDataType("StructY");
assertFalse(structY.isInternallyAligned());
assertFalse(structY.isPackingEnabled());
assertEquals(2, structY.getNumComponents());
assertEquals(1, structY.getComponent(0).getLength());
assertEquals(4, structY.getComponent(1).getLength());

View file

@ -180,7 +180,7 @@ public class DataTypePreviewPluginTest extends AbstractGhidraHeadedIntegrationTe
plugin.addDataType(ShortDataType.dataType);
Structure struct = new StructureDataType("test", 0);
struct.setInternallyAligned(true);
struct.setPackingEnabled(true);
struct.add(IntegerDataType.dataType, "intField", "");
struct.add(LongDataType.dataType, "longField", "");
struct.add(ShortDataType.dataType, "shortField", "");

View file

@ -15,8 +15,7 @@
*/
package ghidra.app.plugin.core.stackeditor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import org.junit.Test;
@ -26,10 +25,6 @@ import ghidra.program.model.data.Pointer;
public class PositiveStackEditorEnablementTest extends AbstractStackEditorTest {
/**
* Constructor for StackEditorLockedActionsTest.
* @param name the testcase name.
*/
public PositiveStackEditorEnablementTest() {
super(true);
}
@ -52,13 +47,13 @@ public class PositiveStackEditorEnablementTest extends AbstractStackEditorTest {
assertEquals(stackModel.getTypeName(), "Stack");
// Check enablement.
for (int i = 0; i < actions.length; i++) {
if ((actions[i] instanceof CycleGroupAction) ||
(actions[i] instanceof HexNumbersAction)) {
checkEnablement(actions[i], true);
for (CompositeEditorTableAction action : actions) {
if ((action instanceof CycleGroupAction) ||
(action instanceof HexNumbersAction)) {
checkEnablement(action, true);
}
else {
checkEnablement(actions[i], false);
checkEnablement(action, false);
}
}
}
@ -83,13 +78,13 @@ public class PositiveStackEditorEnablementTest extends AbstractStackEditorTest {
assertEquals(stackModel.getTypeName(), "Stack");
// Check enablement.
for (int i = 0; i < actions.length; i++) {
if ((actions[i] instanceof CycleGroupAction) ||
(actions[i] instanceof HexNumbersAction)) {
checkEnablement(actions[i], true);
for (CompositeEditorTableAction action : actions) {
if ((action instanceof CycleGroupAction) ||
(action instanceof HexNumbersAction)) {
checkEnablement(action, true);
}
else {
checkEnablement(actions[i], false);
checkEnablement(action, false);
}
}
@ -97,9 +92,9 @@ public class PositiveStackEditorEnablementTest extends AbstractStackEditorTest {
// Check enablement.
int numBytes = getModel().getMaxReplaceLength(0);
for (int i = 0; i < actions.length; i++) {
if (actions[i] instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) actions[i];
for (CompositeEditorTableAction action : actions) {
if (action instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) action;
DataType favDt = fav.getDataType();
int len = favDt.getLength();
boolean enabled = ((len <= numBytes) && ((favDt instanceof Pointer) || (len > 0)));
@ -108,17 +103,17 @@ public class PositiveStackEditorEnablementTest extends AbstractStackEditorTest {
if (offset < 0 && offset > paramOffset) {
enabled = false;
}
checkEnablement(actions[i], enabled);
checkEnablement(action, enabled);
}
else if ((actions[i] instanceof CycleGroupAction) ||
(actions[i] instanceof ShowComponentPathAction) ||
(actions[i] instanceof EditFieldAction) || (actions[i] instanceof ClearAction) ||
(actions[i] instanceof DeleteAction) || (actions[i] instanceof PointerAction) ||
(actions[i] instanceof HexNumbersAction)) {
checkEnablement(actions[i], true);
else if ((action instanceof CycleGroupAction) ||
(action instanceof ShowComponentPathAction) ||
(action instanceof EditFieldAction) || (action instanceof ClearAction) ||
(action instanceof DeleteAction) || (action instanceof PointerAction) ||
(action instanceof HexNumbersAction)) {
checkEnablement(action, true);
}
else {
checkEnablement(actions[i], false);
checkEnablement(action, false);
}
}
}
@ -143,49 +138,49 @@ public class PositiveStackEditorEnablementTest extends AbstractStackEditorTest {
setSelection(new int[] { 19 });// undefined (no variable here).
int numBytes = getModel().getMaxReplaceLength(19);
for (int i = 0; i < actions.length; i++) {
if (actions[i] instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) actions[i];
for (CompositeEditorTableAction action : actions) {
if (action instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) action;
DataType favDt = fav.getDataType();
int len = favDt.getLength();
boolean enabled = ((len <= numBytes) && ((favDt instanceof Pointer) || (len > 0)));
checkEnablement(actions[i], enabled);
checkEnablement(action, enabled);
}
else if ((actions[i] instanceof CycleGroupAction) ||
(actions[i] instanceof HexNumbersAction) ||
(actions[i] instanceof ShowComponentPathAction) ||
(actions[i] instanceof EditFieldAction) || (actions[i] instanceof ClearAction) ||
(actions[i] instanceof PointerAction)) {
checkEnablement(actions[i], true);
else if ((action instanceof CycleGroupAction) ||
(action instanceof HexNumbersAction) ||
(action instanceof ShowComponentPathAction) ||
(action instanceof EditFieldAction) || (action instanceof ClearAction) ||
(action instanceof PointerAction)) {
checkEnablement(action, true);
}
else {
checkEnablement(actions[i], false);
checkEnablement(action, false);
}
}
setSelection(new int[] { 14 });// pointer
numBytes = getModel().getMaxReplaceLength(14);
for (int i = 0; i < actions.length; i++) {
if (actions[i] instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) actions[i];
for (CompositeEditorTableAction action : actions) {
if (action instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) action;
DataType favDt = fav.getDataType();
int len = favDt.getLength();
boolean enabled = (len <= numBytes)
// && !(favDt instanceof TerminatedStringDataType)
// && !(favDt instanceof TerminatedUnicodeDataType)
;
checkEnablement(actions[i], enabled);
checkEnablement(action, enabled);
}
else if ((actions[i] instanceof CycleGroupAction) ||
(actions[i] instanceof HexNumbersAction) ||
(actions[i] instanceof ShowComponentPathAction) ||
(actions[i] instanceof EditFieldAction) || (actions[i] instanceof ClearAction) ||
(actions[i] instanceof ArrayAction) || (actions[i] instanceof PointerAction)) {
checkEnablement(actions[i], true);
else if ((action instanceof CycleGroupAction) ||
(action instanceof HexNumbersAction) ||
(action instanceof ShowComponentPathAction) ||
(action instanceof EditFieldAction) || (action instanceof ClearAction) ||
(action instanceof ArrayAction) || (action instanceof PointerAction)) {
checkEnablement(action, true);
}
else {
checkEnablement(actions[i], false);
checkEnablement(action, false);
}
}
}
@ -197,24 +192,24 @@ public class PositiveStackEditorEnablementTest extends AbstractStackEditorTest {
// Check enablement on first component selected.
model.setSelection(new int[] { 0 });
int numBytes = getModel().getMaxReplaceLength(0);
for (int i = 0; i < actions.length; i++) {
if (actions[i] instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) actions[i];
for (CompositeEditorTableAction action : actions) {
if (action instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) action;
DataType favDt = fav.getDataType();
int len = favDt.getLength();
boolean enabled = ((len <= numBytes) && ((favDt instanceof Pointer) || (len > 0)));
checkEnablement(actions[i], enabled);
checkEnablement(action, enabled);
}
else if ((actions[i] instanceof CycleGroupAction) ||
(actions[i] instanceof HexNumbersAction) ||
(actions[i] instanceof ShowComponentPathAction) ||
(actions[i] instanceof EditFieldAction) || (actions[i] instanceof ClearAction) ||
(actions[i] instanceof DeleteAction) || (actions[i] instanceof ArrayAction) ||
(actions[i] instanceof PointerAction)) {
checkEnablement(actions[i], true);
else if ((action instanceof CycleGroupAction) ||
(action instanceof HexNumbersAction) ||
(action instanceof ShowComponentPathAction) ||
(action instanceof EditFieldAction) || (action instanceof ClearAction) ||
(action instanceof DeleteAction) || (action instanceof ArrayAction) ||
(action instanceof PointerAction)) {
checkEnablement(action, true);
}
else {
checkEnablement(actions[i], false);
checkEnablement(action, false);
}
}
}
@ -226,23 +221,23 @@ public class PositiveStackEditorEnablementTest extends AbstractStackEditorTest {
// Check enablement on central component selected.
model.setSelection(new int[] { 1 });
int numBytes = getModel().getMaxReplaceLength(1);
for (int i = 0; i < actions.length; i++) {
if (actions[i] instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) actions[i];
for (CompositeEditorTableAction action : actions) {
if (action instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) action;
DataType favDt = fav.getDataType();
int len = favDt.getLength();
boolean enabled = ((len <= numBytes) && ((favDt instanceof Pointer) || (len > 0)));
checkEnablement(actions[i], enabled);
checkEnablement(action, enabled);
}
else if ((actions[i] instanceof CycleGroupAction) ||
(actions[i] instanceof HexNumbersAction) ||
(actions[i] instanceof ShowComponentPathAction) ||
(actions[i] instanceof EditFieldAction) || (actions[i] instanceof ClearAction) ||
(actions[i] instanceof ArrayAction) || (actions[i] instanceof PointerAction)) {
checkEnablement(actions[i], true);
else if ((action instanceof CycleGroupAction) ||
(action instanceof HexNumbersAction) ||
(action instanceof ShowComponentPathAction) ||
(action instanceof EditFieldAction) || (action instanceof ClearAction) ||
(action instanceof ArrayAction) || (action instanceof PointerAction)) {
checkEnablement(action, true);
}
else {
checkEnablement(actions[i], false);
checkEnablement(action, false);
}
}
}
@ -254,24 +249,24 @@ public class PositiveStackEditorEnablementTest extends AbstractStackEditorTest {
// Check enablement on last component selected.
model.setSelection(new int[] { model.getNumComponents() - 1 });
int numBytes = getModel().getMaxReplaceLength(model.getNumComponents() - 1);
for (int i = 0; i < actions.length; i++) {
if (actions[i] instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) actions[i];
for (CompositeEditorTableAction action : actions) {
if (action instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) action;
DataType favDt = fav.getDataType();
int len = favDt.getLength();
boolean enabled = ((len <= numBytes) && ((favDt instanceof Pointer) || (len > 0)));
checkEnablement(actions[i], enabled);
checkEnablement(action, enabled);
}
else if ((actions[i] instanceof CycleGroupAction) ||
(actions[i] instanceof HexNumbersAction) ||
(actions[i] instanceof ShowComponentPathAction) ||
(actions[i] instanceof EditFieldAction) || (actions[i] instanceof ClearAction) ||
(actions[i] instanceof DeleteAction) || (actions[i] instanceof ArrayAction) ||
(actions[i] instanceof PointerAction)) {
checkEnablement(actions[i], true);
else if ((action instanceof CycleGroupAction) ||
(action instanceof HexNumbersAction) ||
(action instanceof ShowComponentPathAction) ||
(action instanceof EditFieldAction) || (action instanceof ClearAction) ||
(action instanceof DeleteAction) || (action instanceof ArrayAction) ||
(action instanceof PointerAction)) {
checkEnablement(action, true);
}
else {
checkEnablement(actions[i], false);
checkEnablement(action, false);
}
}
}
@ -282,14 +277,14 @@ public class PositiveStackEditorEnablementTest extends AbstractStackEditorTest {
// Check enablement on a contiguous multi-component selection.
model.setSelection(new int[] { 2, 3, 4 });
for (int i = 0; i < actions.length; i++) {
if ((actions[i] instanceof CycleGroupAction) ||
(actions[i] instanceof HexNumbersAction) || (actions[i] instanceof PointerAction) ||
(actions[i] instanceof ClearAction)) {
checkEnablement(actions[i], true);
for (CompositeEditorTableAction action : actions) {
if ((action instanceof CycleGroupAction) ||
(action instanceof HexNumbersAction) || (action instanceof PointerAction) ||
(action instanceof ClearAction)) {
checkEnablement(action, true);
}
else {
checkEnablement(actions[i], false);
checkEnablement(action, false);
}
}
}
@ -300,13 +295,13 @@ public class PositiveStackEditorEnablementTest extends AbstractStackEditorTest {
// Check enablement on a non-contiguous multi-component selection.
model.setSelection(new int[] { 2, 3, 6, 7 });
for (int i = 0; i < actions.length; i++) {
if ((actions[i] instanceof CycleGroupAction) ||
(actions[i] instanceof HexNumbersAction) || (actions[i] instanceof ClearAction)) {
checkEnablement(actions[i], true);
for (CompositeEditorTableAction action : actions) {
if ((action instanceof CycleGroupAction) ||
(action instanceof HexNumbersAction) || (action instanceof ClearAction)) {
checkEnablement(action, true);
}
else {
checkEnablement(actions[i], false);
checkEnablement(action, false);
}
}
}

View file

@ -15,8 +15,7 @@
*/
package ghidra.app.plugin.core.stackeditor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import javax.swing.JTextField;
@ -29,10 +28,6 @@ import ghidra.program.model.data.Pointer;
public class PositiveStackEditorProviderTest extends AbstractStackEditorTest {
/**
* Constructor for UnionEditorProviderTest.
* @param name the testcase name.
*/
public PositiveStackEditorProviderTest() {
super(true);
}

View file

@ -24,10 +24,7 @@ import docking.widgets.dialogs.NumberInputDialog;
import ghidra.program.model.data.*;
public class StackEditorActions1Test extends AbstractStackEditorTest {
/**
* Constructor for StackEditorActionsTest.
* @param name the testcase name.
*/
public StackEditorActions1Test() {
super(false);
}
@ -54,15 +51,15 @@ public class StackEditorActions1Test extends AbstractStackEditorTest {
// Make array of 2 arrays
assertEquals("", model.getStatus());
invoke(arrayAction);
dialog = env.waitForDialogComponent(NumberInputDialog.class, 1000);
invoke(arrayAction, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 3);
assertEquals("", model.getStatus());
dialog = null;
waitUntilDialogProviderGone(NumberInputDialog.class, 2000);
invoke(arrayAction);
dialog = env.waitForDialogComponent(NumberInputDialog.class, 1000);
invoke(arrayAction, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
okInput(dialog, 2);
dialog = null;

View file

@ -30,10 +30,7 @@ import ghidra.program.model.listing.StackFrame;
import ghidra.program.model.listing.Variable;
public class StackEditorActions2Test extends AbstractStackEditorTest {
/**
* Constructor for StackEditorActionsTest.
* @param name the testcase name.
*/
public StackEditorActions2Test() {
super(false);
}
@ -365,12 +362,12 @@ public class StackEditorActions2Test extends AbstractStackEditorTest {
assertEquals(1, model.getComponent(1).getLength());
assertEquals("", model.getStatus());
invoke(arrayAction);
dialog = env.waitForDialogComponent(NumberInputDialog.class, 1000);
invoke(arrayAction, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
assertEquals("Enter Number", dialog.getTitle());
badInput(dialog, 5);
dialog = env.waitForDialogComponent(NumberInputDialog.class, 1000);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
assertEquals("Enter Number", dialog.getTitle());
okInput(dialog, 4);
@ -395,13 +392,13 @@ public class StackEditorActions2Test extends AbstractStackEditorTest {
checkSelection(new int[] { 0 });
assertEquals("", model.getStatus());
invoke(arrayAction);
invoke(arrayAction, false);
waitForSwing();
dialog = env.waitForDialogComponent(NumberInputDialog.class, 2000);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
assertEquals("Enter Number", dialog.getTitle());
badInput(dialog, 2);
dialog = env.waitForDialogComponent(NumberInputDialog.class, 2000);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
assertEquals("Value must be between 1 and 1", dialog.getStatusText());
assertEquals("Enter Number", dialog.getTitle());
@ -428,8 +425,8 @@ public class StackEditorActions2Test extends AbstractStackEditorTest {
// Cancel the array dialog
assertEquals("", model.getStatus());
invoke(arrayAction);
dialog = env.waitForDialogComponent(NumberInputDialog.class, 1000);
invoke(arrayAction, false);
dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
cancelInput(dialog);
assertEquals("", model.getStatus());

View file

@ -31,10 +31,7 @@ import ghidra.app.plugin.core.compositeeditor.FavoritesAction;
import ghidra.program.model.data.*;
public class StackEditorActions4Test extends AbstractStackEditorTest {
/**
* Constructor for StackEditorActionsTest.
* @param name the testcase name.
*/
public StackEditorActions4Test() {
super(false);
}

View file

@ -32,10 +32,6 @@ import ghidra.program.model.listing.Variable;
public class StackEditorCellEditTest extends AbstractStackEditorTest {
/**
* Constructor for UnionEditorCellEditTest.
* @param name the testcase name.
*/
public StackEditorCellEditTest() {
super(false);
}

View file

@ -24,10 +24,6 @@ import ghidra.program.model.data.*;
public class StackEditorDnDTest extends AbstractStackEditorTest {
/**
* Constructor for StackEditorDnDTest.
* @param name the testcase name.
*/
public StackEditorDnDTest() {
super(false);
}

View file

@ -25,10 +25,6 @@ import ghidra.program.model.data.Pointer;
public class StackEditorEnablementTest extends AbstractStackEditorTest {
/**
* Constructor for StackEditorLockedActionsTest.
* @param name the testcase name.
*/
public StackEditorEnablementTest() {
super(false);
}
@ -51,13 +47,13 @@ public class StackEditorEnablementTest extends AbstractStackEditorTest {
assertEquals(stackModel.getTypeName(), "Stack");
// Check enablement.
for (int i = 0; i < actions.length; i++) {
if ((actions[i] instanceof CycleGroupAction) ||
(actions[i] instanceof HexNumbersAction)) {
checkEnablement(actions[i], true);
for (CompositeEditorTableAction action : actions) {
if ((action instanceof CycleGroupAction) ||
(action instanceof HexNumbersAction)) {
checkEnablement(action, true);
}
else {
checkEnablement(actions[i], false);
checkEnablement(action, false);
}
}
}
@ -82,13 +78,13 @@ public class StackEditorEnablementTest extends AbstractStackEditorTest {
assertEquals(stackModel.getTypeName(), "Stack");
// Check enablement.
for (int i = 0; i < actions.length; i++) {
if ((actions[i] instanceof CycleGroupAction) ||
(actions[i] instanceof HexNumbersAction)) {
checkEnablement(actions[i], true);
for (CompositeEditorTableAction action : actions) {
if ((action instanceof CycleGroupAction) ||
(action instanceof HexNumbersAction)) {
checkEnablement(action, true);
}
else {
checkEnablement(actions[i], false);
checkEnablement(action, false);
}
}
@ -96,23 +92,23 @@ public class StackEditorEnablementTest extends AbstractStackEditorTest {
// Check enablement.
int numBytes = getModel().getMaxReplaceLength(0);
for (int i = 0; i < actions.length; i++) {
if (actions[i] instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) actions[i];
for (CompositeEditorTableAction action : actions) {
if (action instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) action;
DataType favDt = fav.getDataType();
int len = favDt.getLength();
boolean enabled = ((len <= numBytes) && ((favDt instanceof Pointer) || (len > 0)));
checkEnablement(actions[i], enabled);
checkEnablement(action, enabled);
}
else if ((actions[i] instanceof CycleGroupAction) ||
(actions[i] instanceof ShowComponentPathAction) ||
(actions[i] instanceof EditFieldAction) || (actions[i] instanceof ClearAction) ||
(actions[i] instanceof DeleteAction) || (actions[i] instanceof PointerAction) ||
(actions[i] instanceof HexNumbersAction)) {
checkEnablement(actions[i], true);
else if ((action instanceof CycleGroupAction) ||
(action instanceof ShowComponentPathAction) ||
(action instanceof EditFieldAction) || (action instanceof ClearAction) ||
(action instanceof DeleteAction) || (action instanceof PointerAction) ||
(action instanceof HexNumbersAction)) {
checkEnablement(action, true);
}
else {
checkEnablement(actions[i], false);
checkEnablement(action, false);
}
}
}
@ -137,45 +133,45 @@ public class StackEditorEnablementTest extends AbstractStackEditorTest {
setSelection(new int[] { 19 });// Move to a float
int numBytes = getModel().getMaxReplaceLength(19);
for (int i = 0; i < actions.length; i++) {
if (actions[i] instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) actions[i];
for (CompositeEditorTableAction action : actions) {
if (action instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) action;
DataType favDt = fav.getDataType();
int len = favDt.getLength();
boolean enabled = ((len <= numBytes) && ((favDt instanceof Pointer) || (len > 0)));
checkEnablement(actions[i], enabled);
checkEnablement(action, enabled);
}
else if ((actions[i] instanceof CycleGroupAction) ||
(actions[i] instanceof HexNumbersAction) ||
(actions[i] instanceof ShowComponentPathAction) ||
(actions[i] instanceof EditFieldAction) || (actions[i] instanceof ClearAction) ||
(actions[i] instanceof DeleteAction) || (actions[i] instanceof ArrayAction) ||
(actions[i] instanceof PointerAction)) {
checkEnablement(actions[i], true);
else if ((action instanceof CycleGroupAction) ||
(action instanceof HexNumbersAction) ||
(action instanceof ShowComponentPathAction) ||
(action instanceof EditFieldAction) || (action instanceof ClearAction) ||
(action instanceof DeleteAction) || (action instanceof ArrayAction) ||
(action instanceof PointerAction)) {
checkEnablement(action, true);
}
else {
checkEnablement(actions[i], false);
checkEnablement(action, false);
}
}
setSelection(new int[] { 5 });// Move to a pointer
numBytes = getModel().getMaxReplaceLength(5);
for (int i = 0; i < actions.length; i++) {
if (actions[i] instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) actions[i];
for (CompositeEditorTableAction action : actions) {
if (action instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) action;
DataType favDt = fav.getDataType();
checkEnablement(actions[i], true);
checkEnablement(action, true);
}
else if ((actions[i] instanceof CycleGroupAction) ||
(actions[i] instanceof HexNumbersAction) ||
(actions[i] instanceof ShowComponentPathAction) ||
(actions[i] instanceof EditFieldAction) || (actions[i] instanceof ClearAction) ||
(actions[i] instanceof ArrayAction) || (actions[i] instanceof PointerAction)) {
checkEnablement(actions[i], true);
else if ((action instanceof CycleGroupAction) ||
(action instanceof HexNumbersAction) ||
(action instanceof ShowComponentPathAction) ||
(action instanceof EditFieldAction) || (action instanceof ClearAction) ||
(action instanceof ArrayAction) || (action instanceof PointerAction)) {
checkEnablement(action, true);
}
else {
checkEnablement(actions[i], false);
checkEnablement(action, false);
}
}
}
@ -187,24 +183,24 @@ public class StackEditorEnablementTest extends AbstractStackEditorTest {
// Check enablement on first component selected.
runSwing(() -> model.setSelection(new int[] { 0 }));
int numBytes = getModel().getMaxReplaceLength(0);
for (int i = 0; i < actions.length; i++) {
if (actions[i] instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) actions[i];
for (CompositeEditorTableAction action : actions) {
if (action instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) action;
DataType favDt = fav.getDataType();
int len = favDt.getLength();
boolean enabled = ((len <= numBytes) && ((favDt instanceof Pointer) || (len > 0)));
checkEnablement(actions[i], enabled);
checkEnablement(action, enabled);
}
else if ((actions[i] instanceof CycleGroupAction) ||
(actions[i] instanceof HexNumbersAction) ||
(actions[i] instanceof ShowComponentPathAction) ||
(actions[i] instanceof EditFieldAction) || (actions[i] instanceof ClearAction) ||
(actions[i] instanceof DeleteAction) || (actions[i] instanceof ArrayAction) ||
(actions[i] instanceof PointerAction)) {
checkEnablement(actions[i], true);
else if ((action instanceof CycleGroupAction) ||
(action instanceof HexNumbersAction) ||
(action instanceof ShowComponentPathAction) ||
(action instanceof EditFieldAction) || (action instanceof ClearAction) ||
(action instanceof DeleteAction) || (action instanceof ArrayAction) ||
(action instanceof PointerAction)) {
checkEnablement(action, true);
}
else {
checkEnablement(actions[i], false);
checkEnablement(action, false);
}
}
}
@ -217,23 +213,23 @@ public class StackEditorEnablementTest extends AbstractStackEditorTest {
runSwing(() -> model.setSelection(new int[] { 1 }));
int numBytes = getModel().getMaxReplaceLength(1);
for (int i = 0; i < actions.length; i++) {
if (actions[i] instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) actions[i];
for (CompositeEditorTableAction action : actions) {
if (action instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) action;
DataType favDt = fav.getDataType();
int len = favDt.getLength();
boolean enabled = ((len <= numBytes) && ((favDt instanceof Pointer) || (len > 0)));
checkEnablement(actions[i], enabled);
checkEnablement(action, enabled);
}
else if ((actions[i] instanceof CycleGroupAction) ||
(actions[i] instanceof HexNumbersAction) ||
(actions[i] instanceof ShowComponentPathAction) ||
(actions[i] instanceof EditFieldAction) || (actions[i] instanceof ClearAction) ||
(actions[i] instanceof ArrayAction) || (actions[i] instanceof PointerAction)) {
checkEnablement(actions[i], true);
else if ((action instanceof CycleGroupAction) ||
(action instanceof HexNumbersAction) ||
(action instanceof ShowComponentPathAction) ||
(action instanceof EditFieldAction) || (action instanceof ClearAction) ||
(action instanceof ArrayAction) || (action instanceof PointerAction)) {
checkEnablement(action, true);
}
else {
checkEnablement(actions[i], false);
checkEnablement(action, false);
}
}
}
@ -245,24 +241,24 @@ public class StackEditorEnablementTest extends AbstractStackEditorTest {
// Check enablement on last component selected.
runSwing(() -> model.setSelection(new int[] { model.getNumComponents() - 1 }));
int numBytes = getModel().getMaxReplaceLength(model.getNumComponents() - 1);
for (int i = 0; i < actions.length; i++) {
if (actions[i] instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) actions[i];
for (CompositeEditorTableAction action : actions) {
if (action instanceof FavoritesAction) {
FavoritesAction fav = (FavoritesAction) action;
DataType favDt = fav.getDataType();
int len = favDt.getLength();
boolean enabled = ((len <= numBytes) && ((favDt instanceof Pointer) || (len > 0)));
checkEnablement(actions[i], enabled);
checkEnablement(action, enabled);
}
else if ((actions[i] instanceof CycleGroupAction) ||
(actions[i] instanceof HexNumbersAction) ||
(actions[i] instanceof ShowComponentPathAction) ||
(actions[i] instanceof EditFieldAction) || (actions[i] instanceof ClearAction) ||
(actions[i] instanceof DeleteAction) || (actions[i] instanceof ArrayAction) ||
(actions[i] instanceof PointerAction)) {
checkEnablement(actions[i], true);
else if ((action instanceof CycleGroupAction) ||
(action instanceof HexNumbersAction) ||
(action instanceof ShowComponentPathAction) ||
(action instanceof EditFieldAction) || (action instanceof ClearAction) ||
(action instanceof DeleteAction) || (action instanceof ArrayAction) ||
(action instanceof PointerAction)) {
checkEnablement(action, true);
}
else {
checkEnablement(actions[i], false);
checkEnablement(action, false);
}
}
}
@ -273,14 +269,14 @@ public class StackEditorEnablementTest extends AbstractStackEditorTest {
// Check enablement on a contiguous multi-component selection.
runSwing(() -> model.setSelection(new int[] { 2, 3, 4 }));
for (int i = 0; i < actions.length; i++) {
if ((actions[i] instanceof CycleGroupAction) ||
(actions[i] instanceof HexNumbersAction) || (actions[i] instanceof PointerAction) ||
(actions[i] instanceof ClearAction)) {
checkEnablement(actions[i], true);
for (CompositeEditorTableAction action : actions) {
if ((action instanceof CycleGroupAction) ||
(action instanceof HexNumbersAction) || (action instanceof PointerAction) ||
(action instanceof ClearAction)) {
checkEnablement(action, true);
}
else {
checkEnablement(actions[i], false);
checkEnablement(action, false);
}
}
}
@ -291,13 +287,13 @@ public class StackEditorEnablementTest extends AbstractStackEditorTest {
// Check enablement on a non-contiguous multi-component selection.
runSwing(() -> model.setSelection(new int[] { 2, 3, 6, 7 }));
for (int i = 0; i < actions.length; i++) {
if ((actions[i] instanceof CycleGroupAction) ||
(actions[i] instanceof HexNumbersAction) || (actions[i] instanceof ClearAction)) {
checkEnablement(actions[i], true);
for (CompositeEditorTableAction action : actions) {
if ((action instanceof CycleGroupAction) ||
(action instanceof HexNumbersAction) || (action instanceof ClearAction)) {
checkEnablement(action, true);
}
else {
checkEnablement(actions[i], false);
checkEnablement(action, false);
}
}
}

View file

@ -43,7 +43,7 @@ public class FunctionSignatureParserTest extends AbstractGhidraHeadedIntegration
public void setUp() throws Exception {
ProgramBuilder builder = new ToyProgramBuilder("test", false);
StructureDataType s = new StructureDataType("StructA", 0);
s.setInternallyAligned(true);
s.setPackingEnabled(true);
s.add(IntegerDataType.dataType);
builder.addDataType(s);
program = builder.getProgram();
@ -241,7 +241,7 @@ public class FunctionSignatureParserTest extends AbstractGhidraHeadedIntegration
int txId = program.startTransaction("Add Struct");
try {
StructureDataType s = new StructureDataType(new CategoryPath("/Test"), "StructA", 0);
s.setInternallyAligned(true);
s.setPackingEnabled(true);
s.add(ByteDataType.dataType);
program.getDataTypeManager().addDataType(s, null);
}

View file

@ -51,7 +51,7 @@ public class BitFieldListingDisplayTest extends AbstractGhidraHeadedIntegrationT
TaskMonitor.DUMMY, false);
struct = createStructure("Test", 0);
struct.setInternallyAligned(true);
struct.setPackingEnabled(true);
struct.addBitField(IntegerDataType.dataType, 3, "bf1", "Nuts");
struct.addBitField(IntegerDataType.dataType, 24, "bf2", null);
struct.addBitField(IntegerDataType.dataType, 4, "bf3", null);

View file

@ -398,118 +398,118 @@ public class ConflictHandlerTest extends AbstractGhidraHeadedIntegrationTest {
/**
* Tests the
* {@link DataTypeConflictHandler#REPLACE_EMPTY_STRUCTS_OR_RENAME_AND_ADD_HANDLER RESORAAH}
* conflict handler to be sure that, if all else is the same, the aligned version is chosen
* over the unaligned version.
* conflict handler to be sure that, if all else is the same, the packed version is chosen
* over the non-packed version.
* <p>
* Success is the aligned version is chosen over the unaligned version.
* Success is the packed version is chosen over the non-packed version.
*/
@Test
public void testChooseNewAlignedOverExistingUnalignedWhenAllElseIsEqualForEmptyStructures() {
// Unaligned exists first.
Structure empty1Unaligned = new StructureDataType(root, "empty1", 0, dataMgr);
Composite empty1AlignedToAdd = (Composite) empty1Unaligned.copy(dataMgr);
empty1AlignedToAdd.setInternallyAligned(true);
public void testChooseNewPackedOverExistingNonPackedWhenAllElseIsEqualForEmptyStructures() {
// NonPacked exists first.
Structure empty1NonPacked = new StructureDataType(root, "empty1", 0, dataMgr);
Composite empty1PackedToAdd = (Composite) empty1NonPacked.copy(dataMgr);
empty1PackedToAdd.setPackingEnabled(true);
String empty1UnalignedString = empty1Unaligned.toString();
String empty1AlignedToAddString = empty1AlignedToAdd.toString();
String empty1NonPackedString = empty1NonPacked.toString();
String empty1PackedToAddString = empty1PackedToAdd.toString();
Structure empty1AddResult = (Structure) dataMgr.addDataType(empty1AlignedToAdd,
Structure empty1AddResult = (Structure) dataMgr.addDataType(empty1PackedToAdd,
DataTypeConflictHandler.REPLACE_EMPTY_STRUCTS_OR_RENAME_AND_ADD_HANDLER);
String empty1AddResultString = empty1AddResult.toString();
assertEquals(empty1AlignedToAddString, empty1AddResultString);
assertNotEquals(empty1UnalignedString, empty1AddResultString);
assertEquals(empty1PackedToAddString, empty1AddResultString);
assertNotEquals(empty1NonPackedString, empty1AddResultString);
}
/**
* Tests the
* {@link DataTypeConflictHandler#REPLACE_EMPTY_STRUCTS_OR_RENAME_AND_ADD_HANDLER RESORAAH}
* conflict handler to be sure that, if all else is the same, the aligned version is chosen
* over the unaligned version.
* conflict handler to be sure that, if all else is the same, the packed version is chosen
* over the non-packed version.
* <p>
* Success is the aligned version is chosen over the unaligned version.
* Success is the packed version is chosen over the non-packed version.
*/
@Test
public void testChooseNewAlignedOverExistingUnalignedWhenAllElseIsEqualForNonEmptyStructures() {
// Unaligned exists first.
StructureDataType struct1Unaligned = createPopulated(dataMgr);
Composite struct1AlignedToAdd = (Composite) struct1Unaligned.copy(dataMgr);
struct1AlignedToAdd.setInternallyAligned(true);
public void testChooseNewPackedOverExistingNonPackedWhenAllElseIsEqualForNonEmptyStructures() {
// NonPacked exists first.
StructureDataType struct1NonPacked = createPopulated(dataMgr);
Composite struct1PackedToAdd = (Composite) struct1NonPacked.copy(dataMgr);
struct1PackedToAdd.setPackingEnabled(true);
String struct1UnalignedString = struct1Unaligned.toString();
String struct1AlignedToAddString = struct1AlignedToAdd.toString();
String struct1NonPackedString = struct1NonPacked.toString();
String struct1PackedToAddString = struct1PackedToAdd.toString();
Structure struct1AddResult = (Structure) dataMgr.addDataType(struct1AlignedToAdd,
Structure struct1AddResult = (Structure) dataMgr.addDataType(struct1PackedToAdd,
DataTypeConflictHandler.REPLACE_EMPTY_STRUCTS_OR_RENAME_AND_ADD_HANDLER);
String struct1AddResultString = struct1AddResult.toString();
assertEquals(struct1AlignedToAddString, struct1AddResultString);
assertNotEquals(struct1UnalignedString, struct1AddResultString);
assertEquals(struct1PackedToAddString, struct1AddResultString);
assertNotEquals(struct1NonPackedString, struct1AddResultString);
}
/**
* Tests the
* {@link DataTypeConflictHandler#REPLACE_EMPTY_STRUCTS_OR_RENAME_AND_ADD_HANDLER RESORAAH}
* conflict handler to be sure that, if all else is the same, the new unaligned version is
* chosen over the existing unaligned version.
* conflict handler to be sure that, if all else is the same, the new non-packed version is
* chosen over the existing non-packed version.
* <p>
* Success is the new unaligned version is chosen over the existing aligned version.
* Success is the new non-packed version is chosen over the existing packed version.
*/
// TODO: consider whether we want to change the logic of the conflict handler to favor
// aligned over unaligned.
// packed over non-packed.
@Test
public void testChooseNewUnalignedOverExistingAlignedWhenAllElseIsEqualForEmptyStructures() {
public void testChooseNewNonPackedOverExistingPackedWhenAllElseIsEqualForEmptyStructures() {
// Aligned exists first.
Structure empty2Aligned = new StructureDataType(root, "empty2", 0, dataMgr);
Composite empty2UnalignedToAdd = (Composite) empty2Aligned.copy(dataMgr);
// aligning only after making unaligned copy.
empty2Aligned.setInternallyAligned(true);
// Packed exists first.
Structure empty2Packed = new StructureDataType(root, "empty2", 0, dataMgr);
Composite empty2NonPackedToAdd = (Composite) empty2Packed.copy(dataMgr);
// aligning only after making non-packed copy.
empty2Packed.setPackingEnabled(true);
String empty2AlignedString = empty2Aligned.toString();
String empty2UnalignedToAddString = empty2UnalignedToAdd.toString();
String empty2PackedString = empty2Packed.toString();
String empty2NonPackedToAddString = empty2NonPackedToAdd.toString();
Structure empty2AddResult = (Structure) dataMgr.addDataType(empty2UnalignedToAdd,
Structure empty2AddResult = (Structure) dataMgr.addDataType(empty2NonPackedToAdd,
DataTypeConflictHandler.REPLACE_EMPTY_STRUCTS_OR_RENAME_AND_ADD_HANDLER);
String empty2AddResultString = empty2AddResult.toString();
assertEquals(empty2UnalignedToAddString, empty2AddResultString);
assertNotEquals(empty2AlignedString, empty2AddResultString);
assertEquals(empty2NonPackedToAddString, empty2AddResultString);
assertNotEquals(empty2PackedString, empty2AddResultString);
}
/**
* Tests the
* {@link DataTypeConflictHandler#REPLACE_EMPTY_STRUCTS_OR_RENAME_AND_ADD_HANDLER RESORAAH}
* conflict handler to be sure that, if all else is the same, the new unaligned version is
* chosen over the existing aligned version.
* conflict handler to be sure that, if all else is the same, the new non-packed version is
* chosen over the existing packed version.
* <p>
* Success is the new unaligned version is chosen over the existing aligned version.
* Success is the new non-packed version is chosen over the existing packed version.
*/
// TODO: consider whether we want to change the logic of the conflict handler to favor
// aligned over unaligned.
// packed over non-packed.
@Test
public void testChooseNewUnalignedOverExistingAlignedWhenAllElseIsEqualForNonEmptyStructures() {
public void testChooseNewNonPackedOverExistingPackedWhenAllElseIsEqualForNonEmptyStructures() {
// Aligned exists first.
StructureDataType struct2Aligned = createPopulated(dataMgr);
Composite struct2UnalignedToAdd = (Composite) struct2Aligned.copy(dataMgr);
// aligning only after making unaligned copy.
struct2Aligned.setInternallyAligned(true);
// Packed exists first.
StructureDataType struct2Packed = createPopulated(dataMgr);
Composite struct2NonPackedToAdd = (Composite) struct2Packed.copy(dataMgr);
// aligning only after making non-packed copy.
struct2Packed.setPackingEnabled(true);
String struct2AlignedString = struct2Aligned.toString();
String struct2UnalignedToAddString = struct2UnalignedToAdd.toString();
String struct2PackedString = struct2Packed.toString();
String struct2NonPackedToAddString = struct2NonPackedToAdd.toString();
Structure struct2AddResult = (Structure) dataMgr.addDataType(struct2UnalignedToAdd,
Structure struct2AddResult = (Structure) dataMgr.addDataType(struct2NonPackedToAdd,
DataTypeConflictHandler.REPLACE_EMPTY_STRUCTS_OR_RENAME_AND_ADD_HANDLER);
String struct2AddResultString = struct2AddResult.toString();
assertEquals(struct2UnalignedToAddString, struct2AddResultString);
assertNotEquals(struct2AlignedString, struct2AddResultString);
assertEquals(struct2NonPackedToAddString, struct2AddResultString);
assertNotEquals(struct2PackedString, struct2AddResultString);
}
/**
* Tests the
* {@link DataTypeConflictHandler#REPLACE_EMPTY_STRUCTS_OR_RENAME_AND_ADD_HANDLER RESORAAH}
* conflict handler to be sure that, if all else is the same, the aligned version is chosen
* over the unaligned version.
* conflict handler to be sure that, if all else is the same, the packed version is chosen
* over the non-packed version.
* <p>
* Success is the aligned version is chosen over the unaligned version.
* Success is the packed version is chosen over the non-packed version.
*/
@Test
public void testResolveDataTypeNonStructConflict() throws Exception {

View file

@ -61,7 +61,7 @@ public class DataTypeTest extends AbstractGhidraHeadedIntegrationTest {
Structure structA = new StructureDataType("structA", 0);
structA.setCategoryPath(new CategoryPath("/catA"));
structA.setInternallyAligned(true);
structA.setPackingEnabled(true);
Pointer p = new PointerDataType(structA);

View file

@ -39,7 +39,7 @@ public class DataTypeParserTest extends AbstractEditorTest {
try {
DataTypeManager dataTypeManager = cat.getDataTypeManager();
if (dt.getDataTypeManager() != dataTypeManager) {
dt = (Union) dt.clone(dataTypeManager);
dt = dt.clone(dataTypeManager);
}
CategoryPath categoryPath = cat.getCategoryPath();
if (!dt.getCategoryPath().equals(categoryPath)) {

View file

@ -20,6 +20,7 @@ package ghidra.program.database.data;
import static org.junit.Assert.*;
import org.apache.commons.compress.utils.Sets;
import org.junit.*;
import generic.test.AbstractGTest;
@ -45,7 +46,7 @@ public class StructureDataTypeTest extends AbstractGTest {
// transition default little-endian structure to big-endian
DataTypeManager beDtm = new MyBigEndianDataTypeManager();
struct = (Structure) struct.clone(beDtm);
struct = struct.clone(beDtm);
}
private Structure createStructure(String name, int length) {
@ -420,7 +421,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
" 1 word 2 null \"Comment2\"\n" +
@ -438,7 +439,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
" 1 word 2 null \"Comment2\"\n" +
@ -461,7 +462,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
" 1 word 2 null \"Comment2\"\n" +
@ -481,7 +482,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
" 1 word 2 null \"Comment2\"\n" +
@ -506,7 +507,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" +
@ -525,7 +526,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" +
@ -545,7 +546,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" +
@ -573,7 +574,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" +
@ -607,7 +608,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" +
@ -626,7 +627,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" +
@ -646,7 +647,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" +
@ -665,7 +666,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" +
@ -693,7 +694,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" +
@ -894,6 +895,79 @@ public class StructureDataTypeTest extends AbstractGTest {
assertEquals(7, comps[3].getOrdinal());
}
@Test
public void testDeleteMany() {
struct.growStructure(20);
struct.insertAtOffset(12, WordDataType.dataType, -1, "A", null);
struct.insertAtOffset(16, WordDataType.dataType, -1, "B", null);
assertEquals(32, struct.getLength());
assertEquals(26, struct.getNumComponents());
assertEquals(6, struct.getNumDefinedComponents());
struct.delete(Sets.newHashSet(1, 4, 5));
assertEquals(28, struct.getLength());
assertEquals(23, struct.getNumComponents());
assertEquals(5, struct.getNumDefinedComponents());
DataTypeComponent[] comps = struct.getDefinedComponents();
assertEquals(WordDataType.class, comps[3].getDataType().getClass());
assertEquals(5, comps[3].getOrdinal());
assertEquals(8, comps[3].getOffset());
}
@Test
public void testDeleteManyBF() throws InvalidDataTypeException {
struct.insertBitFieldAt(2, 4, 0, IntegerDataType.dataType, 3, "bf1", "bf1Comment");
struct.insertBitFieldAt(2, 4, 3, IntegerDataType.dataType, 3, "bf2", "bf2Comment");
struct.insertBitFieldAt(2, 4, 6, IntegerDataType.dataType, 15, "bf3", "bf3Comment");
struct.insertBitFieldAt(2, 4, 21, IntegerDataType.dataType, 11, "bf4", "bf4Comment");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" +
" 2 int:3(0) 1 bf1 \"bf1Comment\"\n" +
" 2 int:3(3) 1 bf2 \"bf2Comment\"\n" +
" 2 int:15(6) 3 bf3 \"bf3Comment\"\n" +
" 4 int:11(5) 2 bf4 \"bf4Comment\"\n" +
" 6 word 2 null \"Comment2\"\n" +
" 8 dword 4 field3 \"\"\n" +
" 12 byte 1 field4 \"Comment4\"\n" +
"}\n" +
"Size = 13 Actual Alignment = 1", struct);
//@formatter:on
struct.delete(Sets.newHashSet(1, 2, 3, 4, 5, 6));
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" +
// " 2 undefined 1 null \"\"\n" +
// " 3 undefined 1 null \"\"\n" +
// " 4 undefined 1 null \"\"\n" +
" 5 dword 4 field3 \"\"\n" +
" 9 byte 1 field4 \"Comment4\"\n" +
"}\n" +
"Size = 10 Actual Alignment = 1", struct);
//@formatter:on
assertEquals(10, struct.getLength());
assertEquals(7, struct.getNumComponents());
assertEquals(3, struct.getNumDefinedComponents());
DataTypeComponent[] comps = struct.getDefinedComponents();
assertEquals(DWordDataType.class, comps[1].getDataType().getClass());
assertEquals(5, comps[1].getOffset());
}
@Test
public void testDelete() {
struct.delete(1);
@ -904,6 +978,144 @@ public class StructureDataTypeTest extends AbstractGTest {
assertEquals(1, comps[1].getOffset());
}
@Test
public void testDeleteBF() throws InvalidDataTypeException {
struct.insertBitFieldAt(2, 4, 0, IntegerDataType.dataType, 3, "bf1", "bf1Comment");
struct.insertBitFieldAt(2, 4, 3, IntegerDataType.dataType, 3, "bf2", "bf2Comment");
struct.insertBitFieldAt(2, 4, 6, IntegerDataType.dataType, 15, "bf3", "bf3Comment");
struct.insertBitFieldAt(2, 4, 21, IntegerDataType.dataType, 11, "bf4", "bf4Comment");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" +
" 2 int:3(0) 1 bf1 \"bf1Comment\"\n" +
" 2 int:3(3) 1 bf2 \"bf2Comment\"\n" +
" 2 int:15(6) 3 bf3 \"bf3Comment\"\n" +
" 4 int:11(5) 2 bf4 \"bf4Comment\"\n" +
" 6 word 2 null \"Comment2\"\n" +
" 8 dword 4 field3 \"\"\n" +
" 12 byte 1 field4 \"Comment4\"\n" +
"}\n" +
"Size = 13 Actual Alignment = 1", struct);
//@formatter:on
struct.delete(6);
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" +
" 2 int:3(0) 1 bf1 \"bf1Comment\"\n" +
" 2 int:3(3) 1 bf2 \"bf2Comment\"\n" +
" 2 int:15(6) 3 bf3 \"bf3Comment\"\n" +
" 4 int:11(5) 2 bf4 \"bf4Comment\"\n" +
" 6 dword 4 field3 \"\"\n" +
" 10 byte 1 field4 \"Comment4\"\n" +
"}\n" +
"Size = 11 Actual Alignment = 1", struct);
//@formatter:on
struct.delete(3);
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" +
" 2 int:3(0) 1 bf1 \"bf1Comment\"\n" +
" 2 int:15(6) 3 bf3 \"bf3Comment\"\n" +
" 4 int:11(5) 2 bf4 \"bf4Comment\"\n" +
" 6 dword 4 field3 \"\"\n" +
" 10 byte 1 field4 \"Comment4\"\n" +
"}\n" +
"Size = 11 Actual Alignment = 1", struct);
//@formatter:on
struct.delete(3);
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" +
" 2 int:3(0) 1 bf1 \"bf1Comment\"\n" +
// " 3 undefined 1 null \"\"\n" +
" 4 int:11(5) 2 bf4 \"bf4Comment\"\n" +
" 6 dword 4 field3 \"\"\n" +
" 10 byte 1 field4 \"Comment4\"\n" +
"}\n" +
"Size = 11 Actual Alignment = 1", struct);
//@formatter:on
struct.delete(4);
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" +
" 2 int:3(0) 1 bf1 \"bf1Comment\"\n" +
// " 3 undefined 1 null \"\"\n" +
// " 4 undefined 1 null \"\"\n" +
// " 5 undefined 1 null \"\"\n" +
" 6 dword 4 field3 \"\"\n" +
" 10 byte 1 field4 \"Comment4\"\n" +
"}\n" +
"Size = 11 Actual Alignment = 1", struct);
//@formatter:on
struct.delete(2);
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" +
// " 2 undefined 1 null \"\"\n" +
// " 3 undefined 1 null \"\"\n" +
// " 4 undefined 1 null \"\"\n" +
// " 5 undefined 1 null \"\"\n" +
" 6 dword 4 field3 \"\"\n" +
" 10 byte 1 field4 \"Comment4\"\n" +
"}\n" +
"Size = 11 Actual Alignment = 1", struct);
//@formatter:on
struct.delete(2);
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" +
// " 2 undefined 1 null \"\"\n" +
// " 3 undefined 1 null \"\"\n" +
// " 4 undefined 1 null \"\"\n" +
" 5 dword 4 field3 \"\"\n" +
" 9 byte 1 field4 \"Comment4\"\n" +
"}\n" +
"Size = 10 Actual Alignment = 1", struct);
//@formatter:on
assertEquals(10, struct.getLength());
assertEquals(7, struct.getNumComponents());
assertEquals(3, struct.getNumDefinedComponents());
DataTypeComponent[] comps = struct.getDefinedComponents();
assertEquals(DWordDataType.class, comps[1].getDataType().getClass());
assertEquals(5, comps[1].getOffset());
}
@Test
public void testDeleteAtOffset() {
struct.deleteAtOffset(2);
@ -936,15 +1148,51 @@ public class StructureDataTypeTest extends AbstractGTest {
@Test
public void testDeleteAll() {
struct.setPackingEnabled(true); // enable packing for struct
assertEquals(12, struct.getLength());
Structure s = new StructureDataType("test1", 0);
s.add(new ByteDataType());
s.add(new FloatDataType());
assertEquals(1, s.getAlignment());
assertEquals(5, s.getLength());
struct.add(s);
assertEquals(16, struct.getLength());
s.deleteAll();
assertEquals(1, s.getLength());
assertTrue(s.isNotYetDefined());
assertTrue(s.isZeroLength());
assertEquals(0, s.getNumComponents());
assertEquals(12, struct.getLength());
}
@Test
public void testAlignmentAndPacking() {
struct.setPackingEnabled(true); // enable packing for struct
assertEquals(12, struct.getLength());
Structure s = new StructureDataType("test1", 0);
s.add(new ByteDataType());
s.add(new FloatDataType());
assertEquals(1, s.getAlignment());
assertEquals(5, s.getLength());
struct.add(s);
assertEquals(16, struct.getLength());
s.setExplicitMinimumAlignment(8); // does not force packing (s length unaffected)
assertEquals(5, s.getLength());
assertFalse(s.isNotYetDefined());
assertFalse(s.isZeroLength());
assertEquals(2, s.getNumComponents());
assertEquals(24, struct.getLength());
}
@Test
@ -1129,9 +1377,9 @@ public class StructureDataTypeTest extends AbstractGTest {
@Test
public void testReplaceWith2() throws InvalidDataTypeException {
// NOTE: unaligned bitfields should remain unchanged when
// NOTE: pack(disabled) bitfields should remain unchanged when
// transitioning endianess even though it makes little sense.
// Unaligned structures are not intended to be portable!
// pack(disabled) structures are not intended to be portable!
TypeDef td = new TypedefDataType("Foo", IntegerDataType.dataType);
@ -1144,7 +1392,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" +
"pack(disabled)\n" +
"Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
" 1 word 2 null \"Comment2\"\n" +
@ -1169,7 +1417,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/bigStruct\n" +
"Unaligned\n" +
"pack(disabled)\n" +
"Structure bigStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
" 1 word 2 null \"Comment2\"\n" +

View file

@ -22,6 +22,8 @@ import static org.junit.Assert.*;
import org.junit.*;
import com.google.common.collect.Sets;
import generic.test.AbstractGTest;
import ghidra.program.model.data.*;
@ -152,7 +154,7 @@ public class UnionDataTypeTest extends AbstractGTest {
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestUnion\n" +
"Unaligned\n" +
"pack(disabled)\n" +
"Union TestUnion {\n" +
" 0 short 2 null \"\"\n" +
" 0 int:2(0) 1 bf1 \"bf1Comment\"\n" +
@ -170,11 +172,11 @@ public class UnionDataTypeTest extends AbstractGTest {
}
union.insertBitField(0, IntegerDataType.dataType, 2, "bf1", "bf1Comment");
union.insert(0, ShortDataType.dataType);
union.setInternallyAligned(true);
union.setPackingEnabled(true);
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestUnion\n" +
"Aligned\n" +
"pack()\n" +
"Union TestUnion {\n" +
" 0 short 2 null \"\"\n" +
" 0 int:2(0) 1 bf1 \"bf1Comment\"\n" +
@ -191,7 +193,7 @@ public class UnionDataTypeTest extends AbstractGTest {
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestUnion\n" +
"Unaligned\n" +
"pack(disabled)\n" +
"Union TestUnion {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
" 0 word 2 null \"Comment2\"\n" +
@ -214,7 +216,7 @@ public class UnionDataTypeTest extends AbstractGTest {
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestUnion\n" +
"Unaligned\n" +
"pack(disabled)\n" +
"Union TestUnion {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
" 0 word 2 null \"Comment2\"\n" +
@ -261,6 +263,42 @@ public class UnionDataTypeTest extends AbstractGTest {
assertEquals(2, union.getLength());
}
@Test
public void testDeleteMany() throws Exception {
Structure struct = createStructure("struct_1", 0);
struct.add(new ByteDataType());
struct.add(new StringDataType(), 10);
union.add(struct);
assertEquals(11, union.getLength());
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestUnion\n" +
"pack(disabled)\n" +
"Union TestUnion {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
" 0 word 2 null \"Comment2\"\n" +
" 0 dword 4 field3 \"\"\n" +
" 0 byte 1 field4 \"Comment4\"\n" +
" 0 struct_1 11 null \"\"\n" +
"}\n" +
"Size = 11 Actual Alignment = 1", union);
//@formatter:on
union.delete(Sets.newHashSet(2, 4));
assertEquals(2, union.getLength());
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestUnion\n" +
"pack(disabled)\n" +
"Union TestUnion {\n" +
" 0 byte 1 field1 \"Comment1\"\n" +
" 0 word 2 null \"Comment2\"\n" +
" 0 byte 1 field4 \"Comment4\"\n" +
"}\n" +
"Size = 2 Actual Alignment = 1", union);
//@formatter:on
}
@Test
public void testIsPartOf() {
Structure struct = createStructure("struct_1", 0);

View file

@ -15,7 +15,7 @@
*/
package ghidra.program.model.data;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import java.io.FileNotFoundException;
import java.io.InputStream;
@ -36,7 +36,7 @@ public abstract class AbstractCompositeImplBitFieldTest extends AbstractGTest {
DataTypeManager dataMgr = getDataTypeManager();
if (dataMgr.getDataTypeCount(false) != 0) {
Msg.info(this, "Using previously parsed data types");
// Msg.info(this, "Using previously parsed data types");
return; // already have types
}

View file

@ -40,7 +40,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("A1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/A1\n" +
"Aligned\n" +
"pack()\n" +
"Structure A1 {\n" +
" 0 char[5] 5 a \"\"\n" +
" 8 int:3(0) 1 b \"\"\n" +
@ -57,7 +57,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("A2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/A2\n" +
"Aligned\n" +
"pack()\n" +
"Structure A2 {\n" +
" 0 oddStruct 5 a \"\"\n" +
" 8 int:3(0) 1 b \"\"\n" +
@ -74,7 +74,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("A3");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/A3\n" +
"Aligned\n" +
"pack()\n" +
"Structure A3 {\n" +
" 0 char[5] 5 a \"\"\n" +
" 8 int:3(0) 1 b \"\"\n" +
@ -97,7 +97,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("B1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B1\n" +
"Aligned\n" +
"pack()\n" +
"Structure B1 {\n" +
" 0 char 1 a \"\"\n" +
" 2 ushort:6(0) 1 b \"\"\n" +
@ -113,7 +113,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("B1flex");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B1flex\n" +
"Aligned\n" +
"pack()\n" +
"Structure B1flex {\n" +
" 0 char 1 a \"\"\n" +
" 2 ushort:6(0) 1 b \"\"\n" +
@ -130,7 +130,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("B2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B2\n" +
"Aligned\n" +
"pack()\n" +
"Structure B2 {\n" +
" 0 char 1 a \"\"\n" +
" 2 ushort:6(0) 1 b \"\"\n" +
@ -146,7 +146,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("B3");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B3\n" +
"Aligned\n" +
"pack()\n" +
"Structure B3 {\n" +
" 0 char 1 a \"\"\n" +
" 2 ushort:6(0) 1 b \"\"\n" +
@ -163,7 +163,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z1\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z1 {\n" +
" 0 char 1 a \"\"\n" +
" 2 int:0(0) 1 \"\"\n" +
@ -180,7 +180,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("Z2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z2\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z2 {\n" +
" 0 char 1 a \"\"\n" +
" 2 ushort:6(0) 1 b \"\"\n" +
@ -197,7 +197,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("Z3");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z3\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z3 {\n" +
" 0 char 1 a \"\"\n" +
" 2 ushort:6(0) 1 b \"\"\n" +
@ -214,7 +214,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("Z4");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z4\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z4 {\n" +
" 0 char 1 a \"\"\n" +
" 2 ushort:6(0) 1 b \"\"\n" +
@ -231,7 +231,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("Z5");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z5\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z5 {\n" +
" 0 char 1 a \"\"\n" +
" 8 int:0(0) 1 \"\"\n" +
@ -248,7 +248,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("Z6");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z6\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z6 {\n" +
" 0 char 1 a \"\"\n" +
" 8 int:0(0) 1 \"\"\n" +
@ -268,7 +268,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("B1p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B1p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure B1p1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -284,7 +284,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("B2p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B2p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure B2p1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -300,7 +300,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("B3p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B3p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure B3p1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -316,7 +316,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("Z1p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z1p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure Z1p1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 int:0(0) 1 \"\"\n" +
@ -333,7 +333,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("Z2p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z2p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure Z2p1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -350,7 +350,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("Z3p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z3p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure Z3p1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -367,7 +367,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("Z3p1T");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z3p1T\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z3p1T {\n" +
" 0 char 1 a \"\"\n" +
" 1 Z3p1 7 z3p1 \"\"\n" +
@ -381,7 +381,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("Z4p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z4p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure Z4p1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -398,7 +398,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("B1p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B1p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure B1p2 {\n" +
" 0 char 1 a \"\"\n" +
" 2 ushort:6(0) 1 b \"\"\n" +
@ -414,7 +414,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("B2p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B2p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure B2p2 {\n" +
" 0 char 1 a \"\"\n" +
" 2 ushort:6(0) 1 b \"\"\n" +
@ -430,7 +430,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("B3p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B3p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure B3p2 {\n" +
" 0 char 1 a \"\"\n" +
" 2 ushort:6(0) 1 b \"\"\n" +
@ -446,7 +446,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("B4p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B4p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure B4p2 {\n" +
" 0 char 1 a \"\"\n" +
" 2 ushort:6(0) 1 b \"\"\n" +
@ -463,7 +463,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("Z1p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z1p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure Z1p2 {\n" +
" 0 char 1 a \"\"\n" +
" 2 int:0(0) 1 \"\"\n" +
@ -480,7 +480,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("Z1p2x");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z1p2x\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure Z1p2x {\n" +
" 0 char 1 a \"\"\n" +
" 2 int:0(0) 1 \"\"\n" +
@ -515,7 +515,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("Z2p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z2p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure Z2p2 {\n" +
" 0 char 1 a \"\"\n" +
" 2 ushort:6(0) 1 b \"\"\n" +
@ -532,7 +532,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("Z3p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z3p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure Z3p2 {\n" +
" 0 char 1 a \"\"\n" +
" 2 ushort:6(0) 1 b \"\"\n" +
@ -549,7 +549,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("Z4p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z4p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure Z4p2 {\n" +
" 0 char 1 a \"\"\n" +
" 2 ushort:6(0) 1 b \"\"\n" +
@ -566,7 +566,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("Z5p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z5p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure Z5p2 {\n" +
" 0 char 1 a \"\"\n" +
" 2 ushort:12(0) 2 b \"\"\n" +
@ -583,7 +583,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("x1p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x1p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure x1p2 {\n" +
" 0 char 1 a \"\"\n" +
"}\n" +
@ -596,7 +596,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("x2p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x2p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure x2p2 {\n" +
" 0 char 1 a \"\"\n" +
" 2 int:27(0) 4 b \"\"\n" +
@ -610,7 +610,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("x3p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x3p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure x3p2 {\n" +
" 0 char 1 a \"\"\n" +
" 2 short:0(0) 1 \"\"\n" +
@ -625,7 +625,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("x4p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x4p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure x4p2 {\n" +
" 0 char 1 a \"\"\n" +
" 2 int:27(0) 4 b \"\"\n" +
@ -640,7 +640,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("Z5p4");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z5p4\n" +
"Aligned pack(4)\n" +
"pack(4)\n" +
"Structure Z5p4 {\n" +
" 0 char 1 a \"\"\n" +
" 2 ushort:12(0) 2 b \"\"\n" +
@ -657,7 +657,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("x1p4");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x1p4\n" +
"Aligned pack(4)\n" +
"pack(4)\n" +
"Structure x1p4 {\n" +
" 0 char 1 a \"\"\n" +
"}\n" +
@ -670,7 +670,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("x2p4");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x2p4\n" +
"Aligned pack(4)\n" +
"pack(4)\n" +
"Structure x2p4 {\n" +
" 0 char 1 a \"\"\n" +
" 4 int:27(0) 4 b \"\"\n" +
@ -684,7 +684,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("x3p4");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x3p4\n" +
"Aligned pack(4)\n" +
"pack(4)\n" +
"Structure x3p4 {\n" +
" 0 char 1 a \"\"\n" +
" 4 short:0(0) 1 \"\"\n" +
@ -699,7 +699,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("x4p4");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x4p4\n" +
"Aligned pack(4)\n" +
"pack(4)\n" +
"Structure x4p4 {\n" +
" 0 char 1 a \"\"\n" +
" 4 int:27(0) 4 b \"\"\n" +
@ -714,7 +714,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("T1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/T1\n" +
"Aligned\n" +
"pack()\n" +
"Structure T1 {\n" +
" 0 charTypedef 1 a \"\"\n" +
" 4 myEnum:3(0) 1 b \"\"\n" +
@ -730,7 +730,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("T2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/T2\n" +
"Aligned\n" +
"pack()\n" +
"Structure T2 {\n" +
" 0 charTypedef 1 a \"\"\n" +
" 4 intTypedef:17(0) 3 b \"\"\n" +
@ -746,7 +746,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("S1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/S1\n" +
"Aligned\n" +
"pack()\n" +
"Structure S1 {\n" +
" 0 B1 12 b1 \"\"\n" +
" 12 B2 8 b2 \"\"\n" +
@ -763,7 +763,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("S1p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/S1p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure S1p1 {\n" +
" 0 B1 12 b1 \"\"\n" +
" 12 B2 8 b2 \"\"\n" +
@ -780,7 +780,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("S2p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/S2p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure S2p1 {\n" +
" 0 B1p1 9 b1p1 \"\"\n" +
" 9 B2p1 7 b2p1 \"\"\n" +
@ -797,7 +797,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("S1p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/S1p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure S1p2 {\n" +
" 0 B1 12 b1 \"\"\n" +
" 12 B2 8 b2 \"\"\n" +
@ -814,7 +814,7 @@ public class MSVCStructureImplBitFieldTest extends AbstractCompositeImplBitField
Structure struct = getStructure("S2p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/S2p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure S2p2 {\n" +
" 0 B1p2 10 b1p2 \"\"\n" +
" 10 B2p2 8 b2p2 \"\"\n" +

View file

@ -38,7 +38,7 @@ public class MSVCUnionImplBitFieldTest extends AbstractCompositeImplBitFieldTest
Union struct = getUnion("U1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/U1\n" +
"Aligned\n" +
"pack()\n" +
"Union U1 {\n" +
" 0 int:4(0) 1 a \"\"\n" +
" 0 int:2(0) 1 b \"\"\n" +
@ -52,7 +52,7 @@ public class MSVCUnionImplBitFieldTest extends AbstractCompositeImplBitFieldTest
Union struct = getUnion("U1z");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/U1z\n" +
"Aligned\n" +
"pack()\n" +
"Union U1z {\n" +
" 0 int:4(0) 1 a \"\"\n" +
" 0 longlong:0(0) 1 \"\"\n" +
@ -67,7 +67,7 @@ public class MSVCUnionImplBitFieldTest extends AbstractCompositeImplBitFieldTest
Union struct = getUnion("U1p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/U1p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Union U1p1 {\n" +
" 0 int:4(0) 1 a \"\"\n" +
" 0 int:2(0) 1 b \"\"\n" +
@ -81,7 +81,7 @@ public class MSVCUnionImplBitFieldTest extends AbstractCompositeImplBitFieldTest
Union struct = getUnion("U1p1z");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/U1p1z\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Union U1p1z {\n" +
" 0 int:4(0) 1 a \"\"\n" +
" 0 longlong:0(0) 1 \"\"\n" +
@ -96,7 +96,7 @@ public class MSVCUnionImplBitFieldTest extends AbstractCompositeImplBitFieldTest
Union struct = getUnion("U1p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/U1p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Union U1p2 {\n" +
" 0 int:4(0) 1 a \"\"\n" +
" 0 int:2(0) 1 b \"\"\n" +

View file

@ -42,7 +42,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("A1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/A1\n" +
"Aligned\n" +
"pack()\n" +
"Structure A1 {\n" +
" 0 char[5] 5 a \"\"\n" +
" 5 int:3(5) 1 b \"\"\n" +
@ -59,7 +59,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("A2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/A2\n" +
"Aligned\n" +
"pack()\n" +
"Structure A2 {\n" +
" 0 oddStruct 5 a \"\"\n" +
" 5 int:3(5) 1 b \"\"\n" +
@ -76,7 +76,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("A3");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/A3\n" +
"Aligned\n" +
"pack()\n" +
"Structure A3 {\n" +
" 0 char[5] 5 a \"\"\n" +
" 5 int:3(5) 1 b \"\"\n" +
@ -99,7 +99,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("B1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B1\n" +
"Aligned\n" +
"pack()\n" +
"Structure B1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(2) 1 b \"\"\n" +
@ -115,7 +115,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("B1flex");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B1flex\n" +
"Aligned\n" +
"pack()\n" +
"Structure B1flex {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(2) 1 b \"\"\n" +
@ -132,7 +132,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("B2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B2\n" +
"Aligned\n" +
"pack()\n" +
"Structure B2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(2) 1 b \"\"\n" +
@ -148,7 +148,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("B3");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B3\n" +
"Aligned\n" +
"pack()\n" +
"Structure B3 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(2) 1 b \"\"\n" +
@ -165,7 +165,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z1\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z1 {\n" +
" 0 char 1 a \"\"\n" +
" 4 int:0(7) 1 \"\"\n" +
@ -182,7 +182,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("Z2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z2\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(2) 1 b \"\"\n" +
@ -199,7 +199,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("Z3");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z3\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z3 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(2) 1 b \"\"\n" +
@ -216,7 +216,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("Z4");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z4\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z4 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(2) 1 b \"\"\n" +
@ -233,7 +233,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("Z5");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z5\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z5 {\n" +
" 0 char 1 a \"\"\n" +
" 4 int:0(7) 1 \"\"\n" +
@ -250,7 +250,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("Z6");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z6\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z6 {\n" +
" 0 char 1 a \"\"\n" +
" 4 int:0(7) 1 \"\"\n" +
@ -270,7 +270,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("B1p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B1p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure B1p1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(2) 1 b \"\"\n" +
@ -286,7 +286,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("B2p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B2p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure B2p1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(2) 1 b \"\"\n" +
@ -302,7 +302,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("B3p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B3p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure B3p1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(2) 1 b \"\"\n" +
@ -318,7 +318,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("Z1p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z1p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure Z1p1 {\n" +
" 0 char 1 a \"\"\n" +
" 4 int:0(7) 1 \"\"\n" +
@ -335,7 +335,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("Z2p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z2p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure Z2p1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(2) 1 b \"\"\n" +
@ -352,7 +352,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("Z3p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z3p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure Z3p1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(2) 1 b \"\"\n" +
@ -369,7 +369,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("Z3p1T");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z3p1T\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z3p1T {\n" +
" 0 char 1 a \"\"\n" +
" 1 Z3p1 8 z3p1 \"\"\n" +
@ -383,7 +383,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("Z4p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z4p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure Z4p1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(2) 1 b \"\"\n" +
@ -400,7 +400,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("B1p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B1p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure B1p2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(2) 1 b \"\"\n" +
@ -416,7 +416,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("B2p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B2p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure B2p2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(2) 1 b \"\"\n" +
@ -432,7 +432,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("B3p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B3p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure B3p2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(2) 1 b \"\"\n" +
@ -448,7 +448,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("B4p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B4p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure B4p2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(2) 1 b \"\"\n" +
@ -465,7 +465,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("Z1p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z1p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure Z1p2 {\n" +
" 0 char 1 a \"\"\n" +
" 4 int:0(7) 1 \"\"\n" +
@ -482,7 +482,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("Z1p2x");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z1p2x\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure Z1p2x {\n" +
" 0 char 1 a \"\"\n" +
" 4 int:0(7) 1 \"\"\n" +
@ -517,7 +517,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("Z2p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z2p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure Z2p2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(2) 1 b \"\"\n" +
@ -534,7 +534,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("Z3p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z3p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure Z3p2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(2) 1 b \"\"\n" +
@ -551,7 +551,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("Z4p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z4p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure Z4p2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(2) 1 b \"\"\n" +
@ -568,7 +568,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("Z5p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z5p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure Z5p2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:12(4) 2 b \"\"\n" +
@ -585,7 +585,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("x1p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x1p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure x1p2 {\n" +
" 0 char 1 a \"\"\n" +
"}\n" +
@ -598,7 +598,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("x2p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x2p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure x2p2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 int:27(5) 4 b \"\"\n" +
@ -612,7 +612,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("x3p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x3p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure x3p2 {\n" +
" 0 char 1 a \"\"\n" +
" 2 short:0(7) 1 \"\"\n" +
@ -627,7 +627,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("x4p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x4p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure x4p2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 int:27(5) 4 b \"\"\n" +
@ -642,7 +642,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("Z5p4");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z5p4\n" +
"Aligned pack(4)\n" +
"pack(4)\n" +
"Structure Z5p4 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:12(4) 2 b \"\"\n" +
@ -659,7 +659,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("x1p4");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x1p4\n" +
"Aligned pack(4)\n" +
"pack(4)\n" +
"Structure x1p4 {\n" +
" 0 char 1 a \"\"\n" +
"}\n" +
@ -672,7 +672,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("x2p4");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x2p4\n" +
"Aligned pack(4)\n" +
"pack(4)\n" +
"Structure x2p4 {\n" +
" 0 char 1 a \"\"\n" +
" 1 int:27(5) 4 b \"\"\n" +
@ -686,7 +686,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("x3p4");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x3p4\n" +
"Aligned pack(4)\n" +
"pack(4)\n" +
"Structure x3p4 {\n" +
" 0 char 1 a \"\"\n" +
" 2 short:0(7) 1 \"\"\n" +
@ -701,7 +701,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("x4p4");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x4p4\n" +
"Aligned pack(4)\n" +
"pack(4)\n" +
"Structure x4p4 {\n" +
" 0 char 1 a \"\"\n" +
" 1 int:27(5) 4 b \"\"\n" +
@ -716,7 +716,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("T1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/T1\n" +
"Aligned\n" +
"pack()\n" +
"Structure T1 {\n" +
" 0 charTypedef 1 a \"\"\n" +
" 1 myEnum:3(5) 1 b \"\"\n" +
@ -732,7 +732,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("T2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/T2\n" +
"Aligned\n" +
"pack()\n" +
"Structure T2 {\n" +
" 0 charTypedef 1 a \"\"\n" +
" 1 intTypedef:17(7) 3 b \"\"\n" +
@ -748,7 +748,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("S1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/S1\n" +
"Aligned\n" +
"pack()\n" +
"Structure S1 {\n" +
" 0 B1 4 b1 \"\"\n" +
" 4 B2 4 b2 \"\"\n" +
@ -765,7 +765,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("S1p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/S1p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure S1p1 {\n" +
" 0 B1 4 b1 \"\"\n" +
" 4 B2 4 b2 \"\"\n" +
@ -782,7 +782,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("S2p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/S2p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure S2p1 {\n" +
" 0 B1p1 4 b1p1 \"\"\n" +
" 4 B2p1 4 b2p1 \"\"\n" +
@ -799,7 +799,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("S1p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/S1p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure S1p2 {\n" +
" 0 B1 4 b1 \"\"\n" +
" 4 B2 4 b2 \"\"\n" +
@ -816,7 +816,7 @@ public class StructureImplBigEndianBitFieldTest extends AbstractCompositeImplBit
Structure struct = getStructure("S2p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/S2p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure S2p2 {\n" +
" 0 B1p2 4 b1p2 \"\"\n" +
" 4 B2p2 4 b2p2 \"\"\n" +

View file

@ -73,7 +73,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("A1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/A1\n" +
"Aligned\n" +
"pack()\n" +
"Structure A1 {\n" +
" 0 char[5] 5 a \"\"\n" +
" 5 int:3(0) 1 b \"\"\n" +
@ -90,7 +90,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("A2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/A2\n" +
"Aligned\n" +
"pack()\n" +
"Structure A2 {\n" +
" 0 oddStruct 5 a \"\"\n" +
" 5 int:3(0) 1 b \"\"\n" +
@ -107,7 +107,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("A3");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/A3\n" +
"Aligned\n" +
"pack()\n" +
"Structure A3 {\n" +
" 0 char[5] 5 a \"\"\n" +
" 5 int:3(0) 1 b \"\"\n" +
@ -130,7 +130,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("B1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B1\n" +
"Aligned\n" +
"pack()\n" +
"Structure B1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -146,7 +146,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("B1flex");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B1flex\n" +
"Aligned\n" +
"pack()\n" +
"Structure B1flex {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -163,7 +163,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("B2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B2\n" +
"Aligned\n" +
"pack()\n" +
"Structure B2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -179,7 +179,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("B3");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B3\n" +
"Aligned\n" +
"pack()\n" +
"Structure B3 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" + // gcc groups with previous non-bitfield
@ -196,7 +196,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z1\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z1 {\n" +
" 0 char 1 a \"\"\n" +
" 4 int:0(0) 1 \"\"\n" +
@ -213,7 +213,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("Z2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z2\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -230,7 +230,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("Z3");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z3\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z3 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -247,7 +247,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("Z4");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z4\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z4 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -264,7 +264,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("Z5");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z5\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z5 {\n" +
" 0 char 1 a \"\"\n" +
" 4 int:0(0) 1 \"\"\n" +
@ -281,7 +281,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("Z6");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z6\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z6 {\n" +
" 0 char 1 a \"\"\n" +
" 4 int:0(0) 1 \"\"\n" +
@ -301,7 +301,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("B1p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B1p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure B1p1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -317,7 +317,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("B2p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B2p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure B2p1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -333,7 +333,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("B3p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B3p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure B3p1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -349,7 +349,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("Z1p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z1p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure Z1p1 {\n" +
" 0 char 1 a \"\"\n" +
" 4 int:0(0) 1 \"\"\n" +
@ -366,7 +366,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("Z2p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z2p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure Z2p1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -383,7 +383,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("Z3p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z3p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure Z3p1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -400,7 +400,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("Z3p1T");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z3p1T\n" +
"Aligned\n" +
"pack()\n" +
"Structure Z3p1T {\n" +
" 0 char 1 a \"\"\n" +
" 1 Z3p1 8 z3p1 \"\"\n" +
@ -414,7 +414,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("Z4p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z4p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure Z4p1 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -431,7 +431,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("B1p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B1p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure B1p2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -447,7 +447,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("B2p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B2p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure B2p2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -463,7 +463,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("B3p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B3p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure B3p2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -479,7 +479,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("B4p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/B4p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure B4p2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -496,7 +496,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("Z1p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z1p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure Z1p2 {\n" +
" 0 char 1 a \"\"\n" +
" 4 int:0(0) 1 \"\"\n" +
@ -513,7 +513,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("Z1p2x");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z1p2x\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure Z1p2x {\n" +
" 0 char 1 a \"\"\n" +
" 4 int:0(0) 1 \"\"\n" +
@ -548,7 +548,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("Z2p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z2p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure Z2p2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -565,7 +565,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("Z3p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z3p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure Z3p2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -582,7 +582,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("Z4p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z4p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure Z4p2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:6(0) 1 b \"\"\n" +
@ -599,7 +599,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("Z5p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z5p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure Z5p2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:12(0) 2 b \"\"\n" +
@ -616,7 +616,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("x1p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x1p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure x1p2 {\n" +
" 0 char 1 a \"\"\n" +
"}\n" +
@ -629,7 +629,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("x2p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x2p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure x2p2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 int:27(0) 4 b \"\"\n" +
@ -643,7 +643,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("x3p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x3p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure x3p2 {\n" +
" 0 char 1 a \"\"\n" +
" 2 short:0(0) 1 \"\"\n" +
@ -658,7 +658,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("x4p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x4p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure x4p2 {\n" +
" 0 char 1 a \"\"\n" +
" 1 int:27(0) 4 b \"\"\n" +
@ -673,7 +673,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("Z5p4");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/Z5p4\n" +
"Aligned pack(4)\n" +
"pack(4)\n" +
"Structure Z5p4 {\n" +
" 0 char 1 a \"\"\n" +
" 1 ushort:12(0) 2 b \"\"\n" +
@ -690,7 +690,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("x1p4");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x1p4\n" +
"Aligned pack(4)\n" +
"pack(4)\n" +
"Structure x1p4 {\n" +
" 0 char 1 a \"\"\n" +
"}\n" +
@ -703,7 +703,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("x2p4");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x2p4\n" +
"Aligned pack(4)\n" +
"pack(4)\n" +
"Structure x2p4 {\n" +
" 0 char 1 a \"\"\n" +
" 1 int:27(0) 4 b \"\"\n" +
@ -717,7 +717,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("x3p4");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x3p4\n" +
"Aligned pack(4)\n" +
"pack(4)\n" +
"Structure x3p4 {\n" +
" 0 char 1 a \"\"\n" +
" 2 short:0(0) 1 \"\"\n" +
@ -732,7 +732,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("x4p4");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/x4p4\n" +
"Aligned pack(4)\n" +
"pack(4)\n" +
"Structure x4p4 {\n" +
" 0 char 1 a \"\"\n" +
" 1 int:27(0) 4 b \"\"\n" +
@ -747,7 +747,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("T1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/T1\n" +
"Aligned\n" +
"pack()\n" +
"Structure T1 {\n" +
" 0 charTypedef 1 a \"\"\n" +
" 1 myEnum:3(0) 1 b \"\"\n" +
@ -763,7 +763,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("T2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/T2\n" +
"Aligned\n" +
"pack()\n" +
"Structure T2 {\n" +
" 0 charTypedef 1 a \"\"\n" +
" 1 intTypedef:17(0) 3 b \"\"\n" +
@ -779,7 +779,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("S1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/S1\n" +
"Aligned\n" +
"pack()\n" +
"Structure S1 {\n" +
" 0 B1 4 b1 \"\"\n" +
" 4 B2 4 b2 \"\"\n" +
@ -796,7 +796,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("S1p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/S1p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure S1p1 {\n" +
" 0 B1 4 b1 \"\"\n" +
" 4 B2 4 b2 \"\"\n" +
@ -813,7 +813,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("S2p1");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/S2p1\n" +
"Aligned pack(1)\n" +
"pack(1)\n" +
"Structure S2p1 {\n" +
" 0 B1p1 4 b1p1 \"\"\n" +
" 4 B2p1 4 b2p1 \"\"\n" +
@ -830,7 +830,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("S1p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/S1p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure S1p2 {\n" +
" 0 B1 4 b1 \"\"\n" +
" 4 B2 4 b2 \"\"\n" +
@ -847,7 +847,7 @@ public class StructureImplLittleEndianBitFieldTest extends AbstractCompositeImpl
Structure struct = getStructure("S2p2");
//@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/S2p2\n" +
"Aligned pack(2)\n" +
"pack(2)\n" +
"Structure S2p2 {\n" +
" 0 B1p2 4 b1p2 \"\"\n" +
" 4 B2p2 4 b2p2 \"\"\n" +

Some files were not shown because too many files have changed in this diff Show more