static NSObject toObject(Class<? extends NSObject> cls, long handle, long flags, boolean retain) { NSObject o = ObjCObject.toObjCObject(cls, handle, retain ? 0 : FLAG_NO_RETAIN); return o; } @MarshalsPointer
public static <T extends ObjCObject> T toObjCObject(Class<T> cls, long handle, int afterMarshaledFlags) { return toObjCObject(cls, handle, afterMarshaledFlags, false); }
@MarshalsPointer public static ObjCObject toObject(Class<? extends ObjCObject> cls, long handle, long flags) { ObjCObject o = ObjCObject.toObjCObject(cls, handle, 0); return o; }
@MarshalsPointer public static ObjCProtocol protocolToObject(Class<?> cls, long handle, long flags) { Class<? extends ObjCObject> proxyClass = ObjCClass.allObjCProxyClasses.get(cls.getName()); if (proxyClass == null) { proxyClass = ObjCObject.class; } ObjCObject o = ObjCObject.toObjCObject(proxyClass, handle, 0); return (ObjCProtocol) o; }
@MarshalsPointer public static NSError toObject(Class<? extends NSError> cls, long handle, long flags) { if (handle == 0) { return null; } String domain = domain(handle); Class<? extends NSError> nsErrorClass = allNSErrorClasses.get(domain); if (nsErrorClass != null) { cls = nsErrorClass; } NSError o = (NSError) ObjCObject.toObjCObject(cls, handle, 0, true); return o; } @MarshalsPointer
protected static <T extends NSObject> T alloc(Class<T> c) { long h = NSObject.alloc(ObjCClass.getByType(c)); return ObjCObject.toObjCObject(c, h, NSObject.FLAG_NO_RETAIN); }
protected static String domain(long handle) { long h = ObjCRuntime.ptr_objc_msgSend(handle, domain.getHandle()); NSString s = ObjCObject.toObjCObject(NSString.class, h, 0); return s.toString(); }
/** * * @param data * @param options * @return * @since Available in iOS 7.0 and later. * @throws NSErrorException */ @WeaklyLinked public NSAttributedString(NSData data, NSAttributedStringDocumentAttributes options) throws NSErrorException { super((SkipInit) null); long h = NSObject.alloc(ObjCClass.getByType(NSAttributedString.class)); initObject(NSAttributedStringExtensions.init(ObjCObject.toObjCObject(NSAttributedString.class, h, NSObject.FLAG_NO_RETAIN), data, options, null)); } /**
/** * * @param url * @param options * @return * @since Available in iOS 7.0 and later. * @throws NSErrorException */ @WeaklyLinked public NSAttributedString(NSURL url, NSAttributedStringDocumentAttributes options) throws NSErrorException { super((SkipInit) null); long h = NSObject.alloc(ObjCClass.getByType(NSAttributedString.class)); initObject(NSAttributedStringExtensions.init(ObjCObject.toObjCObject(NSAttributedString.class, h, NSObject.FLAG_NO_RETAIN), url, options, null)); } /**
public static <T extends NSObject & UIAppearanceContainer> T getAppearanceForTraitCollection(Class<T> type, UITraitCollection trait, Class<?> ... containedIn) { ObjCClass objCClass = ObjCClass.getByType(type); long proxyHandle = 0; if (containedIn == null || containedIn.length == 0) { proxyHandle = objc_appearanceForTraitCollection(objCClass, appearanceForTraitCollection, trait); } else { if (containedIn.length > 10) { throw new IllegalArgumentException("A maximum of 10 container classes is supported"); } ObjCClass c01 = toObjCClass(containedIn, 0); ObjCClass c02 = toObjCClass(containedIn, 1); ObjCClass c03 = toObjCClass(containedIn, 2); ObjCClass c04 = toObjCClass(containedIn, 3); ObjCClass c05 = toObjCClass(containedIn, 4); ObjCClass c06 = toObjCClass(containedIn, 5); ObjCClass c07 = toObjCClass(containedIn, 6); ObjCClass c08 = toObjCClass(containedIn, 7); ObjCClass c09 = toObjCClass(containedIn, 8); ObjCClass c10 = toObjCClass(containedIn, 9); proxyHandle = objc_appearanceForTraitCollectionWhenContainedIn(objCClass, appearanceForTraitCollectionWhenContainedIn, trait, c01, c02, c03, c04, c05, c06, c07, c08, c09, c10, 0); } return ObjCObject.toObjCObject(type, proxyHandle, 0, true); } }
public static <T extends NSObject & UIAppearanceContainer> T getAppearance(Class<T> type, Class<?> ... containedIn) { ObjCClass objCClass = ObjCClass.getByType(type); long proxyHandle = 0; if (containedIn == null || containedIn.length == 0) { proxyHandle = objc_appearance(objCClass, appearance); } else { if (containedIn.length > 10) { throw new IllegalArgumentException("A maximum of 10 container classes is supported"); } ObjCClass c01 = toObjCClass(containedIn, 0); ObjCClass c02 = toObjCClass(containedIn, 1); ObjCClass c03 = toObjCClass(containedIn, 2); ObjCClass c04 = toObjCClass(containedIn, 3); ObjCClass c05 = toObjCClass(containedIn, 4); ObjCClass c06 = toObjCClass(containedIn, 5); ObjCClass c07 = toObjCClass(containedIn, 6); ObjCClass c08 = toObjCClass(containedIn, 7); ObjCClass c09 = toObjCClass(containedIn, 8); ObjCClass c10 = toObjCClass(containedIn, 9); proxyHandle = objc_appearanceWhenContainedIn(objCClass, appearanceWhenContainedIn, c01, c02, c03, c04, c05, c06, c07, c08, c09, c10, 0); } return ObjCObject.toObjCObject(type, proxyHandle, 0, true); }
@Callback private static @Pointer long retain(@Pointer long self, @Pointer long sel) { int count = ObjCRuntime.int_objc_msgSend(self, retainCount); if (count <= 1) { synchronized (CUSTOM_OBJECTS) { ObjCClass cls = ObjCClass.toObjCClass(ObjCRuntime.object_getClass(self)); ObjCObject obj = ObjCObject.toObjCObject(cls.getType(), self, 0); CUSTOM_OBJECTS.put(self, obj); } } long cls = ObjCRuntime.object_getClass(self); if (logRetainRelease) { logRetainRelease(cls, self, count, true); } Super sup = new Super(self, getNativeSuper(cls)); return ObjCRuntime.ptr_objc_msgSendSuper(sup.getHandle(), sel); }
static NSObject toObject(Class<? extends NSObject> cls, long handle, long flags, boolean retain) { NSObject o = ObjCObject.toObjCObject(cls, handle, retain ? 0 : FLAG_NO_RETAIN); return o; } @MarshalsPointer
static NSObject toObject(Class<? extends NSObject> cls, long handle, long flags, boolean retain) { NSObject o = ObjCObject.toObjCObject(cls, handle, retain ? 0 : FLAG_NO_RETAIN); return o; } @MarshalsPointer
@MarshalsPointer public static ObjCObject toObject(Class<? extends ObjCObject> cls, long handle, long flags) { ObjCObject o = ObjCObject.toObjCObject(cls, handle, 0); return o; }
@MarshalsPointer public static ObjCProtocol protocolToObject(Class<?> cls, long handle, long flags) { Class<? extends ObjCObject> proxyClass = ObjCClass.allObjCProxyClasses.get(cls.getName()); if (proxyClass == null) { proxyClass = ObjCObject.class; } ObjCObject o = ObjCObject.toObjCObject(proxyClass, handle, 0); return (ObjCProtocol) o; }
@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); }
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); }
protected static String domain(long handle) { long h = ObjCRuntime.ptr_objc_msgSend(handle, domain.getHandle()); NSString s = ObjCObject.toObjCObject(NSString.class, h, 0); return s.toString(); }
protected static String domain(long handle) { long h = ObjCRuntime.ptr_objc_msgSend(handle, domain.getHandle()); NSString s = ObjCObject.toObjCObject(NSString.class, h, 0); return s.toString(); }