[macruby-changes] [513] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Thu Aug 28 19:12:46 PDT 2008


Revision: 513
          http://trac.macosforge.org/projects/ruby/changeset/513
Author:   lsansonetti at apple.com
Date:     2008-08-28 19:12:45 -0700 (Thu, 28 Aug 2008)
Log Message:
-----------
fixed variadic objc dispatch, added rb_objc.rb to the test suite, removed a warning when running sample/test.rb

Modified Paths:
--------------
    MacRuby/trunk/objc.m
    MacRuby/trunk/sample/test.rb
    MacRuby/trunk/test/macruby_runner.rb
    MacRuby/trunk/test/ruby/test_objc.rb

Modified: MacRuby/trunk/objc.m
===================================================================
--- MacRuby/trunk/objc.m	2008-08-28 08:02:31 UTC (rev 512)
+++ MacRuby/trunk/objc.m	2008-08-29 02:12:45 UTC (rev 513)
@@ -1239,20 +1239,31 @@
 
     for (i = 0; i < argc; i++) {
 	ffi_type *ffi_argtype;
-	const char *type2;
 
-	type = SkipStackSize(type);
-	type2 = SkipFirstType(type);
-	strncpy(buf, type, MIN(sizeof buf, type2 - type));
-	buf[MIN(sizeof buf, type2 - type)] = '\0';
+	if (*type == '\0') {
+	    if (bs_method->variadic) {
+		buf[0] = '@';
+		buf[1] = '\0';
+	    }
+	    else {
+		rb_bug("incomplete method signature `%s' for argc %d", sig->types, argc);
+	    }
+	}
+	else {
+	    const char *type2;
 
+	    type = SkipStackSize(type);
+	    type2 = SkipFirstType(type);
+	    strncpy(buf, type, MIN(sizeof buf, type2 - type));
+	    buf[MIN(sizeof buf, type2 - type)] = '\0';
+	    type = type2;
+	}
+
 	ffi_argtypes[i + 2] = rb_objc_octype_to_ffitype(buf);
 	assert(ffi_argtypes[i + 2]->size > 0);
 	ffi_argtype = ffi_argtypes[i + 2];
 	ffi_args[i + 2] = (void *)alloca(ffi_argtype->size);
 	rb_objc_rval_to_ocval(argv[i], buf, ffi_args[i + 2]);
-	
-	type = type2;
     }
 
     ffi_argtypes[count] = NULL;

Modified: MacRuby/trunk/sample/test.rb
===================================================================
--- MacRuby/trunk/sample/test.rb	2008-08-28 08:02:31 UTC (rev 512)
+++ MacRuby/trunk/sample/test.rb	2008-08-29 02:12:45 UTC (rev 513)
@@ -1948,7 +1948,10 @@
 $y = Marshal.dump($x)
 test_ok($x == Marshal.load($y))
 
-StrClone=String.clone;
+old_verbose = $VERBOSE # because String.clone produces a warning in MacRuby
+$VERBOSE = nil
+StrClone=String.clone
+$VERBOSE = old_verbose
 test_ok(Marshal.load(Marshal.dump(StrClone.new("abc"))).class == StrClone)
 
 [[1,2,3,4], [81, 2, 118, 3146]].each { |w,x,y,z|

Modified: MacRuby/trunk/test/macruby_runner.rb
===================================================================
--- MacRuby/trunk/test/macruby_runner.rb	2008-08-28 08:02:31 UTC (rev 512)
+++ MacRuby/trunk/test/macruby_runner.rb	2008-08-29 02:12:45 UTC (rev 513)
@@ -3,6 +3,6 @@
 $:.unshift('./lib')
 require 'test/unit'
 
-tests = %w{ array string stringchar hash }
+tests = %w{ array string stringchar hash objc }
 
 tests.each { |x| require("test/ruby/test_#{x}.rb") }

Modified: MacRuby/trunk/test/ruby/test_objc.rb
===================================================================
--- MacRuby/trunk/test/ruby/test_objc.rb	2008-08-28 08:02:31 UTC (rev 512)
+++ MacRuby/trunk/test/ruby/test_objc.rb	2008-08-29 02:12:45 UTC (rev 513)
@@ -145,9 +145,8 @@
     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.new
+    assert_equal(42, obj.foo)
     obj = TestSuperMethod.performSelector(:new)
     assert_equal(42, obj.foo)
   end
@@ -252,30 +251,19 @@
     n = nil
     assert_kind_of(NSNull, n.self)
     assert_equal(NSNull.null, n.self)
-    # TODO this currently SEGV
-    #m = String
-    #assert_equal(m, m.self)
+    m = String
+    assert_equal(m, m.self)
   end
 
   def test_call_superclass
     o = Object.new
-    assert_equal(NSObject, o.superclass)
+    assert_equal(nil, o.superclass)
     s = 'foo'
     assert_equal(NSMutableString, s.superclass)
-    n = 42
-    assert_equal(NSNumber, n.superclass)
     n = nil 
     assert_equal(NSObject, n.superclass)
   end
 
-  def test_no_direct_nsobject_subclass
-    old_verbose = $VERBOSE
-    $VERBOSE = nil # no warn
-    klass = eval("class Foo < NSObject; end; Foo")
-    assert_equal(Object, klass.superclass)
-    $VERBOSE = old_verbose
-  end
-
   class TestSuper1
     def foo; 'xxx'; end
   end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080828/51bc1b14/attachment.html 


More information about the macruby-changes mailing list