mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
commit
1044bf5f7e
3 changed files with 28 additions and 92 deletions
|
@ -936,16 +936,18 @@ public abstract class CompEditorModel extends CompositeEditorModel {
|
|||
endRowIndex <= 0 || endRowIndex >= numComps) {
|
||||
return false;
|
||||
}
|
||||
DataTypeComponent comp = getComponent(startRowIndex - 1);
|
||||
deleteComponent(startRowIndex - 1);
|
||||
try {
|
||||
insert(endRowIndex, comp.getDataType(), comp.getLength(), comp.getFieldName(),
|
||||
comp.getComment());
|
||||
}
|
||||
catch (InvalidDataTypeException e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return viewDTM.withTransaction("Shift Up", () -> {
|
||||
DataTypeComponent comp = getComponent(startRowIndex - 1);
|
||||
deleteComponent(startRowIndex - 1);
|
||||
try {
|
||||
insert(endRowIndex, comp.getDataType(), comp.getLength(), comp.getFieldName(),
|
||||
comp.getComment());
|
||||
}
|
||||
catch (InvalidDataTypeException e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -962,16 +964,18 @@ public abstract class CompEditorModel extends CompositeEditorModel {
|
|||
endRowIndex < 0 || endRowIndex >= numComps - 1) {
|
||||
return false;
|
||||
}
|
||||
DataTypeComponent comp = getComponent(endRowIndex + 1);
|
||||
deleteComponent(endRowIndex + 1);
|
||||
try {
|
||||
insert(startRowIndex, comp.getDataType(), comp.getLength(), comp.getFieldName(),
|
||||
comp.getComment());
|
||||
}
|
||||
catch (InvalidDataTypeException e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return viewDTM.withTransaction("Shift Down", () -> {
|
||||
DataTypeComponent comp = getComponent(endRowIndex + 1);
|
||||
deleteComponent(endRowIndex + 1);
|
||||
try {
|
||||
insert(startRowIndex, comp.getDataType(), comp.getLength(), comp.getFieldName(),
|
||||
comp.getComment());
|
||||
}
|
||||
catch (InvalidDataTypeException e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1066,6 +1070,7 @@ public abstract class CompEditorModel extends CompositeEditorModel {
|
|||
replace(rowIndex, array, array.getLength()); // Can throw UsrException.
|
||||
}
|
||||
});
|
||||
componentEdited();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1629,15 +1634,6 @@ public abstract class CompEditorModel extends CompositeEditorModel {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the indicated data type from any components to prevent a cycle
|
||||
* being created by this component being updated. Structures will actually
|
||||
* clear any components containing the indicated data type.
|
||||
* Unions will delete their components that contain the data type.
|
||||
* @param comp the composite data type that contains the data type being edited.
|
||||
*/
|
||||
abstract void removeDtFromComponents(Composite comp);
|
||||
|
||||
//==================================================================================================
|
||||
// End of Override CompositeViewerModel CategoryChangeListener methods
|
||||
//==================================================================================================
|
||||
|
|
|
@ -1064,33 +1064,6 @@ class StructureEditorModel extends CompEditorModel {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void removeDtFromComponents(Composite comp) {
|
||||
DataType newDt = viewDTM.getDataType(comp.getDataTypePath());
|
||||
if (newDt == null) {
|
||||
return;
|
||||
}
|
||||
boolean clearedComponents = viewDTM.withTransaction("Remove Components", () -> {
|
||||
boolean cleared = false;
|
||||
int num = getNumComponents();
|
||||
for (int i = num - 1; i >= 0; i--) {
|
||||
DataTypeComponent dtc = getComponent(i);
|
||||
DataType dt = dtc.getDataType();
|
||||
if (dt instanceof Composite) {
|
||||
Composite dtcComp = (Composite) dt;
|
||||
if (dtcComp.isPartOf(newDt)) {
|
||||
clearComponents(new int[] { i });
|
||||
cleared = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cleared;
|
||||
});
|
||||
if (clearedComponents) {
|
||||
setStatus("Components containing " + comp.getDisplayName() + " were cleared.", true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowingUndefinedBytes() {
|
||||
return !viewComposite.isPackingEnabled();
|
||||
|
|
|
@ -540,54 +540,21 @@ class UnionEditorModel extends CompEditorModel {
|
|||
throw new UnsupportedOperationException("Can't clear components in a union.");
|
||||
}
|
||||
|
||||
@Override
|
||||
void removeDtFromComponents(Composite comp) {
|
||||
DataTypePath path = comp.getDataTypePath();
|
||||
DataType newDt = viewDTM.getDataType(path);
|
||||
if (newDt == null) {
|
||||
return;
|
||||
}
|
||||
viewDTM.withTransaction("Remove use of " + path, () -> {
|
||||
int num = getNumComponents();
|
||||
for (int i = num - 1; i >= 0; i--) {
|
||||
DataTypeComponent dtc = getComponent(i);
|
||||
DataType dt = dtc.getDataType();
|
||||
if (dt instanceof Composite) {
|
||||
Composite dtcComp = (Composite) dt;
|
||||
if (dtcComp.isPartOf(newDt)) {
|
||||
deleteComponent(i);
|
||||
String msg =
|
||||
"Components containing " + comp.getDisplayName() + " were removed.";
|
||||
setStatus(msg, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ?????
|
||||
*
|
||||
* @param rowIndex the index of the row
|
||||
*/
|
||||
@Override
|
||||
protected boolean isAtEnd(int rowIndex) {
|
||||
// Not applicable to union
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cause the component at the specified index to consume undefined bytes
|
||||
* that follow it.
|
||||
* Note: this method adjusts the selection.
|
||||
* @return the number of Undefined bytes consumed.
|
||||
*/
|
||||
@Override
|
||||
protected int consumeByComponent(int rowIndex) {
|
||||
// Not applicable to union
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowingUndefinedBytes() {
|
||||
// Not applicable to union
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue