Revision: 2790 http://trac.macosforge.org/projects/ruby/changeset/2790 Author: lsansonetti@apple.com Date: 2009-10-13 19:06:19 -0700 (Tue, 13 Oct 2009) Log Message: ----------- fixing some #autoload bugs Modified Paths: -------------- MacRuby/trunk/load.c MacRuby/trunk/variable.c MacRuby/trunk/vm.cpp MacRuby/trunk/vm.h Modified: MacRuby/trunk/load.c =================================================================== --- MacRuby/trunk/load.c 2009-10-13 23:38:08 UTC (rev 2789) +++ MacRuby/trunk/load.c 2009-10-14 02:06:19 UTC (rev 2790) @@ -330,7 +330,7 @@ */ static VALUE -rb_mod_autoload_p(VALUE mod, VALUE sym) +rb_mod_autoload_p(VALUE mod, SEL sel, VALUE sym) { return rb_autoload_p(mod, rb_to_id(sym)); } @@ -349,15 +349,11 @@ static VALUE rb_f_autoload(VALUE obj, SEL sel, VALUE sym, VALUE file) { -#if 0 - VALUE klass = rb_vm_cbase(); - if (NIL_P(klass)) { - rb_raise(rb_eTypeError, "Can not set autoload on singleton class"); + VALUE klass = (VALUE)rb_vm_get_current_class(); + if (klass == 0) { + klass = rb_cObject; } - return rb_mod_autoload(klass, sym, file); -#endif - // TODO - return Qnil; + return rb_mod_autoload(klass, 0, sym, file); } /* @@ -367,16 +363,11 @@ static VALUE rb_f_autoload_p(VALUE obj, SEL sel, VALUE sym) { -#if 0 - /* use rb_vm_cbase() as same as rb_f_autoload. */ - VALUE klass = rb_vm_cbase(); - if (NIL_P(klass)) { - return Qnil; + VALUE klass = (VALUE)rb_vm_get_current_class(); + if (klass == 0) { + klass = rb_cObject; } - return rb_mod_autoload_p(klass, sym); -#endif - // TODO - return Qnil; + return rb_mod_autoload_p(klass, 0, sym); } void Modified: MacRuby/trunk/variable.c =================================================================== --- MacRuby/trunk/variable.c 2009-10-13 23:38:08 UTC (rev 2789) +++ MacRuby/trunk/variable.c 2009-10-14 02:06:19 UTC (rev 2790) @@ -1453,11 +1453,7 @@ GC_WB(&DATA_PTR(av), tbl); } fn = rb_str_new2(file); -#if __LP64__ - RCLASS_RC_FLAGS(fn) &= ~FL_TAINT; -#else - FL_UNSET(fn, FL_TAINT); -#endif + rb_obj_untaint(fn); OBJ_FREEZE(fn); st_insert(tbl, id, (st_data_t)rb_node_newnode(NODE_MEMO, fn, rb_safe_level(), 0)); } Modified: MacRuby/trunk/vm.cpp =================================================================== --- MacRuby/trunk/vm.cpp 2009-10-13 23:38:08 UTC (rev 2789) +++ MacRuby/trunk/vm.cpp 2009-10-14 02:06:19 UTC (rev 2790) @@ -3890,6 +3890,13 @@ } extern "C" +Class +rb_vm_get_current_class(void) +{ + return GET_VM()->get_current_class(); +} + +extern "C" void rb_vm_set_current_scope(VALUE mod, rb_vm_scope_t scope) { Modified: MacRuby/trunk/vm.h =================================================================== --- MacRuby/trunk/vm.h 2009-10-13 23:38:08 UTC (rev 2789) +++ MacRuby/trunk/vm.h 2009-10-14 02:06:19 UTC (rev 2790) @@ -382,6 +382,7 @@ void rb_vm_set_abort_on_exception(bool flag); Class rb_vm_set_current_class(Class klass); +Class rb_vm_get_current_class(void); bool rb_vm_is_multithreaded(void); void rb_vm_set_multithreaded(bool flag);
participants (1)
-
source_changes@macosforge.org