[macruby-changes] [193] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Thu May 15 12:11:56 PDT 2008
Revision: 193
http://trac.macosforge.org/projects/ruby/changeset/193
Author: lsansonetti at apple.com
Date: 2008-05-15 12:11:55 -0700 (Thu, 15 May 2008)
Log Message:
-----------
#frozen? should return true for immutable CF objects, fixing bootstraptest/test_objectspace.rb
Modified Paths:
--------------
MacRuby/trunk/bootstraptest/test_objectspace.rb
MacRuby/trunk/objc.m
MacRuby/trunk/object.c
MacRuby/trunk/string.c
Modified: MacRuby/trunk/bootstraptest/test_objectspace.rb
===================================================================
--- MacRuby/trunk/bootstraptest/test_objectspace.rb 2008-05-15 08:06:22 UTC (rev 192)
+++ MacRuby/trunk/bootstraptest/test_objectspace.rb 2008-05-15 19:11:55 UTC (rev 193)
@@ -8,8 +8,9 @@
rescue RangeError
next
end
- next if o.is_a?(Hash) # Some CF dictionaries cannot be inspected because
- # they contain pointers to C raw data.
+ # Some CF containers cannot be inspected because they contain pointers
+ # to C raw data.
+ next if o.is_a?(Hash) or o.is_a?(Array)
o.inspect if defined?(o.inspect)
}
}, '[ruby-dev:31911]'
Modified: MacRuby/trunk/objc.m
===================================================================
--- MacRuby/trunk/objc.m 2008-05-15 08:06:22 UTC (rev 192)
+++ MacRuby/trunk/objc.m 2008-05-15 19:11:55 UTC (rev 193)
@@ -2710,6 +2710,24 @@
return Qnil;
}
+extern bool __CFStringIsMutable(void *);
+extern bool _CFArrayIsMutable(void *);
+extern bool _CFDictionaryIsMutable(void *);
+
+bool
+rb_objc_is_immutable(VALUE v)
+{
+ switch(TYPE(v)) {
+ case T_STRING:
+ return !__CFStringIsMutable((void *)v);
+ case T_ARRAY:
+ return !_CFArrayIsMutable((void *)v);
+ case T_HASH:
+ return !_CFDictionaryIsMutable((void *)v);
+ }
+ return false;
+}
+
void
Init_ObjC(void)
{
Modified: MacRuby/trunk/object.c
===================================================================
--- MacRuby/trunk/object.c 2008-05-15 08:06:22 UTC (rev 192)
+++ MacRuby/trunk/object.c 2008-05-15 19:11:55 UTC (rev 193)
@@ -815,7 +815,8 @@
}
#if WITH_OBJC
if (rb_objc_is_non_native(obj)) {
- return rb_objc_flag_check(obj, FL_FREEZE) ? Qtrue : Qfalse;
+ return rb_objc_is_immutable(obj) || rb_objc_flag_check(obj, FL_FREEZE)
+ ? Qtrue : Qfalse;
}
#endif
if (FL_TEST(obj, FL_FREEZE)) return Qtrue;
Modified: MacRuby/trunk/string.c
===================================================================
--- MacRuby/trunk/string.c 2008-05-15 08:06:22 UTC (rev 192)
+++ MacRuby/trunk/string.c 2008-05-15 19:11:55 UTC (rev 193)
@@ -1209,8 +1209,8 @@
str_modifiable(VALUE str)
{
#if WITH_OBJC
- bool _CFStringIsMutable(void *);
- if (!__CFStringIsMutable(str))
+ bool __CFStringIsMutable(void *);
+ if (!__CFStringIsMutable((void *)str))
rb_raise(rb_eRuntimeError, "can't modify immutable string");
#else
if (FL_TEST(str, STR_TMPLOCK)) {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080515/35eb74a5/attachment.htm
More information about the macruby-changes
mailing list