From 7b6ba21ce5964cb13ba06431db8190302b06ffe1 Mon Sep 17 00:00:00 2001 From: theraven Date: Mon, 4 Jul 2011 11:28:33 +0000 Subject: [PATCH] Small bug fixes: - Don't call C++ constructors if they don't exist. - Don't check the owner of retain / release methods if they are not implemented. - Add arc.m as a file to ignore when checking for GC compatibility. --- abi_version.c | 3 ++- dtable.c | 6 +++--- runtime.c | 11 +++++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/abi_version.c b/abi_version.c index 5321d57..4ddb64f 100644 --- a/abi_version.c +++ b/abi_version.c @@ -72,7 +72,7 @@ static BOOL endsWith(const char *string, const char *suffix) PRIVATE BOOL objc_check_abi_version(struct objc_module_abi_8 *module) { - static int runtime_modules = 4; + static int runtime_modules = 5; // As a quick and ugly hack, skip these three tests for the .m files in the // runtime. They should (in theory, at least) be aware of the GC mode and // behave accordingly. @@ -80,6 +80,7 @@ PRIVATE BOOL objc_check_abi_version(struct objc_module_abi_8 *module) { if (endsWith(module->name, "properties.m") || endsWith(module->name, "associate.m") || + endsWith(module->name, "arc.m") || endsWith(module->name, "blocks_runtime.m") || endsWith(module->name, "Protocol2.m")) { diff --git a/dtable.c b/dtable.c index 2fd0846..05779ea 100644 --- a/dtable.c +++ b/dtable.c @@ -52,19 +52,19 @@ static void checkARCAccessors(Class cls) isARC = sel_registerName("_ARCCompliantRetainRelease"); } struct objc_slot *slot = objc_get_slot(cls, retain); - if (!ownsMethod(slot->owner, isARC)) + 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 (!ownsMethod(slot->owner, isARC)) + 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 (!ownsMethod(slot->owner, isARC)) + if ((NULL != slot) && !ownsMethod(slot->owner, isARC)) { objc_clear_class_flag(cls, objc_class_flag_fast_arc); return; diff --git a/runtime.c b/runtime.c index 5467be7..68f4138 100644 --- a/runtime.c +++ b/runtime.c @@ -55,12 +55,15 @@ static void call_cxx_construct_for_class(Class cls, id obj) cxx_construct = sel_registerName(".cxx_contruct"); } struct objc_slot *slot = objc_get_slot(cls, cxx_construct); - cls = slot->owner->super_class; - if (Nil != cls) + if (NULL != slot) { - call_cxx_construct_for_class(cls, obj); + cls = slot->owner->super_class; + if (Nil != cls) + { + call_cxx_construct_for_class(cls, obj); + } + slot->method(obj, cxx_construct); } - slot->method(obj, cxx_construct); } PRIVATE void call_cxx_construct(id obj)