use of com.ibm.j9ddr.StructureReader in project openj9 by eclipse.
the class PointerGenerator method generateClasses.
private void generateClasses() {
String fileName = opts.get("-f");
String supersetFileName = opts.get("-s");
try {
J9DDRStructureStore store = new J9DDRStructureStore(fileName, supersetFileName);
System.out.println("superset directory name : " + fileName);
System.out.println("superset file name : " + store.getSuperSetFileName());
InputStream inputStream = store.getSuperset();
structureReader = new StructureReader(inputStream);
inputStream.close();
} catch (IOException e) {
System.out.println("Problem with file: " + fileName);
e.printStackTrace();
return;
}
outputDir = getOutputDir("-p");
if (opts.get("-h") != null) {
// where to write the helpers to if the option is set
outputDirHelpers = getOutputDir("-h");
}
typeManager = new StructureTypeManager(structureReader.getStructures());
for (StructureDescriptor structure : structureReader.getStructures()) {
try {
if (FlagStructureList.isFlagsStructure(structure.getName())) {
generateBuildFlags(structure);
} else {
generateClass(structure);
}
} catch (FileNotFoundException e) {
String error = String.format("File Not Found processing: %s: %s", structure.getPointerName(), e.getMessage());
System.out.println(error);
} catch (IOException e) {
String error = String.format("IOException processing: %s: %s", structure.getPointerName(), e.getMessage());
System.out.println(error);
}
}
}
use of com.ibm.j9ddr.StructureReader in project openj9 by eclipse.
the class StructureStubGenerator method generateClasses.
private void generateClasses() {
String supersetDirectoryName = opts.get("-f");
String supersetFileName = opts.get("-s");
try {
J9DDRStructureStore store = new J9DDRStructureStore(supersetDirectoryName, supersetFileName);
System.out.println("superset directory name : " + supersetDirectoryName);
System.out.println("superset file name : " + store.getSuperSetFileName());
InputStream inputStream = store.getSuperset();
structureReader = new StructureReader(inputStream);
inputStream.close();
} catch (IOException e) {
System.out.println("Could not find file: " + supersetDirectoryName + "/" + supersetFileName);
return;
}
outputDir = getOutputDir();
for (StructureDescriptor structure : structureReader.getStructures()) {
try {
if (FlagStructureList.isFlagsStructure(structure.getName())) {
// generateBuildFlags(structure);
} else {
generateClass(structure);
}
} catch (FileNotFoundException e) {
String error = String.format("File Not Found processing: %s: %s", structure.getName(), e.getMessage());
System.out.println(error);
} catch (IOException e) {
String error = String.format("IOException processing: %s: %s", structure.getName(), e.getMessage());
System.out.println(error);
}
}
}
use of com.ibm.j9ddr.StructureReader in project openj9 by eclipse.
the class J9DDRStructureStore method updateSuperset.
public void updateSuperset() throws IOException {
StructureReader reader = null;
if ((structureBytes.length > 2) && (structureBytes[0] == SUPERSET_ID[0]) && (structureBytes[1] == SUPERSET_ID[1])) {
// creating a reader using an input stream treats it as a superset input i.e. text
InputStream in = new ByteArrayInputStream(structureBytes);
reader = new StructureReader(in);
} else {
// using an image input stream to the reader indicates that is in binary blob format
ImageInputStream inputStream = new MemoryCacheImageInputStream(new ByteArrayInputStream(structureBytes));
reader = new StructureReader(inputStream);
}
for (StructureDescriptor structure : reader.getStructures()) {
String structureHeader = structure.deflate();
HashSet<String> structureContents = superset.get(structureHeader);
if (structureContents == null) {
structureContents = new HashSet<String>();
superset.put(structureHeader, structureContents);
}
for (FieldDescriptor field : structure.getFields()) {
addFieldToSuperset(structureContents, field);
}
for (ConstantDescriptor constant : structure.getConstants()) {
String constantHeader = constant.deflate();
structureContents.add(constantHeader);
}
}
writeSuperset();
}
use of com.ibm.j9ddr.StructureReader in project openj9 by eclipse.
the class PrintBlob method main.
/**
* @param args
*/
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.err.println("Expected 1 argument. Got " + args.length);
System.exit(1);
}
File blobFile = new File(args[0]);
ImageInputStream iis = new FileImageInputStream(blobFile);
iis.setByteOrder(ByteOrder.LITTLE_ENDIAN);
StructureReader structReader = new StructureReader(iis);
List<StructureDescriptor> structures = new ArrayList<StructureDescriptor>(structReader.getStructures());
Collections.sort(structures, new Comparator<StructureDescriptor>() {
public int compare(StructureDescriptor o1, StructureDescriptor o2) {
return o1.getName().compareTo(o2.getName());
}
});
for (StructureDescriptor thisStruct : structures) {
String superClass = thisStruct.getSuperName();
if (superClass != null && superClass.length() > 0) {
System.out.println("Structure: " + thisStruct.getName() + " extends " + superClass);
} else {
System.out.println("Structure: " + thisStruct.getName());
}
// List<FieldDescriptor> fields = new ArrayList<FieldDescriptor>(thisStruct.getFields());
//
// Collections.sort(fields, new Comparator<FieldDescriptor>(){
//
// public int compare(FieldDescriptor o1, FieldDescriptor o2)
// {
// return o1.getName().compareTo(o2.getName());
// }});
//
// System.out.println("\tFields");
//
// for (FieldDescriptor thisField : fields) {
// System.out.println("\t\t" + thisField.getName() + " - " + thisField.getType());
// }
//
// List<ConstantDescriptor> constants = new ArrayList<ConstantDescriptor>(thisStruct.getConstants());
//
// Collections.sort(constants, new Comparator<ConstantDescriptor>(){
//
// public int compare(ConstantDescriptor o1, ConstantDescriptor o2)
// {
// return o1.getName().compareTo(o2.getName());
// }});
//
// System.out.println("\tConstants:");
// for (ConstantDescriptor thisConstant : constants) {
// System.out.println("\t\t" + thisConstant.getName());
// }
}
}
Aggregations