protected FieldDefsRes fieldDefs(ClassDoc clazz, String cname, boolean bottomMost) throws ClassNotFoundException { FieldDefsRes res; int offset; boolean didTwoWordFields = false; ClassDoc superclazz = clazz.superclass(); if (superclazz != null) { String supername = superclazz.qualifiedName(); res = new FieldDefsRes(clazz, fieldDefs(superclazz, cname, false), bottomMost); offset = res.parent.byteSize; } else { res = new FieldDefsRes(clazz, null, bottomMost); offset = 0; } FieldDoc[] fields = clazz.fields(); for (int i = 0; i < fields.length; i++) { FieldDoc field = fields[i]; if (doubleAlign && !didTwoWordFields && (offset % 8) == 0) { offset = doTwoWordFields(res, clazz, offset, cname, false); didTwoWordFields = true; } String tc = field.type().typeName(); boolean twoWords = (tc.equals("long") || tc.equals("double")); if (!doubleAlign || !twoWords) { if (doField(res, field, cname, false)) offset += 4; } } if (doubleAlign && !didTwoWordFields) { if ((offset % 8) != 0) offset += 4; offset = doTwoWordFields(res, clazz, offset, cname, true); } res.byteSize = offset; return res; }
/* Returns "true" iff added a field. */ private boolean doField(FieldDefsRes res, FieldDoc field, String cname, boolean padWord) throws ClassNotFoundException { String fieldDef = addStructMember(field, cname, padWord); if (fieldDef != null) { if (!res.printedOne) { /* add separator */ if (res.bottomMost) { if (res.s.length() != 0) res.s = res.s + " /* local members: */" + lineSep; } else { res.s = res.s + " /* inherited members from " + res.className + ": */" + lineSep; } res.printedOne = true; } res.s = res.s + fieldDef; return true; } // Otherwise. return false; }