Skip to content

Commit 66fc367

Browse files
committed
GT-3414 revert Iterable change.
1 parent 5a66f68 commit 66fc367

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/strings/ViewStringsTableModel.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import ghidra.util.table.field.AbstractProgramLocationTableColumn;
4040
import ghidra.util.table.field.AddressBasedLocation;
4141
import ghidra.util.task.TaskMonitor;
42-
import util.CollectionUtils;
4342

4443
/**
4544
* Table model for the "Defined Strings" table.
@@ -115,8 +114,7 @@ protected void doLoad(Accumulator<ProgramLocation> accumulator, TaskMonitor moni
115114
monitor.setCancelEnabled(true);
116115
monitor.initialize(listing.getNumDefinedData());
117116
Swing.allowSwingToProcessEvents();
118-
for (Data stringInstance : CollectionUtils.asIterable(
119-
DefinedDataIterator.definedStrings(localProgram))) {
117+
for (Data stringInstance : DefinedDataIterator.definedStrings(localProgram)) {
120118
accumulator.add(createIndexedStringInstanceLocation(localProgram, stringInstance));
121119
monitor.checkCanceled();
122120
monitor.incrementProgress(1);
@@ -142,8 +140,7 @@ public ProgramLocation findEquivProgramLocation(ProgramLocation pl) {
142140
}
143141

144142
public void addDataInstance(Program localProgram, Data data, TaskMonitor monitor) {
145-
for (Data stringInstance : CollectionUtils.asIterable(
146-
DefinedDataIterator.definedStrings(data))) {
143+
for (Data stringInstance : DefinedDataIterator.definedStrings(data)) {
147144
addObject(createIndexedStringInstanceLocation(localProgram, stringInstance));
148145
}
149146
}

Ghidra/Features/Base/src/test/java/ghidra/program/util/DefinedDataIteratorTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void test_Ints() throws Exception {
7979
builder.createString("0x10", "test1", StandardCharsets.UTF_8, true, stringDT);
8080
builder.applyFixedLengthDataType("0x100", struct1DT, struct1DT.getLength());
8181

82-
List<Data> list = CollectionUtils.asList(
82+
List<Data> list = CollectionUtils.asList((Iterable<Data>)
8383
DefinedDataIterator.byDataType(program, dt -> dt instanceof IntegerDataType));
8484

8585
assertTrue(list.get(0).getAddress().getOffset() == 0x0);
@@ -94,7 +94,8 @@ public void test_Strings() throws Exception {
9494
builder.createString("0x10", "test1", StandardCharsets.UTF_8, true, stringDT);
9595
builder.applyFixedLengthDataType("0x100", struct1DT, struct1DT.getLength());
9696

97-
List<Data> list = CollectionUtils.asList(DefinedDataIterator.definedStrings(program));
97+
List<Data> list =
98+
CollectionUtils.asList((Iterable<Data>) DefinedDataIterator.definedStrings(program));
9899

99100
assertTrue(list.get(0).getAddress().getOffset() == 0x10);
100101
assertTrue(list.get(1).getAddress().getOffset() == 0x100 + 10);
@@ -113,7 +114,8 @@ public void test_ArrayOfStructs() throws Exception {
113114
int lastEle = numElements - 1;
114115
int elementSize = structArray.getElementLength();
115116

116-
List<Data> list = CollectionUtils.asList(DefinedDataIterator.definedStrings(program));
117+
List<Data> list =
118+
CollectionUtils.asList((Iterable<Data>) DefinedDataIterator.definedStrings(program));
117119

118120
assertEquals(list.get(0).getAddress().getOffset(), 0x10);
119121
assertEquals(list.get(1 + 0).getAddress().getOffset(), 0x100 + 10);
@@ -135,14 +137,14 @@ public void test_Typedefs() throws CodeUnitInsertionException {
135137
builder.applyFixedLengthDataType("0x20", intDT, intTD.getLength());
136138

137139
// iterating by data type ignores typedefs, so we should get all 3 ints
138-
List<Data> list = CollectionUtils.asList(
140+
List<Data> list = CollectionUtils.asList((Iterable<Data>)
139141
DefinedDataIterator.byDataType(program, dt -> dt instanceof IntegerDataType));
140142

141143
assertEquals(3, list.size());
142144

143145
// iterating by data instance, we can inspect the actual data type and get the
144146
// typedef
145-
list = CollectionUtils.asList(DefinedDataIterator.byDataInstance(program,
147+
list = CollectionUtils.asList((Iterable<Data>) DefinedDataIterator.byDataInstance(program,
146148
data -> data.getDataType() instanceof TypeDef));
147149
assertEquals(2, list.size());
148150
}

Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/DataIterator.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*
2626
* @see CollectionUtils#asIterable
2727
*/
28-
public interface DataIterator extends Iterator<Data> {
28+
public interface DataIterator extends Iterator<Data>, Iterable<Data> {
2929
public static final DataIterator EMPTY = of(/*nothing*/);
3030

3131
/**
@@ -44,6 +44,11 @@ public static DataIterator of(Data... dataInstances) {
4444
@Override
4545
public Data next();
4646

47+
@Override
48+
default Iterator<Data> iterator() {
49+
return this;
50+
}
51+
4752
// --------------------------------------------------------------------------------
4853
// Helper static stuff
4954
// --------------------------------------------------------------------------------

Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/util/demangler/DemangledAddressTableTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import ghidra.test.AbstractGhidraHeadlessIntegrationTest;
2929
import ghidra.test.ToyProgramBuilder;
3030
import ghidra.util.task.TaskMonitor;
31-
import util.CollectionUtils;
3231

3332
public class DemangledAddressTableTest extends AbstractGhidraHeadlessIntegrationTest {
3433

@@ -228,7 +227,7 @@ public void testApply_WithUndefinedArray() throws Exception {
228227
private void assertPointersAt(int totalNonPointerData, int totalInstructions, String... addrs) {
229228
Listing listing = program.getListing();
230229
int index = 0;
231-
for (Data d : CollectionUtils.asIterable(listing.getDefinedData(true))) {
230+
for (Data d : listing.getDefinedData(true)) {
232231
if (d.isPointer()) {
233232
assertTrue("too many pointers found, expected only " + addrs.length,
234233
index < addrs.length);

0 commit comments

Comments
 (0)