/** * Creates a new {@link FunctionPtr} which points to the specified * {@link Callback} {@link Method}. * * @param callbackMethod the {@link Callback} {@link Method} this * {@link FunctionPtr} will point at. * @throws IllegalArgumentException if the specified {@link Method} isn't * a {@link Callback}. */ public FunctionPtr(Method callbackMethod) { super(0); if (callbackMethod == null) { throw new NullPointerException("callbackMethod"); } if (!callbackMethod.isAnnotationPresent(Callback.class)) { throw new IllegalArgumentException("The method " + callbackMethod + " is not a @Callback method"); } setHandle(VM.getCallbackMethodImpl(callbackMethod)); }
public void setHostCallback(AUHostCallback callback, AUScope scope) throws OSStatusException { long cid = callbackId.getAndIncrement(); AUHostCallbackInfo struct = new AUHostCallbackInfo(cid, new FunctionPtr(cbHostGetBeatAndTempo), new FunctionPtr(cbHostGetMusicalTimeLocation), new FunctionPtr(cbHostGetTransportState), new FunctionPtr(cbHostGetTransportState2)); setProperty(AUGenericProperty.HostCallbacks, struct, scope); synchronized (hostCallbacks) { hostCallbacks.put(cid, callback); } } public AUInputSamplesInOutputCallback getInputSamplesInOutputCallback(AUScope scope) throws OSStatusException {
/** * @throws OSStatusException * @since Available in iOS 6.0 and later. */ public static MTAudioProcessingTap create(Callbacks callbacks, MTAudioProcessingTapCreationFlags flags) throws OSStatusException { MTAudioProcessingTap.MTAudioProcessingTapPtr ptr = new MTAudioProcessingTap.MTAudioProcessingTapPtr(); long callbackId = MTAudioProcessingTap.callbackId.getAndIncrement(); MTAudioProcessingTapCallbacksStruct struct = new MTAudioProcessingTapCallbacksStruct(0, callbackId, new FunctionPtr(cbInit), new FunctionPtr(cbFinalize), new FunctionPtr(cbPrepare), new FunctionPtr(cbUnprepare), new FunctionPtr(cbProcess)); OSStatus status = create(null, struct, flags, ptr); if (OSStatusException.throwIfNecessary(status)) { synchronized (MTAudioProcessingTap.callbacks) { MTAudioProcessingTap.callbacks.put(callbackId, callbacks); } return ptr.get(); } return null; } /**
public static void setUncaughtExceptionHandler(VoidBlock1<NSException> handler) { if (handler == null) { throw new NullPointerException("handler"); } NSException.handler = handler; try { setUncaughtExceptionHandler(new FunctionPtr(NSException.class.getDeclaredMethod("handler", NSException.class))); } catch (Throwable t) { throw new Error(t); } }
public void setInputSamplesInOutputCallback(AUInputSamplesInOutputCallback callback, AUScope scope) throws OSStatusException { long cid = callbackId.getAndIncrement(); AUInputSamplesInOutputCallbackStruct struct = new AUInputSamplesInOutputCallbackStruct(new FunctionPtr(cbInputSamplesInOutput), cid); setProperty(AUGenericProperty.InputSamplesInOutput, struct, scope); synchronized (isioCallbacks) { isioCallbacks.put(cid, callback); } } public void scheduleAudioSlice(AUScheduledAudioSlice slice, AUScope scope) throws OSStatusException {
public void setRenderCallback(AURenderCallback callback, AUScope scope) throws OSStatusException { long cid = callbackId.getAndIncrement(); AURenderCallbackStruct struct = new AURenderCallbackStruct(new FunctionPtr(cbRender), cid); setProperty(AUGenericProperty.SetRenderCallback, struct, scope); synchronized (renderCallbacks) { renderCallbacks.put(cid, callback); } } public void setHostCallback(AUHostCallback callback, AUScope scope) throws OSStatusException {
/** * @since Available in iOS 3.2 and later. */ public List<CTFontDescriptor> getMatchingFontDescriptorsSorted(SortCallback sortCallback) { long refconId = CTFontCollection.refconId.getAndIncrement(); synchronized (sortCallbacks) { sortCallbacks.put(refconId, sortCallback); } return getMatchingFontDescriptorsSorted(new FunctionPtr(cbSort), refconId); } /*<methods>*/
public void registerExternalChangeCallback(ExternalChangeCallback callback) { long refconId = ABAddressBook.changeCallbackId.getAndIncrement(); registerExternalChangeCallback(new FunctionPtr(cbExternalChange), refconId); synchronized (externalChangeCallbacks) { externalChangeCallbacks.put(refconId, callback); } } public void unregisterExternalChangeCallback(ExternalChangeCallback callback) {
public void setCallback(String name, OperatorCallback callback) { if (localInfoId == -1) { localInfoId = CGPDFOperatorTable.infoId.getAndIncrement(); } setCallback(name, new FunctionPtr(cbOperator)); synchronized (callbacks) { callbacks.put(localInfoId, callback); } } /*<methods>*/
/** * @throws OSStatusException * @since Available in iOS 2.0 and later. */ public static AudioFile initialize(Callbacks callback, AudioFileType fileType, AudioStreamBasicDescription format, AudioFileFlags flags) throws OSStatusException { if (callback == null) { throw new NullPointerException("callbacks"); } AudioFile.AudioFilePtr ptr = new AudioFile.AudioFilePtr(); long cid = callbackId.getAndIncrement(); OSStatus status = initialize0(cid, new FunctionPtr(cbRead), new FunctionPtr(cbWrite), new FunctionPtr(cbGetSize), new FunctionPtr(cbSetSize), fileType, format, flags, ptr); if (OSStatusException.throwIfNecessary(status)) { synchronized (callbacks) { callbacks.put(cid, callback); } return ptr.get(); } return null; } /**
/** * @throws OSStatusException * @since Available in iOS 2.0 and later. */ public static AudioFile open(Callbacks callback, AudioFileType fileTypeHint) throws OSStatusException { if (callback == null) { throw new NullPointerException("callbacks"); } AudioFile.AudioFilePtr ptr = new AudioFile.AudioFilePtr(); long cid = callbackId.getAndIncrement(); OSStatus status = open0(cid, new FunctionPtr(cbRead), new FunctionPtr(cbWrite), new FunctionPtr(cbGetSize), new FunctionPtr(cbSetSize), fileTypeHint, ptr); if (OSStatusException.throwIfNecessary(status)) { synchronized (callbacks) { callbacks.put(cid, callback); } return ptr.get(); } return null; } /**
/** * @since Available in iOS 4.0 and later. */ public static CGBitmapContext create(IntPtr data, long width, long height, long bitsPerComponent, long bytesPerRow, CGColorSpace space, CGBitmapInfo bitmapInfo, ReleaseDataCallback releaseCallback) { long releaseInfo = CGBitmapContext.releaseInfo.getAndIncrement(); CGBitmapContext result = create(data, width, height, bitsPerComponent, bytesPerRow, space, bitmapInfo, new FunctionPtr(cbReleaseData), releaseInfo); if (result != null) { synchronized (callbacks) { callbacks.put(releaseInfo, releaseCallback); } } return result; }
public CTRunDelegate() { CTRunDelegateCallbacks callbacks = new CTRunDelegateCallbacks(); callbacks.setGetAscent(new FunctionPtr(cbGetAscent)); callbacks.setGetDescent(new FunctionPtr(cbGetDescent)); callbacks.setGetWidth(new FunctionPtr(cbGetWidth)); long refconId = CTRunDelegate.refconId.getAndIncrement(); delegate = CTRunDelegateIntern.create(callbacks, refconId); synchronized(runCallbacks) { runCallbacks.put(refconId, this); } } /*<constructors>*//*</constructors>*/
public void setInvalidationCallBack(InvalidationCallback callback) { invalidationCallback = callback; if (callback == null) { setInvalidationCallBack0(null); } else { setInvalidationCallBack0(new FunctionPtr(cbInvalidate)); } } public static CFRunLoopSource createRunLoopSource(CFMachPort port, @MachineSizedSInt long order) {
public void setInvalidationCallBack(InvalidationCallback callback) { invalidationCallback = callback; if (callback == null) { setInvalidationCallBack0(null); } else { setInvalidationCallBack0(new FunctionPtr(cbInvalidate)); } } public static CFRunLoopSource createRunLoopSource(CFMessagePort local, @MachineSizedSInt long order) {
@Override public void putAll(CFDictionary dict) { dict.applyFunction(new FunctionPtr(cbPutAll), getHandle()); } @Override
/** * @throws OSStatusException * @since Available in iOS 2.0 and later. */ public void setNodeInputCallback(int destNode, int destInputNumber, AURenderCallback inputCallback) throws OSStatusException { long cid = callbackId.getAndIncrement(); AURenderCallbackStruct struct = new AURenderCallbackStruct(new FunctionPtr(cbRender), cid); OSStatus status = setNodeInputCallback0(destNode, destInputNumber, struct); if (OSStatusException.throwIfNecessary(status)) { synchronized (renderCallbacks) { renderCallbacks.put(cid, inputCallback); } } } /**
public CVPixelFormatDescription setFillExtendedPixelsCallback(FillExtendedPixelsCallback callback) { if (refcon == -1) { refcon = CVPixelFormatDescription.refconId.getAndIncrement(); } CVFillExtendedPixelsCallBackData data = new CVFillExtendedPixelsCallBackData(1, new FunctionPtr(cbFillExtendedPixels), refcon); NSData val = new NSData(data); set(Keys.FillExtendedPixelsCallback(), val); synchronized (callbacks) { callbacks.put(refcon, callback); } return this; }
public static CGPattern create(CGRect bounds, CGAffineTransform matrix, double xStep, double yStep, CGPatternTiling tiling, boolean isColored, DrawPattern drawPattern) { long infoId = CGPattern.infoId.getAndIncrement(); CGPatternCallbacks callbacks = new CGPatternCallbacks(); callbacks.setDrawPattern(new FunctionPtr(cbDrawPattern)); callbacks.setReleaseInfo(new FunctionPtr(cbReleaseInfo)); CGPattern result = create(infoId, bounds, matrix, xStep, yStep, tiling, isColored, callbacks); if (result != null) { synchronized (infos) { infos.put(infoId, drawPattern); } } return result; }
public void setMIDICallbacks(AUOutputMIDICallback callback, AUScope scope) throws OSStatusException { AUOutputMIDICallbacksStruct struct = null; if (callback == null) { struct = getProperty(AUOutputProperty.MIDICallbacks, AUOutputMIDICallbacksStruct.class, scope); if (struct != null) { setProperty(AUOutputProperty.MIDICallbacks, null, scope); synchronized (midiCallbacks) { midiCallbacks.remove(struct.getUserData()); } } } else { long cid = callbackId.getAndIncrement(); struct = new AUOutputMIDICallbacksStruct(cid, new FunctionPtr(cbMIDIEvent), new FunctionPtr(cbMIDISysEx)); setProperty(AUOutputProperty.MIDICallbacks, struct, scope); synchronized (midiCallbacks) { midiCallbacks.put(cid, callback); } } } /* End: Convenience methods for getting/setting properties */