public String toDebugString() { StringBuilder sb = new StringBuilder(); sb.append("@interface ").append(getName()); long superclass = ObjCRuntime.class_getSuperclass(getHandle()); if (superclass != 0) { sb.append(" : ").append(VM.newStringUTF(ObjCRuntime.class_getName(superclass))); } IntPtr outCount = new IntPtr(); long protocols = ObjCRuntime.class_copyProtocolList(getHandle(), outCount.getHandle()); if (outCount.get() > 0) { sb.append(" <"); for (int i = 0; i < outCount.get(); i++) { if (i > 0) { sb.append(", "); } sb.append(VM.newStringUTF(ObjCRuntime.protocol_getName(VM.getPointer(protocols)))); protocols += (Bro.IS_64BIT ? 8 : 4); } sb.append('>'); } sb.append('\n'); sb.append("@end"); return sb.toString(); }
@SuppressWarnings("unchecked") private static List<String> getProtocols(long handle, boolean isProtocol) { final long protocols = isProtocol ? ObjCRuntime.protocol_copyProtocolList(handle, 0) : ObjCRuntime.class_copyProtocolList(handle, 0); if (protocols == 0) { return (List<String>) Collections.EMPTY_LIST; } ArrayList<String> names = new ArrayList<>(); for (long protos = protocols; VM.getPointer(protos) != 0; protos += Bro.IS_64BIT ? 8 : 4) { long protocol = VM.getPointer(protocols); names.add(VM.newStringUTF(ObjCRuntime.protocol_getName(protocol))); } for (long protos = protocols; VM.getPointer(protos) != 0; protos += Bro.IS_64BIT ? 8 : 4) { long protocol = VM.getPointer(protocols); names.addAll(getProtocols(protocol, true)); } VM.free(protocols); return names; }
public String toDebugString() { StringBuilder sb = new StringBuilder(); sb.append("@interface ").append(getName()); long superclass = ObjCRuntime.class_getSuperclass(getHandle()); if (superclass != 0) { sb.append(" : ").append(VM.newStringUTF(ObjCRuntime.class_getName(superclass))); } IntPtr outCount = new IntPtr(); long protocols = ObjCRuntime.class_copyProtocolList(getHandle(), outCount.getHandle()); if (outCount.get() > 0) { sb.append(" <"); for (int i = 0; i < outCount.get(); i++) { if (i > 0) { sb.append(", "); } sb.append(VM.newStringUTF(ObjCRuntime.protocol_getName(VM.getPointer(protocols)))); protocols += (Bro.IS_64BIT ? 8 : 4); } sb.append('>'); } sb.append('\n'); sb.append("@end"); return sb.toString(); }
@SuppressWarnings("unchecked") private static List<String> getProtocols(long handle, boolean isProtocol) { final long protocols = isProtocol ? ObjCRuntime.protocol_copyProtocolList(handle, 0) : ObjCRuntime.class_copyProtocolList(handle, 0); if (protocols == 0) { return (List<String>) Collections.EMPTY_LIST; } ArrayList<String> names = new ArrayList<>(); for (long protos = protocols; VM.getPointer(protos) != 0; protos += Bro.IS_64BIT ? 8 : 4) { long protocol = VM.getPointer(protocols); names.add(VM.newStringUTF(ObjCRuntime.protocol_getName(protocol))); } for (long protos = protocols; VM.getPointer(protos) != 0; protos += Bro.IS_64BIT ? 8 : 4) { long protocol = VM.getPointer(protocols); names.addAll(getProtocols(protocol, true)); } VM.free(protocols); return names; }