Skip to content

Commit

Permalink
fixing some #autoload bugs
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@2790 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information
lrz committed Oct 14, 2009
1 parent 6c31fdd commit e05d13f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 deletions.
27 changes: 9 additions & 18 deletions load.c
Expand Up @@ -330,7 +330,7 @@ rb_mod_autoload(VALUE mod, SEL sel, VALUE sym, VALUE file)
*/

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));
}
Expand All @@ -349,15 +349,11 @@ rb_mod_autoload_p(VALUE mod, VALUE sym)
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);
}

/*
Expand All @@ -367,16 +363,11 @@ rb_f_autoload(VALUE obj, SEL sel, VALUE sym, VALUE file)
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
Expand Down
6 changes: 1 addition & 5 deletions variable.c
Expand Up @@ -1453,11 +1453,7 @@ rb_autoload(VALUE mod, ID id, const char *file)
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));
}
Expand Down
7 changes: 7 additions & 0 deletions vm.cpp
Expand Up @@ -3889,6 +3889,13 @@ rb_vm_set_current_class(Class klass)
return old;
}

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)
Expand Down
1 change: 1 addition & 0 deletions vm.h
Expand Up @@ -382,6 +382,7 @@ bool rb_vm_abort_on_exception(void);
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);
Expand Down

0 comments on commit e05d13f

Please sign in to comment.