Revision: 2777 http://trac.macosforge.org/projects/ruby/changeset/2777 Author: lsansonetti@apple.com Date: 2009-10-09 19:38:26 -0700 (Fri, 09 Oct 2009) Log Message: ----------- fixed bugs post KVO Modified Paths: -------------- MacRuby/trunk/include/ruby/ruby.h MacRuby/trunk/objc.m MacRuby/trunk/variable.c Modified: MacRuby/trunk/include/ruby/ruby.h =================================================================== --- MacRuby/trunk/include/ruby/ruby.h 2009-10-10 00:23:24 UTC (rev 2776) +++ MacRuby/trunk/include/ruby/ruby.h 2009-10-10 02:38:26 UTC (rev 2777) @@ -555,6 +555,7 @@ # define RCLASS_SCOPE_PRIVATE (1<<24) /* class opened for private methods */ # define RCLASS_SCOPE_PROTECTED (1<<25) /* class opened for protected methods */ # define RCLASS_SCOPE_MOD_FUNC (1<<26) /* class opened for module_function methods */ +# define RCLASS_KVO_CHECK_DONE (1<<27) /* class created by KVO and flags merged */ # if defined(__LP64__) # define _PTR_TYPE uint64_t # define RCLASS_VERSION(m) (class_getVersion((Class)m)) Modified: MacRuby/trunk/objc.m =================================================================== --- MacRuby/trunk/objc.m 2009-10-10 00:23:24 UTC (rev 2776) +++ MacRuby/trunk/objc.m 2009-10-10 02:38:26 UTC (rev 2777) @@ -592,13 +592,11 @@ static Class rb_obj_imp_isaForAutonotifying(void *rcv, SEL sel) { - Class ret; long ret_version; -#define KVO_CHECK_DONE 0x100000 + Class ret = ((Class (*)(void *, SEL))old_imp_isaForAutonotifying)(rcv, sel); - ret = ((Class (*)(void *, SEL)) old_imp_isaForAutonotifying)(rcv, sel); - if (ret != NULL && ((ret_version = RCLASS_VERSION(ret)) & KVO_CHECK_DONE) == 0) { + if (ret != NULL && ((ret_version = RCLASS_VERSION(ret)) & RCLASS_KVO_CHECK_DONE) == 0) { const char *name = class_getName(ret); if (strncmp(name, "NSKVONotifying_", 15) == 0) { Class ret_orig; @@ -612,10 +610,9 @@ if ((orig_v & RCLASS_IS_RUBY_CLASS) == RCLASS_IS_RUBY_CLASS) { ret_version |= RCLASS_IS_RUBY_CLASS; } - // XXX merge more flags? } } - ret_version |= KVO_CHECK_DONE; + ret_version |= RCLASS_KVO_CHECK_DONE; RCLASS_SET_VERSION(ret, ret_version); } return ret; Modified: MacRuby/trunk/variable.c =================================================================== --- MacRuby/trunk/variable.c 2009-10-10 00:23:24 UTC (rev 2776) +++ MacRuby/trunk/variable.c 2009-10-10 02:38:26 UTC (rev 2777) @@ -961,6 +961,14 @@ CFMakeCollectable(clone_dict); } +static inline bool +rb_class_has_ivar_dict(VALUE mod) +{ + const long v = RCLASS_VERSION(mod); + return (v & RCLASS_IS_RUBY_CLASS) == RCLASS_IS_RUBY_CLASS + && (v & RCLASS_KVO_CHECK_DONE) != RCLASS_KVO_CHECK_DONE; +} + #define RCLASS_RUBY_IVAR_DICT(mod) \ (*(CFMutableDictionaryRef *) \ ((void *)mod + class_getInstanceSize(*(Class *)RCLASS_SUPER(mod)))) @@ -970,7 +978,7 @@ { CFMutableDictionaryRef dict; - if (RCLASS_RUBY(mod)) { + if (rb_class_has_ivar_dict(mod)) { dict = RCLASS_RUBY_IVAR_DICT(mod); } else { @@ -986,7 +994,7 @@ void rb_class_ivar_set_dict(VALUE mod, CFMutableDictionaryRef dict) { - if (RCLASS_RUBY(mod)) { + if (rb_class_has_ivar_dict(mod)) { CFMutableDictionaryRef old_dict = RCLASS_RUBY_IVAR_DICT(mod); if (old_dict != dict) { if (old_dict != NULL) {
participants (1)
-
source_changes@macosforge.org