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> <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>. 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>. 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>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</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> <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> <H1 align="center">Ghidra 9.1 Change History (October 2019)</H1>
<blockquote><p><u>New Features</u></p> <blockquote><p><u>New Features</u></p>
<ul> <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>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>. 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> <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; } 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; } 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; } 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; } 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; } table, th, td { border: 1px solid black; border-collapse: collapse; font-size:10pt; }
th { font-family:times new roman; font-size:14pt; font-weight:bold; padding-left:10px; padding-right:14px; } td { font-family:times new roman; font-size:14pt; padding-left:10px; padding-right:10px; text-align:left; vertical-align:top; }
code { color:black; font-family:courier new font-size: 14pt; } 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; } span.code { font-family:courier new font-size: 14pt; color:#000000; }
</STYLE> </STYLE>
</HEAD> </HEAD>
@ -39,6 +41,145 @@
vulnerabilities in networks and systems. vulnerabilities in networks and systems.
</P> </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 /> <BR />
<H1> What's New in Ghidra 9.2</H1> <H1> What's New in Ghidra 9.2</H1>

View file

@ -80,8 +80,8 @@ public class DBTraceDataTypeManager extends DataTypeManagerDB
} }
@Override @Override
public void dataTypeChanged(DataType dataType) { public void dataTypeChanged(DataType dataType, boolean isAutoChange) {
super.dataTypeChanged(dataType); super.dataTypeChanged(dataType, isAutoChange);
if (!isCreatingDataType()) { if (!isCreatingDataType()) {
trace.getCodeManager().invalidateCache(false); trace.getCodeManager().invalidateCache(false);
trace.getSymbolManager().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/Plus.png||GHIDRA||||END|
src/main/help/help/topics/DataTypeEditors/images/StructureEditBitfield.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/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/StructureEditorWithFlexArray.png||GHIDRA||||END|
src/main/help/help/topics/DataTypeEditors/images/UnionEditor.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/Unpackage.gif||GHIDRA||||END|
src/main/help/help/topics/DataTypeEditors/images/cstruct.png||GHIDRA||reviewed||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| 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> <UL>
<LI><I>Edit Actions</I>: The icon buttons at the top of the editor are used to modify this <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 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 action</A> associated with it. These allow the user to: apply changes, insert
bytes, reorganize the current components, duplicate components, clear components (changes Undefined components, reorganize the current components, duplicate components, clear components (changes
them to Undefined bytes), delete components, create array components, and unpackage a 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> structure or array component changing it into its component parts.<BR>
</LI> </LI>
@ -79,11 +79,9 @@
be changed by <A href="#Structure_Editor_Cycle">cycling</A> the data type.</LI> 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 <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 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 href="#Structure_Editor_Description">description</A> can be specified here.<BR>
changed between <A href="#Structure_Editor_InternallyAligned">unaligned and
aligned</A>.<BR>
</LI> </LI>
<LI>Immediately below the structure information area is a status line where status messages <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 <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 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 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> </BLOCKQUOTE>
<H2><A name="Structure_Editor_ActualAlignment"></A>Alignment</H2> <H2><A name="Structure_Editor_ActualAlignment"></A>Alignment</H2>
<BLOCKQUOTE> <BLOCKQUOTE>
<P>At the bottom of the editor is an <SPAN style="font-style: italic;">Alignment</SPAN> <P>At the bottom of the editor is a read-only <SPAN style="font-style: italic;">Alignment</SPAN>
field, which indicates how the structure or union being edited will be aligned within other field which conveys the acutal alignment of this data type.
data types. All unaligned structures and unions will have an alignment of 1 (byte aligned) All non-packed structures and unions (i.e., pack disabled) will have a default alignment of 1 (byte aligned)
and will therefore not be aligned within other data types. For aligned structures and unions unless a <A href="#Structure_Editor_Align">minimum alignment</A> value has been specified. For packed structures and unions
the alignment value is determined based on the alignments of the individual components they the actual alignment value is calculated based on the <A href="#Structure_Editor_Pack">pack</A> setting,
contain, whether they are <A href="#Structure_Editor_PackMaximum">packed internally</A> and preferred alignments of the individual components,
whether they have a <A href="#Structure_Editor_AlignMinimum">minimum alignment</A> and the minimum alignment setting. The size of a packed structure or union will always be a multiple
specified.<BR> 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> </P>
</BLOCKQUOTE> </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> <BLOCKQUOTE>
<P>In the lower right corner of the editor is an <SPAN style= <P>In the lower right corner of the editor is a series of <SPAN style=
"font-style: italic;">Align</SPAN> check box. When the box is checked the structure or union "font-style: italic;">pack</SPAN> choice buttons. The <B>disabled</B> button corresponds to a non-packed
is aligned. Click the checkbox to change between aligned and unaligned. When a structure or structure or union, while the <B>default</B> or value-entry buttons enable packing.<BR>
union is aligned, additional choices will appear that allow minimum alignment and packing to
be specified.<BR>
</P> </P>
</BLOCKQUOTE> </BLOCKQUOTE>
<BLOCKQUOTE> <BLOCKQUOTE>
<H3>Unaligned Structures</H3> <H3>Non-Packed Structures</H3>
<BLOCKQUOTE> <BLOCKQUOTE>
<P>When a structure is unaligned, with the exception of bitfields, each component shown within <P>When packing is disabled for a structure all bytes are accounted for
the editor immediately follows the one before it. In other words, no automatic alignment or padding occurs. by the displayed components. Use of <i>undefined</i> filler components as padding and reservation of space.
Unaligned structures may be used to position components with known data This differs from a packed structure which does not reveal padding in the form of components and does not provide
types at specific offsets within a structure. Therefore, when editing an unaligned structure, a means of reserving space.
the structure editor attempts to prevent defined components from moving Non-packed structures may be used to position components with known data
to a different offset when performing operations like drag and drop which may consume undefined bytes. <BR> 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> </P>
<DIV style="text-align: center; margin-top: 10px;"> <DIV style="text-align: center; margin-top: 10px;">
@ -192,108 +199,114 @@
</DIV> </DIV>
</BLOCKQUOTE> </BLOCKQUOTE>
<H3>Aligned Structures</H3> <H3>Packed Structures</H3>
<BLOCKQUOTE> <BLOCKQUOTE>
<P>An aligned structure is defined similar to a structure in a C header file. The data types <P>A packed structure is defined similar to a structure in a C header file and is intended
are specified for each of the components, but their offsets will be automatically adjusted to to automatically adjust component placement, size and alignment in a manner consistent
the correct alignment based on the data type and position in the structure. A default with the associated compiler specification. Data types
"undefined" byte cannot be added to an aligned structure, although an "undefined1" component are specified for each of the components, but their offsets are automatically computed
can be and is treated like any other fixed-length datatype. The overall size of the structure is based upon the pack settings and preferred alignment of each component's data type. A default
determined by the components it contains and the specified pack value. The alignment and datatype (i.e., <i>undefined</i>) cannot be added to a packed structure, although other sized datatypes
packing behavior is determined by the effective data organization as defined by each compiler (e.g., <i>undefined1</i>, <i>undefined4</i>, etc.) may be used as component place-holders and will
specification (data type archives utilize a default data organization). When you select the pack appropriately based upon their size. The overall size of the structure is
<B>Align</B> checkbox, the GUI displays buttons to allow an align attribute, <SPAN style= determined by the components it contains, the pack setting (default or explicit value) and the minimum alignment setting.
"font-weight: bold; font-style: italic;">align( minimum )</SPAN>, to be specified. It also The default alignment and pack behavior is controlled by the effective data organization. This can
allows a pack value, <SPAN style="font-style: italic;"><SPAN style= cause the same structure viewed within a program to be layed-out quite differently than within a datatype archive
"font-weight: bold;">pack</SPAN></SPAN> <SPAN style= which uses a default data organization.</P>
"font-weight: bold; font-style: italic;">( maximum )</SPAN>, to be specified. The following <P>The following image shows the editor state reflecting a default packed structure with
image shows these GUI components for aligning the data type being edited.<BR> default alignment.<BR>
</P> </P>
<DIV style="text-align: center; margin-top: 10px;"> <DIV style="text-align: center; margin-top: 10px;">
<IMG alt="" src="images/StructureEditorAligned.png"><BR> <IMG alt="" src="images/StructureEditorPacked.png"><BR>
</DIV> </DIV>
</BLOCKQUOTE> </BLOCKQUOTE>
<H4><A name="Structure_Editor_AlignMinimum"></A>align( minimum )</H4> <H4><A name="Structure_Editor_Align"></A>align (minimum)</H4>
<BLOCKQUOTE> <BLOCKQUOTE>
<P>This indicates the minimum alignment to be used when aligning this data type inside <P>This setting controls the minimum alignment to be used when computing this data type's
another data type. Setting this to a value other than <SPAN style= <A href="#Structure_Editor_ActualAlignment">actual alignment</A>.<BR>
"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> </P>
<UL> <UL>
<LI><SPAN style="font-weight: bold;">none</SPAN> - Sets this data type to have <SPAN style= <LI><SPAN style="font-weight: bold;">default</SPAN> - Sets this data type to compute its <SPAN style=
"font-weight: bold;">no</SPAN> specified minimum alignment when aligning this data type "font-weight: bold;">default</SPAN> alignment based only on the pack setting and the alignment of
inside another data type. Align this data type based only on its components and their the individual components. If packing is disabled (i.e., explicit component placement by offset)
minimum alignments and packing.<BR> the default alignment will always be 1-byte and preferred component alignments are ignored.<BR>
</LI> </LI>
<LI><SPAN style="font-weight: bold;">machine</SPAN> - Sets this data type to have a minimum <LI>explicit value - The radio-button with a text field next to it allows you to specify an
alignment that is a multiple of the <SPAN style="font-weight: bold;">machine</SPAN> explicit minimum alignment value. This sets the data types minimum alignment. The
alignment when aligning this data type inside another data type. In this case <SPAN style= computed alignment for the data type will be a multiple of this value.</LI>
"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><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>
<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> </UL>
<P><IMG alt="Note:" src="../../shared/note.png"> The equivalent of having <I>no C code align <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>none</B>. The equivalent for a C code attribute</I> on the structure or union is to choose <B>default</B>. The equivalent for the C code
attribute of <I>align()</I> without a value is to choose <B>machine</B> alignment. The <i>aligned</i> attribute 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> equivalent of <I>aligned(4)</I> or <I>alignas(4)</I> is to specify an explicit alignment <B>value</B> of 4.</P>
</BLOCKQUOTE> </BLOCKQUOTE>
<H4><A name="Structure_Editor_PackMaximum"></A>pack( maximum )</H4> <H4><A name="Structure_Editor_Pack"></A>pack</H4>
<BLOCKQUOTE> <BLOCKQUOTE>
<P>This indicates a packing value to be used when aligning the components within this data <P>This setting controls the packing behavior of the structure or union. In general, packing should
type. Setting this to a value other than <B>none</B> forces each component of this structure be disabled when a complete definition is unknown and it is neccessary to reverse engineer the
to be packed so that its maximum alignment within the structure is no more than the pack component specifications. This is the initial state of a new structure with the <B>pack</B>
value. However, a component will not be packed if the data type or one of its subcomponents checkbox left unchecked. When a the specifications of a composite are known, such as from
data types has a minimum alignment value specified that exceeds the pack value. Packing also a source header file, it may be preferred to enable packing to allow for automatic placement of
affects the padding at the end of this structure so that the overall size of the structure is components and calculation of alignment and size. To enable packing the <B>pack</B> checkbox
the smallest possible multiple of the pack value. If the minimum alignment is greater than should be checked and either a <B>default</B> or explicit pack value specified.<BR>
the pack value, the end of the structure or union is padded based on the minimum alignment
instead.<BR>
</P> </P>
<UL> <UL>
<LI><B>none</B> - The components within this structure should align themselves in the <LI><B>default</B> - The components within this structure should align besed upon the
default way for the compiler. The components are not being packed with a reduced alignment.<BR> preferred alignment of each component.<BR>
</LI> </LI>
<LI>by value - The bottom button with a text field next to it allows you to specify a pack <LI>explicit value - The button with a text entry field next to it allows you to specify an explicit pack
value. The <B>specified value</B> indicates the maximum alignment to use when packing any value. The specified value indicates the maximum alignment to use when packing each
component.<BR> component.<BR>
</LI> </LI>
</UL> </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 <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>
<P><IMG alt="Note:" src="../../shared/note.png"> The equivalent of having <I>no C #pragma <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 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> <B>1</B>. The equivalent of <I># pragma</I> <I>pack(4)</I> is to specify a <B>pack value</B>
of 4.<BR> of 4.<BR>
</P> </P>
</BLOCKQUOTE> </BLOCKQUOTE>
<H3>Unaligned Unions</H3> <H3>Non-packed Unions</H3>
<BLOCKQUOTE> <BLOCKQUOTE>
<P>When a union is unaligned, the union is the size of its largest component.&nbsp; There is <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 alignment&nbsp; is 1 when putting an unaligned union into other no alignment padding and the default alignment&nbsp; is 1. As with structures, a <A href=
data types.<BR> "#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> </P>
<DIV style="text-align: center; margin-top: 10px;"> <DIV style="text-align: center; margin-top: 10px;">
@ -301,21 +314,21 @@
</DIV> </DIV>
</BLOCKQUOTE> </BLOCKQUOTE>
<H3>Aligned Unions</H3> <H3>Packed Unions</H3>
<BLOCKQUOTE> <BLOCKQUOTE>
<P>&nbsp;In an aligned union the overall size is at least the size of the largest component, <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 alignment and packing. The <A href= but will be padded based on the actual computed alignment. The <A href=
"#Structure_Editor_AlignMinimum">minimum alignment</A> is specified just as within a "#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 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_Editor_Pack">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, 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 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 a minimum alignment and pack value are specified, the minimum alignment will override the
pack value if it is larger.</P> pack value if it is larger.</P>
<DIV style="text-align: center; margin-top: 10px;"> <DIV style="text-align: center; margin-top: 10px;">
<IMG alt="" src="images/UnionEditorAligned.png"> <IMG alt="" src="images/UnionEditorPacked.png">
</DIV> </DIV>
</BLOCKQUOTE> </BLOCKQUOTE>
@ -334,25 +347,25 @@
bit-size is generally appended to the base-datatype for datatype specification and bit-size is generally appended to the base-datatype for datatype specification and
presentation purposes (e.g., char:1).</li> presentation purposes (e.g., char:1).</li>
<li>A zero-length bitfield may be defined within a byte but its' precise bit position <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 is controlled by endianess alone. A zero-length bitfield has no affect within a non-packed
structure and is intended for use within aligned structures where it may impart alignment structure and is intended for use within packed structures where it may impart alignment
affects based upon compiler conventions.</li> 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> 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>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 <li>Unoccupied bits within a partially occupied byte are not represented by any component
(similar to padding bytes within aligned structures).</li> (similar to padding bytes within packed structures).</li>
<li>A separate <a href="#Structure_Bitfield_Editor">Bitfield Editor</a>, for use with unaligned structures only, <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 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. structures since additional bytes will be introduced.
The BitField Editor may be displayed using the the Add Bitfield and 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 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> </ul>
</BLOCKQUOTE> </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 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) 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> while big-endian packs starting with bit-7 (msb).</P>
@ -401,9 +414,10 @@
Insert Undefined Byte</H3> Insert Undefined Byte</H3>
<BLOCKQUOTE> <BLOCKQUOTE>
<P>Undefined Bytes can only be inserted into a structure that is not aligned. A single <P>Within a non-packed structure <i>undefined</i> components are inserted before the current selection by clicking the <IMG src=
Undefined byte is 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
"images/Plus.png" alt=""> <B>Insert Undefined Byte</B> button.</P> 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> </BLOCKQUOTE>
<H3><A name="Structure_Editor_Move_Components_Up"></A> <IMG src="images/up.png" alt=""> Move <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> <LI>A single copy of the component is created immediately following the selected one.</LI>
</OL> </OL>
<P>If the structure is not aligned, then there must be enough Undefined bytes following the <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 an unaligned structure, Undefined bytes get component to accommodate the duplicate. In such a such a structure, <i>undefined</i> bytes get
replaced by the new copy of the component.</P> consumed by the new copy of the component.</P>
</BLOCKQUOTE> </BLOCKQUOTE>
<H3><A name="Structure_Editor_Duplicate_Multiple_of_Component"></A> <IMG src= <H3><A name="Structure_Editor_Duplicate_Multiple_of_Component"></A> <IMG src=
@ -460,8 +474,8 @@
Component...</B> button.</LI> Component...</B> button.</LI>
<LI><A name="Structure_Editor_Duplicates_NumberInputDialog"></A> The number of duplicates <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 dialog appears. In a non-packed structure, you can only indicate as many duplicates as will
fit in place of Undefined bytes.</LI> fit in place of <i>undefined</i> bytes.</LI>
</OL> </OL>
</BLOCKQUOTE> </BLOCKQUOTE>
@ -502,10 +516,10 @@
Clear Component(s)</H3> Clear Component(s)</H3>
<BLOCKQUOTE> <BLOCKQUOTE>
<P>Clearing a component changes it into Undefined byte components that take up the same <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 be cleared in unaligned amount of space as the component being cleared. Components can only be cleared in non-packed
structures, but not in unions or aligned structures. This is because the resulting Undefined structures (i.e., pack disabled), but not in unions or packed structures. This is because the resulting <i>undefined</i>
bytes are not valid components in a union or aligned structure.</P> components are not valid in a union or packed structure.</P>
<P>To clear components in a 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>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> will be equal to the length of the component being cleared.</LI>
</OL> </OL>
@ -542,8 +556,8 @@
<BLOCKQUOTE> <BLOCKQUOTE>
<OL start="4"> <OL start="4">
<LI>Specify the number of elements. For an unaligned structure, the maximum size of the <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 Undefined bytes following the selected component.</LI> array is limited by the number of <i>undefined</i> components following the selected component.</LI>
<LI>Press the <B>OK</B> button.</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 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 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 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> </OL>
</BLOCKQUOTE> </BLOCKQUOTE>
@ -621,12 +635,12 @@
</BLOCKQUOTE><BR> </BLOCKQUOTE><BR>
</BLOCKQUOTE> </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> <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 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> table view (e.g., char:1).</P>
<H3><A name="Structure_Editor_Add_Bitfield"></A>Add Bitfield</H3> <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 <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. 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, <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> </BLOCKQUOTE>
<P><IMG src="../../shared/tip.png" alt="" border="0"> To rearrange the order of the component <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> <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 <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 <I>Name</I> and <I>Comment</I> are not editable on <i>undefined</i> components.</P>
Undefined byte.</P>
<P>To place an editable field into edit mode:</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 <H4><A name="EffectOfChangingDataTypeSize"></A> <U>Effect of Changing a Component's
Size</U></H4> 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 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> alignment.<BR>
</P> </P>
<P>How a structure is affected by changing a component's data type depends on whether the <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> <BLOCKQUOTE>
<P><B>Unaligned</B> - If the structure is <I>unaligned</I>, then the new component must <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 Undefined byte components be less than or equal to the original component's size plus any <i>undefined</i> components
that immediately follow it in the structure. In an unaligned structure, decreasing the that immediately follow it in the structure. Decreasing the
component size will create Undefined byte components following it to maintain the component size will create <i>undefined</i> components following it to maintain the
structure size. Increasing the component size replaces Undefined bytes immediately structure size and placement of other components. Increasing the component size replaces
following the component. The last component of a structure can be always be changed which <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> can cause the structure to grow larger.<BR>
</P> </P>
<P><B>Aligned</B> - If the structure is <I>aligned</I>, the component can change size, <P><B>Packed</B> - If the structure is <I>packed</I>, a component can change size or alignment,
which affects the structure's overall size and the alignment of individual components which can affect the placement of subsequent components within a structure and/or the
that follow it.</P> overall size and alignment of both structures and unions.</P>
</BLOCKQUOTE> </BLOCKQUOTE>
</BLOCKQUOTE> </BLOCKQUOTE>
@ -859,7 +873,7 @@
</BLOCKQUOTE> </BLOCKQUOTE>
<BLOCKQUOTE> <BLOCKQUOTE>
<H3>Union or Aligned Structure<BR> <H3>Union or Packed Structure<BR>
</H3> </H3>
<P>The first data type in a cycle group can be added to the end of a structure as a new <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> cycle group. The data type can then be cycled to any other data type in the group.</P>
</BLOCKQUOTE> </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 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 boundary of the current component. If <i>undefined</i> components follow the selected component, the
Undefined bytes can be replaced by cycling the data type to a larger sized data type. component 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 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> cycled. However, the last component is not restricted to a particular size.<BR>
</P> </P>
</BLOCKQUOTE> </BLOCKQUOTE>
@ -957,8 +971,8 @@
<H2><A name="AddDataType"></A>Adding a Data Type</H2> <H2><A name="AddDataType"></A>Adding a Data Type</H2>
<BLOCKQUOTE> <BLOCKQUOTE>
<P>A data type can be added as a component by replacing Undefined bytes. When editing an <P>A data type can be added as a component by replacing <i>undefined</i> components. When editing a
unaligned structure, there must be enough Undefined bytes for the data type to replace. 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> data type can also be added to the end of a structure or union.</P>
<BLOCKQUOTE> <BLOCKQUOTE>
@ -997,7 +1011,7 @@
<H2><A name="InsertDataType"></A>Inserting a Data Type</H2> <H2><A name="InsertDataType"></A>Inserting a Data Type</H2>
<BLOCKQUOTE> <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> <BLOCKQUOTE>
<H3>Drag and Drop</H3> <H3>Drag and Drop</H3>
@ -1025,9 +1039,9 @@
<H2><A name="ReplaceDataType"></A>Replacing a Data Type</H2> <H2><A name="ReplaceDataType"></A>Replacing a Data Type</H2>
<BLOCKQUOTE> <BLOCKQUOTE>
<P>A component can have its data type replaced with a different data type. If an unaligned <P>A component can have its data type replaced with a different data type. If a non-packed
structure is being edited then Undefined bytes are created or consumed as necessary to 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 aligned 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 structures, the data type simply changes for the component and the overall size is adjusted
accordingly.</P> accordingly.</P>
@ -1041,22 +1055,22 @@
component in the editor. component in the editor.
If the mouse pointer is a 'circle with a slash' then the data type cannot be 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 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 won't fit in the structure in place of the original component. If editing a union or
aligned structure the data type should always fit and the drop is allowed. If editing an packed structure the data type will always fit and the drop is allowed (provided the datatype is allowed). If editing a
unaligned structure, the component is replaced only if the new component will fit. (see 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> <A href="#EffectOfChangingDataTypeSize">Effect of Changing a Component's Size</A>)</P>
<H4>Contiguous Selection of Multiple Components</H4> <H4>Contiguous Selection of Multiple Components</H4>
<P>Drag a data type to a block of selected components. <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 a block of selected components. This is because the new component (s) will occupy the
same space as the currently selected components.<BR> same space as the currently selected components.<BR>
<B>In a union</B>, all selected components will be replaced with a single component <B>In a union</B>, all selected components will be replaced with a single component
containing the data type dropped.<BR> containing the data type dropped.<BR>
<B>In a structure</B>, as many components of the dropped data type as will fit in the <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 selection are created to replace the selection. In a non-packed structure any left over
bytes in the selection will become Undefined bytes.</P> 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 <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> 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 <B>In a union</B>, all selected components will be replaced with a single component
containing the favorite data type.<B><BR> containing the favorite data type.<B><BR>
In a structure</B>, only favorites that will fit in place of the selection will be 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 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, <P><IMG src="../../shared/note.png" alt=""> For information about Pointers as a Favorite,
see <A href="#Structure_Editor_Favorite">Favorites Basics</A>.</P> see <A href="#Structure_Editor_Favorite">Favorites Basics</A>.</P>
@ -1248,14 +1262,14 @@
</U></P> </U></P>
</BLOCKQUOTE> </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> <BLOCKQUOTE>
<P>The Bitfield Editor is used by the Structure Editor when adding or modifying bitfield components <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 within non-packed 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., 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). 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> 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 <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> Archive</B></I> action.</P>
</BLOCKQUOTE> </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> <BLOCKQUOTE>
<P>Right-click on the program or data type archive where data types are to be aligned, <P>Right-click on the program or data type archive where structures and unions are to be packed,
and select the <I><B>Align All...</B></I> action. A confirmation dialog will appear to and select the <I><B>Pack 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 make sure you want to pack all composites in the program or data type
archive. If you continue, all structures and unions that are unaligned will be changed to archive. If you continue, all non-packed composites will have default packing enabled.</P>
aligned data types with no minimum alignment (the default) and no packing.</P>
</BLOCKQUOTE> </BLOCKQUOTE>
<H3><A name="synchronizing"></A> <A name="Update"></A> Updating an Archive From a Source <H3><A name="synchronizing"></A> <A name="Update"></A> Updating an Archive From a Source
@ -926,15 +925,14 @@
</TBODY> </TBODY>
</TABLE> </TABLE>
</BLOCKQUOTE> </BLOCKQUOTE>
<!-- disabled feature
<H3><A name="Align_Data_Type"></A>Aligning a Data Type</H3> <H3><A name="Align_Data_Type"></A>Aligning a Data Type</H3>
<BLOCKQUOTE> <BLOCKQUOTE>
<P>Right-click on the structure or union to be aligned. Select the <I><B>Align</B></I> <P>Right-click on the structure or union to be packed. Select the <I><B>Pack</B></I>
action. If the data type is unaligned it will be changed to an aligned data type with no action. If the data type is non-packed it will be changed to be default packed.</P>
minimum alignment (the default) and no packing.</P>
</BLOCKQUOTE> </BLOCKQUOTE>
-->
<H3><A name="Commit_To_Archive"></A>Committing Changes To Source Archive</H3> <H3><A name="Commit_To_Archive"></A>Committing Changes To Source Archive</H3>
<BLOCKQUOTE> <BLOCKQUOTE>

View file

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

View file

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

View file

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

View file

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

View file

@ -38,7 +38,7 @@ public class BitFieldEditorDialog extends DialogComponentProvider {
private Composite composite; private Composite composite;
private CompositeChangeListener listener; 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, BitFieldEditorDialog(Composite composite, DataTypeManagerService dtmService, int editOrdinal,
boolean showOffsetsInHex, CompositeChangeListener listener) { boolean showOffsetsInHex, CompositeChangeListener listener) {
@ -290,11 +290,11 @@ public class BitFieldEditorDialog extends DialogComponentProvider {
} }
private static String getCompositeType(Composite composite) { private static String getCompositeType(Composite composite) {
// currently supports unaligned case only! // currently supports non-packed case only!
if (composite.isInternallyAligned()) { if (composite.isPackingEnabled()) {
throw new IllegalArgumentException("Aligned use not supported"); 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"; String type = (composite instanceof Union) ? "Union" : "Structure";
return alignmentMode + " " + type; return alignmentMode + " " + type;
} }
@ -309,7 +309,7 @@ public class BitFieldEditorDialog extends DialogComponentProvider {
baseDataType = ((BitFieldDataType) dtc.getDataType()).getBaseDataType(); baseDataType = ((BitFieldDataType) dtc.getDataType()).getBaseDataType();
} }
} }
else if (!composite.isNotYetDefined()) { else if (!composite.isZeroLength()) {
offset = composite.getLength(); offset = composite.getLength();
} }
@ -346,7 +346,7 @@ public class BitFieldEditorDialog extends DialogComponentProvider {
// Assume a reasonable alignment in identifying aligned offset // Assume a reasonable alignment in identifying aligned offset
int alignment = CompositeAlignmentHelper.getPackedAlignment(dataOrganization, int alignment = CompositeAlignmentHelper.getPackedAlignment(dataOrganization,
Composite.NOT_PACKING, bitfieldDt.getBaseDataType(), bitfieldDt.getBaseTypeSize()); CompositeInternal.NO_PACKING, bitfieldDtc);
int adjustedOffset = offset - (offset % alignment); 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 * <code>BitFieldEditorPanel</code> provides the ability to add or modify bitfields
* within unaligned structures. * within non-packed structures.
*/ */
public class BitFieldEditorPanel extends JPanel { public class BitFieldEditorPanel extends JPanel {
@ -81,9 +81,9 @@ public class BitFieldEditorPanel extends JPanel {
super(); super();
this.composite = composite; this.composite = composite;
if (composite.isInternallyAligned()) { if (composite.isPackingEnabled()) {
// A different bitfield editor should be used for aligned composites // 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)); setLayout(new VerticalLayout(5));
@ -169,7 +169,7 @@ public class BitFieldEditorPanel extends JPanel {
int offset = placementComponent.getAllocationOffset(); int offset = placementComponent.getAllocationOffset();
decrementButton.setEnabled(offset > 0); decrementButton.setEnabled(offset > 0);
int length = composite.isNotYetDefined() ? 0 : composite.getLength(); int length = composite.isZeroLength() ? 0 : composite.getLength();
incrementButton.setEnabled(offset < length); incrementButton.setEnabled(offset < length);
} }
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -58,7 +58,7 @@ public class InsertUndefinedAction extends CompositeEditorTableAction {
int index = model.getMinIndexSelected(); int index = model.getMinIndexSelected();
if (index >= 0) { if (index >= 0) {
DataType undefinedDt = DataType undefinedDt =
model.viewComposite.isInternallyAligned() ? Undefined1DataType.dataType model.viewComposite.isPackingEnabled() ? Undefined1DataType.dataType
: DataType.DEFAULT; : DataType.DEFAULT;
DataTypeInstance dti = DataTypeInstance.getDataTypeInstance(undefinedDt, -1); DataTypeInstance dti = DataTypeInstance.getDataTypeInstance(undefinedDt, -1);
model.insert(index, dti.getDataType(), dti.getLength()); model.insert(index, dti.getDataType(), dti.getLength());
@ -77,7 +77,7 @@ public class InsertUndefinedAction extends CompositeEditorTableAction {
if (model.viewComposite instanceof Structure) { if (model.viewComposite instanceof Structure) {
boolean isContiguousSelection = model.getSelection().getNumRanges() == 1; boolean isContiguousSelection = model.getSelection().getNumRanges() == 1;
DataType undefinedDt = DataType undefinedDt =
model.viewComposite.isInternallyAligned() ? Undefined1DataType.dataType model.viewComposite.isPackingEnabled() ? Undefined1DataType.dataType
: DataType.DEFAULT; : DataType.DEFAULT;
enabled = isContiguousSelection && enabled = isContiguousSelection &&
model.isInsertAllowed(model.getMinIndexSelected(), undefinedDt); 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.FieldRange;
import docking.widgets.fieldpanel.support.FieldSelection; import docking.widgets.fieldpanel.support.FieldSelection;
import ghidra.docking.settings.SettingsImpl; import ghidra.docking.settings.SettingsImpl;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.program.model.lang.InsufficientBytesException; import ghidra.program.model.lang.InsufficientBytesException;
import ghidra.util.Msg; import ghidra.util.Msg;
@ -201,17 +200,7 @@ class StructureEditorModel extends CompEditorModel {
@Override @Override
public int getNumComponents() { public int getNumComponents() {
if (viewComposite == null) { return viewComposite == null ? 0 : viewComposite.getNumComponents();
return 0;
}
if (isShowingUndefinedBytes()) {
if (viewComposite.isNotYetDefined()) {
return 0;
}
return viewComposite.getNumComponents();
}
DataTypeComponent[] definedComponents = ((Structure) viewComposite).getDefinedComponents();
return definedComponents.length;
} }
@Override @Override
@ -252,14 +241,14 @@ class StructureEditorModel extends CompEditorModel {
@Override @Override
protected boolean isSizeEditable() { protected boolean isSizeEditable() {
return !isAligned(); return !isPackingEnabled();
} }
void setStructureSize(int size) { void setStructureSize(int size) {
if (viewComposite == null) { if (viewComposite == null) {
return; return;
} }
int currentLength = viewComposite.isNotYetDefined() ? 0 : viewComposite.getLength(); int currentLength = viewComposite.isZeroLength() ? 0 : viewComposite.getLength();
if (currentLength == size) { if (currentLength == size) {
return; return;
} }
@ -449,8 +438,8 @@ class StructureEditorModel extends CompEditorModel {
DataTypeComponent comp = deleteComponentAndResidual(startIndex - 1); DataTypeComponent comp = deleteComponentAndResidual(startIndex - 1);
try { try {
if (!isAligned() && comp.isBitFieldComponent()) { if (!isPackingEnabled() && comp.isBitFieldComponent()) {
// insert residual undefined bytes before inserting unaligned bitfield // insert residual undefined bytes before inserting non-packed bitfield
int lenChange = len - getLength(); int lenChange = len - getLength();
insert(endIndex, DataType.DEFAULT, 1, lenChange, TaskMonitor.DUMMY); insert(endIndex, DataType.DEFAULT, 1, lenChange, TaskMonitor.DUMMY);
} }
@ -485,8 +474,8 @@ class StructureEditorModel extends CompEditorModel {
DataTypeComponent comp = deleteComponentAndResidual(endIndex + 1); DataTypeComponent comp = deleteComponentAndResidual(endIndex + 1);
try { try {
if (!isAligned() && comp.isBitFieldComponent()) { if (!isPackingEnabled() && comp.isBitFieldComponent()) {
// insert residual undefined bytes before inserting unaligned bitfield // insert residual undefined bytes before inserting non-packed bitfield
int lenChange = len - getLength(); int lenChange = len - getLength();
insert(startIndex, DataType.DEFAULT, 1, lenChange, TaskMonitor.DUMMY); insert(startIndex, DataType.DEFAULT, 1, lenChange, TaskMonitor.DUMMY);
} }
@ -507,7 +496,7 @@ class StructureEditorModel extends CompEditorModel {
DataTypeComponent comp = getComponent(index); DataTypeComponent comp = getComponent(index);
deleteComponent(index); deleteComponent(index);
if (isAligned() || !comp.isBitFieldComponent() || index >= getNumComponents()) { if (isPackingEnabled() || !comp.isBitFieldComponent() || index >= getNumComponents()) {
return comp; return comp;
} }
@ -627,7 +616,7 @@ class StructureEditorModel extends CompEditorModel {
} }
@Override @Override
public void deleteSelectedComponents(TaskMonitor monitor) throws UsrException { public void deleteSelectedComponents() throws UsrException {
if (!isDeleteAllowed()) { if (!isDeleteAllowed()) {
throw new UsrException("Deleting is not allowed."); throw new UsrException("Deleting is not allowed.");
} }
@ -646,7 +635,7 @@ class StructureEditorModel extends CompEditorModel {
selectionChanged(); selectionChanged();
return; return;
} }
super.deleteSelectedComponents(monitor); super.deleteSelectedComponents();
} }
@Override @Override
@ -660,14 +649,14 @@ class StructureEditorModel extends CompEditorModel {
int rowIndex = getRow(); int rowIndex = getRow();
DataTypeComponent comp = getComponent(rowIndex); DataTypeComponent comp = getComponent(rowIndex);
DataType dt = comp.getDataType(); DataType dt = comp.getDataType();
if (viewComposite.isInternallyAligned()) { if (viewComposite.isPackingEnabled()) {
return true; return true;
} }
if (dt.equals(DataType.DEFAULT)) { if (dt.equals(DataType.DEFAULT)) {
return true; // Insert an undefined and push everything down. return true; // Insert an undefined and push everything down.
} }
if (comp.isBitFieldComponent()) { 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. // Can always duplicate at the end.
if (isAtEnd(rowIndex) || onlyUndefinedsUntilEnd(rowIndex + 1)) { if (isAtEnd(rowIndex) || onlyUndefinedsUntilEnd(rowIndex + 1)) {
@ -956,7 +945,7 @@ class StructureEditorModel extends CompEditorModel {
dtc.getComment()); dtc.getComment());
} }
else { else {
if (isAligned() || !(dataType instanceof BitFieldDataType)) { if (isPackingEnabled() || !(dataType instanceof BitFieldDataType)) {
dtc = ((Structure) viewComposite).insert(rowIndex, dataType, length, name, dtc = ((Structure) viewComposite).insert(rowIndex, dataType, length, name,
comment); 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 @Override
public boolean isShowingUndefinedBytes() { public boolean isShowingUndefinedBytes() {
return !viewComposite.isInternallyAligned(); return !viewComposite.isPackingEnabled();
} }
public void createInternalStructure(TaskMonitor monitor) public void createInternalStructure(TaskMonitor monitor)
@ -1259,7 +1216,7 @@ class StructureEditorModel extends CompEditorModel {
final StructureDataType structureDataType = final StructureDataType structureDataType =
new StructureDataType(originalCategoryPath, uniqueName, length, originalDTM); new StructureDataType(originalCategoryPath, uniqueName, length, originalDTM);
// if (isAligned()) { // if (isPackingEnabled()) {
// structureDataType.setPackingValue(getPackingValue()); // structureDataType.setPackingValue(getPackingValue());
// } // }
@ -1281,7 +1238,7 @@ class StructureEditorModel extends CompEditorModel {
length += compLength; length += compLength;
if (!structureDataType.isInternallyAligned() && component.isBitFieldComponent()) { if (!structureDataType.isPackingEnabled() && component.isBitFieldComponent()) {
BitFieldDataType bitfield = (BitFieldDataType) dt; BitFieldDataType bitfield = (BitFieldDataType) dt;
structureDataType.insertBitFieldAt(component.getOffset() - firstDtc.getOffset(), structureDataType.insertBitFieldAt(component.getOffset() - firstDtc.getOffset(),
compLength, bitfield.getBitOffset(), bitfield.getBaseDataType(), compLength, bitfield.getBitOffset(), bitfield.getBaseDataType(),
@ -1296,8 +1253,8 @@ class StructureEditorModel extends CompEditorModel {
lastDtc = component; lastDtc = component;
} }
DataType addedDataType = createDataTypeInOriginalDTM(structureDataType); DataType addedDataType = createDataTypeInOriginalDTM(structureDataType);
if (viewComposite.isInternallyAligned()) { if (viewComposite.isPackingEnabled()) {
deleteSelectedComponents(monitor); deleteSelectedComponents();
insert(minRow, addedDataType, addedDataType.getLength()); insert(minRow, addedDataType, addedDataType.getLength());
} }
else { else {
@ -1434,7 +1391,7 @@ class StructureEditorModel extends CompEditorModel {
DataTypeComponent dtc = struct.getComponent(i); DataTypeComponent dtc = struct.getComponent(i);
DataType dt = dtc.getDataType(); DataType dt = dtc.getDataType();
int compLength = dtc.getLength(); int compLength = dtc.getLength();
if (!isAligned()) { if (!isPackingEnabled()) {
if (dtc.isBitFieldComponent()) { if (dtc.isBitFieldComponent()) {
BitFieldDataType bitfield = (BitFieldDataType) dt; BitFieldDataType bitfield = (BitFieldDataType) dt;
viewStruct.insertBitFieldAt(currentOffset + dtc.getOffset(), compLength, 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.data.*;
import ghidra.program.model.lang.InsufficientBytesException; 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; import ghidra.util.task.TaskMonitor;
class UnionEditorModel extends CompEditorModel { 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 * Returns the number of undefined bytes that are available in the structure
* beginning at the specified row index. * 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. dataType.setLastChangeTimeInSourceArchive(0); // Set timestamp so user must re-sync.
fixedSync = true; fixedSync = true;
dataTypeManager.dataTypeChanged(dataType);
} }
} }
if (fixedSync) { if (fixedSync) {

View file

@ -152,10 +152,11 @@ public class DataTypesProvider extends ComponentProviderAdapter {
addLocalAction(new DeleteArchiveAction(plugin)); addLocalAction(new DeleteArchiveAction(plugin));
addLocalAction(new RenameAction(plugin)); addLocalAction(new RenameAction(plugin));
addLocalAction(new EditAction(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 PackDataTypeAction( plugin ));
// addLocalAction( new PackSizeDataTypeAction( plugin )); // addLocalAction( new PackSizeDataTypeAction( plugin ));
addLocalAction(new AlignAllDataTypesAction(plugin)); // addLocalAction(new PackAllDataTypesAction(plugin));
// addLocalAction( new DefineDataTypeAlignmentAction( plugin )); // addLocalAction( new DefineDataTypeAlignmentAction( plugin ));
addLocalAction(new CreateEnumFromSelectionAction(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.DataTypeNode;
import ghidra.app.plugin.core.datamgr.tree.DataTypeTreeNode; import ghidra.app.plugin.core.datamgr.tree.DataTypeTreeNode;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.HelpLocation;
import ghidra.util.Msg; import ghidra.util.Msg;
public class AlignDataTypeAction extends DockingAction { public class Pack1DataTypeAction extends DockingAction {
private DataTypeManagerPlugin plugin;
public AlignDataTypeAction(DataTypeManagerPlugin plugin) { public Pack1DataTypeAction(DataTypeManagerPlugin plugin) {
super("Align Data Type", plugin.getName()); super("Pack1 Data Type", plugin.getName());
setPopupMenuData(new MenuData(new String[] { "Align" }, "Edit")); this.plugin = plugin;
setHelpLocation(new HelpLocation(plugin.getName(), getName())); setPopupMenuData(new MenuData(new String[] { "Pack (1)" }, "Edit"));
}
@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 @Override
public boolean isEnabledForContext(ActionContext context) { 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(); Object contextObject = context.getContextObject();
if (!(contextObject instanceof GTree)) { if (!(contextObject instanceof GTree)) {
return null; return false;
} }
GTree gTree = (GTree) contextObject; GTree gTree = (GTree) contextObject;
TreePath[] selectionPaths = gTree.getSelectionPaths(); TreePath[] selectionPaths = gTree.getSelectionPaths();
if (selectionPaths.length != 1) { if (selectionPaths.length != 1) {
return null; return false;
} }
DataTypeTreeNode node = (DataTypeTreeNode) selectionPaths[0].getLastPathComponent(); DataTypeTreeNode node = (DataTypeTreeNode) selectionPaths[0].getLastPathComponent();
if (!(node instanceof DataTypeNode)) { if (!(node instanceof DataTypeNode)) {
return null; return false;
} }
return (DataTypeNode) node; setEnabled(node.isModifiable());
return true;
} }
@Override @Override
public void actionPerformed(ActionContext context) { public void actionPerformed(ActionContext context) {
GTree gTree = (GTree) context.getContextObject(); GTree gTree = (GTree) context.getContextObject();
TreePath[] selectionPaths = gTree.getSelectionPaths(); TreePath[] selectionPaths = gTree.getSelectionPaths();
for (TreePath treePath : selectionPaths) { if (selectionPaths.length != 1) {
final DataTypeNode dataTypeNode = (DataTypeNode) treePath.getLastPathComponent(); Msg.error(this, "Pack is only allowed on an individual data type.");
DataType dataType = dataTypeNode.getDataType(); return;
DataTypeManager dataTypeManager = dataType.getDataTypeManager();
DataOrganization dataOrganization = dataTypeManager.getDataOrganization();
alignDataType(dataType, dataOrganization);
} }
} TreePath treePath = selectionPaths[0];
final DataTypeNode dataTypeNode = (DataTypeNode) treePath.getLastPathComponent();
private void alignDataType(DataType dataType, DataOrganization dataOrganization) { DataType dataType = dataTypeNode.getDataType();
DataTypeManager dataTypeManager = dataType.getDataTypeManager(); DataTypeManager dataTypeManager = dataType.getDataTypeManager();
if (dataTypeManager == null) { if (dataTypeManager == null) {
Msg.error(this, "Can't align data type " + dataType.getName() + Msg.error(this,
" without a data type manager."); "Can't pack 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; return;
} }
int transactionID = -1; int transactionID = -1;
boolean commit = false; boolean commit = false;
try { try {
// start a transaction // start a transaction
transactionID = dataTypeManager.startTransaction("align " + dataType.getName()); transactionID = dataTypeManager.startTransaction("pack of " + dataType.getName());
((Structure) dataType).setInternallyAligned(true); packDataType(dataType);
commit = true; commit = true;
} }
finally { 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.archive.Archive;
import ghidra.app.plugin.core.datamgr.tree.*; import ghidra.app.plugin.core.datamgr.tree.*;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.HelpLocation;
import ghidra.util.Msg; import ghidra.util.Msg;
public class AlignAllDataTypesAction extends DockingAction { public class PackAllDataTypesAction extends DockingAction {
private DataTypeManagerPlugin plugin; private DataTypeManagerPlugin plugin;
public AlignAllDataTypesAction(DataTypeManagerPlugin plugin) { public PackAllDataTypesAction(DataTypeManagerPlugin plugin) {
super("Align All Data Types", plugin.getName()); super("Pack All Composites", plugin.getName());
this.plugin = plugin; this.plugin = plugin;
setPopupMenuData(new MenuData(new String[] { "Align All..." }, "Edit")); setPopupMenuData(new MenuData(new String[] { "Pack All..." }, "Edit"));
setHelpLocation(new HelpLocation(plugin.getName(), getName())); // setHelpLocation(new HelpLocation(plugin.getName(), getName()));
} }
@Override @Override
@ -85,27 +84,27 @@ public class AlignAllDataTypesAction extends DockingAction {
int result = int result =
OptionDialog.showOptionDialog( OptionDialog.showOptionDialog(
plugin.getTool().getToolFrame(), plugin.getTool().getToolFrame(),
"Align Data Types", "Pack All Composites",
"Are you sure you want to align all of the data types in " + "Are you sure you want to enable packing of all non-packed composites in " +
dataTypeManager.getName() + dataTypeManager.getName() +
"?\nBoth structures and unions that are currently unaligned will become aligned.\n" + "?\nAll structures and unions that are not currently packed will default packing enabled.\n" +
"This could cause component offsets to change and datatype sizes to change.\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); "Do you want to continue?", "Continue", OptionDialog.WARNING_MESSAGE);
if (result == OptionDialog.CANCEL_OPTION) { if (result == OptionDialog.CANCEL_OPTION) {
return; return;
} }
alignDataTypes(dataTypeManager, dataOrganization); packDataTypes(dataTypeManager, dataOrganization);
} }
else { else {
Msg.showWarn(this, gTree, "Alignment Not Allowed", Msg.showWarn(this, gTree, "Modification Not Allowed",
"The archive must be modifiable to align data types."); "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) { 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; return;
} }
int transactionID = -1; int transactionID = -1;
@ -113,9 +112,8 @@ public class AlignAllDataTypesAction extends DockingAction {
try { try {
// start a transaction // start a transaction
transactionID = transactionID =
dataTypeManager.startTransaction("Align all data types in " + dataTypeManager.startTransaction("Pack Composite Types");
dataTypeManager.getName()); packEachStructure(dataTypeManager, dataOrganization);
alignEachStructure(dataTypeManager, dataOrganization);
commit = true; commit = true;
} }
finally { finally {
@ -124,12 +122,14 @@ public class AlignAllDataTypesAction extends DockingAction {
} }
} }
private void alignEachStructure(DataTypeManager dataTypeManager, private void packEachStructure(DataTypeManager dataTypeManager,
DataOrganization dataOrganization) { DataOrganization dataOrganization) {
Iterator<? extends Composite> allComposites = dataTypeManager.getAllComposites(); Iterator<? extends Composite> allComposites = dataTypeManager.getAllComposites();
while (allComposites.hasNext()) { while (allComposites.hasNext()) {
Composite composite = allComposites.next(); 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.app.plugin.core.datamgr.tree.DataTypeTreeNode;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.Msg; import ghidra.util.Msg;
import ghidra.util.exception.InvalidInputException;
public class PackDataTypeAction extends DockingAction { public class PackDataTypeAction extends DockingAction {
private DataTypeManagerPlugin plugin;
public PackDataTypeAction(DataTypeManagerPlugin plugin) { public PackDataTypeAction(DataTypeManagerPlugin plugin) {
super("Pack Data Type", plugin.getName()); super("Pack Data Type", plugin.getName());
this.plugin = plugin; setPopupMenuData(new MenuData(new String[] { "Pack (default)" }, "Edit"));
setPopupMenuData(new MenuData(new String[] { "Pack" }, "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 @Override
public boolean isEnabledForContext(ActionContext context) { 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(); Object contextObject = context.getContextObject();
if (!(contextObject instanceof GTree)) { if (!(contextObject instanceof GTree)) {
return false; return null;
} }
GTree gTree = (GTree) contextObject; GTree gTree = (GTree) contextObject;
TreePath[] selectionPaths = gTree.getSelectionPaths(); TreePath[] selectionPaths = gTree.getSelectionPaths();
if (selectionPaths.length != 1) { if (selectionPaths.length != 1) {
return false; return null;
} }
DataTypeTreeNode node = (DataTypeTreeNode) selectionPaths[0].getLastPathComponent(); DataTypeTreeNode node = (DataTypeTreeNode) selectionPaths[0].getLastPathComponent();
if (!(node instanceof DataTypeNode)) { if (!(node instanceof DataTypeNode)) {
return false; return null;
} }
setEnabled(node.isModifiable()); return (DataTypeNode) node;
return true;
} }
@Override @Override
public void actionPerformed(ActionContext context) { public void actionPerformed(ActionContext context) {
GTree gTree = (GTree) context.getContextObject(); GTree gTree = (GTree) context.getContextObject();
TreePath[] selectionPaths = gTree.getSelectionPaths(); TreePath[] selectionPaths = gTree.getSelectionPaths();
if (selectionPaths.length != 1) { for (TreePath treePath : selectionPaths) {
Msg.error(this, "Pack is only allowed on an individual data type."); final DataTypeNode dataTypeNode = (DataTypeNode) treePath.getLastPathComponent();
return; 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(); DataTypeManager dataTypeManager = dataType.getDataTypeManager();
if (dataTypeManager == null) { if (dataTypeManager == null) {
Msg.error(this, Msg.error(this, "Can't align data type " + dataType.getName() +
"Can't pack data type " + dataType.getName() + " without a data type manager."); " 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; return;
} }
int transactionID = -1; int transactionID = -1;
boolean commit = false; boolean commit = false;
try { try {
// start a transaction // start a transaction
transactionID = dataTypeManager.startTransaction("pack of " + dataType.getName()); transactionID = dataTypeManager.startTransaction("align " + dataType.getName());
packDataType(dataType); ((Structure) dataType).setPackingEnabled(true);
commit = true; commit = true;
} }
catch (InvalidInputException iie) {
// TODO Auto-generated catch block
iie.printStackTrace();
}
finally { finally {
// commit the changes // commit the changes
dataTypeManager.endTransaction(transactionID, commit); 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.app.plugin.core.datamgr.tree.DataTypeTreeNode;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.Msg; import ghidra.util.Msg;
import ghidra.util.exception.InvalidInputException;
public class PackSizeDataTypeAction extends DockingAction { public class PackSizeDataTypeAction extends DockingAction {
@ -73,7 +72,8 @@ public class PackSizeDataTypeAction extends DockingAction {
return; return;
} }
NumberInputDialog numberInputDialog = new NumberInputDialog("pack alignment", 0, 0, 16); NumberInputDialog numberInputDialog =
new NumberInputDialog("explicit pack value", 0, 0, 16);
if (!numberInputDialog.show()) { if (!numberInputDialog.show()) {
return; return;
} }
@ -88,9 +88,8 @@ public class PackSizeDataTypeAction extends DockingAction {
packDataType(dataType, packSize); packDataType(dataType, packSize);
commit = true; commit = true;
} }
catch (InvalidInputException iie) { catch (IllegalArgumentException iie) {
// TODO Auto-generated catch block Msg.showError(this, null, "Invalid Pack Value", iie.getMessage());
iie.printStackTrace();
} }
finally { finally {
// commit the changes // commit the changes
@ -98,13 +97,13 @@ public class PackSizeDataTypeAction extends DockingAction {
} }
} }
private void packDataType(DataType dataType, int packSize) throws InvalidInputException { private void packDataType(DataType dataType, int packSize) throws IllegalArgumentException {
if (!(dataType instanceof Structure)) { if (!(dataType instanceof Composite)) {
Msg.error(this, 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; return;
} }
((Structure) dataType).pack(packSize); ((Composite) dataType).pack(packSize);
} }
} }

View file

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

View file

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

View file

@ -15,8 +15,9 @@
*/ */
package ghidra.app.plugin.core.stackeditor; package ghidra.app.plugin.core.stackeditor;
import java.util.Collections; import java.util.*;
import java.util.Comparator;
import javax.help.UnsupportedOperationException;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.exception.AssertException; import ghidra.util.exception.AssertException;
@ -54,6 +55,49 @@ public abstract class BiDirectionDataType extends StructureDataType
this.splitOffset = splitOffset; 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) { protected DataTypeComponent getDefinedComponentAt(int offset) {
if (offset < splitOffset - negativeLength || offset >= splitOffset + positiveLength) { if (offset < splitOffset - negativeLength || offset >= splitOffset + positiveLength) {
return null; return null;
@ -108,20 +152,15 @@ public abstract class BiDirectionDataType extends StructureDataType
return positiveLength; return positiveLength;
} }
@Override
public int getLength() {
return structLength;
}
@Override @Override
public void delete(int index) { public void delete(int index) {
if (index < 0 || index >= numComponents) { if (index < 0 || index >= numComponents) {
throw new ArrayIndexOutOfBoundsException(index); throw new IndexOutOfBoundsException(index);
} }
DataTypeComponent comp = getComponent(index); DataTypeComponent comp = getComponent(index);
int offset = comp.getOffset(); int offset = comp.getOffset();
int length = comp.getLength(); int length = comp.getLength();
int idx = Collections.binarySearch(components, new Integer(index), ordinalComparator); int idx = Collections.binarySearch(components, index, ordinalComparator);
if (idx >= 0) { if (idx >= 0) {
DataTypeComponent dtc = components.remove(idx); DataTypeComponent dtc = components.remove(idx);
dtc.getDataType().removeParent(this); dtc.getDataType().removeParent(this);
@ -137,7 +176,7 @@ public abstract class BiDirectionDataType extends StructureDataType
} }
@Override @Override
public void delete(int[] ordinals) { public void delete(Set<Integer> ordinals) {
for (int ordinal : ordinals) { for (int ordinal : ordinals) {
delete(ordinal); delete(ordinal);
} }
@ -173,6 +212,7 @@ public abstract class BiDirectionDataType extends StructureDataType
} }
} }
structLength += deltaLength; structLength += deltaLength;
// nonpackedAlignedStructLength = -1;
} }
/* /*
@ -198,7 +238,7 @@ public abstract class BiDirectionDataType extends StructureDataType
protected DataTypeComponent getDefinedComponent(int ordinal) { protected DataTypeComponent getDefinedComponent(int ordinal) {
if (ordinal < 0 || ordinal >= numComponents) { if (ordinal < 0 || ordinal >= numComponents) {
throw new ArrayIndexOutOfBoundsException(ordinal); throw new IndexOutOfBoundsException(ordinal);
} }
int idx = Collections.binarySearch(components, new Integer(ordinal), ordinalComparator); int idx = Collections.binarySearch(components, new Integer(ordinal), ordinalComparator);
if (idx >= 0) { if (idx >= 0) {
@ -210,7 +250,7 @@ public abstract class BiDirectionDataType extends StructureDataType
@Override @Override
public DataTypeComponent getComponent(int ordinal) { public DataTypeComponent getComponent(int ordinal) {
if (ordinal < 0 || ordinal >= numComponents) { if (ordinal < 0 || ordinal >= numComponents) {
throw new ArrayIndexOutOfBoundsException(ordinal); throw new IndexOutOfBoundsException(ordinal);
} }
int idx = Collections.binarySearch(components, new Integer(ordinal), ordinalComparator); int idx = Collections.binarySearch(components, new Integer(ordinal), ordinalComparator);
if (idx >= 0) { if (idx >= 0) {
@ -255,12 +295,14 @@ public abstract class BiDirectionDataType extends StructureDataType
numComponents += deltaLength; numComponents += deltaLength;
positiveLength += deltaLength; positiveLength += deltaLength;
structLength += deltaLength; structLength += deltaLength;
// nonpackedAlignedStructLength = -1;
} }
if (nextOffset < splitOffset - negativeLength) { if (nextOffset < splitOffset - negativeLength) {
int deltaLength = splitOffset - nextOffset - negativeLength; int deltaLength = splitOffset - nextOffset - negativeLength;
numComponents += deltaLength; numComponents += deltaLength;
negativeLength += deltaLength; negativeLength += deltaLength;
structLength += deltaLength; structLength += deltaLength;
// nonpackedAlignedStructLength = -1;
} }
checkAncestry(dataType); checkAncestry(dataType);
dataType = dataType.clone(getDataTypeManager()); dataType = dataType.clone(getDataTypeManager());
@ -319,6 +361,7 @@ public abstract class BiDirectionDataType extends StructureDataType
numComponents++; numComponents++;
positiveLength += length; positiveLength += length;
structLength += length; structLength += length;
// nonpackedAlignedStructLength = -1;
notifySizeChanged(); notifySizeChanged();
return dtc; return dtc;
} }
@ -341,6 +384,7 @@ public abstract class BiDirectionDataType extends StructureDataType
numComponents++; numComponents++;
negativeLength += length; negativeLength += length;
structLength += length; structLength += length;
// nonpackedAlignedStructLength = -1;
notifySizeChanged(); notifySizeChanged();
return dtc; return dtc;
} }
@ -367,39 +411,14 @@ public abstract class BiDirectionDataType extends StructureDataType
} }
numComponents += absAmount; numComponents += absAmount;
structLength += absAmount; structLength += absAmount;
// nonpackedAlignedStructLength = -1;
notifySizeChanged(); notifySizeChanged();
} }
@Override @Override
public DataTypeComponent insert(int index, DataType dataType, int length, String newName, public DataTypeComponent insert(int index, DataType dataType, int length, String newName,
String comment) { String comment) {
throw new AssertException("BiDirectionDataType.insert() not implemented."); throw new UnsupportedOperationException("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;
} }
protected void insertAtOffset(int offset, int numBytes) { protected void insertAtOffset(int offset, int numBytes) {
@ -441,6 +460,7 @@ public abstract class BiDirectionDataType extends StructureDataType
} }
numComponents += numBytes; numComponents += numBytes;
structLength += numBytes; structLength += numBytes;
// nonpackedAlignedStructLength = -1;
notifySizeChanged(); notifySizeChanged();
} }
@ -479,7 +499,7 @@ public abstract class BiDirectionDataType extends StructureDataType
if ((splitOffset != biDir.getSplitOffset()) || if ((splitOffset != biDir.getSplitOffset()) ||
(negativeLength != biDir.getNegativeLength()) || (negativeLength != biDir.getNegativeLength()) ||
(positiveLength != biDir.getPositiveLength()) || (positiveLength != biDir.getPositiveLength()) ||
(structLength != biDir.getLength())) { (getLength() != biDir.getLength())) {
return false; return false;
} }
DataTypeComponent[] myComps = getDefinedComponents(); DataTypeComponent[] myComps = getDefinedComponents();
@ -499,72 +519,13 @@ public abstract class BiDirectionDataType extends StructureDataType
@Override @Override
public void dataTypeSizeChanged(DataType dt) { public void dataTypeSizeChanged(DataType dt) {
throw new AssertException("BiDirectionDataType.dataTypeSizeChanged() not implemented."); // ignore
// 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);
// }
} }
/** @Override
* public void dataTypeAlignmentChanged(DataType dt) {
* @param index the index of the defined component that is consuming the bytes. // ignore
* @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 @Override
public abstract BiDirectionDataType clone(DataTypeManager dtm); public abstract BiDirectionDataType clone(DataTypeManager dtm);
@ -572,7 +533,7 @@ public abstract class BiDirectionDataType extends StructureDataType
@Override @Override
public void clearComponent(int index) { public void clearComponent(int index) {
if (index < 0 || index >= numComponents) { if (index < 0 || index >= numComponents) {
throw new ArrayIndexOutOfBoundsException(index); throw new IndexOutOfBoundsException(index);
} }
int idx = Collections.binarySearch(components, new Integer(index), ordinalComparator); int idx = Collections.binarySearch(components, new Integer(index), ordinalComparator);
if (idx >= 0) { if (idx >= 0) {
@ -589,81 +550,20 @@ public abstract class BiDirectionDataType extends StructureDataType
} }
public void replaceWith(Structure struct) { public void replaceWith(Structure struct) {
throw new AssertException("BiDirectionDataType.replaceWith() not implemented."); throw new UnsupportedOperationException(
// int oldLength = structLength; "BiDirectionDataType.replaceWith() not implemented.");
// doReplaceWith(struct);
// if (oldLength != structLength) {
// sizeChanged();
// }
// else if (dtMgr != null) {
// dtMgr.dataTypeChanged(this);
// }
} }
// 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 @Override
public void dataTypeDeleted(DataType dt) { public void dataTypeDeleted(DataType dt) {
throw new AssertException("BiDirectionDataType.dataTypeDeleted() not implemented."); throw new UnsupportedOperationException(
// boolean didChange = false; "BiDirectionDataType.dataTypeDeleted() not implemented.");
// 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);
// }
} }
@Override @Override
public void dataTypeReplaced(DataType oldDt, DataType newDt) { public void dataTypeReplaced(DataType oldDt, DataType newDt) {
throw new AssertException("BiDirectionDataType.dataTypeReplaced() not implemented."); throw new UnsupportedOperationException(
// int n = components.size(); "BiDirectionDataType.dataTypeReplaced() not implemented.");
// 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);
// }
} }
@Override @Override
@ -682,9 +582,9 @@ public abstract class BiDirectionDataType extends StructureDataType
@Override @Override
public DataTypeComponent replace(int index, DataType dataType, int length, String newName, 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) { if (index < 0 || index >= numComponents) {
throw new ArrayIndexOutOfBoundsException(index); throw new IndexOutOfBoundsException(index);
} }
validateDataType(dataType); validateDataType(dataType);
checkAncestry(dataType); checkAncestry(dataType);

View file

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

View file

@ -82,8 +82,7 @@ class DWARFDataTypeConflictHandler extends DataTypeConflictHandler {
* @return true if empty or default and false otherwise * @return true if empty or default and false otherwise
*/ */
private boolean isCompositeDefault(Composite composite) { private boolean isCompositeDefault(Composite composite) {
return composite.isNotYetDefined() return composite.isNotYetDefined() || (composite.getNumDefinedComponents() == 0);
|| ((composite instanceof Structure) && ((Structure) composite).getNumDefinedComponents() == 0);
} }
private boolean isCompositePart(Composite full, Composite part, Set<Long> visitedDataTypes) { 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) { CategoryPath categoryPath, String structureName, int packValue) {
StructureDataType struct = StructureDataType struct =
new StructureDataType(categoryPath, structureName, 0, dataTypeManager); new StructureDataType(categoryPath, structureName, 0, dataTypeManager);
struct.setInternallyAligned(true); struct.setPackingEnabled(true);
struct.setPackingValue(packValue); if (packValue > 0) {
struct.setExplicitPackingValue(packValue);
}
return struct; return struct;
} }

View file

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

View file

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

View file

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

View file

@ -623,7 +623,7 @@ public class DataTypesXmlMgr {
XmlAttributes attrs = new XmlAttributes(); XmlAttributes attrs = new XmlAttributes();
attrs.addAttribute("NAME", struct.getDisplayName()); attrs.addAttribute("NAME", struct.getDisplayName());
attrs.addAttribute("NAMESPACE", struct.getCategoryPath().getPath()); 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); writer.startElement("STRUCTURE", attrs);
writeRegularComment(writer, struct.getDescription()); writeRegularComment(writer, struct.getDescription());
DataTypeComponent[] members = struct.getComponents(); DataTypeComponent[] members = struct.getComponents();
@ -637,7 +637,7 @@ public class DataTypesXmlMgr {
XmlAttributes attrs = new XmlAttributes(); XmlAttributes attrs = new XmlAttributes();
attrs.addAttribute("NAME", union.getDisplayName()); attrs.addAttribute("NAME", union.getDisplayName());
attrs.addAttribute("NAMESPACE", union.getCategoryPath().getPath()); 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); writer.startElement("UNION", attrs);
writeRegularComment(writer, union.getDescription()); writeRegularComment(writer, union.getDescription());
DataTypeComponent[] members = union.getComponents(); DataTypeComponent[] members = union.getComponents();
@ -649,7 +649,7 @@ public class DataTypesXmlMgr {
private void writerMember(XmlWriter writer, DataTypeComponent member) { private void writerMember(XmlWriter writer, DataTypeComponent member) {
XmlAttributes attrs = new XmlAttributes(); 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("OFFSET", member.getOffset(), true);
attrs.addAttribute("DATATYPE", member.getDataType().getDisplayName()); attrs.addAttribute("DATATYPE", member.getDataType().getDisplayName());
attrs.addAttribute("DATATYPE_NAMESPACE", member.getDataType().getCategoryPath().getPath()); 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); <STRUCT> ( DeclSpec() )* { comp = new StructureDataType(ANONYMOUS_STRUCT_PREFIX + cnt++, 0);
// Always set the packing, because by default structures should be aligned // Always set the packing, because by default structures should be aligned
// setting 0 turns off packing, but sets structures to be aligned if (packSize > 0) {
comp.setPackingValue(this.packSize); comp.setExplicitPackingValue(packSize);
}
else {
comp.setPackingEnabled(true); // ensure default packing enabled
}
} }
| |
<UNION> ( DeclSpec() )* { comp = new UnionDataType(ANONYMOUS_UNION_PREFIX + cnt++); <UNION> ( DeclSpec() )* { comp = new UnionDataType(ANONYMOUS_UNION_PREFIX + cnt++);
// Always set the packing, because by default structures should be aligned // Always set the packing, because by default structures should be aligned
// setting 0 turns off packing, but sets structures to be aligned. if (packSize > 0) {
comp.setPackingValue(this.packSize); comp.setExplicitPackingValue(packSize);
}
else {
comp.setPackingEnabled(true); // ensure default packing enabled
}
} }
) )
{ {

View file

@ -604,7 +604,7 @@ public class DataTypeMerge3Test extends AbstractDataTypeMergeTest {
executeMerge(); 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); setErrorsExpected(true);
@ -2201,7 +2201,7 @@ public class DataTypeMerge3Test extends AbstractDataTypeMergeTest {
(Union) dtm.getDataType(new CategoryPath("/Category1/Category2"), "CoolUnion"); (Union) dtm.getDataType(new CategoryPath("/Category1/Category2"), "CoolUnion");
//@formatter:off //@formatter:off
assertEquals("/Category1/Category2/CoolUnion\n" + assertEquals("/Category1/Category2/CoolUnion\n" +
"Unaligned\n" + "pack(disabled)\n" +
"Union CoolUnion {\n" + "Union CoolUnion {\n" +
" 0 qword 8 null \"\"\n" + " 0 qword 8 null \"\"\n" +
" 0 byte:4(4) 1 BF1 \"my bf1\"\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.program.model.data.*;
import ghidra.util.InvalidNameException; import ghidra.util.InvalidNameException;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
import ghidra.util.task.TaskMonitorAdapter; import ghidra.util.task.TaskMonitor;
/** /**
* More data type merge tests. * More data type merge tests.
@ -502,7 +502,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
int transactionID = program.startTransaction("test"); int transactionID = program.startTransaction("test");
Structure foo = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Foo"); Structure foo = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Foo");
try { try {
dtm.remove(foo, TaskMonitorAdapter.DUMMY_MONITOR); dtm.remove(foo, TaskMonitor.DUMMY);
commit = true; commit = true;
} }
finally { finally {
@ -709,7 +709,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
// delete Bar from Foo // delete Bar from Foo
fs.delete(3); fs.delete(3);
// add Foo to Bar // add Foo to Bar
dtm.remove(bs, TaskMonitorAdapter.DUMMY_MONITOR); dtm.remove(bs, TaskMonitor.DUMMY);
// Add s1, s2, s3 // Add s1, s2, s3
Structure s1 = new StructureDataType(new CategoryPath("/MISC"), "S1", 0); Structure s1 = new StructureDataType(new CategoryPath("/MISC"), "S1", 0);
@ -809,7 +809,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
// delete Bar from Foo // delete Bar from Foo
foo.delete(3); foo.delete(3);
// remove Bar from the data type manager // remove Bar from the data type manager
dtm.remove(bar, TaskMonitorAdapter.DUMMY_MONITOR); dtm.remove(bar, TaskMonitor.DUMMY);
// Add s1, s2, s3 // Add s1, s2, s3
Structure s1 = new StructureDataType(new CategoryPath("/MISC"), "S1", 0); Structure s1 = new StructureDataType(new CategoryPath("/MISC"), "S1", 0);
@ -920,7 +920,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
// delete Bar from Foo // delete Bar from Foo
fs.delete(3); fs.delete(3);
// remove Bar from the data type manager // remove Bar from the data type manager
dtm.remove(bs, TaskMonitorAdapter.DUMMY_MONITOR); dtm.remove(bs, TaskMonitor.DUMMY);
// Add s1, s2, s3 // Add s1, s2, s3
Structure s1 = new StructureDataType(new CategoryPath("/MISC"), "S1", 0); 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"); Structure fs = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Foo");
try { try {
// delete Foo from the data type manager // delete Foo from the data type manager
dtm.remove(fs, TaskMonitorAdapter.DUMMY_MONITOR); dtm.remove(fs, TaskMonitor.DUMMY);
commit = true; commit = true;
} }
finally { finally {
@ -1051,7 +1051,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
dtm.getDataType(new CategoryPath("/MISC"), "Bar"); dtm.getDataType(new CategoryPath("/MISC"), "Bar");
try { try {
// delete Foo from the data type manager // delete Foo from the data type manager
dtm.remove(foo, TaskMonitorAdapter.DUMMY_MONITOR); dtm.remove(foo, TaskMonitor.DUMMY);
// Add s1, s2, s3 // Add s1, s2, s3
Structure s1 = new StructureDataType(new CategoryPath("/MISC"), "S1", 0); 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"); Structure fs = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Foo");
try { try {
// delete Foo from the data type manager // delete Foo from the data type manager
dtm.remove(fs, TaskMonitorAdapter.DUMMY_MONITOR); dtm.remove(fs, TaskMonitor.DUMMY);
commit = true; commit = true;
} }
finally { finally {
@ -1146,7 +1146,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
dtm.getDataType(new CategoryPath("/MISC"), "Bar"); dtm.getDataType(new CategoryPath("/MISC"), "Bar");
try { try {
// delete Foo from the data type manager // delete Foo from the data type manager
dtm.remove(foo, TaskMonitorAdapter.DUMMY_MONITOR); dtm.remove(foo, TaskMonitor.DUMMY);
// Add s1, s2, s3 // Add s1, s2, s3
Structure s1 = new StructureDataType(new CategoryPath("/MISC"), "S1", 0); 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"); Structure bar = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Bar");
try { try {
// remove Bar from the data type manager // remove Bar from the data type manager
dtm.remove(bar, TaskMonitorAdapter.DUMMY_MONITOR); dtm.remove(bar, TaskMonitor.DUMMY);
commit = true; commit = true;
} }
finally { finally {
@ -1441,7 +1441,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
Structure bar = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Bar"); Structure bar = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Bar");
try { try {
// remove Bar from the data type manager // remove Bar from the data type manager
dtm.remove(bar, TaskMonitorAdapter.DUMMY_MONITOR); dtm.remove(bar, TaskMonitor.DUMMY);
commit = true; commit = true;
} }
finally { finally {
@ -1555,7 +1555,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
Structure bar = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Bar"); Structure bar = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Bar");
try { try {
// remove Bar from the data type manager // remove Bar from the data type manager
dtm.remove(bar, TaskMonitorAdapter.DUMMY_MONITOR); dtm.remove(bar, TaskMonitor.DUMMY);
commit = true; commit = true;
} }
finally { finally {
@ -1643,7 +1643,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
Structure bar = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Bar"); Structure bar = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Bar");
try { try {
// remove Bar from the data type manager // remove Bar from the data type manager
dtm.remove(bar, TaskMonitorAdapter.DUMMY_MONITOR); dtm.remove(bar, TaskMonitor.DUMMY);
commit = true; commit = true;
} }
finally { finally {
@ -1750,7 +1750,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
Structure bar = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Bar"); Structure bar = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Bar");
try { try {
// remove Bar from the data type manager // remove Bar from the data type manager
dtm.remove(bar, TaskMonitorAdapter.DUMMY_MONITOR); dtm.remove(bar, TaskMonitor.DUMMY);
commit = true; commit = true;
} }
finally { finally {
@ -1844,7 +1844,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
Structure bar = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Bar"); Structure bar = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Bar");
try { try {
// remove Bar from the data type manager // remove Bar from the data type manager
dtm.remove(bar, TaskMonitorAdapter.DUMMY_MONITOR); dtm.remove(bar, TaskMonitor.DUMMY);
commit = true; commit = true;
} }
finally { finally {
@ -1943,7 +1943,7 @@ public class DataTypeMerge4Test extends AbstractDataTypeMergeTest {
Structure bar = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Bar"); Structure bar = (Structure) dtm.getDataType(new CategoryPath("/MISC"), "Bar");
try { try {
// remove Bar from the data type manager // remove Bar from the data type manager
dtm.remove(bar, TaskMonitorAdapter.DUMMY_MONITOR); dtm.remove(bar, TaskMonitor.DUMMY);
commit = true; commit = true;
} }
finally { finally {

View file

@ -21,7 +21,7 @@ import org.junit.Test;
import ghidra.program.database.*; import ghidra.program.database.*;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.task.TaskMonitorAdapter; import ghidra.util.task.TaskMonitor;
/** /**
* Data type merge tests for aligned data types. * Data type merge tests for aligned data types.
@ -31,9 +31,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
private void setupStructureMachineAlignedVsValue() throws Exception { private void setupStructureMachineAlignedVsValue() throws Exception {
mtf.initialize("notepad", new OriginalProgramModifierListener() { mtf.initialize("notepad", new OriginalProgramModifierListener() {
/* (non-Javadoc)
* @see ghidra.framework.data.OriginalProgramModifierListener#modifyOriginal(ghidra.program.database.ProgramDB)
*/
@Override @Override
public void modifyOriginal(ProgramDB program) throws Exception { public void modifyOriginal(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -45,7 +43,8 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
new CategoryPath("/Category1/Category2/Category3"), "IntStruct"); new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
assertEquals(15, s.getLength()); assertEquals(15, s.getLength());
assertEquals(1, s.getAlignment()); assertEquals(1, s.getAlignment());
s.setInternallyAligned(true); s.setToDefaultPacking();
// Offsets change to 0,2,4,8. // Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).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 @Override
public void modifyLatest(ProgramDB program) throws Exception { public void modifyLatest(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -72,7 +68,8 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try { try {
Structure s = (Structure) dtm.getDataType( Structure s = (Structure) dtm.getDataType(
new CategoryPath("/Category1/Category2/Category3"), "IntStruct"); new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
s.setToMachineAlignment(); s.setToMachineAligned();
// Offsets change to 0,2,4,8. // Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).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 @Override
public void modifyPrivate(ProgramDB program) throws Exception { public void modifyPrivate(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -99,7 +93,8 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try { try {
Structure s = (Structure) dtm.getDataType( Structure s = (Structure) dtm.getDataType(
new CategoryPath("/Category1/Category2/Category3"), "IntStruct"); new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
s.setMinimumAlignment(4); s.setExplicitMinimumAlignment(4);
// Offsets change to 0,2,4,8. // Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset()); assertEquals(2, s.getComponent(1).getOffset());
@ -129,11 +124,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager(); DataTypeManager dtm = resultProgram.getDataTypeManager();
Category c = dtm.getCategory(new CategoryPath("/Category1/Category2/Category3")); Category c = dtm.getCategory(new CategoryPath("/Category1/Category2/Category3"));
Structure s = (Structure) c.getDataType("IntStruct"); Structure s = (Structure) c.getDataType("IntStruct");
assertEquals(true, s.isInternallyAligned()); assertTrue(s.hasDefaultPacking());
assertEquals(false, s.isDefaultAligned()); assertTrue(s.isMachineAligned());
assertEquals(true, s.isMachineAligned());
assertEquals(8, s.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset()); assertEquals(2, s.getComponent(1).getOffset());
assertEquals(4, s.getComponent(2).getOffset()); assertEquals(4, s.getComponent(2).getOffset());
@ -155,11 +148,10 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager(); DataTypeManager dtm = resultProgram.getDataTypeManager();
Category c = dtm.getCategory(new CategoryPath("/Category1/Category2/Category3")); Category c = dtm.getCategory(new CategoryPath("/Category1/Category2/Category3"));
Structure s = (Structure) c.getDataType("IntStruct"); Structure s = (Structure) c.getDataType("IntStruct");
assertEquals(true, s.isInternallyAligned()); assertTrue(s.hasDefaultPacking());
assertEquals(false, s.isDefaultAligned()); assertTrue(s.hasExplicitMinimumAlignment());
assertEquals(false, s.isMachineAligned()); assertEquals(4, s.getExplicitMinimumAlignment());
assertEquals(4, s.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset()); assertEquals(2, s.getComponent(1).getOffset());
assertEquals(4, s.getComponent(2).getOffset()); assertEquals(4, s.getComponent(2).getOffset());
@ -181,11 +173,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager(); DataTypeManager dtm = resultProgram.getDataTypeManager();
Category c = dtm.getCategory(new CategoryPath("/Category1/Category2/Category3")); Category c = dtm.getCategory(new CategoryPath("/Category1/Category2/Category3"));
Structure s = (Structure) c.getDataType("IntStruct"); Structure s = (Structure) c.getDataType("IntStruct");
assertEquals(true, s.isInternallyAligned()); assertTrue(s.hasDefaultPacking());
assertEquals(true, s.isDefaultAligned()); assertTrue(s.isDefaultAligned());
assertEquals(false, s.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, s.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset()); assertEquals(2, s.getComponent(1).getOffset());
assertEquals(4, s.getComponent(2).getOffset()); assertEquals(4, s.getComponent(2).getOffset());
@ -197,9 +187,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
private void setupStructurePack1VsPack2() throws Exception { private void setupStructurePack1VsPack2() throws Exception {
mtf.initialize("notepad", new OriginalProgramModifierListener() { mtf.initialize("notepad", new OriginalProgramModifierListener() {
/* (non-Javadoc)
* @see ghidra.framework.data.OriginalProgramModifierListener#modifyOriginal(ghidra.program.database.ProgramDB)
*/
@Override @Override
public void modifyOriginal(ProgramDB program) throws Exception { public void modifyOriginal(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -211,7 +199,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
new CategoryPath("/Category1/Category2/Category3"), "IntStruct"); new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
assertEquals(15, s.getLength()); assertEquals(15, s.getLength());
assertEquals(1, s.getAlignment()); assertEquals(1, s.getAlignment());
s.setInternallyAligned(true); s.setToDefaultPacking();
// Offsets change to 0,2,4,8. // Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
@ -220,7 +208,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(8, s.getComponent(3).getOffset()); assertEquals(8, s.getComponent(3).getOffset());
assertEquals(16, s.getLength()); assertEquals(16, s.getLength());
assertEquals(4, s.getAlignment()); assertEquals(4, s.getAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
commit = true; commit = true;
} }
finally { finally {
@ -228,9 +216,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
} }
} }
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyLatest(ghidra.program.database.ProgramDB)
*/
@Override @Override
public void modifyLatest(ProgramDB program) throws Exception { public void modifyLatest(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -240,7 +225,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try { try {
Structure s = (Structure) dtm.getDataType( Structure s = (Structure) dtm.getDataType(
new CategoryPath("/Category1/Category2/Category3"), "IntStruct"); new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
s.setPackingValue(1); s.pack(1);
// Offsets change to 0,2,4,8. // Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
@ -249,7 +234,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(7, s.getComponent(3).getOffset()); assertEquals(7, s.getComponent(3).getOffset());
assertEquals(15, s.getLength()); assertEquals(15, s.getLength());
assertEquals(1, s.getAlignment()); assertEquals(1, s.getAlignment());
assertEquals(1, s.getPackingValue());
commit = true; commit = true;
} }
finally { finally {
@ -257,9 +242,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
} }
} }
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyPrivate(ghidra.program.database.ProgramDB)
*/
@Override @Override
public void modifyPrivate(ProgramDB program) throws Exception { public void modifyPrivate(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -269,7 +251,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try { try {
Structure s = (Structure) dtm.getDataType( Structure s = (Structure) dtm.getDataType(
new CategoryPath("/Category1/Category2/Category3"), "IntStruct"); new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
s.setPackingValue(2); s.pack(2);
// Offsets change to 0,2,4,8. // Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
@ -278,7 +260,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(8, s.getComponent(3).getOffset()); assertEquals(8, s.getComponent(3).getOffset());
assertEquals(16, s.getLength()); assertEquals(16, s.getLength());
assertEquals(2, s.getAlignment()); assertEquals(2, s.getAlignment());
assertEquals(2, s.getPackingValue());
commit = true; commit = true;
} }
finally { finally {
@ -302,11 +284,10 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Structure s = Structure s =
(Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"), (Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"),
"IntStruct"); "IntStruct");
assertEquals(true, s.isInternallyAligned()); assertTrue(s.hasExplicitPackingValue());
assertEquals(true, s.isDefaultAligned()); assertEquals(1, s.getExplicitPackingValue());
assertEquals(false, s.isMachineAligned()); assertTrue(s.isDefaultAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, s.getMinimumAlignment());
assertEquals(1, s.getPackingValue());
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(1, s.getComponent(1).getOffset()); assertEquals(1, s.getComponent(1).getOffset());
assertEquals(3, s.getComponent(2).getOffset()); assertEquals(3, s.getComponent(2).getOffset());
@ -329,11 +310,10 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Structure s = Structure s =
(Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"), (Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"),
"IntStruct"); "IntStruct");
assertEquals(true, s.isInternallyAligned()); assertTrue(s.hasExplicitPackingValue());
assertEquals(true, s.isDefaultAligned()); assertEquals(2, s.getExplicitPackingValue());
assertEquals(false, s.isMachineAligned()); assertTrue(s.isDefaultAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, s.getMinimumAlignment());
assertEquals(2, s.getPackingValue());
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset()); assertEquals(2, s.getComponent(1).getOffset());
assertEquals(4, s.getComponent(2).getOffset()); assertEquals(4, s.getComponent(2).getOffset());
@ -355,11 +335,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager(); DataTypeManager dtm = resultProgram.getDataTypeManager();
Category c = dtm.getCategory(new CategoryPath("/Category1/Category2/Category3")); Category c = dtm.getCategory(new CategoryPath("/Category1/Category2/Category3"));
Structure s = (Structure) c.getDataType("IntStruct"); Structure s = (Structure) c.getDataType("IntStruct");
assertEquals(true, s.isInternallyAligned()); assertTrue(s.hasDefaultPacking());
assertEquals(true, s.isDefaultAligned()); assertTrue(s.isDefaultAligned());
assertEquals(false, s.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, s.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset()); assertEquals(2, s.getComponent(1).getOffset());
assertEquals(4, s.getComponent(2).getOffset()); assertEquals(4, s.getComponent(2).getOffset());
@ -371,9 +349,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
private void setupStructureMinAlignVsPack() throws Exception { private void setupStructureMinAlignVsPack() throws Exception {
mtf.initialize("notepad", new OriginalProgramModifierListener() { mtf.initialize("notepad", new OriginalProgramModifierListener() {
/* (non-Javadoc)
* @see ghidra.framework.data.OriginalProgramModifierListener#modifyOriginal(ghidra.program.database.ProgramDB)
*/
@Override @Override
public void modifyOriginal(ProgramDB program) throws Exception { public void modifyOriginal(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -385,7 +361,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
new CategoryPath("/Category1/Category2/Category3"), "IntStruct"); new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
assertEquals(15, s.getLength()); assertEquals(15, s.getLength());
assertEquals(1, s.getAlignment()); assertEquals(1, s.getAlignment());
s.setInternallyAligned(true); s.setToDefaultPacking();
// Offsets change to 0,2,4,8. // Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
@ -394,7 +370,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(8, s.getComponent(3).getOffset()); assertEquals(8, s.getComponent(3).getOffset());
assertEquals(16, s.getLength()); assertEquals(16, s.getLength());
assertEquals(4, s.getAlignment()); assertEquals(4, s.getAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
commit = true; commit = true;
} }
finally { finally {
@ -402,9 +378,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
} }
} }
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyLatest(ghidra.program.database.ProgramDB)
*/
@Override @Override
public void modifyLatest(ProgramDB program) throws Exception { public void modifyLatest(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -414,7 +387,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try { try {
Structure s = (Structure) dtm.getDataType( Structure s = (Structure) dtm.getDataType(
new CategoryPath("/Category1/Category2/Category3"), "IntStruct"); new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
s.setToMachineAlignment(); s.setToMachineAligned();
// Offsets change to 0,2,4,8. // Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset()); 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 @Override
public void modifyPrivate(ProgramDB program) throws Exception { public void modifyPrivate(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -442,7 +412,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try { try {
Structure s = (Structure) dtm.getDataType( Structure s = (Structure) dtm.getDataType(
new CategoryPath("/Category1/Category2/Category3"), "IntStruct"); new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
s.setPackingValue(1); s.pack(1);
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(1, s.getComponent(1).getOffset()); assertEquals(1, s.getComponent(1).getOffset());
@ -450,7 +420,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(7, s.getComponent(3).getOffset()); assertEquals(7, s.getComponent(3).getOffset());
assertEquals(15, s.getLength()); assertEquals(15, s.getLength());
assertEquals(1, s.getAlignment()); assertEquals(1, s.getAlignment());
assertEquals(1, s.getPackingValue());
commit = true; commit = true;
} }
finally { finally {
@ -474,11 +444,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Structure s = Structure s =
(Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"), (Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"),
"IntStruct"); "IntStruct");
assertEquals(true, s.isInternallyAligned()); assertTrue(s.hasDefaultPacking());
assertEquals(false, s.isDefaultAligned()); assertTrue(s.isMachineAligned());
assertEquals(true, s.isMachineAligned());
assertEquals(8, s.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset()); assertEquals(2, s.getComponent(1).getOffset());
assertEquals(4, s.getComponent(2).getOffset()); assertEquals(4, s.getComponent(2).getOffset());
@ -501,11 +469,10 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Structure s = Structure s =
(Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"), (Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"),
"IntStruct"); "IntStruct");
assertEquals(true, s.isInternallyAligned()); assertTrue(s.hasExplicitPackingValue());
assertEquals(true, s.isDefaultAligned()); assertEquals(1, s.getExplicitPackingValue());
assertEquals(false, s.isMachineAligned()); assertTrue(s.isDefaultAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, s.getMinimumAlignment());
assertEquals(1, s.getPackingValue());
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(1, s.getComponent(1).getOffset()); assertEquals(1, s.getComponent(1).getOffset());
assertEquals(3, s.getComponent(2).getOffset()); assertEquals(3, s.getComponent(2).getOffset());
@ -517,9 +484,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
private void setupStructureAddVsAlign() throws Exception { private void setupStructureAddVsAlign() throws Exception {
mtf.initialize("notepad", new ProgramModifierListener() { mtf.initialize("notepad", new ProgramModifierListener() {
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyLatest(ghidra.program.database.ProgramDB)
*/
@Override @Override
public void modifyLatest(ProgramDB program) throws Exception { public void modifyLatest(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -534,6 +499,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
s.add(new IntegerDataType()); s.add(new IntegerDataType());
// Offsets change to 0,2,4,8. // Offsets change to 0,2,4,8.
assertFalse(s.isPackingEnabled());
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(1, s.getComponent(1).getOffset()); assertEquals(1, s.getComponent(1).getOffset());
assertEquals(3, s.getComponent(2).getOffset()); assertEquals(3, s.getComponent(2).getOffset());
@ -541,7 +507,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(15, s.getComponent(4).getOffset()); assertEquals(15, s.getComponent(4).getOffset());
assertEquals(19, s.getLength()); assertEquals(19, s.getLength());
assertEquals(1, s.getAlignment()); assertEquals(1, s.getAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
commit = true; commit = true;
} }
finally { finally {
@ -549,9 +514,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
} }
} }
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyPrivate(ghidra.program.database.ProgramDB)
*/
@Override @Override
public void modifyPrivate(ProgramDB program) throws Exception { public void modifyPrivate(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -563,7 +525,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
new CategoryPath("/Category1/Category2/Category3"), "IntStruct"); new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
assertEquals(15, s.getLength()); assertEquals(15, s.getLength());
assertEquals(1, s.getAlignment()); assertEquals(1, s.getAlignment());
s.setInternallyAligned(true); s.setToDefaultPacking();
// Offsets change to 0,2,4,8. // Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
@ -572,7 +534,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(8, s.getComponent(3).getOffset()); assertEquals(8, s.getComponent(3).getOffset());
assertEquals(16, s.getLength()); assertEquals(16, s.getLength());
assertEquals(4, s.getAlignment()); assertEquals(4, s.getAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
commit = true; commit = true;
} }
finally { finally {
@ -596,11 +558,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Structure s = Structure s =
(Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"), (Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"),
"IntStruct"); "IntStruct");
assertEquals(false, s.isInternallyAligned()); assertFalse(s.isPackingEnabled());
assertEquals(true, s.isDefaultAligned()); assertTrue(s.isDefaultAligned());
assertEquals(false, s.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, s.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(1, s.getComponent(1).getOffset()); assertEquals(1, s.getComponent(1).getOffset());
assertEquals(3, s.getComponent(2).getOffset()); assertEquals(3, s.getComponent(2).getOffset());
@ -624,11 +584,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Structure s = Structure s =
(Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"), (Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"),
"IntStruct"); "IntStruct");
assertEquals(true, s.isInternallyAligned()); assertTrue(s.hasDefaultPacking());
assertEquals(true, s.isDefaultAligned()); assertTrue(s.isDefaultAligned());
assertEquals(false, s.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, s.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset()); assertEquals(2, s.getComponent(1).getOffset());
assertEquals(4, s.getComponent(2).getOffset()); assertEquals(4, s.getComponent(2).getOffset());
@ -640,9 +598,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
private void setupStructureFieldNameVsPack() throws Exception { private void setupStructureFieldNameVsPack() throws Exception {
mtf.initialize("notepad", new OriginalProgramModifierListener() { mtf.initialize("notepad", new OriginalProgramModifierListener() {
/* (non-Javadoc)
* @see ghidra.framework.data.OriginalProgramModifierListener#modifyOriginal(ghidra.program.database.ProgramDB)
*/
@Override @Override
public void modifyOriginal(ProgramDB program) throws Exception { public void modifyOriginal(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -654,7 +610,8 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
new CategoryPath("/Category1/Category2/Category3"), "IntStruct"); new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
assertEquals(15, s.getLength()); assertEquals(15, s.getLength());
assertEquals(1, s.getAlignment()); assertEquals(1, s.getAlignment());
s.setInternallyAligned(true); s.setToDefaultPacking();
// Offsets change to 0,2,4,8. // Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).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 @Override
public void modifyLatest(ProgramDB program) throws Exception { public void modifyLatest(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -685,6 +639,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(4, s.getAlignment()); assertEquals(4, s.getAlignment());
s.getComponent(1).setFieldName("MyComponentOne"); s.getComponent(1).setFieldName("MyComponentOne");
assertTrue(s.hasDefaultPacking());
assertTrue(s.isDefaultAligned());
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset()); assertEquals(2, s.getComponent(1).getOffset());
assertEquals("MyComponentOne", s.getComponent(1).getFieldName()); assertEquals("MyComponentOne", s.getComponent(1).getFieldName());
@ -692,7 +649,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(8, s.getComponent(3).getOffset()); assertEquals(8, s.getComponent(3).getOffset());
assertEquals(16, s.getLength()); assertEquals(16, s.getLength());
assertEquals(4, s.getAlignment()); assertEquals(4, s.getAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
commit = true; commit = true;
} }
finally { finally {
@ -700,9 +657,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
} }
} }
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyPrivate(ghidra.program.database.ProgramDB)
*/
@Override @Override
public void modifyPrivate(ProgramDB program) throws Exception { public void modifyPrivate(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -714,7 +668,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
new CategoryPath("/Category1/Category2/Category3"), "IntStruct"); new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
assertEquals(16, s.getLength()); assertEquals(16, s.getLength());
assertEquals(4, s.getAlignment()); assertEquals(4, s.getAlignment());
s.setPackingValue(1); s.pack(1);
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(1, s.getComponent(1).getOffset()); assertEquals(1, s.getComponent(1).getOffset());
@ -722,7 +676,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(7, s.getComponent(3).getOffset()); assertEquals(7, s.getComponent(3).getOffset());
assertEquals(15, s.getLength()); assertEquals(15, s.getLength());
assertEquals(1, s.getAlignment()); assertEquals(1, s.getAlignment());
assertEquals(1, s.getPackingValue());
commit = true; commit = true;
} }
finally { finally {
@ -746,11 +700,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Structure s = Structure s =
(Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"), (Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"),
"IntStruct"); "IntStruct");
assertEquals(true, s.isInternallyAligned()); assertTrue(s.hasDefaultPacking());
assertEquals(true, s.isDefaultAligned()); assertTrue(s.isDefaultAligned());
assertEquals(false, s.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, s.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(2, s.getComponent(1).getOffset()); assertEquals(2, s.getComponent(1).getOffset());
assertEquals(4, s.getComponent(2).getOffset()); assertEquals(4, s.getComponent(2).getOffset());
@ -773,11 +725,10 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Structure s = Structure s =
(Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"), (Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"),
"IntStruct"); "IntStruct");
assertEquals(true, s.isInternallyAligned()); assertTrue(s.hasExplicitPackingValue());
assertEquals(true, s.isDefaultAligned()); assertEquals(1, s.getExplicitPackingValue());
assertEquals(false, s.isMachineAligned()); assertTrue(s.isDefaultAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, s.getMinimumAlignment());
assertEquals(1, s.getPackingValue());
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(1, s.getComponent(1).getOffset()); assertEquals(1, s.getComponent(1).getOffset());
assertEquals(3, s.getComponent(2).getOffset()); assertEquals(3, s.getComponent(2).getOffset());
@ -789,9 +740,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
private void setupStructureRemoveVsPack() throws Exception { private void setupStructureRemoveVsPack() throws Exception {
mtf.initialize("notepad", new OriginalProgramModifierListener() { mtf.initialize("notepad", new OriginalProgramModifierListener() {
/* (non-Javadoc)
* @see ghidra.framework.data.OriginalProgramModifierListener#modifyOriginal(ghidra.program.database.ProgramDB)
*/
@Override @Override
public void modifyOriginal(ProgramDB program) throws Exception { public void modifyOriginal(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -803,7 +752,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
new CategoryPath("/Category1/Category2/Category3"), "IntStruct"); new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
assertEquals(15, s.getLength()); assertEquals(15, s.getLength());
assertEquals(1, s.getAlignment()); assertEquals(1, s.getAlignment());
s.setInternallyAligned(true); s.setToDefaultPacking();
// Offsets change to 0,2,4,8. // Offsets change to 0,2,4,8.
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
@ -812,7 +761,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(8, s.getComponent(3).getOffset()); assertEquals(8, s.getComponent(3).getOffset());
assertEquals(16, s.getLength()); assertEquals(16, s.getLength());
assertEquals(4, s.getAlignment()); assertEquals(4, s.getAlignment());
assertEquals(Composite.NOT_PACKING, s.getPackingValue());
commit = true; commit = true;
} }
finally { finally {
@ -820,9 +769,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
} }
} }
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyLatest(ghidra.program.database.ProgramDB)
*/
@Override @Override
public void modifyLatest(ProgramDB program) throws Exception { public void modifyLatest(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -832,7 +778,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try { try {
Structure s = (Structure) dtm.getDataType( Structure s = (Structure) dtm.getDataType(
new CategoryPath("/Category1/Category2/Category3"), "IntStruct"); new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
dtm.remove(s, TaskMonitorAdapter.DUMMY_MONITOR); dtm.remove(s, TaskMonitor.DUMMY);
// Offsets change to 0,2,4,8. // Offsets change to 0,2,4,8.
Structure intStruct = (Structure) dtm.getDataType( 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 @Override
public void modifyPrivate(ProgramDB program) throws Exception { public void modifyPrivate(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -857,7 +800,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try { try {
Structure s = (Structure) dtm.getDataType( Structure s = (Structure) dtm.getDataType(
new CategoryPath("/Category1/Category2/Category3"), "IntStruct"); new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
s.setPackingValue(1); s.pack(1);
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(1, s.getComponent(1).getOffset()); assertEquals(1, s.getComponent(1).getOffset());
@ -865,7 +808,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(7, s.getComponent(3).getOffset()); assertEquals(7, s.getComponent(3).getOffset());
assertEquals(15, s.getLength()); assertEquals(15, s.getLength());
assertEquals(1, s.getAlignment()); assertEquals(1, s.getAlignment());
assertEquals(1, s.getPackingValue());
commit = true; commit = true;
} }
finally { finally {
@ -906,11 +849,10 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Structure s = Structure s =
(Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"), (Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"),
"IntStruct"); "IntStruct");
assertEquals(true, s.isInternallyAligned()); assertTrue(s.hasExplicitPackingValue());
assertEquals(true, s.isDefaultAligned()); assertEquals(1, s.getExplicitPackingValue());
assertEquals(false, s.isMachineAligned()); assertTrue(s.isDefaultAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, s.getMinimumAlignment());
assertEquals(1, s.getPackingValue());
assertEquals(0, s.getComponent(0).getOffset()); assertEquals(0, s.getComponent(0).getOffset());
assertEquals(1, s.getComponent(1).getOffset()); assertEquals(1, s.getComponent(1).getOffset());
assertEquals(3, s.getComponent(2).getOffset()); assertEquals(3, s.getComponent(2).getOffset());
@ -922,9 +864,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
private void setupStructureInUnionAndViceVersa() throws Exception { private void setupStructureInUnionAndViceVersa() throws Exception {
mtf.initialize("notepad", new OriginalProgramModifierListener() { mtf.initialize("notepad", new OriginalProgramModifierListener() {
/* (non-Javadoc)
* @see ghidra.framework.data.OriginalProgramModifierListener#modifyOriginal(ghidra.program.database.ProgramDB)
*/
@Override @Override
public void modifyOriginal(ProgramDB program) throws Exception { public void modifyOriginal(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -934,11 +874,11 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try { try {
Structure s = (Structure) dtm.getDataType( Structure s = (Structure) dtm.getDataType(
new CategoryPath("/Category1/Category2/Category3"), "IntStruct"); new CategoryPath("/Category1/Category2/Category3"), "IntStruct");
s.setInternallyAligned(true); s.setPackingEnabled(true);
Union union = (Union) dtm.getDataType(new CategoryPath("/Category1/Category2"), Union union = (Union) dtm.getDataType(new CategoryPath("/Category1/Category2"),
"CoolUnion"); "CoolUnion");
union.setInternallyAligned(true); union.setPackingEnabled(true);
commit = 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 @Override
public void modifyLatest(ProgramDB program) throws Exception { public void modifyLatest(ProgramDB program) throws Exception {
boolean commit = false; 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 @Override
public void modifyPrivate(ProgramDB program) throws Exception { public void modifyPrivate(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -1019,11 +953,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Structure intStruct = Structure intStruct =
(Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"), (Structure) dtm.getDataType(new CategoryPath("/Category1/Category2/Category3"),
"IntStruct"); "IntStruct");
assertEquals(true, intStruct.isInternallyAligned()); assertTrue(intStruct.hasDefaultPacking());
assertEquals(true, intStruct.isDefaultAligned()); assertTrue(intStruct.isDefaultAligned());
assertEquals(false, intStruct.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, intStruct.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, intStruct.getPackingValue());
assertEquals(5, intStruct.getNumComponents()); assertEquals(5, intStruct.getNumComponents());
assertEquals(0, intStruct.getComponent(0).getOffset()); assertEquals(0, intStruct.getComponent(0).getOffset());
assertEquals(2, intStruct.getComponent(1).getOffset()); assertEquals(2, intStruct.getComponent(1).getOffset());
@ -1036,11 +968,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
Union coolUnion = Union coolUnion =
(Union) dtm.getDataType(new CategoryPath("/Category1/Category2"), "CoolUnion"); (Union) dtm.getDataType(new CategoryPath("/Category1/Category2"), "CoolUnion");
assertEquals(true, coolUnion.isInternallyAligned()); assertTrue(coolUnion.hasDefaultPacking());
assertEquals(true, coolUnion.isDefaultAligned()); assertTrue(coolUnion.isDefaultAligned());
assertEquals(false, coolUnion.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, coolUnion.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, coolUnion.getPackingValue());
assertEquals(6, coolUnion.getNumComponents()); assertEquals(6, coolUnion.getNumComponents());
assertEquals("qword", coolUnion.getComponent(0).getDataType().getDisplayName()); assertEquals("qword", coolUnion.getComponent(0).getDataType().getDisplayName());
assertEquals("word", coolUnion.getComponent(1).getDataType().getDisplayName()); assertEquals("word", coolUnion.getComponent(1).getDataType().getDisplayName());
@ -1061,9 +991,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
public void setupUnionMachineAlignedVsValue() throws Exception { public void setupUnionMachineAlignedVsValue() throws Exception {
mtf.initialize("notepad", new OriginalProgramModifierListener() { mtf.initialize("notepad", new OriginalProgramModifierListener() {
/* (non-Javadoc)
* @see ghidra.framework.data.OriginalProgramModifierListener#modifyOriginal(ghidra.program.database.ProgramDB)
*/
@Override @Override
public void modifyOriginal(ProgramDB program) throws Exception { public void modifyOriginal(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -1075,7 +1003,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
"CoolUnion"); "CoolUnion");
assertEquals(96, union.getLength()); assertEquals(96, union.getLength());
assertEquals(1, union.getAlignment()); assertEquals(1, union.getAlignment());
union.setInternallyAligned(true); union.setPackingEnabled(true);
assertEquals(8, union.getComponent(0).getLength()); assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).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 @Override
public void modifyLatest(ProgramDB program) throws Exception { public void modifyLatest(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -1103,7 +1028,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try { try {
Union union = (Union) dtm.getDataType(new CategoryPath("/Category1/Category2"), Union union = (Union) dtm.getDataType(new CategoryPath("/Category1/Category2"),
"CoolUnion"); "CoolUnion");
union.setToMachineAlignment(); union.setToMachineAligned();
assertEquals(8, union.getComponent(0).getLength()); assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).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 @Override
public void modifyPrivate(ProgramDB program) throws Exception { public void modifyPrivate(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -1131,7 +1053,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try { try {
Union union = (Union) dtm.getDataType(new CategoryPath("/Category1/Category2"), Union union = (Union) dtm.getDataType(new CategoryPath("/Category1/Category2"),
"CoolUnion"); "CoolUnion");
union.setMinimumAlignment(4); union.setExplicitMinimumAlignment(4);
assertEquals(8, union.getComponent(0).getLength()); assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).getLength()); assertEquals(2, union.getComponent(1).getLength());
@ -1162,11 +1084,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager(); DataTypeManager dtm = resultProgram.getDataTypeManager();
Category c = dtm.getCategory(new CategoryPath("/Category1/Category2")); Category c = dtm.getCategory(new CategoryPath("/Category1/Category2"));
Union union = (Union) c.getDataType("CoolUnion"); Union union = (Union) c.getDataType("CoolUnion");
assertEquals(true, union.isInternallyAligned()); assertTrue(union.hasDefaultPacking());
assertEquals(false, union.isDefaultAligned()); assertTrue(union.isMachineAligned());
assertEquals(true, union.isMachineAligned());
assertEquals(8, union.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, union.getPackingValue());
assertEquals(8, union.getComponent(0).getLength()); assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).getLength()); assertEquals(2, union.getComponent(1).getLength());
assertEquals(4, union.getComponent(2).getLength()); assertEquals(4, union.getComponent(2).getLength());
@ -1189,11 +1109,10 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager(); DataTypeManager dtm = resultProgram.getDataTypeManager();
Category c = dtm.getCategory(new CategoryPath("/Category1/Category2")); Category c = dtm.getCategory(new CategoryPath("/Category1/Category2"));
Union union = (Union) c.getDataType("CoolUnion"); Union union = (Union) c.getDataType("CoolUnion");
assertEquals(true, union.isInternallyAligned()); assertTrue(union.hasDefaultPacking());
assertEquals(false, union.isDefaultAligned()); assertTrue(union.hasExplicitMinimumAlignment());
assertEquals(false, union.isMachineAligned()); assertEquals(4, union.getExplicitMinimumAlignment());
assertEquals(4, union.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, union.getPackingValue());
assertEquals(8, union.getComponent(0).getLength()); assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).getLength()); assertEquals(2, union.getComponent(1).getLength());
assertEquals(4, union.getComponent(2).getLength()); assertEquals(4, union.getComponent(2).getLength());
@ -1216,11 +1135,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager(); DataTypeManager dtm = resultProgram.getDataTypeManager();
Category c = dtm.getCategory(new CategoryPath("/Category1/Category2")); Category c = dtm.getCategory(new CategoryPath("/Category1/Category2"));
Union union = (Union) c.getDataType("CoolUnion"); Union union = (Union) c.getDataType("CoolUnion");
assertEquals(true, union.isInternallyAligned()); assertTrue(union.hasDefaultPacking());
assertEquals(true, union.isDefaultAligned()); assertTrue(union.isDefaultAligned());
assertEquals(false, union.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, union.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, union.getPackingValue());
assertEquals(8, union.getComponent(0).getLength()); assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).getLength()); assertEquals(2, union.getComponent(1).getLength());
assertEquals(4, union.getComponent(2).getLength()); assertEquals(4, union.getComponent(2).getLength());
@ -1233,9 +1150,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
public void setupUnionPack1VsPack2() throws Exception { public void setupUnionPack1VsPack2() throws Exception {
mtf.initialize("notepad", new OriginalProgramModifierListener() { mtf.initialize("notepad", new OriginalProgramModifierListener() {
/* (non-Javadoc)
* @see ghidra.framework.data.OriginalProgramModifierListener#modifyOriginal(ghidra.program.database.ProgramDB)
*/
@Override @Override
public void modifyOriginal(ProgramDB program) throws Exception { public void modifyOriginal(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -1247,7 +1162,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
"CoolUnion"); "CoolUnion");
assertEquals(96, union.getLength()); assertEquals(96, union.getLength());
assertEquals(1, union.getAlignment()); assertEquals(1, union.getAlignment());
union.setInternallyAligned(true); union.setPackingEnabled(true);
assertEquals(8, union.getComponent(0).getLength()); assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).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 @Override
public void modifyLatest(ProgramDB program) throws Exception { public void modifyLatest(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -1275,7 +1187,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try { try {
Union union = (Union) dtm.getDataType(new CategoryPath("/Category1/Category2"), Union union = (Union) dtm.getDataType(new CategoryPath("/Category1/Category2"),
"CoolUnion"); "CoolUnion");
union.setPackingValue(1); union.pack(1);
assertEquals(8, union.getComponent(0).getLength()); assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).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 @Override
public void modifyPrivate(ProgramDB program) throws Exception { public void modifyPrivate(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -1303,7 +1212,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
try { try {
Union union = (Union) dtm.getDataType(new CategoryPath("/Category1/Category2"), Union union = (Union) dtm.getDataType(new CategoryPath("/Category1/Category2"),
"CoolUnion"); "CoolUnion");
union.setPackingValue(2); union.pack(2);
assertEquals(8, union.getComponent(0).getLength()); assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).getLength()); assertEquals(2, union.getComponent(1).getLength());
@ -1334,11 +1243,10 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager(); DataTypeManager dtm = resultProgram.getDataTypeManager();
Category c = dtm.getCategory(new CategoryPath("/Category1/Category2")); Category c = dtm.getCategory(new CategoryPath("/Category1/Category2"));
Union union = (Union) c.getDataType("CoolUnion"); Union union = (Union) c.getDataType("CoolUnion");
assertEquals(true, union.isInternallyAligned()); assertTrue(union.hasExplicitPackingValue());
assertEquals(true, union.isDefaultAligned()); assertEquals(1, union.getExplicitPackingValue());
assertEquals(false, union.isMachineAligned()); assertTrue(union.isDefaultAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, union.getMinimumAlignment());
assertEquals(1, union.getPackingValue());
assertEquals(8, union.getComponent(0).getLength()); assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).getLength()); assertEquals(2, union.getComponent(1).getLength());
assertEquals(4, union.getComponent(2).getLength()); assertEquals(4, union.getComponent(2).getLength());
@ -1361,11 +1269,10 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager(); DataTypeManager dtm = resultProgram.getDataTypeManager();
Category c = dtm.getCategory(new CategoryPath("/Category1/Category2")); Category c = dtm.getCategory(new CategoryPath("/Category1/Category2"));
Union union = (Union) c.getDataType("CoolUnion"); Union union = (Union) c.getDataType("CoolUnion");
assertEquals(true, union.isInternallyAligned()); assertTrue(union.hasExplicitPackingValue());
assertEquals(true, union.isDefaultAligned()); assertEquals(2, union.getExplicitPackingValue());
assertEquals(false, union.isMachineAligned()); assertTrue(union.isDefaultAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, union.getMinimumAlignment());
assertEquals(2, union.getPackingValue());
assertEquals(8, union.getComponent(0).getLength()); assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).getLength()); assertEquals(2, union.getComponent(1).getLength());
assertEquals(4, union.getComponent(2).getLength()); assertEquals(4, union.getComponent(2).getLength());
@ -1388,11 +1295,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager(); DataTypeManager dtm = resultProgram.getDataTypeManager();
Category c = dtm.getCategory(new CategoryPath("/Category1/Category2")); Category c = dtm.getCategory(new CategoryPath("/Category1/Category2"));
Union union = (Union) c.getDataType("CoolUnion"); Union union = (Union) c.getDataType("CoolUnion");
assertEquals(true, union.isInternallyAligned()); assertTrue(union.hasDefaultPacking());
assertEquals(true, union.isDefaultAligned()); assertTrue(union.isDefaultAligned());
assertEquals(false, union.isMachineAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, union.getMinimumAlignment());
assertEquals(Composite.NOT_PACKING, union.getPackingValue());
assertEquals(8, union.getComponent(0).getLength()); assertEquals(8, union.getComponent(0).getLength());
assertEquals(2, union.getComponent(1).getLength()); assertEquals(2, union.getComponent(1).getLength());
assertEquals(4, union.getComponent(2).getLength()); assertEquals(4, union.getComponent(2).getLength());
@ -1416,9 +1321,7 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
struct2.add(new StringDataType(), 4); struct2.add(new StringDataType(), 4);
mtf.initialize("notepad", new ProgramModifierListener() { mtf.initialize("notepad", new ProgramModifierListener() {
/* (non-Javadoc)
* @see ghidra.framework.data.ProgramModifierListener#modifyLatest(ghidra.program.database.ProgramDB)
*/
@Override @Override
public void modifyLatest(ProgramDB program) throws Exception { public void modifyLatest(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -1444,12 +1347,9 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertTrue(new PointerDataType(new FloatDataType()).isEquivalent( assertTrue(new PointerDataType(new FloatDataType()).isEquivalent(
s.getComponent(0).getDataType())); s.getComponent(0).getDataType()));
assertTrue(new FloatDataType().isEquivalent(s.getComponent(1).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 @Override
public void modifyPrivate(ProgramDB program) throws Exception { public void modifyPrivate(ProgramDB program) throws Exception {
boolean commit = false; boolean commit = false;
@ -1474,7 +1374,6 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(4, s.getComponent(1).getLength()); assertEquals(4, s.getComponent(1).getLength());
assertTrue(new CharDataType().isEquivalent(s.getComponent(0).getDataType())); assertTrue(new CharDataType().isEquivalent(s.getComponent(0).getDataType()));
assertTrue(new StringDataType().isEquivalent(s.getComponent(1).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( assertTrue(new PointerDataType(new FloatDataType()).isEquivalent(
s1.getComponent(0).getDataType())); s1.getComponent(0).getDataType()));
assertTrue(new FloatDataType().isEquivalent(s1.getComponent(1).getDataType())); assertTrue(new FloatDataType().isEquivalent(s1.getComponent(1).getDataType()));
assertEquals(Composite.NOT_PACKING, s1.getPackingValue());
Structure s2 = Structure s2 =
(Structure) dtm.getDataType(new CategoryPath("/Category1"), "ABCStructure.conflict"); (Structure) dtm.getDataType(new CategoryPath("/Category1"), "ABCStructure.conflict");
@ -1508,6 +1406,5 @@ public class DataTypeMerge6Test extends AbstractDataTypeMergeTest {
assertEquals(4, s2.getComponent(1).getLength()); assertEquals(4, s2.getComponent(1).getLength());
assertTrue(new CharDataType().isEquivalent(s2.getComponent(0).getDataType())); assertTrue(new CharDataType().isEquivalent(s2.getComponent(0).getDataType()));
assertTrue(new StringDataType().isEquivalent(s2.getComponent(1).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); Structure inner = new StructureDataType("inner", 0);
inner.add(new ByteDataType()); inner.add(new ByteDataType());
inner.add(new WordDataType()); inner.add(new WordDataType());
inner.setInternallyAligned(true); inner.setPackingEnabled(true);
try { try {
Category rootCategory = dtm.getCategory(rootPath); Category rootCategory = dtm.getCategory(rootPath);
@ -103,7 +103,7 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
Structure outer = new StructureDataType("outer", 0); Structure outer = new StructureDataType("outer", 0);
outer.add(new ByteDataType()); outer.add(new ByteDataType());
outer.add(inner); outer.add(inner);
outer.setInternallyAligned(true); outer.setPackingEnabled(true);
int transactionID = program.startTransaction("create outer struct, modify inner"); int transactionID = program.startTransaction("create outer struct, modify inner");
try { try {
@ -134,14 +134,14 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
waitForCompletion(); waitForCompletion();
DataTypeManager dtm = resultProgram.getDataTypeManager(); DataTypeManager dtm = resultProgram.getDataTypeManager();
Structure inner = (Structure) dtm.getDataType(rootPath, "inner"); StructureInternal inner = (StructureInternal) dtm.getDataType(rootPath, "inner");
assertNull(inner); assertNull(inner);
Structure outer = (Structure) dtm.getDataType(rootPath, "outer"); StructureInternal outer = (StructureInternal) dtm.getDataType(rootPath, "outer");
assertNotNull(outer); assertNotNull(outer);
assertEquals(true, outer.isInternallyAligned()); assertEquals(true, outer.isPackingEnabled());
assertEquals(true, outer.isDefaultAligned()); assertEquals(true, outer.isDefaultAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, outer.getMinimumAlignment()); assertEquals(CompositeInternal.DEFAULT_ALIGNMENT, outer.getStoredMinimumAlignment());
assertEquals(Composite.NOT_PACKING, outer.getPackingValue()); assertEquals(CompositeInternal.DEFAULT_PACKING, outer.getStoredPackingValue());
assertEquals(1, outer.getNumComponents()); assertEquals(1, outer.getNumComponents());
assertTrue(new ByteDataType().isEquivalent(outer.getComponent(0).getDataType())); assertTrue(new ByteDataType().isEquivalent(outer.getComponent(0).getDataType()));
assertEquals(1, outer.getLength()); assertEquals(1, outer.getLength());
@ -162,24 +162,24 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
waitForCompletion(); waitForCompletion();
DataTypeManager dtm = resultProgram.getDataTypeManager(); DataTypeManager dtm = resultProgram.getDataTypeManager();
Structure inner = (Structure) dtm.getDataType(rootPath, "inner"); StructureInternal inner = (StructureInternal) dtm.getDataType(rootPath, "inner");
assertNotNull(inner); assertNotNull(inner);
assertEquals(true, inner.isInternallyAligned()); assertEquals(true, inner.isPackingEnabled());
assertEquals(true, inner.isDefaultAligned()); assertEquals(true, inner.isDefaultAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, inner.getMinimumAlignment()); assertEquals(CompositeInternal.DEFAULT_ALIGNMENT, inner.getStoredMinimumAlignment());
assertEquals(Composite.NOT_PACKING, inner.getPackingValue()); assertEquals(CompositeInternal.DEFAULT_PACKING, inner.getStoredPackingValue());
assertEquals(2, inner.getNumComponents()); assertEquals(2, inner.getNumComponents());
assertTrue(new CharDataType().isEquivalent(inner.getComponent(0).getDataType())); assertTrue(new CharDataType().isEquivalent(inner.getComponent(0).getDataType()));
assertTrue(new WordDataType().isEquivalent(inner.getComponent(1).getDataType())); assertTrue(new WordDataType().isEquivalent(inner.getComponent(1).getDataType()));
assertEquals(4, inner.getLength()); assertEquals(4, inner.getLength());
assertEquals(2, inner.getAlignment()); assertEquals(2, inner.getAlignment());
Structure outer = (Structure) dtm.getDataType(rootPath, "outer"); StructureInternal outer = (StructureInternal) dtm.getDataType(rootPath, "outer");
assertNotNull(outer); assertNotNull(outer);
assertEquals(true, outer.isInternallyAligned()); assertEquals(true, outer.isPackingEnabled());
assertEquals(true, outer.isDefaultAligned()); assertEquals(true, outer.isDefaultAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, outer.getMinimumAlignment()); assertEquals(CompositeInternal.DEFAULT_ALIGNMENT, outer.getStoredMinimumAlignment());
assertEquals(Composite.NOT_PACKING, outer.getPackingValue()); assertEquals(CompositeInternal.DEFAULT_PACKING, outer.getStoredPackingValue());
assertEquals(2, outer.getNumComponents()); assertEquals(2, outer.getNumComponents());
assertTrue(new ByteDataType().isEquivalent(outer.getComponent(0).getDataType())); assertTrue(new ByteDataType().isEquivalent(outer.getComponent(0).getDataType()));
assertEquals(inner, outer.getComponent(1).getDataType()); assertEquals(inner, outer.getComponent(1).getDataType());
@ -220,7 +220,7 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
Structure inner = new StructureDataType("inner", 0); Structure inner = new StructureDataType("inner", 0);
inner.add(new ByteDataType()); inner.add(new ByteDataType());
inner.add(new WordDataType()); inner.add(new WordDataType());
inner.setInternallyAligned(true); inner.setPackingEnabled(true);
try { try {
Category rootCategory = dtm.getCategory(rootPath); Category rootCategory = dtm.getCategory(rootPath);
@ -263,7 +263,7 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
Structure outer = new StructureDataType("outer", 0); Structure outer = new StructureDataType("outer", 0);
outer.add(new ByteDataType()); outer.add(new ByteDataType());
outer.add(inner); outer.add(inner);
outer.setInternallyAligned(true); outer.setPackingEnabled(true);
int transactionID = int transactionID =
program.startTransaction("create outer struct, don't modify inner"); program.startTransaction("create outer struct, don't modify inner");
@ -283,14 +283,14 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
waitForCompletion(); waitForCompletion();
DataTypeManager dtm = resultProgram.getDataTypeManager(); DataTypeManager dtm = resultProgram.getDataTypeManager();
Structure inner = (Structure) dtm.getDataType(rootPath, "inner"); StructureInternal inner = (StructureInternal) dtm.getDataType(rootPath, "inner");
assertNull(inner); assertNull(inner);
Structure outer = (Structure) dtm.getDataType(rootPath, "outer"); StructureInternal outer = (StructureInternal) dtm.getDataType(rootPath, "outer");
assertNotNull(outer); assertNotNull(outer);
assertEquals(true, outer.isInternallyAligned()); assertEquals(true, outer.isPackingEnabled());
assertEquals(true, outer.isDefaultAligned()); assertEquals(true, outer.isDefaultAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, outer.getMinimumAlignment()); assertEquals(CompositeInternal.DEFAULT_ALIGNMENT, outer.getStoredMinimumAlignment());
assertEquals(Composite.NOT_PACKING, outer.getPackingValue()); assertEquals(CompositeInternal.DEFAULT_PACKING, outer.getStoredPackingValue());
assertEquals(1, outer.getNumComponents()); assertEquals(1, outer.getNumComponents());
assertTrue(new ByteDataType().isEquivalent(outer.getComponent(0).getDataType())); assertTrue(new ByteDataType().isEquivalent(outer.getComponent(0).getDataType()));
assertEquals(1, outer.getLength()); assertEquals(1, outer.getLength());
@ -335,7 +335,7 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
Structure inner = new StructureDataType("inner", 0); Structure inner = new StructureDataType("inner", 0);
inner.add(new ByteDataType()); inner.add(new ByteDataType());
inner.add(new WordDataType()); inner.add(new WordDataType());
inner.setInternallyAligned(true); inner.setPackingEnabled(true);
try { try {
Category rootCategory = dtm.getCategory(rootPath); Category rootCategory = dtm.getCategory(rootPath);
@ -378,7 +378,7 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
Structure other = new StructureDataType("other", 0); Structure other = new StructureDataType("other", 0);
other.add(new ByteDataType()); other.add(new ByteDataType());
other.add(new PointerDataType(new VoidDataType())); other.add(new PointerDataType(new VoidDataType()));
other.setInternallyAligned(true); other.setPackingEnabled(true);
Structure outer = new StructureDataType("outer", 0); Structure outer = new StructureDataType("outer", 0);
outer.add(new ByteDataType()); outer.add(new ByteDataType());
@ -386,7 +386,7 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
outer.add(new FloatDataType()); outer.add(new FloatDataType());
outer.add(other); outer.add(other);
outer.add(new ByteDataType()); outer.add(new ByteDataType());
outer.setInternallyAligned(true); outer.setPackingEnabled(true);
int transactionID = program.startTransaction( int transactionID = program.startTransaction(
"create outer struct with other structure after inner"); "create outer struct with other structure after inner");
@ -407,15 +407,15 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
DataTypeManager dtm = resultProgram.getDataTypeManager(); DataTypeManager dtm = resultProgram.getDataTypeManager();
Structure inner = (Structure) dtm.getDataType(rootPath, "inner"); StructureInternal inner = (StructureInternal) dtm.getDataType(rootPath, "inner");
assertNull(inner); assertNull(inner);
Structure other = (Structure) dtm.getDataType(rootPath, "other"); StructureInternal other = (StructureInternal) dtm.getDataType(rootPath, "other");
assertNotNull(other); assertNotNull(other);
assertEquals(true, other.isInternallyAligned()); assertEquals(true, other.isPackingEnabled());
assertEquals(true, other.isDefaultAligned()); assertEquals(true, other.isDefaultAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, other.getMinimumAlignment()); assertEquals(CompositeInternal.DEFAULT_ALIGNMENT, other.getStoredMinimumAlignment());
assertEquals(Composite.NOT_PACKING, other.getPackingValue()); assertEquals(CompositeInternal.DEFAULT_PACKING, other.getStoredPackingValue());
assertEquals(2, other.getNumComponents()); assertEquals(2, other.getNumComponents());
assertTrue(new ByteDataType().isEquivalent(other.getComponent(0).getDataType())); assertTrue(new ByteDataType().isEquivalent(other.getComponent(0).getDataType()));
assertTrue(new PointerDataType(new VoidDataType()).isEquivalent( assertTrue(new PointerDataType(new VoidDataType()).isEquivalent(
@ -423,12 +423,12 @@ public class DataTypeMergeFixupTest extends AbstractDataTypeMergeTest {
assertEquals(8, other.getLength()); assertEquals(8, other.getLength());
assertEquals(4, other.getAlignment()); assertEquals(4, other.getAlignment());
Structure outer = (Structure) dtm.getDataType(rootPath, "outer"); StructureInternal outer = (StructureInternal) dtm.getDataType(rootPath, "outer");
assertNotNull(outer); assertNotNull(outer);
assertEquals(true, outer.isInternallyAligned()); assertEquals(true, outer.isPackingEnabled());
assertEquals(true, outer.isDefaultAligned()); assertEquals(true, outer.isDefaultAligned());
assertEquals(Composite.DEFAULT_ALIGNMENT_VALUE, outer.getMinimumAlignment()); assertEquals(CompositeInternal.DEFAULT_ALIGNMENT, outer.getStoredMinimumAlignment());
assertEquals(Composite.NOT_PACKING, outer.getPackingValue()); assertEquals(CompositeInternal.DEFAULT_PACKING, outer.getStoredPackingValue());
assertEquals(4, outer.getNumComponents()); assertEquals(4, outer.getNumComponents());
assertTrue(new ByteDataType().isEquivalent(outer.getComponent(0).getDataType())); assertTrue(new ByteDataType().isEquivalent(outer.getComponent(0).getDataType()));
assertTrue(new FloatDataType().isEquivalent(outer.getComponent(1).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(CharDataType.dataType);
struct.add(IntegerDataType.dataType); struct.add(IntegerDataType.dataType);
struct.add(CharDataType.dataType); struct.add(CharDataType.dataType);
struct.setInternallyAligned(true); struct.setPackingEnabled(true);
builder.applyDataType("0x1001100", struct); builder.applyDataType("0x1001100", struct);
builder.setBytes("0x1001200", "01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f"); builder.setBytes("0x1001200", "01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f");
struct = new StructureDataType("struct2", 12); struct = new StructureDataType("struct2", 12);
struct.setInternallyAligned(false); struct.setPackingEnabled(false);
struct.insertAtOffset(0, CharDataType.dataType, -1); struct.insertAtOffset(0, CharDataType.dataType, -1);
struct.insertAtOffset(4, IntegerDataType.dataType, -1); struct.insertAtOffset(4, IntegerDataType.dataType, -1);
struct.insertAtOffset(8, CharDataType.dataType, -1); struct.insertAtOffset(8, CharDataType.dataType, -1);
@ -486,7 +486,7 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTest
showTool(tool); showTool(tool);
loadProgram(); 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 options = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_FIELDS);
options.setBoolean("Bytes Field.Display Structure Alignment Bytes", true); 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.database.ProgramBuilder;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.program.model.data.Composite; import ghidra.program.model.data.Composite;
import ghidra.program.model.data.Composite.AlignmentType;
import ghidra.program.model.data.Enum; import ghidra.program.model.data.Enum;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
import ghidra.test.AbstractGhidraHeadedIntegrationTest; import ghidra.test.AbstractGhidraHeadedIntegrationTest;
@ -213,8 +212,7 @@ public abstract class AbstractEditorTest extends AbstractGhidraHeadedIntegration
} }
protected CycleGroupAction getCycleGroup(DataType dt) { protected CycleGroupAction getCycleGroup(DataType dt) {
for (int cycleIndex = 0; cycleIndex < cycles.size(); cycleIndex++) { for (CycleGroupAction action : cycles) {
CycleGroupAction action = cycles.get(cycleIndex);
CycleGroup group = action.getCycleGroup(); CycleGroup group = action.getCycleGroup();
DataType[] types = group.getDataTypes(); DataType[] types = group.getDataTypes();
for (DataType type : types) { for (DataType type : types) {
@ -227,8 +225,7 @@ public abstract class AbstractEditorTest extends AbstractGhidraHeadedIntegration
} }
protected FavoritesAction getFavorite(String name) { protected FavoritesAction getFavorite(String name) {
for (int favIndex = 0; favIndex < favorites.size(); favIndex++) { for (FavoritesAction action : favorites) {
FavoritesAction action = favorites.get(favIndex);
if (action.getDataType().getDisplayName().equals(name)) { if (action.getDataType().getDisplayName().equals(name)) {
return action; return action;
} }
@ -332,13 +329,17 @@ public abstract class AbstractEditorTest extends AbstractGhidraHeadedIntegration
} }
protected void invoke(final DockingActionIf action) { protected void invoke(final DockingActionIf action) {
invoke(action, true);
}
protected void invoke(final DockingActionIf action, boolean wait) {
assertNotNull(action); assertNotNull(action);
boolean isEnabled = runSwing(() -> action.isEnabled()); boolean isEnabled = runSwing(() -> action.isEnabled());
if (!isEnabled) { if (!isEnabled) {
Msg.debug(this, "Calling actionPerformed() on a disabled action: " + action.getName(), Msg.debug(this, "Calling actionPerformed() on a disabled action: " + action.getName(),
ReflectionUtilities.createJavaFilteredThrowable()); ReflectionUtilities.createJavaFilteredThrowable());
} }
runSwing(() -> action.actionPerformed(new ActionContext()), false); runSwing(() -> action.actionPerformed(new ActionContext()), wait);
waitForSwing(); waitForSwing();
} }
@ -811,20 +812,30 @@ public abstract class AbstractEditorTest extends AbstractGhidraHeadedIntegration
actionEnablement); actionEnablement);
} }
protected void assertIsInternallyAligned(boolean aligned) { protected void assertIsPackingEnabled(boolean aligned) {
assertEquals(aligned, ((CompEditorModel) model).isAligned()); assertEquals(aligned, ((CompEditorModel) model).isPackingEnabled());
} }
protected void assertPackingValue(int value) { protected void assertDefaultPacked() {
assertEquals(value, ((CompEditorModel) model).getPackingValue()); assertEquals(PackingType.DEFAULT, ((CompEditorModel) model).getPackingType());
} }
protected void assertMinimumAlignmentType(AlignmentType alignmentType) { protected void assertPacked(int pack) {
assertEquals(alignmentType, ((CompEditorModel) model).getMinimumAlignmentType()); assertEquals(PackingType.EXPLICIT, ((CompEditorModel) model).getPackingType());
assertEquals(pack, ((CompEditorModel) model).getExplicitPackingValue());
} }
protected void assertMinimumAlignmentValue(int value) { protected void assertIsDefaultAligned() {
assertEquals(value, ((CompEditorModel) model).getMinimumAlignment()); 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) { protected void assertActualAlignment(int value) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -20,6 +20,7 @@ package ghidra.program.database.data;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.apache.commons.compress.utils.Sets;
import org.junit.*; import org.junit.*;
import generic.test.AbstractGTest; import generic.test.AbstractGTest;
@ -45,7 +46,7 @@ public class StructureDataTypeTest extends AbstractGTest {
// transition default little-endian structure to big-endian // transition default little-endian structure to big-endian
DataTypeManager beDtm = new MyBigEndianDataTypeManager(); DataTypeManager beDtm = new MyBigEndianDataTypeManager();
struct = (Structure) struct.clone(beDtm); struct = struct.clone(beDtm);
} }
private Structure createStructure(String name, int length) { private Structure createStructure(String name, int length) {
@ -420,7 +421,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off //@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" + CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" + "pack(disabled)\n" +
"Structure TestStruct {\n" + "Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" + " 0 byte 1 field1 \"Comment1\"\n" +
" 1 word 2 null \"Comment2\"\n" + " 1 word 2 null \"Comment2\"\n" +
@ -438,7 +439,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off //@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" + CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" + "pack(disabled)\n" +
"Structure TestStruct {\n" + "Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" + " 0 byte 1 field1 \"Comment1\"\n" +
" 1 word 2 null \"Comment2\"\n" + " 1 word 2 null \"Comment2\"\n" +
@ -461,7 +462,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off //@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" + CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" + "pack(disabled)\n" +
"Structure TestStruct {\n" + "Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" + " 0 byte 1 field1 \"Comment1\"\n" +
" 1 word 2 null \"Comment2\"\n" + " 1 word 2 null \"Comment2\"\n" +
@ -481,7 +482,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off //@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" + CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" + "pack(disabled)\n" +
"Structure TestStruct {\n" + "Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" + " 0 byte 1 field1 \"Comment1\"\n" +
" 1 word 2 null \"Comment2\"\n" + " 1 word 2 null \"Comment2\"\n" +
@ -506,7 +507,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off //@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" + CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" + "pack(disabled)\n" +
"Structure TestStruct {\n" + "Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" + " 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" + // " 1 undefined 1 null \"\"\n" +
@ -525,7 +526,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off //@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" + CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" + "pack(disabled)\n" +
"Structure TestStruct {\n" + "Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" + " 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" + // " 1 undefined 1 null \"\"\n" +
@ -545,7 +546,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off //@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" + CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" + "pack(disabled)\n" +
"Structure TestStruct {\n" + "Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" + " 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" + // " 1 undefined 1 null \"\"\n" +
@ -573,7 +574,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off //@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" + CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" + "pack(disabled)\n" +
"Structure TestStruct {\n" + "Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" + " 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" + // " 1 undefined 1 null \"\"\n" +
@ -607,7 +608,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off //@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" + CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" + "pack(disabled)\n" +
"Structure TestStruct {\n" + "Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" + " 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" + // " 1 undefined 1 null \"\"\n" +
@ -626,7 +627,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off //@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" + CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" + "pack(disabled)\n" +
"Structure TestStruct {\n" + "Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" + " 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" + // " 1 undefined 1 null \"\"\n" +
@ -646,7 +647,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off //@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" + CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" + "pack(disabled)\n" +
"Structure TestStruct {\n" + "Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" + " 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" + // " 1 undefined 1 null \"\"\n" +
@ -665,7 +666,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off //@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" + CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" + "pack(disabled)\n" +
"Structure TestStruct {\n" + "Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" + " 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" + // " 1 undefined 1 null \"\"\n" +
@ -693,7 +694,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off //@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" + CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" + "pack(disabled)\n" +
"Structure TestStruct {\n" + "Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" + " 0 byte 1 field1 \"Comment1\"\n" +
// " 1 undefined 1 null \"\"\n" + // " 1 undefined 1 null \"\"\n" +
@ -894,6 +895,79 @@ public class StructureDataTypeTest extends AbstractGTest {
assertEquals(7, comps[3].getOrdinal()); 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 @Test
public void testDelete() { public void testDelete() {
struct.delete(1); struct.delete(1);
@ -904,6 +978,144 @@ public class StructureDataTypeTest extends AbstractGTest {
assertEquals(1, comps[1].getOffset()); 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 @Test
public void testDeleteAtOffset() { public void testDeleteAtOffset() {
struct.deleteAtOffset(2); struct.deleteAtOffset(2);
@ -936,15 +1148,51 @@ public class StructureDataTypeTest extends AbstractGTest {
@Test @Test
public void testDeleteAll() { public void testDeleteAll() {
struct.setPackingEnabled(true); // enable packing for struct
assertEquals(12, struct.getLength());
Structure s = new StructureDataType("test1", 0); Structure s = new StructureDataType("test1", 0);
s.add(new ByteDataType()); s.add(new ByteDataType());
s.add(new FloatDataType()); s.add(new FloatDataType());
assertEquals(1, s.getAlignment());
assertEquals(5, s.getLength());
struct.add(s); struct.add(s);
assertEquals(16, struct.getLength());
s.deleteAll(); s.deleteAll();
assertEquals(1, s.getLength()); assertEquals(1, s.getLength());
assertTrue(s.isNotYetDefined()); assertTrue(s.isNotYetDefined());
assertTrue(s.isZeroLength());
assertEquals(0, s.getNumComponents()); 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 @Test
@ -1129,9 +1377,9 @@ public class StructureDataTypeTest extends AbstractGTest {
@Test @Test
public void testReplaceWith2() throws InvalidDataTypeException { 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. // 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); TypeDef td = new TypedefDataType("Foo", IntegerDataType.dataType);
@ -1144,7 +1392,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off //@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" + CompositeTestUtils.assertExpectedComposite(this, "/TestStruct\n" +
"Unaligned\n" + "pack(disabled)\n" +
"Structure TestStruct {\n" + "Structure TestStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" + " 0 byte 1 field1 \"Comment1\"\n" +
" 1 word 2 null \"Comment2\"\n" + " 1 word 2 null \"Comment2\"\n" +
@ -1169,7 +1417,7 @@ public class StructureDataTypeTest extends AbstractGTest {
//@formatter:off //@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/bigStruct\n" + CompositeTestUtils.assertExpectedComposite(this, "/bigStruct\n" +
"Unaligned\n" + "pack(disabled)\n" +
"Structure bigStruct {\n" + "Structure bigStruct {\n" +
" 0 byte 1 field1 \"Comment1\"\n" + " 0 byte 1 field1 \"Comment1\"\n" +
" 1 word 2 null \"Comment2\"\n" + " 1 word 2 null \"Comment2\"\n" +

View file

@ -22,6 +22,8 @@ import static org.junit.Assert.*;
import org.junit.*; import org.junit.*;
import com.google.common.collect.Sets;
import generic.test.AbstractGTest; import generic.test.AbstractGTest;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
@ -152,7 +154,7 @@ public class UnionDataTypeTest extends AbstractGTest {
//@formatter:off //@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestUnion\n" + CompositeTestUtils.assertExpectedComposite(this, "/TestUnion\n" +
"Unaligned\n" + "pack(disabled)\n" +
"Union TestUnion {\n" + "Union TestUnion {\n" +
" 0 short 2 null \"\"\n" + " 0 short 2 null \"\"\n" +
" 0 int:2(0) 1 bf1 \"bf1Comment\"\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.insertBitField(0, IntegerDataType.dataType, 2, "bf1", "bf1Comment");
union.insert(0, ShortDataType.dataType); union.insert(0, ShortDataType.dataType);
union.setInternallyAligned(true); union.setPackingEnabled(true);
//@formatter:off //@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestUnion\n" + CompositeTestUtils.assertExpectedComposite(this, "/TestUnion\n" +
"Aligned\n" + "pack()\n" +
"Union TestUnion {\n" + "Union TestUnion {\n" +
" 0 short 2 null \"\"\n" + " 0 short 2 null \"\"\n" +
" 0 int:2(0) 1 bf1 \"bf1Comment\"\n" + " 0 int:2(0) 1 bf1 \"bf1Comment\"\n" +
@ -191,7 +193,7 @@ public class UnionDataTypeTest extends AbstractGTest {
//@formatter:off //@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestUnion\n" + CompositeTestUtils.assertExpectedComposite(this, "/TestUnion\n" +
"Unaligned\n" + "pack(disabled)\n" +
"Union TestUnion {\n" + "Union TestUnion {\n" +
" 0 byte 1 field1 \"Comment1\"\n" + " 0 byte 1 field1 \"Comment1\"\n" +
" 0 word 2 null \"Comment2\"\n" + " 0 word 2 null \"Comment2\"\n" +
@ -214,7 +216,7 @@ public class UnionDataTypeTest extends AbstractGTest {
//@formatter:off //@formatter:off
CompositeTestUtils.assertExpectedComposite(this, "/TestUnion\n" + CompositeTestUtils.assertExpectedComposite(this, "/TestUnion\n" +
"Unaligned\n" + "pack(disabled)\n" +
"Union TestUnion {\n" + "Union TestUnion {\n" +
" 0 byte 1 field1 \"Comment1\"\n" + " 0 byte 1 field1 \"Comment1\"\n" +
" 0 word 2 null \"Comment2\"\n" + " 0 word 2 null \"Comment2\"\n" +
@ -261,6 +263,42 @@ public class UnionDataTypeTest extends AbstractGTest {
assertEquals(2, union.getLength()); 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 @Test
public void testIsPartOf() { public void testIsPartOf() {
Structure struct = createStructure("struct_1", 0); Structure struct = createStructure("struct_1", 0);

View file

@ -15,7 +15,7 @@
*/ */
package ghidra.program.model.data; package ghidra.program.model.data;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.*;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.InputStream; import java.io.InputStream;
@ -36,7 +36,7 @@ public abstract class AbstractCompositeImplBitFieldTest extends AbstractGTest {
DataTypeManager dataMgr = getDataTypeManager(); DataTypeManager dataMgr = getDataTypeManager();
if (dataMgr.getDataTypeCount(false) != 0) { 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 return; // already have types
} }

View file

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

View file

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

View file

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

View file

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

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