[macruby-changes] [3316] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jan 20 17:46:06 PST 2010
Revision: 3316
http://trac.macosforge.org/projects/ruby/changeset/3316
Author: lsansonetti at apple.com
Date: 2010-01-20 17:46:03 -0800 (Wed, 20 Jan 2010)
Log Message:
-----------
RubyHash becomes Hash, do not hide other NSDictionary-based classes
Modified Paths:
--------------
MacRuby/trunk/dispatcher.cpp
MacRuby/trunk/hash.c
MacRuby/trunk/object.c
MacRuby/trunk/spec/frozen/tags/macruby/core/marshal/load_tags.txt
MacRuby/trunk/spec/macruby/core/hash_spec.rb
Modified: MacRuby/trunk/dispatcher.cpp
===================================================================
--- MacRuby/trunk/dispatcher.cpp 2010-01-20 23:49:09 UTC (rev 3315)
+++ MacRuby/trunk/dispatcher.cpp 2010-01-21 01:46:03 UTC (rev 3316)
@@ -793,18 +793,6 @@
}
if (block != NULL) {
- if (self == rb_cNSMutableHash && sel == selNew) {
- // Because Hash.new can accept a block.
- vm->add_current_block(block);
-
- struct Finally {
- RoxorVM *vm;
- Finally(RoxorVM *_vm) { vm = _vm; }
- ~Finally() { vm->pop_current_block(); }
- } finalizer(vm);
-
- return rb_hash_new2(argc, argv);
- }
rb_warn("passing a block to an Objective-C method - " \
"will be ignored");
}
@@ -812,9 +800,6 @@
if (self == rb_cNSMutableArray) {
self = rb_cRubyArray;
}
- if (self == rb_cNSMutableHash) {
- self = rb_cRubyHash;
- }
}
else if (sel == selClass) {
// Because +[NSObject class] returns self.
@@ -846,17 +831,6 @@
if (klass == (Class)rb_cRubyArray) {
return rb_cNSMutableArray;
}
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
- if (klass == (Class)rb_cCFHash || klass == (Class)rb_cNSHash0) {
-#else
- if (klass == (Class)rb_cCFHash) {
-#endif
- return RHASH_IMMUTABLE(self)
- ? rb_cNSHash : rb_cNSMutableHash;
- }
- if (klass == (Class)rb_cRubyHash) {
- return rb_cNSMutableHash;
- }
}
#if ROXOR_VM_DEBUG
Modified: MacRuby/trunk/hash.c
===================================================================
--- MacRuby/trunk/hash.c 2010-01-20 23:49:09 UTC (rev 3315)
+++ MacRuby/trunk/hash.c 2010-01-21 01:46:03 UTC (rev 3316)
@@ -226,11 +226,10 @@
static VALUE
hash_alloc(VALUE klass)
{
- if ((klass == 0 || klass == rb_cRubyHash || klass == rb_cNSMutableHash)
- && rb_cRubyHash != 0) {
+ if (rb_cRubyHash != 0 && (klass == 0 || __is_rhash(klass))) {
NEWOBJ(hash, rb_hash_t);
hash->basic.flags = 0;
- hash->basic.klass = rb_cRubyHash;
+ hash->basic.klass = klass == 0 ? rb_cRubyHash : klass;
GC_WB(&hash->tbl, st_init_table(&objhash));
hash->ifnone = Qnil;
hash->has_proc_default = false;
@@ -2615,8 +2614,6 @@
bool
rb_objc_hash_is_pure(VALUE hash)
{
- return *(VALUE *)hash == rb_cCFHash || *(VALUE *)hash == rb_cRubyHash;
-#if 0
VALUE k = *(VALUE *)hash;
while (RCLASS_SINGLETON(k)) {
k = RCLASS_SUPER(k);
@@ -2631,7 +2628,6 @@
k = RCLASS_SUPER(k);
}
return true;
-#endif
}
static CFIndex
@@ -2861,7 +2857,6 @@
rb_cHash = rb_cNSHash = (VALUE)objc_getClass("NSDictionary");
rb_cNSMutableHash = (VALUE)objc_getClass("NSMutableDictionary");
rb_set_class_path(rb_cNSMutableHash, rb_cObject, "NSMutableDictionary");
- rb_const_set(rb_cObject, rb_intern("Hash"), rb_cNSMutableHash);
rb_include_module(rb_cHash, rb_mEnumerable);
@@ -2934,7 +2929,9 @@
rb_objc_define_method(rb_cHash, "compare_by_identity", rb_hash_compare_by_id, 0);
rb_objc_define_method(rb_cHash, "compare_by_identity?", rb_hash_compare_by_id_p, 0);
- rb_cRubyHash = rb_define_class("RubyHash", rb_cNSMutableHash);
+ rb_cRubyHash = rb_define_class("Hash", rb_cNSMutableHash);
+ rb_objc_define_method(*(VALUE *)rb_cRubyHash, "new",
+ rb_class_new_instance_imp, -1);
rb_objc_define_method(*(VALUE *)rb_cRubyHash, "alloc", hash_alloc, 0);
rb_objc_install_method2((Class)rb_cRubyHash, "count",
(IMP)imp_rhash_count);
Modified: MacRuby/trunk/object.c
===================================================================
--- MacRuby/trunk/object.c 2010-01-20 23:49:09 UTC (rev 3315)
+++ MacRuby/trunk/object.c 2010-01-21 01:46:03 UTC (rev 3316)
@@ -165,9 +165,6 @@
if (cl == rb_cCFArray || cl == rb_cRubyArray) {
return rb_cNSMutableArray;
}
- if (cl == rb_cCFHash || cl == rb_cRubyHash) {
- return rb_cNSMutableHash;
- }
return cl;
}
Modified: MacRuby/trunk/spec/frozen/tags/macruby/core/marshal/load_tags.txt
===================================================================
--- MacRuby/trunk/spec/frozen/tags/macruby/core/marshal/load_tags.txt 2010-01-20 23:49:09 UTC (rev 3315)
+++ MacRuby/trunk/spec/frozen/tags/macruby/core/marshal/load_tags.txt 2010-01-21 01:46:03 UTC (rev 3316)
@@ -1,6 +1,4 @@
critical:Marshal::load calls the proc for recursively visited data
-critical:Marshal::load loads a Hash subclass
-critical:Marshal::load loads an extended_user_hash with a parameter to initialize
fails:Marshal::load loads an extended Object
fails:Marshal::load loads a 1...2
fails:Marshal::load loads a 1..2
Modified: MacRuby/trunk/spec/macruby/core/hash_spec.rb
===================================================================
--- MacRuby/trunk/spec/macruby/core/hash_spec.rb 2010-01-20 23:49:09 UTC (rev 3315)
+++ MacRuby/trunk/spec/macruby/core/hash_spec.rb 2010-01-21 01:46:03 UTC (rev 3316)
@@ -1,8 +1,9 @@
require File.dirname(__FILE__) + "/../spec_helper"
describe "The Hash class" do
- it "is an alias to NSMutableDictionary" do
- Hash.should == NSMutableDictionary
+ it "is a direct subclass of NSMutableDictionary" do
+ Hash.class.should == Class
+ Hash.superclass.should == NSMutableDictionary
end
it "can be subclassed and later instantiated" do
@@ -59,9 +60,9 @@
describe "An NSDictionary object" do
it "is an instance of the NSDictionary class" do
a = NSDictionary.dictionary
- a.class.should == NSDictionary
+ a.is_a?(NSDictionary).should == true
a = NSDictionary.dictionaryWithObject(42, forKey:42)
- a.class.should == NSDictionary
+ a.is_a?(NSDictionary).should == true
end
it "is immutable" do
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100120/a6ee6f87/attachment.html>
More information about the macruby-changes
mailing list