private void updateMenu(NSArray<UIMenuItem> items) { long imp = VM.getCallbackMethodImpl(cbForwarder); long typeEncodings = VM.getStringUTFChars("v@:@"); for (UIMenuItem item : items) { Selector sel = item.getAction(); ObjCRuntime.class_addMethod(UI_MENU_CONTROLLER, sel.getHandle(), imp, typeEncodings); } } /*<methods>*/
private static void registerCallbackMethod(long cls, long selector, long newSelector, Method method) { long superMethod = ObjCRuntime.class_getInstanceMethod(cls, selector); long typeEncoding = ObjCRuntime.method_getTypeEncoding(superMethod); if (!ObjCRuntime.class_addMethod(cls, selector, VM.getCallbackMethodImpl(method), typeEncoding)) { throw new Error( "Failed to register callback method on the ObjectOwnershipHelper: class_addMethod(...) failed"); } // find the super class that is a native class and cache it long superClass = ObjCRuntime.class_getSuperclass(cls); long nativeSuper = 0; while (superClass != 0) { ObjCClass objCClass = ObjCClass.toObjCClass(superClass); if (!objCClass.isCustom()) { nativeSuper = superClass; break; } superClass = ObjCRuntime.class_getSuperclass(superClass); } if (nativeSuper == 0) { throw new Error("Couldn't find native super class for " + VM.newStringUTF(ObjCRuntime.class_getName(cls))); } synchronized (customClassToNativeSuper) { customClassToNativeSuper.put(cls, nativeSuper); } }
if (!ObjCRuntime.class_addMethod(ownerHandle, selector.getHandle(), impl, encoding != null ? VM.getStringUTFChars(encoding) : 0L)) { throw new ObjCClassNotFoundException("Failed to add method " + selName + " to custom Objective-C class for Java class: " + type);
public static void registerSubclass(Class<? extends PFObject> 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(); ObjCRuntime.class_addProtocol(cls, ObjCRuntime.objc_getProtocol(name_PFSubclassing)); long method = VM.getCallbackMethodImpl(cbParseClassName); ObjCRuntime.class_addMethod(ObjCRuntime.object_getClass(cls), sel_parseClassName, method, typeEncodings_parseClassName); ObjCRuntime.void_objc_msgSend(cls, sel_registerSubclass); }
private void updateMenu(NSArray<UIMenuItem> items) { long imp = VM.getCallbackMethodImpl(cbForwarder); long typeEncodings = VM.getStringUTFChars("v@:@"); for (UIMenuItem item : items) { Selector sel = item.getAction(); ObjCRuntime.class_addMethod(UI_MENU_CONTROLLER, sel.getHandle(), imp, typeEncodings); } } /*<methods>*/
private void updateMenu(NSArray<UIMenuItem> items) { long imp = VM.getCallbackMethodImpl(cbForwarder); long typeEncodings = VM.getStringUTFChars("v@:@"); for (UIMenuItem item : items) { Selector sel = item.getAction(); ObjCRuntime.class_addMethod(UI_MENU_CONTROLLER, sel.getHandle(), imp, typeEncodings); } } /*<methods>*/
private static void registerCallbackMethod(long cls, long selector, long newSelector, Method method) { long superMethod = ObjCRuntime.class_getInstanceMethod(cls, selector); long typeEncoding = ObjCRuntime.method_getTypeEncoding(superMethod); if (!ObjCRuntime.class_addMethod(cls, selector, VM.getCallbackMethodImpl(method), typeEncoding)) { throw new Error( "Failed to register callback method on the ObjectOwnershipHelper: class_addMethod(...) failed"); } // find the super class that is a native class and cache it long superClass = ObjCRuntime.class_getSuperclass(cls); long nativeSuper = 0; while (superClass != 0) { ObjCClass objCClass = ObjCClass.toObjCClass(superClass); if (!objCClass.isCustom()) { nativeSuper = superClass; break; } superClass = ObjCRuntime.class_getSuperclass(superClass); } if (nativeSuper == 0) { throw new Error("Couldn't find native super class for " + VM.newStringUTF(ObjCRuntime.class_getName(cls))); } synchronized (customClassToNativeSuper) { customClassToNativeSuper.put(cls, nativeSuper); } }
if (!ObjCRuntime.class_addMethod(ownerHandle, selector.getHandle(), impl, encoding != null ? VM.getStringUTFChars(encoding) : 0L)) { throw new ObjCClassNotFoundException("Failed to add method " + selName + " to custom Objective-C class for Java class: " + type);