Revision: 392 http://trac.macosforge.org/projects/ruby/changeset/392 Author: lsansonetti@apple.com Date: 2008-08-02 01:05:20 -0700 (Sat, 02 Aug 2008) Log Message: ----------- wip Modified Paths: -------------- MacRuby/branches/lrz_unstable/array.c MacRuby/branches/lrz_unstable/bignum.c MacRuby/branches/lrz_unstable/numeric.c MacRuby/branches/lrz_unstable/object.c Modified: MacRuby/branches/lrz_unstable/array.c =================================================================== --- MacRuby/branches/lrz_unstable/array.c 2008-08-02 02:56:32 UTC (rev 391) +++ MacRuby/branches/lrz_unstable/array.c 2008-08-02 08:05:20 UTC (rev 392) @@ -1736,10 +1736,19 @@ rb_ary_modify(ary); n = RARRAY_LEN(ary); if (n > 0) { + void **values; + CFRange range; long i; - for (i = 0; i < (n / 2); i++) - CFArrayExchangeValuesAtIndices((CFMutableArrayRef)ary, - i, n - i - 1); + + values = alloca(sizeof(void *) * n); + range = CFRangeMake(0, n); + CFArrayGetValues((CFArrayRef)ary, range, (const void **)values); + for (i = 0; i < (n / 2); i++) { + void *v = values[i]; + values[i] = values[n - i - 1]; + values[n - i - 1] = v; + } + CFArrayReplaceValues((CFMutableArrayRef)ary, range, (const void **)values, n); } #else VALUE *p1, *p2; Modified: MacRuby/branches/lrz_unstable/bignum.c =================================================================== --- MacRuby/branches/lrz_unstable/bignum.c 2008-08-02 02:56:32 UTC (rev 391) +++ MacRuby/branches/lrz_unstable/bignum.c 2008-08-02 08:05:20 UTC (rev 392) @@ -2680,6 +2680,16 @@ return NUM2LL(rcv); } +static bool +imp_rb_bignum_isEqual(void *rcv, SEL sel, void *other) +{ + if (other == NULL) + return false; + if (*(Class *)other != (Class)rb_cBignum) + return false; + return rb_big_eq((VALUE)rcv, (VALUE)other) == Qtrue; +} + static inline void rb_objc_install_method(Class klass, SEL sel, IMP imp) { @@ -2698,6 +2708,8 @@ (IMP)imp_rb_bignum_getValue); rb_objc_install_method(klass, sel_registerName("longLongValue"), (IMP)imp_rb_bignum_longLongValue); + rb_objc_install_method(klass, sel_registerName("isEqual:"), + (IMP)imp_rb_bignum_isEqual); } #endif Modified: MacRuby/branches/lrz_unstable/numeric.c =================================================================== --- MacRuby/branches/lrz_unstable/numeric.c 2008-08-02 02:56:32 UTC (rev 391) +++ MacRuby/branches/lrz_unstable/numeric.c 2008-08-02 08:05:20 UTC (rev 392) @@ -106,7 +106,7 @@ val = (struct RFixnum *)CFDictionaryGetValue(fixnum_cache, (const void *)fixnum); if (val == NULL) { - val = (struct RFixnum *)rb_objc_newobj(sizeof(struct RFixnum)); + val = (struct RFixnum *)malloc(sizeof(struct RFixnum)); val->klass = rb_cFixnum; val->value = FIX2LONG(fixnum); CFDictionarySetValue(fixnum_cache, (const void *)fixnum, (const void *)val); Modified: MacRuby/branches/lrz_unstable/object.c =================================================================== --- MacRuby/branches/lrz_unstable/object.c 2008-08-02 02:56:32 UTC (rev 391) +++ MacRuby/branches/lrz_unstable/object.c 2008-08-02 08:05:20 UTC (rev 392) @@ -1598,11 +1598,14 @@ obj = rb_obj_alloc(klass); init_obj = rb_obj_call_init(obj, argc, argv); - p = CLASS_OF(init_obj); - while (p != 0) { - if (p == klass) - return init_obj; - p = RCLASS_SUPER(p); + + if (init_obj != Qnil) { + p = CLASS_OF(init_obj); + while (p != 0) { + if (p == klass) + return init_obj; + p = RCLASS_SUPER(p); + } } return obj;