/** * Create a Java NSObject down-casting an existing NSObject to a more derived * type. */ public static <T extends ObjCObject> T cast(ObjCObject object, Class<T> desiredType) { if (object == null) return null; return wrap(object.id(), desiredType, true); }
public Object toNative(Object value, ToNativeContext context) { if (value == null) return null; ObjCObject valueAsNSObject = (ObjCObject) value; ID idToReturn = valueAsNSObject.id(); return idToReturn.toNative(); }
private Object invokeSpecialMethod(final Method method, final Object[] args) { if (OBJECT_TOSTRING.equals(method)) return invokeDescription(); if (OBJECT_EQUALS.equals(method)) { if (args[0] == null) return false; if (args[0] instanceof ObjCObject) return invokeIsEqual(((ObjCObject) args[0]).id()); return false; } if (OCOBJECT_ID.equals(method)) return ocInstance; throw new IllegalArgumentException("Not a special method " + method); }
public NSInvocationOperation call() { NSInvocationOperation result = NSInvocationOperation.CLASS.alloc(); //when the NSOperationQueue executes the NSInvocationOperation, run() is //called on this object. result = result.initWithTarget_selector_object(toInvoke.id(), RUN_SELECTOR, null); return result; } });
@Override public Memory bufferForResult(Object methodCallResult) { Memory buffer = new Memory(NATIVE_POINTER_SIZE); buffer.setNativeLong(0, ((ObjCObject) methodCallResult).id()); return buffer; }};
public NSInvocationOperation call() { NSInvocationOperation result = NSInvocationOperation.CLASS.alloc(); //when the NSOperationQueue executes the NSInvocationOperation, run() is //called on this object. result = result.initWithTarget_selector_object(toInvoke.id(), RUN_SELECTOR, null); return result; } });
/** Set the delegate that will receive events when speech is generated. * @param delegate the delegate to set, replacing any existing one */ public synchronized void setDelegate(final NSSpeechSynthesizerDelegate delegate) { if ( delegate != null ) { this.delegate = delegate; delegateProxy = Rococoa.proxy(delegate); setDelegate(this.delegateProxy.id()); } }
private Object marshall(Object arg) { // Note that this is not the only marshalling that is done. // RococoaTypeMapper also gets involved. if (arg == null) return null; if (arg instanceof ObjCObjectByReference) { // Forward conversion (another backwards conversion will take place in fillInReferences) IDByReference idref = new IDByReference(); ObjCObject ob = ((ObjCObjectByReference)arg).getValueAs(ObjCObject.class); if (ob != null) idref.setValue(ob.id()); return idref; } return arg; }