[macruby-changes] [1426] MacRuby/branches/experimental
source_changes at macosforge.org
source_changes at macosforge.org
Sat Apr 18 15:53:24 PDT 2009
Revision: 1426
http://trac.macosforge.org/projects/ruby/changeset/1426
Author: lsansonetti at apple.com
Date: 2009-04-18 15:53:23 -0700 (Sat, 18 Apr 2009)
Log Message:
-----------
more work on the new objc dispatcher
Modified Paths:
--------------
MacRuby/branches/experimental/include/ruby/ruby.h
MacRuby/branches/experimental/roxor.cpp
MacRuby/branches/experimental/spec/frozen/macruby/fixtures/method.m
MacRuby/branches/experimental/spec/frozen/macruby/method_spec.rb
Modified: MacRuby/branches/experimental/include/ruby/ruby.h
===================================================================
--- MacRuby/branches/experimental/include/ruby/ruby.h 2009-04-18 06:23:07 UTC (rev 1425)
+++ MacRuby/branches/experimental/include/ruby/ruby.h 2009-04-18 22:53:23 UTC (rev 1426)
@@ -1154,7 +1154,7 @@
if (obj == (id)kCFBooleanFalse) {
return Qfalse;
}
- if (obj == (id)kCFNull) {
+ if (obj == (id)kCFNull || obj == nil) {
return Qnil;
}
if (*(Class *)obj == (Class)rb_cFixnum) {
Modified: MacRuby/branches/experimental/roxor.cpp
===================================================================
--- MacRuby/branches/experimental/roxor.cpp 2009-04-18 06:23:07 UTC (rev 1425)
+++ MacRuby/branches/experimental/roxor.cpp 2009-04-18 22:53:23 UTC (rev 1426)
@@ -4852,13 +4852,21 @@
func_name = "rb_vm_ocval_to_rval";
break;
+ case _C_CHR:
+ case _C_SHT:
case _C_INT:
- func_name = "rb_vm_int_to_rval";
- break;
+ val = new SExtInst(val, RubyObjTy, "", bb);
+ val = BinaryOperator::CreateShl(val, oneVal, "", bb);
+ val = BinaryOperator::CreateOr(val, oneVal, "", bb);
+ return val;
+ case _C_UCHR:
+ case _C_USHT:
case _C_UINT:
- func_name = "rb_vm_uint_to_rval";
- break;
+ val = new ZExtInst(val, RubyObjTy, "", bb);
+ val = BinaryOperator::CreateShl(val, oneVal, "", bb);
+ val = BinaryOperator::CreateOr(val, oneVal, "", bb);
+ return val;
case _C_LNG_LNG:
func_name = "rb_vm_long_long_to_rval";
Modified: MacRuby/branches/experimental/spec/frozen/macruby/fixtures/method.m
===================================================================
--- MacRuby/branches/experimental/spec/frozen/macruby/fixtures/method.m 2009-04-18 06:23:07 UTC (rev 1425)
+++ MacRuby/branches/experimental/spec/frozen/macruby/fixtures/method.m 2009-04-18 22:53:23 UTC (rev 1426)
@@ -5,11 +5,20 @@
@implementation TestMethod
+- (void)methodReturningVoid
+{
+}
+
- (id)methodReturningSelf
{
return self;
}
+- (id)methodReturningNil
+{
+ return nil;
+}
+
- (id)methodReturningCFTrue
{
return (id)kCFBooleanTrue;
@@ -25,6 +34,51 @@
return (id)kCFNull;
}
+- (char)methodReturningChar
+{
+ return (char)42;
+}
+
+- (char)methodReturningChar2
+{
+ return (char)-42;
+}
+
+- (unsigned char)methodReturningUnsignedChar
+{
+ return (unsigned char)42;
+}
+
+- (short)methodReturningShort
+{
+ return (short)42;
+}
+
+- (short)methodReturningShort2
+{
+ return (short)-42;
+}
+
+- (unsigned short)methodReturningUnsignedShort
+{
+ return (unsigned short)42;
+}
+
+- (int)methodReturningInt
+{
+ return 42;
+}
+
+- (int)methodReturningInt2
+{
+ return -42;
+}
+
+- (unsigned int)methodReturningUnsignedInt
+{
+ return 42;
+}
+
@end
void
Modified: MacRuby/branches/experimental/spec/frozen/macruby/method_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/macruby/method_spec.rb 2009-04-18 06:23:07 UTC (rev 1425)
+++ MacRuby/branches/experimental/spec/frozen/macruby/method_spec.rb 2009-04-18 22:53:23 UTC (rev 1426)
@@ -130,6 +130,23 @@
o.methods(false, true).include?(:'performSelector').should == true
end
+ it "can be called on an immediate object" do
+ 123.self.should == 123
+ true.self.should == true
+ false.self.should == false
+ nil.self.should == nil
+ end
+
+ it "returning void returns nil in Ruby" do
+ o = TestMethod.new
+ o.methodReturningVoid.should == nil
+ end
+
+ it "returning nil returns nil in Ruby" do
+ o = TestMethod.new
+ o.methodReturningNil.should == nil
+ end
+
it "returning self returns the same receiver object" do
o = TestMethod.new
o.methodReturningSelf.should == o
@@ -153,4 +170,37 @@
o.methodReturningCFNull.should == nil
o.methodReturningCFNull.class.should == NilClass
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
+ o = TestMethod.new
+ o.methodReturningUnsignedChar.should == 42
+ end
+
+ 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
+ o = TestMethod.new
+ o.methodReturningUnsignedShort.should == 42
+ end
+
+ 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
+ o = TestMethod.new
+ o.methodReturningUnsignedInt.should == 42
+ end
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090418/02dc50a0/attachment.html>
More information about the macruby-changes
mailing list