Ejemplo n.º 1
0
/**
 * Checks whether the class implements memory management methods, and whether
 * they are safe to use with ARC.
 */
static void checkARCAccessors(Class cls)
{
	static SEL retain, release, autorelease, isARC;
	if (NULL == retain)
	{
		retain = sel_registerName("retain");
		release = sel_registerName("release");
		autorelease = sel_registerName("autorelease");
		isARC = sel_registerName("_ARCCompliantRetainRelease");
	}
	struct objc_slot *slot = objc_get_slot(cls, retain);
	if ((NULL != slot) && !ownsMethod(slot->owner, isARC))
	{
		objc_clear_class_flag(cls, objc_class_flag_fast_arc);
		return;
	}
	slot = objc_get_slot(cls, release);
	if ((NULL != slot) && !ownsMethod(slot->owner, isARC))
	{
		objc_clear_class_flag(cls, objc_class_flag_fast_arc);
		return;
	}
	slot = objc_get_slot(cls, autorelease);
	if ((NULL != slot) && !ownsMethod(slot->owner, isARC))
	{
		objc_clear_class_flag(cls, objc_class_flag_fast_arc);
		return;
	}
	objc_set_class_flag(cls, objc_class_flag_fast_arc);
}
Ejemplo n.º 2
0
/*
 * Checks whether the class implements memory management methods, and whether
 * they are safe to use with ARC.
 */
static void checkARCAccessors(Class cls)
{
	if (!ownsMethod(cls, objc_is_arc_compatible_selector)){
		/*
		 * The class doesn't implement the isARC selector, which means 
		 * we need to check if it implements custom ARR methods.
		 */
		if (_objc_check_class_for_custom_arr_method(cls, objc_retain_selector)){
			return;
		}
		if (_objc_check_class_for_custom_arr_method(cls, objc_release_selector)){
			return;
		}
		if (_objc_check_class_for_custom_arr_method(cls, objc_autorelease_selector)){
			return;
		}
	}
	cls->flags.has_custom_arr = NO;
}