1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 02:36:01 +02:00

Fix interface of ElfBinaryArchive to allow proper derivation

This commit is contained in:
Markus Schorn 2006-09-28 08:47:09 +00:00
parent 6e62fd8891
commit 196254955b
2 changed files with 20 additions and 21 deletions

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.utils.elf.parser;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import org.eclipse.cdt.core.IBinaryParser;
import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
@ -26,7 +27,7 @@ import org.eclipse.core.runtime.IPath;
*/
public class ElfBinaryArchive extends BinaryFile implements IBinaryArchive {
ArrayList children;
private ArrayList children;
public ElfBinaryArchive(IBinaryParser parser, IPath p) throws IOException {
super(parser, p, IBinaryFile.ARCHIVE);
@ -44,7 +45,8 @@ public class ElfBinaryArchive extends BinaryFile implements IBinaryArchive {
try {
ar = new AR(getPath().toOSString());
AR.ARHeader[] headers = ar.getHeaders();
addArchiveMembers(headers, children);
IBinaryObject[] bobjs= createArchiveMembers(headers);
children.addAll(Arrays.asList(bobjs));
} catch (IOException e) {
//e.printStackTrace();
}
@ -56,14 +58,21 @@ public class ElfBinaryArchive extends BinaryFile implements IBinaryArchive {
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 children2
* @deprecated use {@link ElfBinaryArchive#createArchiveMembers(ARHeader[])}
*/
protected void addArchiveMembers(ARHeader[] headers, ArrayList children2) {
for (int i = 0; i < headers.length; i++) {
IBinaryObject bin = new ElfBinaryObject(getBinaryParser(), getPath(), headers[i]);
children.add(bin);
}
protected void addArchiveMembers(ARHeader[] headers, ArrayList children) {
IBinaryObject[] bobjs= createArchiveMembers(headers);
children.addAll(Arrays.asList(bobjs));
}
}

View file

@ -11,7 +11,6 @@
package org.eclipse.cdt.utils.elf.parser;
import java.io.IOException;
import java.util.ArrayList;
import org.eclipse.cdt.core.IBinaryParser;
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
@ -21,24 +20,15 @@ import org.eclipse.core.runtime.IPath;
public class GNUElfBinaryArchive extends ElfBinaryArchive {
/**
* @param parser
* @param p
* @throws IOException
*/
public GNUElfBinaryArchive(IBinaryParser parser, IPath p) throws IOException {
super(parser, p);
}
/* (non-Javadoc)
* @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) {
protected IBinaryObject[] createArchiveMembers(ARHeader[] headers) {
IBinaryObject[] result= new IBinaryObject[headers.length];
for (int i = 0; i < headers.length; i++) {
IBinaryObject bin = new GNUElfBinaryObject(getBinaryParser(), getPath(), headers[i]);
children.add(bin);
result[i] = new GNUElfBinaryObject(getBinaryParser(), getPath(), headers[i]);
}
return result;
}
}