public static NSAutoreleasePool push() { return Rococoa.create("NSAutoreleasePool", NSAutoreleasePool.class); } }
public QTMovieView call() throws Exception { return Rococoa.create("QTMovieView", QTMovieView.class); //$NON-NLS-1$ }}); }
public static NSAutoreleasePool new_() { return Rococoa.create("NSAutoreleasePool", NSAutoreleasePool.class); }
/** * Create a Java NSObject representing an instance of the Objective-C class * ocClassName. The Objective-C instance is created by calling the static * factory method named ocMethodName, passing args. */ public static <T extends ObjCObject> T create(String ocClassName, Class<T> javaClass, String ocMethodName, Object... args) { boolean weOwnObject = Foundation.selectorNameMeansWeOwnReturnedObject(ocMethodName); // If we don't own the object we know that it has been autorelease'd // But we need to own these objects, so that they are not dealloc'd when // the pool is release'd. So we retain them. // Objects that we own (because they were created with 'alloc' or 'new') // have not been autorelease'd, so we don't retain them. boolean retain = !weOwnObject; return create(ocClassName, javaClass, ocMethodName, retain, args); }
private static <T extends ObjCObject> T create(String ocClassName, Class<T> javaClass, String ocFactoryName, boolean retain, Object... args) { if (logging.isTraceEnabled()) { logging.trace("creating [{} ({})].{}({})", new Object[] {ocClassName, javaClass.getName(), ocFactoryName, new VarArgsUnpacker(args)}); } ID ocClass = Foundation.getClass(ocClassName); ID ocInstance = Foundation.send(ocClass, ocFactoryName, ID.class, args); int initialRetainCount = Foundation.cfGetRetainCount(ocInstance); T result = wrap(ocInstance, javaClass, retain); checkRetainCount(ocInstance, retain ? initialRetainCount + 1 : initialRetainCount); return result; }