e$B1J0f!wCNG=!%6e9)Bg$G$9!%e(B
e$B8=>u$Ne(B 1.9 e$B$G$O!$e(Bautoload e$BEPO?$7$F$$$k%U%!%$%k$re(B
e$BL@<(E*$Ke(B require e$B$7$h$&$H$9$k$HNc30$,H/@8$7$^$9!%e(B
1.8 e$B$G$3$l$r$d$k$H!$BP>]%U%!%$%k$r#22sFI$s$G$7$^$&$i$7$$$3$H$Ke(B
e$B=i$a$F5$$,IU$-$^$7$?!%e(B(^_^;
e$B$3$N;EMM$N>l9g!$!VMxJX@-$N$?$a$Ke(B autoload
e$BEPO?$O$7$F$$$k$b$N$N!$e(B
e$BD>@\e(B require e$B$9$k?M$b$$$k!W$H$$$&%1!<%9$G:$$C$F$7$^$$$^$9!%e(B
e$BMW$O!$BP>]%U%!%$%kCf$NDj?tDj5A$KBP$7$Fe(B autoload
e$B$,5/F0$7$F$7$^$&$N$,e(B
e$BLdBj$G$9$+$i!$BP>]%U%!%$%k$NF,$Ge(B autoload e$BDj5A$r;&$7$F$d$l$Pe(B
e$BMxMQ<T$NMxJX@-$rAK32$9$k$3$H$J$/2sHr$G$-$k$O$:$G$9!%e(B
e$B$7$+$7!$8=>u$G$OL@<(E*$Ke(B autoload e$BDj5A$r<h$j=|$/%a%=%C%I$,e(B
e$BB8:_$7$J$$$h$&$K8+<u$1$i$l$^$9!%e(B
e$B$=$3$Ge(B Kernel#autoload_delete, Module#autoload_delete e$B$re(B
e$BDI2C$9$k$H$$$&$N$O$$$+$,$G$7$g$&$+!)e(B
e$B$3$l$rMQ$$$l$P!$Nc$($Pe(B
----<zzz.rb>-----------------------------------------
autoload_delete(:ZZZ)
class ZZZ
$XXX ||= 0
$XXX += 1
p $XXX
… defs …
end
e$B$KBP$7$F!$e(B
autoload(:ZZZ, ‘zzz’)
ZZZ.new
e$B$G$be(B
require ‘zzz’
ZZZ.new
e$B$G$be(B
autoload(:ZZZ, ‘zzz’)
require ‘zzz’
ZZZ.new
e$B$G$b%(%i!<$K$J$i$:$KF0$$$F$/$l$^$9!%e(B
e$B$D$$$G$K!$e(B1.8 e$B$N$h$&$Ke(B $XXX e$B$,e(B 2
e$B$K$J$C$?$j$9$k$3$H$b$J$/!%e(B(^_^)
e$B%Q%C%A$r0J2<$KE:IU$7$^$9!%e(B
e$B$J$*!$e(Bautoload(name, nil) e$B$G:o=|$H$$$&$N$b9M$($^$7$?$,!$e(B
e$BEPO?Ku>C;~$K0JA0$KEPO?$5$l$F$$$?%U%!%$%k$rJV$7$?J}$,JXMx$He(B
e$B;W$o$l$^$7$?$N$G!$La$jCM$N@-3J$N0c$$$+$iJL%a%=%C%I$H$7$F$$$^$9!%e(B
Index: eval_load.c
— eval_load.c (revision 13825)
+++ eval_load.c (working copy)
@@ -512,6 +512,27 @@
}
/*
-
- call-seq:
-
-
mod.autoload_delete(name) => filename or nil
-
-
-
- Unregisters the autoload definition about name.
-
- Returns the unregisterd filename (when registered by autoload) or
-
- nil (when no registered).
-
-
-
module A
-
-
-
end
-
-
-
A.autoload(:B, "b")
-
-
-
A.autoload_delete(:B) # returns "b"
-
-
-
A.autoload_delete(:C) # returns nil
-
- */
+static VALUE
+rb_mod_autoload_delete(VALUE mod, VALUE sym)
+{
- return rb_autoload_delete(mod, rb_to_id(sym));
+}
+/*
- MISSING: documentation
*/
@@ -543,6 +564,31 @@
}
/*
-
- call-seq:
-
-
autoload_delete(module) => filename or nil
-
-
-
- Unregisters the autoload definition about module.
-
- the first time that module (which may be a
String
or
- the first time that module (which may be a
-
- a symbol) is accessed.
-
- Returns the unregisterd filename (when registered by autoload) or
-
- nil (when no registered).
-
-
-
autoload(:MyModule, "/foo/modules/my_module.rb")
-
-
-
autoload_delete(:MyModule) # returns
-
“/foo/modules/my_module.rb”
-
-
autoload_delete(:MyNoModule) # returns nil
-
- */
+static VALUE
+rb_f_autoload_delete(VALUE mod, VALUE sym)
+{
- VALUE klass = ruby_cbase();
- if (NIL_P(klass)) {
- rb_raise(rb_eTypeError, “Can not set autoload on singleton class”);
- }
- return rb_mod_autoload_delete(klass, sym);
+}
+/*
- MISSING: documentation
*/
@@ -572,8 +618,10 @@
rb_define_global_function(“load”, rb_f_load, -1);
rb_define_global_function(“require”, rb_f_require, 1);
rb_define_method(rb_cModule, “autoload”, rb_mod_autoload, 2);
-
rb_define_method(rb_cModule, “autoload_delete”,
rb_mod_autoload_delete, 1);
rb_define_method(rb_cModule, “autoload?”, rb_mod_autoload_p, 1);
rb_define_global_function(“autoload”, rb_f_autoload, 2); -
rb_define_global_function(“autoload_delete”, rb_f_autoload_delete,
1);
rb_define_global_function(“autoload?”, rb_f_autoload_p, 1);ruby_dln_librefs = rb_ary_new();
Index: include/ruby/intern.h
===================================================================
— include/ruby/intern.h (revision 13825)
+++ include/ruby/intern.h (working copy)
@@ -570,6 +570,7 @@
VALUE rb_class_name(VALUE);
void rb_autoload(VALUE, ID, const char*);
VALUE rb_autoload_load(VALUE, ID);
+VALUE rb_autoload_delete(VALUE, ID);
VALUE rb_autoload_p(VALUE, ID);
void rb_gc_mark_global_tbl(void);
VALUE rb_f_trace_var(int, VALUE*);
Index: variable.c
===================================================================
— variable.c (revision 13825)
+++ variable.c (working copy)
@@ -1398,6 +1398,18 @@
}
VALUE
+rb_autoload_delete(VALUE klass, ID id)
+{
- VALUE file;
- NODE *load = autoload_delete(klass, id);
- if (!load || !(file = load->nd_lit) ||
rb_provided(RSTRING_PTR(file))) { - return Qnil;
- }
- return file;
+}
+VALUE
rb_autoload_p(VALUE mod, ID id)
{
struct st_table *tbl = RCLASS_IV_TBL(mod);