static long alloc(ObjCClass c) { long h = ObjCRuntime.ptr_objc_msgSend(c.getHandle(), alloc.getHandle()); if (h == 0L) { throw new OutOfMemoryError(); } return h; }
@MarshalsPointer public static long toNative(Class<? extends ObjCObject> o, long flags) { if (o == null) { return 0L; } ObjCClass c = ObjCClass.getByType(o); return c.getHandle(); } }
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 ObjCClass register(Class<? extends ObjCObject> type, String name) { ObjCClass superclass = getByType((Class<? extends ObjCObject>) type.getSuperclass()); long handle = ObjCRuntime.objc_allocateClassPair(superclass.getHandle(), VM.getStringUTFChars(name), 0); if (handle == 0L) { throw new ObjCClassNotFoundException("Failed to create custom Objective-C class for Java class: " + type); } else { long methodPtr = isClassMethod ? ObjCRuntime.class_getClassMethod(superclass.getHandle(), selector.getHandle()) : ObjCRuntime.class_getInstanceMethod(superclass.getHandle(), selector.getHandle()); if (methodPtr != 0L) { long encodingPtr = ObjCRuntime.method_getTypeEncoding(methodPtr);
static long alloc(ObjCClass c) { long h = ObjCRuntime.ptr_objc_msgSend(c.getHandle(), alloc.getHandle()); if (h == 0L) { throw new OutOfMemoryError(); } return h; }
static long alloc(ObjCClass c) { long h = ObjCRuntime.ptr_objc_msgSend(c.getHandle(), alloc.getHandle()); if (h == 0L) { throw new OutOfMemoryError(); } return h; }
public static <T extends PFObject> T create(Class<T> subclass) { if (subclass == null) { throw new NullPointerException("subclass"); } if (!subclass.isAnnotationPresent(ParseClassName.class)) { throw new UnsupportedOperationException("Class is missing required @ParseClassName annotation: " + subclass.getSimpleName()); } long cls = ObjCClass.getByType(subclass).getHandle(); long instance = ObjCRuntime.ptr_objc_msgSend(cls, sel_object); return ObjCObject.toObjCObject(subclass, instance, 0); }
@SuppressWarnings("unchecked") public static <T extends PFObject> PFQuery<T> getQuery(Class<T> subclass) { if (subclass == null) { throw new NullPointerException("subclass"); } if (!subclass.isAnnotationPresent(ParseClassName.class)) { throw new UnsupportedOperationException("Class is missing required @ParseClassName annotation: " + subclass.getSimpleName()); } long cls = ObjCClass.getByType(subclass).getHandle(); long instance = ObjCRuntime.ptr_objc_msgSend(cls, sel_query); return ObjCObject.toObjCObject(PFQuery.class, instance, 0); }
@MarshalsPointer public static long toNative(Class<? extends ObjCObject> o, long flags) { if (o == null) { return 0L; } ObjCClass c = ObjCClass.getByType(o); return c.getHandle(); } }
@SuppressWarnings("unchecked") public static <T extends PFObject> PFQuery<T> getQuery(Class<T> subclass, NSPredicate predicate) { if (subclass == null) { throw new NullPointerException("subclass"); } if (predicate == null) { throw new NullPointerException("predicate"); } if (!subclass.isAnnotationPresent(ParseClassName.class)) { throw new UnsupportedOperationException("Class is missing required @ParseClassName annotation: " + subclass.getSimpleName()); } long cls = ObjCClass.getByType(subclass).getHandle(); long instance = ObjCRuntime.ptr_objc_msgSend_ptr(cls, sel_queryWithPredicate$, predicate.getHandle()); return ObjCObject.toObjCObject(PFQuery.class, instance, 0); }
public static <T extends PFObject> T createWithoutData(Class<T> subclass, String objectId) { if (subclass == null) { throw new NullPointerException("subclass"); } if (objectId == null) { throw new NullPointerException("objectId"); } if (!subclass.isAnnotationPresent(ParseClassName.class)) { throw new UnsupportedOperationException("Class is missing required @ParseClassName annotation: " + subclass.getSimpleName()); } long cls = ObjCClass.getByType(subclass).getHandle(); long instance = ObjCRuntime.ptr_objc_msgSend_ptr(cls, sel_objectWithoutDataWithObjectId$, new NSString(objectId).getHandle()); return ObjCObject.toObjCObject(subclass, instance, 0); }
public static void registerSubclass(Class<? extends PFObject> subclass) { if (subclass == null) { throw new NullPointerException("subclass"); } if (!subclass.isAnnotationPresent(ParseClassName.class)) { throw new UnsupportedOperationException("Class is missing required @ParseClassName annotation: " + subclass.getSimpleName()); } long cls = ObjCClass.getByType(subclass).getHandle(); ObjCRuntime.class_addProtocol(cls, ObjCRuntime.objc_getProtocol(name_PFSubclassing)); long method = VM.getCallbackMethodImpl(cbParseClassName); ObjCRuntime.class_addMethod(ObjCRuntime.object_getClass(cls), sel_parseClassName, method, typeEncodings_parseClassName); ObjCRuntime.void_objc_msgSend(cls, sel_registerSubclass); }
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 ObjCClass register(Class<? extends ObjCObject> type, String name) { ObjCClass superclass = getByType((Class<? extends ObjCObject>) type.getSuperclass()); long handle = ObjCRuntime.objc_allocateClassPair(superclass.getHandle(), VM.getStringUTFChars(name), 0); if (handle == 0L) { throw new ObjCClassNotFoundException("Failed to create custom Objective-C class for Java class: " + type); } else { long methodPtr = isClassMethod ? ObjCRuntime.class_getClassMethod(superclass.getHandle(), selector.getHandle()) : ObjCRuntime.class_getInstanceMethod(superclass.getHandle(), selector.getHandle()); if (methodPtr != 0L) { long encodingPtr = ObjCRuntime.method_getTypeEncoding(methodPtr);