[macruby-changes] [1434] MacRuby/branches/experimental
source_changes at macosforge.org
source_changes at macosforge.org
Tue Apr 21 00:53:42 PDT 2009
Revision: 1434
http://trac.macosforge.org/projects/ruby/changeset/1434
Author: lsansonetti at apple.com
Date: 2009-04-21 00:53:42 -0700 (Tue, 21 Apr 2009)
Log Message:
-----------
more struct work
Modified Paths:
--------------
MacRuby/branches/experimental/roxor.cpp
MacRuby/branches/experimental/spec/frozen/macruby/method_spec.rb
Modified: MacRuby/branches/experimental/roxor.cpp
===================================================================
--- MacRuby/branches/experimental/roxor.cpp 2009-04-21 02:11:23 UTC (rev 1433)
+++ MacRuby/branches/experimental/roxor.cpp 2009-04-21 07:53:42 UTC (rev 1434)
@@ -588,6 +588,10 @@
}
return NULL;
}
+
+ size_t get_type_size(const Type *type) {
+ return ee->getTargetData()->getTypeSizeInBits(type);
+ }
};
RoxorVM *RoxorVM::current = NULL;
@@ -5179,6 +5183,20 @@
const char *p = GetFirstType(types, buf, sizeof buf);
const Type *ret_type = convert_type(buf);
+ Value *sret = NULL;
+
+ if (ret_type->getTypeID() == Type::StructTyID
+ && GET_VM()->get_type_size(ret_type) > 128) {
+
+ // We are returning a large struct, we need to pass a pointer as the
+ // first argument to the structure data and return void to conform to
+ // the ABI (at least x86_64).
+ f_types.push_back(PointerType::getUnqual(ret_type));
+ sret = new AllocaInst(ret_type, "", bb);
+ params.push_back(sret);
+ ret_type = Type::VoidTy;
+ }
+
// self
p = SkipFirstType(p);
f_types.push_back(RubyObjTy);
@@ -5213,8 +5231,15 @@
"", bb);
// Compile retval.
+ Value *retval;
+ if (sret != NULL) {
+ retval = new LoadInst(sret, "", bb);
+ }
+ else {
+ retval = imp_call;
+ }
GetFirstType(types, buf, sizeof buf);
- Value *retval = compile_conversion_to_ruby(buf, ret_type, imp_call);
+ retval = compile_conversion_to_ruby(buf, convert_type(buf), retval);
ReturnInst::Create(retval, bb);
return f;
Modified: MacRuby/branches/experimental/spec/frozen/macruby/method_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/macruby/method_spec.rb 2009-04-21 02:11:23 UTC (rev 1433)
+++ MacRuby/branches/experimental/spec/frozen/macruby/method_spec.rb 2009-04-21 07:53:42 UTC (rev 1434)
@@ -254,4 +254,36 @@
o.methodReturningDouble.should be_close(3.1415, 0.0001)
o.methodReturningDouble.class.should == Float
end
+
+ it "returning 'NSPoint' returns an NSPoint boxed object in Ruby" do
+ o = TestMethod.new
+ b = o.methodReturningNSPoint
+ b.class.should == NSPoint
+ b.x.class.should == Float
+ b.x.should == 1.0
+ b.y.class.should == Float
+ b.y.should == 2.0
+ end
+
+ it "returning 'NSSize' returns an NSSize boxed object in Ruby" do
+ o = TestMethod.new
+ b = o.methodReturningNSSize
+ b.class.should == NSSize
+ b.width.class.should == Float
+ b.width.should == 3.0
+ b.height.class.should == Float
+ b.height.should == 4.0
+ end
+
+ it "returning 'NSRect' returns an NSRect boxed object in Ruby" do
+ o = TestMethod.new
+ b = o.methodReturningNSRect
+ b.class.should == NSRect
+ b.origin.class.should == NSPoint
+ b.origin.x.should == 1.0
+ b.origin.y.should == 2.0
+ b.size.class.should == NSSize
+ b.size.width.should == 3.0
+ b.size.height.should == 4.0
+ end
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090421/9681a284/attachment.html>
More information about the macruby-changes
mailing list