[macruby-changes] [719] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Nov 7 19:17:50 PST 2008
Revision: 719
http://trac.macosforge.org/projects/ruby/changeset/719
Author: ben at tanjero.com
Date: 2008-11-07 19:17:50 -0800 (Fri, 07 Nov 2008)
Log Message:
-----------
Moves the taint and frozen flags for CF-backed objects into the sekrit extra field of the CFRuntimeBase structure.
Modified Paths:
--------------
MacRuby/trunk/array.c
MacRuby/trunk/hash.c
MacRuby/trunk/include/ruby/ruby.h
MacRuby/trunk/object.c
MacRuby/trunk/ruby.c
MacRuby/trunk/variable.c
Modified: MacRuby/trunk/array.c
===================================================================
--- MacRuby/trunk/array.c 2008-11-07 21:54:30 UTC (rev 718)
+++ MacRuby/trunk/array.c 2008-11-08 03:17:50 UTC (rev 719)
@@ -36,7 +36,11 @@
rb_ary_modify_check(VALUE ary)
{
long mask;
+#ifdef __LP64__
+ mask = RCLASS_RC_FLAGS(ary);
+#else
mask = rb_objc_flag_get_mask((void *)ary);
+#endif
if (mask == 0) {
bool _CFArrayIsMutable(void *);
if (!_CFArrayIsMutable((void *)ary))
Modified: MacRuby/trunk/hash.c
===================================================================
--- MacRuby/trunk/hash.c 2008-11-07 21:54:30 UTC (rev 718)
+++ MacRuby/trunk/hash.c 2008-11-08 03:17:50 UTC (rev 719)
@@ -189,7 +189,11 @@
rb_hash_modify_check(VALUE hash)
{
long mask;
+#ifdef __LP64__
+ mask = RCLASS_RC_FLAGS(hash);
+#else
mask = rb_objc_flag_get_mask((const void *)hash);
+#endif
if (mask == 0) {
bool _CFDictionaryIsMutable(void *);
if (!_CFDictionaryIsMutable((void *)hash))
@@ -1865,7 +1869,7 @@
VALUE val = rb_f_getenv(Qnil, RARRAY_AT(keys, i));
if (!NIL_P(val)) {
if (RTEST(rb_yield_values(2, RARRAY_AT(keys, i), val))) {
- FL_UNSET(RARRAY_AT(keys, i), FL_TAINT);
+ rb_obj_untaint(RARRAY_AT(keys, i));
env_delete(Qnil, RARRAY_AT(keys, i));
del++;
}
Modified: MacRuby/trunk/include/ruby/ruby.h
===================================================================
--- MacRuby/trunk/include/ruby/ruby.h 2008-11-07 21:54:30 UTC (rev 718)
+++ MacRuby/trunk/include/ruby/ruby.h 2008-11-08 03:17:50 UTC (rev 719)
@@ -517,6 +517,7 @@
# define RCLASS_SUPER(m) (*(VALUE *)((void *)m + (sizeof(void *) * 1)))
# define RCLASS_SET_SUPER(m, s) (class_setSuperclass((Class)m, (Class)s))
# define RCLASS_META(m) (class_isMetaClass((Class)m))
+# define RCLASS_RC_FLAGS(m) (*(uint32_t *) ((void *)(m) + sizeof(uintptr_t) + (sizeof(uint8_t) * 4)))
# else
# define RCLASS_VERSION(m) (*(long *)((void *)m + (sizeof(void *) * 3)))
# define RCLASS_SET_VERSION(m,f) do { RCLASS_VERSION(m) = f; } while (0)
Modified: MacRuby/trunk/object.c
===================================================================
--- MacRuby/trunk/object.c 2008-11-07 21:54:30 UTC (rev 718)
+++ MacRuby/trunk/object.c 2008-11-08 03:17:50 UTC (rev 719)
@@ -166,8 +166,21 @@
init_copy(VALUE dest, VALUE obj)
{
if (NATIVE(obj)) {
+#ifdef __LP64__
+ switch (TYPE(obj)) {
+ case T_STRING:
+ case T_ARRAY:
+ case T_HASH:
+ if (RCLASS_RC_FLAGS(obj) & FL_TAINT)
+ RCLASS_RC_FLAGS(dest) |= FL_TAINT;
+ default:
+ if (rb_objc_flag_check((const void *)obj, FL_TAINT))
+ rb_objc_flag_set((const void *)dest, FL_TAINT, true);
+ }
+#else
if (rb_objc_flag_check((const void *)obj, FL_TAINT))
rb_objc_flag_set((const void *)dest, FL_TAINT, true);
+#endif
goto call_init_copy;
}
if (OBJ_FROZEN(dest)) {
@@ -178,11 +191,6 @@
rb_copy_generic_ivar(dest, obj);
rb_gc_copy_finalizer(dest, obj);
switch (TYPE(obj)) {
- case T_NATIVE:
- if (rb_objc_flag_check((const void *)obj, FL_TAINT))
- rb_objc_flag_set((const void *)dest, FL_TAINT, true);
- break;
-
case T_OBJECT:
ROBJECT(dest)->ivars.type = ROBJECT(obj)->ivars.type;
switch (RB_IVAR_TYPE(ROBJECT(obj)->ivars)) {
@@ -283,6 +291,9 @@
clone = rb_obj_alloc(rb_obj_class(obj));
RBASIC(clone)->klass = rb_singleton_class_clone(obj);
RBASIC(clone)->flags = (RBASIC(obj)->flags | FL_TEST(clone, FL_TAINT)) & ~(FL_FREEZE|FL_FINALIZE);
+#ifdef __LP64__
+ RCLASS_RC_FLAGS(clone) = RCLASS_RC_FLAGS(obj);
+#endif
break;
}
@@ -731,7 +742,16 @@
rb_obj_tainted(VALUE obj)
{
if (!SPECIAL_CONST_P(obj) && NATIVE(obj)) {
- return rb_objc_flag_check((const void *)obj, FL_TAINT) ? Qtrue : Qfalse;
+ switch (TYPE(obj)) {
+ case T_STRING:
+ case T_ARRAY:
+ case T_HASH:
+#ifdef __LP64__
+ return (RCLASS_RC_FLAGS(obj) & FL_TAINT == FL_TAINT) ? Qtrue : Qfalse;
+#endif
+ default:
+ return rb_objc_flag_check((const void *)obj, FL_TAINT) ? Qtrue : Qfalse;
+ }
}
if (FL_TEST(obj, FL_TAINT))
return Qtrue;
@@ -752,7 +772,17 @@
{
rb_secure(4);
if (!SPECIAL_CONST_P(obj) && NATIVE(obj)) {
- rb_objc_flag_set((const void *)obj, FL_TAINT, true);
+ switch (TYPE(obj)) {
+ case T_STRING:
+ case T_ARRAY:
+ case T_HASH:
+#ifdef __LP64__
+ RCLASS_RC_FLAGS(obj) |= FL_TAINT;
+ break;
+#endif
+ default:
+ rb_objc_flag_set((const void *)obj, FL_TAINT, true);
+ }
return obj;
}
if (!OBJ_TAINTED(obj)) {
@@ -777,7 +807,17 @@
{
rb_secure(3);
if (!SPECIAL_CONST_P(obj) && NATIVE(obj)) {
- rb_objc_flag_set((const void *)obj, FL_TAINT, false);
+ switch (TYPE(obj)) {
+ case T_STRING:
+ case T_ARRAY:
+ case T_HASH:
+#ifdef __LP64__
+ RCLASS_RC_FLAGS(obj) &= ~FL_TAINT;
+ break;
+#endif
+ default:
+ rb_objc_flag_set((const void *)obj, FL_TAINT, false);
+ }
return obj;
}
if (OBJ_TAINTED(obj)) {
@@ -832,7 +872,17 @@
st_insert(immediate_frozen_tbl, obj, (st_data_t)Qtrue);
}
else if (NATIVE(obj)) {
- rb_objc_flag_set((const void *)obj, FL_FREEZE, true);
+ switch(TYPE(obj)) {
+ case T_STRING:
+ case T_ARRAY:
+ case T_HASH:
+#ifdef __LP64__
+ RCLASS_RC_FLAGS(obj) |= FL_FREEZE;
+ break;
+#endif
+ default:
+ rb_objc_flag_set((const void *)obj, FL_FREEZE, true);
+ }
}
else if ((type = TYPE(obj)) == T_CLASS || type == T_MODULE) {
RCLASS_SET_VERSION_FLAG(obj, RCLASS_IS_FROZEN);
@@ -867,6 +917,9 @@
case T_STRING:
case T_ARRAY:
case T_HASH:
+#ifdef __LP64__
+ return (RCLASS_RC_FLAGS(obj) & FL_FREEZE) == FL_FREEZE ? Qtrue : Qfalse;
+#endif
case T_NATIVE:
return rb_objc_is_immutable(obj)
|| rb_objc_flag_check((const void *)obj, FL_FREEZE)
Modified: MacRuby/trunk/ruby.c
===================================================================
--- MacRuby/trunk/ruby.c 2008-11-07 21:54:30 UTC (rev 718)
+++ MacRuby/trunk/ruby.c 2008-11-08 03:17:50 UTC (rev 719)
@@ -1203,8 +1203,13 @@
opt->xflag = 0;
if (rb_safe_level() >= 4) {
+#if __LP64__
+ RCLASS_RC_FLAGS(rb_argv) &= ~FL_TAINT;
+ RCLASS_RC_FLAGS(GET_VM()->load_path) &= ~FL_TAINT;
+#else
FL_UNSET(rb_argv, FL_TAINT);
FL_UNSET(GET_VM()->load_path, FL_TAINT);
+#endif
}
if (opt->do_check) {
Modified: MacRuby/trunk/variable.c
===================================================================
--- MacRuby/trunk/variable.c 2008-11-07 21:54:30 UTC (rev 718)
+++ MacRuby/trunk/variable.c 2008-11-08 03:17:50 UTC (rev 719)
@@ -1904,7 +1904,11 @@
DATA_PTR(av) = tbl = st_init_numtable();
}
fn = rb_str_new2(file);
+#if __LP64__
+ RCLASS_RC_FLAGS(fn) &= ~FL_TAINT;
+#else
FL_UNSET(fn, FL_TAINT);
+#endif
OBJ_FREEZE(fn);
st_insert(tbl, id, (st_data_t)rb_node_newnode(NODE_MEMO, fn, rb_safe_level(), 0));
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20081107/4284c09d/attachment-0001.html>
More information about the macruby-changes
mailing list