static protected void addPadding(DataOut out, int alignment) { int x = out.offset() % alignment; if (x != 0) { out.skip("padding", alignment - x);// Padding } }
private void write(DataOut out) { List<SectionItem<?>> list = new ArrayList<>(mapItem.items); // mapItem is useless now this.mapItem = null; for (int i = 0; i < list.size(); i++) { SectionItem<?> section = list.get(i); list.set(i, null); BaseItem.addPadding(out, out.offset(), section.sectionType.alignment); if (out.offset() != section.offset) { throw new RuntimeException(section.sectionType + " start with different position, planned:" + section.offset + ", but is:" + out.offset()); } section.write(out); } }
sb.append(" "); sb.append(String.format("%05d ", out0.offset())); sb.append(method.getName() + " ["); for (Object arg : args) {
public void write(DataOut out) { out.begin("Section:" + sectionType); List<T> items = this.items; if (sectionType == SectionType.TYPE_STRING_DATA_ITEM) { Buffer buff = new Buffer(); for (int i = 0; i < items.size(); i++) { T t = items.get(i); items.set(i, null); addPadding(out, sectionType.alignment); if (out.offset() != t.offset) { throw new RuntimeException(); } StringDataItem stringDataItem = (StringDataItem) t; stringDataItem.write(out, buff); buff.reset(); } } else { for (int i = 0; i < items.size(); i++) { T t = items.get(i); items.set(i, null); addPadding(out, sectionType.alignment); if (out.offset() != t.offset) { System.err.println("Error for type:" + this.sectionType + ", " + t.index); throw new RuntimeException(); } t.write(out); } } out.end(); }
static protected void addPadding(DataOut out, int alignment) { int x = out.offset() % alignment; if (x != 0) { out.skip("padding", alignment - x);// Padding } }
private void write(DataOut out) { List<SectionItem<?>> list = new ArrayList<>(mapItem.items); // mapItem is useless now this.mapItem = null; for (int i = 0; i < list.size(); i++) { SectionItem<?> section = list.get(i); list.set(i, null); BaseItem.addPadding(out, out.offset(), section.sectionType.alignment); if (out.offset() != section.offset) { throw new RuntimeException(section.sectionType + " start with different position, planned:" + section.offset + ", but is:" + out.offset()); } section.write(out); } }
sb.append(" "); sb.append(String.format("%05d ", out0.offset())); sb.append(method.getName() + " ["); for (Object arg : args) {
public void write(DataOut out) { out.begin("Section:" + sectionType); List<T> items = this.items; if (sectionType == SectionType.TYPE_STRING_DATA_ITEM) { Buffer buff = new Buffer(); for (int i = 0; i < items.size(); i++) { T t = items.get(i); items.set(i, null); addPadding(out, sectionType.alignment); if (out.offset() != t.offset) { throw new RuntimeException(); } StringDataItem stringDataItem = (StringDataItem) t; stringDataItem.write(out, buff); buff.reset(); } } else { for (int i = 0; i < items.size(); i++) { T t = items.get(i); items.set(i, null); addPadding(out, sectionType.alignment); if (out.offset() != t.offset) { System.err.println("Error for type:" + this.sectionType + ", " + t.index); throw new RuntimeException(); } t.write(out); } } out.end(); }