mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 10:46:02 +02:00
Fix interface of ElfBinaryArchive to allow proper derivation
This commit is contained in:
parent
6e62fd8891
commit
196254955b
2 changed files with 20 additions and 21 deletions
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.utils.elf.parser;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.IBinaryParser;
|
import org.eclipse.cdt.core.IBinaryParser;
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
|
||||||
|
@ -26,7 +27,7 @@ import org.eclipse.core.runtime.IPath;
|
||||||
*/
|
*/
|
||||||
public class ElfBinaryArchive extends BinaryFile implements IBinaryArchive {
|
public class ElfBinaryArchive extends BinaryFile implements IBinaryArchive {
|
||||||
|
|
||||||
ArrayList children;
|
private ArrayList children;
|
||||||
|
|
||||||
public ElfBinaryArchive(IBinaryParser parser, IPath p) throws IOException {
|
public ElfBinaryArchive(IBinaryParser parser, IPath p) throws IOException {
|
||||||
super(parser, p, IBinaryFile.ARCHIVE);
|
super(parser, p, IBinaryFile.ARCHIVE);
|
||||||
|
@ -44,7 +45,8 @@ public class ElfBinaryArchive extends BinaryFile implements IBinaryArchive {
|
||||||
try {
|
try {
|
||||||
ar = new AR(getPath().toOSString());
|
ar = new AR(getPath().toOSString());
|
||||||
AR.ARHeader[] headers = ar.getHeaders();
|
AR.ARHeader[] headers = ar.getHeaders();
|
||||||
addArchiveMembers(headers, children);
|
IBinaryObject[] bobjs= createArchiveMembers(headers);
|
||||||
|
children.addAll(Arrays.asList(bobjs));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
//e.printStackTrace();
|
//e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -56,14 +58,21 @@ public class ElfBinaryArchive extends BinaryFile implements IBinaryArchive {
|
||||||
return (IBinaryObject[]) children.toArray(new IBinaryObject[0]);
|
return (IBinaryObject[]) children.toArray(new IBinaryObject[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IBinaryObject[] createArchiveMembers(ARHeader[] headers) {
|
||||||
|
IBinaryObject[] result= new IBinaryObject[headers.length];
|
||||||
|
for (int i = 0; i < headers.length; i++) {
|
||||||
|
result[i]= new ElfBinaryObject(getBinaryParser(), getPath(), headers[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param headers
|
* @param headers
|
||||||
* @param children2
|
* @param children2
|
||||||
|
* @deprecated use {@link ElfBinaryArchive#createArchiveMembers(ARHeader[])}
|
||||||
*/
|
*/
|
||||||
protected void addArchiveMembers(ARHeader[] headers, ArrayList children2) {
|
protected void addArchiveMembers(ARHeader[] headers, ArrayList children) {
|
||||||
for (int i = 0; i < headers.length; i++) {
|
IBinaryObject[] bobjs= createArchiveMembers(headers);
|
||||||
IBinaryObject bin = new ElfBinaryObject(getBinaryParser(), getPath(), headers[i]);
|
children.addAll(Arrays.asList(bobjs));
|
||||||
children.add(bin);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
package org.eclipse.cdt.utils.elf.parser;
|
package org.eclipse.cdt.utils.elf.parser;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.IBinaryParser;
|
import org.eclipse.cdt.core.IBinaryParser;
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
||||||
|
@ -21,24 +20,15 @@ import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public class GNUElfBinaryArchive extends ElfBinaryArchive {
|
public class GNUElfBinaryArchive extends ElfBinaryArchive {
|
||||||
|
|
||||||
/**
|
|
||||||
* @param parser
|
|
||||||
* @param p
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
public GNUElfBinaryArchive(IBinaryParser parser, IPath p) throws IOException {
|
public GNUElfBinaryArchive(IBinaryParser parser, IPath p) throws IOException {
|
||||||
super(parser, p);
|
super(parser, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IBinaryObject[] createArchiveMembers(ARHeader[] headers) {
|
||||||
/* (non-Javadoc)
|
IBinaryObject[] result= new IBinaryObject[headers.length];
|
||||||
* @see org.eclipse.cdt.utils.elf.parser.BinaryArchive#addArchiveMembers(org.eclipse.cdt.utils.elf.AR.ARHeader[], java.util.ArrayList)
|
|
||||||
*/
|
|
||||||
protected void addArchiveMembers(ARHeader[] headers, ArrayList children2) {
|
|
||||||
for (int i = 0; i < headers.length; i++) {
|
for (int i = 0; i < headers.length; i++) {
|
||||||
IBinaryObject bin = new GNUElfBinaryObject(getBinaryParser(), getPath(), headers[i]);
|
result[i] = new GNUElfBinaryObject(getBinaryParser(), getPath(), headers[i]);
|
||||||
children.add(bin);
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue