[macruby-changes] [1427] MacRuby/branches/experimental

source_changes at macosforge.org source_changes at macosforge.org
Sat Apr 18 18:21:07 PDT 2009


Revision: 1427
          http://trac.macosforge.org/projects/ruby/changeset/1427
Author:   lsansonetti at apple.com
Date:     2009-04-18 18:21:07 -0700 (Sat, 18 Apr 2009)
Log Message:
-----------
more work

Modified Paths:
--------------
    MacRuby/branches/experimental/roxor.cpp
    MacRuby/branches/experimental/spec/frozen/macruby/fixtures/method.m
    MacRuby/branches/experimental/spec/frozen/macruby/method_spec.rb

Added Paths:
-----------
    MacRuby/branches/experimental/spec/frozen/macruby/fixtures/method.bridgesupport

Modified: MacRuby/branches/experimental/roxor.cpp
===================================================================
--- MacRuby/branches/experimental/roxor.cpp	2009-04-18 22:53:23 UTC (rev 1426)
+++ MacRuby/branches/experimental/roxor.cpp	2009-04-19 01:21:07 UTC (rev 1427)
@@ -4806,30 +4806,30 @@
 
 extern "C"
 VALUE
-rb_vm_long_long_to_rval(long long l)
+rb_vm_long_to_rval(long l)
 {
-    return LL2NUM(l);
+    return INT2NUM(l);
 }
 
 extern "C"
 VALUE
-rb_vm_ulong_long_to_rval(unsigned long long l)
+rb_vm_ulong_to_rval(long l)
 {
-    return ULL2NUM(l);
+    return UINT2NUM(l);
 }
 
 extern "C"
 VALUE
-rb_vm_int_to_rval(int val)
+rb_vm_long_long_to_rval(long long l)
 {
-    return INT2NUM(val);
+    return LL2NUM(l);
 }
 
 extern "C"
 VALUE
-rb_vm_uint_to_rval(unsigned int val)
+rb_vm_ulong_long_to_rval(unsigned long long l)
 {
-    return UINT2NUM(val);
+    return ULL2NUM(l);
 }
 
 Value *
@@ -4868,6 +4868,14 @@
 	    val = BinaryOperator::CreateOr(val, oneVal, "", bb);
 	    return val;
 
+	case _C_LNG:
+	    func_name = "rb_vm_long_to_rval";
+	    break;
+
+	case _C_ULNG:
+	    func_name = "rb_vm_ulong_to_rval";
+	    break;
+
 	case _C_LNG_LNG:
 	    func_name = "rb_vm_long_long_to_rval";
 	    break;
@@ -4876,6 +4884,18 @@
 	    func_name = "rb_vm_ulong_long_to_rval";
 	    break;
 
+	case _C_FLT:
+	    {
+		char buf = _C_DBL;
+		const Type *dbl_type = convert_type(&buf); 
+		val = new FPExtInst(val, dbl_type, "", bb);
+		llvm_type = dbl_type;
+	    }
+	    // fall through	
+	case _C_DBL:
+	    func_name = "rb_float_new";
+	    break;
+
 	default:
 	    printf("unrecognized compile type `%s' to Ruby - aborting\n", type);
 	    abort();

Added: MacRuby/branches/experimental/spec/frozen/macruby/fixtures/method.bridgesupport
===================================================================
--- MacRuby/branches/experimental/spec/frozen/macruby/fixtures/method.bridgesupport	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/macruby/fixtures/method.bridgesupport	2009-04-19 01:21:07 UTC (rev 1427)
@@ -0,0 +1,12 @@
+<?xml version='1.0'?>
+<!DOCTYPE signatures SYSTEM "file://localhost/System/Library/DTDs/BridgeSupport.dtd">
+<signatures version='0.9'>
+  <class name='TestMethod'>
+    <method selector='methodReturningYES'>
+      <retval type='B'/>
+    </method>
+    <method selector='methodReturningNO'>
+      <retval type='B'/>
+    </method>
+  </class>
+</signatures>

Modified: MacRuby/branches/experimental/spec/frozen/macruby/fixtures/method.m
===================================================================
--- MacRuby/branches/experimental/spec/frozen/macruby/fixtures/method.m	2009-04-18 22:53:23 UTC (rev 1426)
+++ MacRuby/branches/experimental/spec/frozen/macruby/fixtures/method.m	2009-04-19 01:21:07 UTC (rev 1427)
@@ -34,6 +34,16 @@
     return (id)kCFNull;
 }
 
+- (BOOL)methodReturningYES
+{
+    return YES;
+}
+
+- (BOOL)methodReturningNO
+{
+    return NO;
+}
+
 - (char)methodReturningChar
 {
     return (char)42;
@@ -79,6 +89,58 @@
     return 42;
 }
 
+- (long)methodReturningLong
+{
+    return 42;
+}
+ 
+- (long)methodReturningLong2
+{
+    return -42;
+}
+
+- (long)methodReturningLong3
+{
+#if __LP64__
+    return 4611686018427387904;
+#else
+    return 1073741824;
+#endif
+}
+
+- (long)methodReturningLong4
+{
+#if __LP64__
+    return -4611686018427387905;
+#else
+    return -1073741825;
+#endif
+}
+
+- (unsigned long)methodReturningUnsignedLong
+{
+    return 42;
+}
+
+- (unsigned long)methodReturningUnsignedLong2
+{
+#if __LP64__
+    return 4611686018427387904;
+#else
+    return 1073741824;
+#endif
+}
+
+- (float)methodReturningFloat
+{
+    return 3.1415;
+}
+
+- (double)methodReturningDouble
+{
+    return 3.1415;
+}
+
 @end
 
 void

Modified: MacRuby/branches/experimental/spec/frozen/macruby/method_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/macruby/method_spec.rb	2009-04-18 22:53:23 UTC (rev 1426)
+++ MacRuby/branches/experimental/spec/frozen/macruby/method_spec.rb	2009-04-19 01:21:07 UTC (rev 1427)
@@ -104,6 +104,7 @@
   `/usr/bin/gcc #{fixture_source} -o #{fixture_ext} -g -framework Foundation -dynamiclib -fobjc-gc -arch i386 -arch x86_64 -arch ppc`
 end
 require '/tmp/method'
+load_bridge_support_file File.dirname(__FILE__) + '/fixtures/method.bridgesupport'
 
 describe "An Objective-C method" do
   it "named using the setFoo pattern can be called using #foo=" do
@@ -171,36 +172,81 @@
     o.methodReturningCFNull.class.should == NilClass
   end
 
-  it "returning 'char' returns a fixnum in Ruby" do
+  it "returning YES returns true in Ruby" do
     o = TestMethod.new
+    o.methodReturningYES.should == true
+  end
+
+  it "returning NO returns true in Ruby" do
+    o = TestMethod.new
+    o.methodReturningNO.should == false
+  end
+
+  it "returning 'char' returns a Fixnum in Ruby" do
+    o = TestMethod.new
     o.methodReturningChar.should == 42
     o.methodReturningChar2.should == -42
   end
  
-  it "returning 'unsigned char' returns a fixnum in Ruby" do
+  it "returning 'unsigned char' returns a Fixnum in Ruby" do
     o = TestMethod.new
     o.methodReturningUnsignedChar.should == 42
   end
 
-  it "returning 'short' returns a fixnum in Ruby" do
+  it "returning 'short' returns a Fixnum in Ruby" do
     o = TestMethod.new
     o.methodReturningShort.should == 42
     o.methodReturningShort2.should == -42
   end
 
-  it "returning 'unsigned short' returns a fixnum in Ruby" do
+  it "returning 'unsigned short' returns a Fixnum in Ruby" do
     o = TestMethod.new
     o.methodReturningUnsignedShort.should == 42
   end
 
-  it "returning 'int' returns a fixnum in Ruby" do
+  it "returning 'int' returns a Fixnum in Ruby" do
     o = TestMethod.new
     o.methodReturningInt.should == 42
     o.methodReturningInt2.should == -42
   end
 
-  it "returning 'unsigned int' returns a fixnum in Ruby" do
+  it "returning 'unsigned int' returns a Fixnum in Ruby" do
     o = TestMethod.new
     o.methodReturningUnsignedInt.should == 42
   end
+
+  it "returning 'long' returns a Fixnum if possible in Ruby" do
+    o = TestMethod.new
+    o.methodReturningLong.should == 42
+    o.methodReturningLong2.should == -42
+  end
+
+  it "returning 'long' returns a Bignum if it cannot fix in a Fixnum in Ruby" do
+    o = TestMethod.new
+    o.methodReturningLong3.should ==
+      (RUBY_ARCH == 'x86_64' ? 4611686018427387904 : 1073741824)
+    o.methodReturningLong4.should ==
+      (RUBY_ARCH == 'x86_64' ? -4611686018427387905 : -1073741825)
+  end
+
+  it "returning 'unsigned long' returns a Fixnum if possible in Ruby" do
+    o = TestMethod.new
+    o.methodReturningUnsignedLong.should == 42
+  end
+
+  it "returning 'unsigned long' returns a Bignum if it cannot fix in a Fixnum in Ruby" do
+    o = TestMethod.new
+    o.methodReturningUnsignedLong2.should ==
+      (RUBY_ARCH == 'x86_64' ? 4611686018427387904 : 1073741824)
+  end
+
+  it "returning 'float' returns a Float in Ruby" do
+    o = TestMethod.new
+    o.methodReturningFloat.should be_close(3.1415, 0.0001)
+  end
+
+  it "returning 'double' returns a Float in Ruby" do
+    o = TestMethod.new
+    o.methodReturningDouble.should be_close(3.1415, 0.0001)
+  end
 end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090418/860bd97a/attachment-0001.html>


More information about the macruby-changes mailing list