mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
GT-3414 revert Iterable change.
This commit is contained in:
parent
5a66f68e47
commit
66fc367b18
4 changed files with 16 additions and 13 deletions
|
@ -39,7 +39,6 @@ import ghidra.util.table.column.GColumnRenderer;
|
|||
import ghidra.util.table.field.AbstractProgramLocationTableColumn;
|
||||
import ghidra.util.table.field.AddressBasedLocation;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
import util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* Table model for the "Defined Strings" table.
|
||||
|
@ -115,8 +114,7 @@ class ViewStringsTableModel extends AddressBasedTableModel<ProgramLocation> {
|
|||
monitor.setCancelEnabled(true);
|
||||
monitor.initialize(listing.getNumDefinedData());
|
||||
Swing.allowSwingToProcessEvents();
|
||||
for (Data stringInstance : CollectionUtils.asIterable(
|
||||
DefinedDataIterator.definedStrings(localProgram))) {
|
||||
for (Data stringInstance : DefinedDataIterator.definedStrings(localProgram)) {
|
||||
accumulator.add(createIndexedStringInstanceLocation(localProgram, stringInstance));
|
||||
monitor.checkCanceled();
|
||||
monitor.incrementProgress(1);
|
||||
|
@ -142,8 +140,7 @@ class ViewStringsTableModel extends AddressBasedTableModel<ProgramLocation> {
|
|||
}
|
||||
|
||||
public void addDataInstance(Program localProgram, Data data, TaskMonitor monitor) {
|
||||
for (Data stringInstance : CollectionUtils.asIterable(
|
||||
DefinedDataIterator.definedStrings(data))) {
|
||||
for (Data stringInstance : DefinedDataIterator.definedStrings(data)) {
|
||||
addObject(createIndexedStringInstanceLocation(localProgram, stringInstance));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ public class DefinedDataIteratorTest extends AbstractGhidraHeadlessIntegrationTe
|
|||
builder.createString("0x10", "test1", StandardCharsets.UTF_8, true, stringDT);
|
||||
builder.applyFixedLengthDataType("0x100", struct1DT, struct1DT.getLength());
|
||||
|
||||
List<Data> list = CollectionUtils.asList(
|
||||
List<Data> list = CollectionUtils.asList((Iterable<Data>)
|
||||
DefinedDataIterator.byDataType(program, dt -> dt instanceof IntegerDataType));
|
||||
|
||||
assertTrue(list.get(0).getAddress().getOffset() == 0x0);
|
||||
|
@ -94,7 +94,8 @@ public class DefinedDataIteratorTest extends AbstractGhidraHeadlessIntegrationTe
|
|||
builder.createString("0x10", "test1", StandardCharsets.UTF_8, true, stringDT);
|
||||
builder.applyFixedLengthDataType("0x100", struct1DT, struct1DT.getLength());
|
||||
|
||||
List<Data> list = CollectionUtils.asList(DefinedDataIterator.definedStrings(program));
|
||||
List<Data> list =
|
||||
CollectionUtils.asList((Iterable<Data>) DefinedDataIterator.definedStrings(program));
|
||||
|
||||
assertTrue(list.get(0).getAddress().getOffset() == 0x10);
|
||||
assertTrue(list.get(1).getAddress().getOffset() == 0x100 + 10);
|
||||
|
@ -113,7 +114,8 @@ public class DefinedDataIteratorTest extends AbstractGhidraHeadlessIntegrationTe
|
|||
int lastEle = numElements - 1;
|
||||
int elementSize = structArray.getElementLength();
|
||||
|
||||
List<Data> list = CollectionUtils.asList(DefinedDataIterator.definedStrings(program));
|
||||
List<Data> list =
|
||||
CollectionUtils.asList((Iterable<Data>) DefinedDataIterator.definedStrings(program));
|
||||
|
||||
assertEquals(list.get(0).getAddress().getOffset(), 0x10);
|
||||
assertEquals(list.get(1 + 0).getAddress().getOffset(), 0x100 + 10);
|
||||
|
@ -135,14 +137,14 @@ public class DefinedDataIteratorTest extends AbstractGhidraHeadlessIntegrationTe
|
|||
builder.applyFixedLengthDataType("0x20", intDT, intTD.getLength());
|
||||
|
||||
// iterating by data type ignores typedefs, so we should get all 3 ints
|
||||
List<Data> list = CollectionUtils.asList(
|
||||
List<Data> list = CollectionUtils.asList((Iterable<Data>)
|
||||
DefinedDataIterator.byDataType(program, dt -> dt instanceof IntegerDataType));
|
||||
|
||||
assertEquals(3, list.size());
|
||||
|
||||
// iterating by data instance, we can inspect the actual data type and get the
|
||||
// typedef
|
||||
list = CollectionUtils.asList(DefinedDataIterator.byDataInstance(program,
|
||||
list = CollectionUtils.asList((Iterable<Data>) DefinedDataIterator.byDataInstance(program,
|
||||
data -> data.getDataType() instanceof TypeDef));
|
||||
assertEquals(2, list.size());
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import util.CollectionUtils;
|
|||
*
|
||||
* @see CollectionUtils#asIterable
|
||||
*/
|
||||
public interface DataIterator extends Iterator<Data> {
|
||||
public interface DataIterator extends Iterator<Data>, Iterable<Data> {
|
||||
public static final DataIterator EMPTY = of(/*nothing*/);
|
||||
|
||||
/**
|
||||
|
@ -44,6 +44,11 @@ public interface DataIterator extends Iterator<Data> {
|
|||
@Override
|
||||
public Data next();
|
||||
|
||||
@Override
|
||||
default Iterator<Data> iterator() {
|
||||
return this;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// Helper static stuff
|
||||
// --------------------------------------------------------------------------------
|
||||
|
|
|
@ -28,7 +28,6 @@ import ghidra.program.model.symbol.*;
|
|||
import ghidra.test.AbstractGhidraHeadlessIntegrationTest;
|
||||
import ghidra.test.ToyProgramBuilder;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
import util.CollectionUtils;
|
||||
|
||||
public class DemangledAddressTableTest extends AbstractGhidraHeadlessIntegrationTest {
|
||||
|
||||
|
@ -228,7 +227,7 @@ public class DemangledAddressTableTest extends AbstractGhidraHeadlessIntegration
|
|||
private void assertPointersAt(int totalNonPointerData, int totalInstructions, String... addrs) {
|
||||
Listing listing = program.getListing();
|
||||
int index = 0;
|
||||
for (Data d : CollectionUtils.asIterable(listing.getDefinedData(true))) {
|
||||
for (Data d : listing.getDefinedData(true)) {
|
||||
if (d.isPointer()) {
|
||||
assertTrue("too many pointers found, expected only " + addrs.length,
|
||||
index < addrs.length);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue