protected void initObject(long handle) { if (handle == 0) { throw new RuntimeException("Objective-C initialization method returned nil"); } long oldHandle = getHandle(); if (handle != oldHandle) { if (oldHandle != 0) { removePeerObject(this); } setHandle(handle); setPeerObject(handle, this); } }
protected ObjCObject() { long handle = alloc(); setHandle(handle); if (handle != 0) { // Make sure the peer is set immediately even if a different handle // is set later with initObject(). setPeerObject(handle, this); } customClass = getObjCClass().isCustom(); }
/** * Creates a new instance of the specified {@link ObjCClass}. If * {@code makePeer == true} this method MUST be called while the * {@link #objcBridgeLock} is held. */ @SuppressWarnings("unchecked") private static <T extends ObjCObject> T createInstance(ObjCClass objCClass, long handle, int afterMarshaledFlags, boolean makePeer) { Class<T> c = (Class<T>) objCClass.getType(); T o = VM.allocateObject(c); o.setHandle(handle); if (makePeer) { setPeerObject(handle, o); } if (objCClass.isCustom()) { VM.setBoolean(VM.getObjectAddress(o) + CUSTOM_CLASS_OFFSET, true); } o.afterMarshaled(afterMarshaledFlags); return o; }
protected void initObject(long handle) { if (handle == 0) { throw new RuntimeException("Objective-C initialization method returned nil"); } long oldHandle = getHandle(); if (handle != oldHandle) { if (oldHandle != 0) { removePeerObject(this); } setHandle(handle); setPeerObject(handle, this); } }
protected ObjCObject() { long handle = alloc(); setHandle(handle); if (handle != 0) { // Make sure the peer is set immediately even if a different handle // is set later with initObject(). setPeerObject(handle, this); } customClass = getObjCClass().isCustom(); }
/** * Creates a new instance of the specified {@link ObjCClass}. If * {@code makePeer == true} this method MUST be called while the * {@link #objcBridgeLock} is held. */ @SuppressWarnings("unchecked") private static <T extends ObjCObject> T createInstance(ObjCClass objCClass, long handle, int afterMarshaledFlags, boolean makePeer) { Class<T> c = (Class<T>) objCClass.getType(); T o = VM.allocateObject(c); o.setHandle(handle); if (makePeer) { setPeerObject(handle, o); } if (objCClass.isCustom()) { VM.setBoolean(VM.getObjectAddress(o) + CUSTOM_CLASS_OFFSET, true); } o.afterMarshaled(afterMarshaledFlags); return o; }