[macruby-changes] [310] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Sat Jul 5 20:49:20 PDT 2008
Revision: 310
http://trac.macosforge.org/projects/ruby/changeset/310
Author: lsansonetti at apple.com
Date: 2008-07-05 20:49:19 -0700 (Sat, 05 Jul 2008)
Log Message:
-----------
fixed a few regressions introduced by the perf work
Modified Paths:
--------------
MacRuby/trunk/objc.m
MacRuby/trunk/test/ruby/test_objc.rb
Modified: MacRuby/trunk/objc.m
===================================================================
--- MacRuby/trunk/objc.m 2008-07-06 03:48:53 UTC (rev 309)
+++ MacRuby/trunk/objc.m 2008-07-06 03:49:19 UTC (rev 310)
@@ -1136,13 +1136,11 @@
ffi_args[1] = &ctx->selector;
if (super_call) {
- Class sklass;
Method smethod;
- sklass = class_getSuperclass(klass);
- assert(sklass != NULL);
- smethod = class_getInstanceMethod(sklass, ctx->selector);
+ smethod = class_getInstanceMethod(klass, ctx->selector);
assert(smethod != ctx->method);
- imp = method_getImplementation(smethod);
+ imp = method_getImplementation(smethod);
+ assert(imp != NULL);
}
else {
if (ctx->imp != NULL && ctx->klass == klass) {
@@ -1236,9 +1234,21 @@
assert(rb_current_cfunc_node != NULL);
if (rb_current_cfunc_node->u3.value == 0) {
+ const char *selname;
+ size_t selnamelen;
+
ctx = (struct objc_ruby_closure_context *)xmalloc(sizeof(
struct objc_ruby_closure_context));
- ctx->selector = sel_registerName(rb_id2name(rb_frame_this_func()));
+
+ selname = rb_id2name(rb_frame_this_func());
+ selnamelen = strlen(selname);
+ if (argc == 1 && selname[selnamelen - 1] != ':') {
+ char *tmp = alloca(selnamelen + 2);
+ snprintf(tmp, selnamelen + 2, "%s:", selname);
+ selname = (const char *)tmp;
+ }
+ ctx->selector = sel_registerName(selname);
+
ctx->bs_method = rb_bs_find_method(*(Class *)rcv, ctx->selector);
ctx->method = class_getInstanceMethod(*(Class *)rcv, ctx->selector);
assert(ctx->method != NULL);
Modified: MacRuby/trunk/test/ruby/test_objc.rb
===================================================================
--- MacRuby/trunk/test/ruby/test_objc.rb 2008-07-06 03:48:53 UTC (rev 309)
+++ MacRuby/trunk/test/ruby/test_objc.rb 2008-07-06 03:49:19 UTC (rev 310)
@@ -71,6 +71,26 @@
assert_equal('xxxyyy', r)
end
+ class TestSuperMethod
+ def init
+ super
+ @foo = 42
+ self
+ end
+ attr_reader :foo
+ end
+ def test_super_method
+ obj = TestSuperMethod.alloc.init
+ assert_equal(42, obj.foo)
+ obj = TestSuperMethod.performSelector(:alloc).performSelector(:init)
+ assert_equal(42, obj.foo)
+ # FIXME this doesn't work yet
+ #obj = TestSuperMethod.new
+ #assert_equal(42, obj.foo)
+ obj = TestSuperMethod.performSelector(:new)
+ assert_equal(42, obj.foo)
+ end
+
def test_pure_objc_ivar
o = NSObject.alloc.init
assert_kind_of(NSObject, o)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080705/300d7ed7/attachment.html
More information about the macruby-changes
mailing list