[macruby-changes] [1519] MacRuby/branches/experimental
source_changes at macosforge.org
source_changes at macosforge.org
Sat May 2 21:09:07 PDT 2009
Revision: 1519
http://trac.macosforge.org/projects/ruby/changeset/1519
Author: lsansonetti at apple.com
Date: 2009-05-02 21:09:05 -0700 (Sat, 02 May 2009)
Log Message:
-----------
when loading a BS structure which has the same type as a previously-loaded BS structure, let's create an alias under the new name to the previously-loaded class
Modified Paths:
--------------
MacRuby/branches/experimental/roxor.cpp
MacRuby/branches/experimental/spec/macruby/spec_helper.rb
MacRuby/branches/experimental/spec/macruby/struct_spec.rb
Modified: MacRuby/branches/experimental/roxor.cpp
===================================================================
--- MacRuby/branches/experimental/roxor.cpp 2009-05-03 03:05:49 UTC (rev 1518)
+++ MacRuby/branches/experimental/roxor.cpp 2009-05-03 04:09:05 UTC (rev 1519)
@@ -9320,6 +9320,11 @@
GET_VM()->bs_boxed.find(octype);
if (iter != GET_VM()->bs_boxed.end()) {
+ // A boxed class of this type already exists, so let's create an
+ // alias to it.
+ rb_vm_bs_boxed_t *boxed = iter->second;
+ const ID name = rb_intern(((bs_element_opaque_t *)value)->name);
+ rb_const_set(rb_cObject, name, boxed->klass);
return false;
}
Modified: MacRuby/branches/experimental/spec/macruby/spec_helper.rb
===================================================================
--- MacRuby/branches/experimental/spec/macruby/spec_helper.rb 2009-05-03 03:05:49 UTC (rev 1518)
+++ MacRuby/branches/experimental/spec/macruby/spec_helper.rb 2009-05-03 04:09:05 UTC (rev 1519)
@@ -1,4 +1,4 @@
-framework 'Foundation'
+framework 'Cocoa'
SPEC_ROOT = File.dirname(__FILE__)
FIXTURES = File.join(SPEC_ROOT, "fixtures")
Modified: MacRuby/branches/experimental/spec/macruby/struct_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/macruby/struct_spec.rb 2009-05-03 03:05:49 UTC (rev 1518)
+++ MacRuby/branches/experimental/spec/macruby/struct_spec.rb 2009-05-03 04:09:05 UTC (rev 1519)
@@ -145,20 +145,20 @@
it "has a nice #inspect message that lists the fields" do
p = NSPoint.new
- p.inspect.should == "#<NSPoint x=0.0 y=0.0>"
+ p.inspect.should == "#<CGPoint x=0.0 y=0.0>"
p.x = 1
p.y = 2
- p.inspect.should == "#<NSPoint x=1.0 y=2.0>"
+ p.inspect.should == "#<CGPoint x=1.0 y=2.0>"
s = NSSize.new(3, 4)
- s.inspect.should == "#<NSSize width=3.0 height=4.0>"
+ s.inspect.should == "#<CGSize width=3.0 height=4.0>"
r = NSRect.new
- r.inspect.should == "#<NSRect origin=#<NSPoint x=0.0 y=0.0> size=#<NSSize width=0.0 height=0.0>>"
+ r.inspect.should == "#<CGRect origin=#<CGPoint x=0.0 y=0.0> size=#<CGSize width=0.0 height=0.0>>"
r.origin = p
- r.inspect.should == "#<NSRect origin=#<NSPoint x=1.0 y=2.0> size=#<NSSize width=0.0 height=0.0>>"
+ r.inspect.should == "#<CGRect origin=#<CGPoint x=1.0 y=2.0> size=#<CGSize width=0.0 height=0.0>>"
r.size = s
- r.inspect.should == "#<NSRect origin=#<NSPoint x=1.0 y=2.0> size=#<NSSize width=3.0 height=4.0>>"
+ r.inspect.should == "#<CGRect origin=#<CGPoint x=1.0 y=2.0> size=#<CGSize width=3.0 height=4.0>>"
end
it "can be duplicated using #dup or #clone" do
@@ -203,4 +203,13 @@
NSRect.type.should == '{_NSRect={_NSPoint=ff}{_NSSize=ff}}'
end
end
+
+ it "defined after a structure which has the same type is an alias to the other structure class" do
+ NSPoint.should == CGPoint
+ NSSize.should == CGSize
+ NSRect.should == CGRect
+ NSPoint.object_id.should == CGPoint.object_id
+ NSSize.object_id.should == CGSize.object_id
+ NSRect.object_id.should == CGRect.object_id
+ end
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090502/3d81e8bb/attachment.html>
More information about the macruby-changes
mailing list