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/ruby/eval.c,v
retrieving revision 1.890
diff -u -r1.890 eval.c
— eval.c 23 Feb 2006 04:24:39 -0000 1.890
+++ eval.c 11 May 2006 15:56:35 -0000
@@ -6618,7 +6618,7 @@
NORETURN(static void load_failed(VALUE));
void
-rb_load(VALUE fname, int wrap)
+rb_load_to(VALUE fname, int wrap, VALUE wrapper_mod)
{
VALUE tmp;
int state;
@@ -6647,8 +6647,14 @@
ruby_wrapper = 0;
}
else {
- /* load in anonymous module as toplevel */
- ruby_wrapper = rb_module_new();
-
if (rb_obj_is_kind_of(wrapper_mod, rb_cModule)) {
-
/* load in the module as toplevel */
-
ruby_wrapper = wrapper_mod;
-
}
-
else {
-
/* load in anonymous module as toplevel */
-
ruby_wrapper = rb_module_new();
-
self = rb_obj_clone(ruby_top_self);}
rb_extend_object(self, ruby_wrapper);
PUSH_CREF(ruby_wrapper);
@@ -6712,6 +6718,12 @@
}
void
+rb_load(VALUE fname, int wrap)
+{
- rb_load_to(fname, wrap, Qnil);
+}
+void
rb_load_protect(VALUE fname, int wrap, int *state)
{
int status;
@@ -6727,6 +6739,22 @@
if (state) *state = status;
}
+void
+rb_load_protect_to(VALUE fname, int wrap, VALUE wrapper_mod, int
*state)
+{
- int status;
- PUSH_THREAD_TAG();
- if ((status = EXEC_TAG()) == 0) {
- rb_load_to(fname, wrap, wrapper_mod);
- }
- else if (status == TAG_THREAD) {
- rb_thread_start_1();
- }
- POP_THREAD_TAG();
- if (state) *state = status;
+}
/*
- call-seq:
-
load(filename, wrap=false) => true
@@ -6752,6 +6780,26 @@
return Qtrue;
}
+/*
-
- call-seq:
-
-
load_to(filename, wrapper) => true
-
-
-
- Loads and executes the Ruby
-
- program in the file filename under the specified module wrapper
-
- (See also the wrap parameter of
load
function).
- (See also the wrap parameter of
-
- If the filename does not
-
- resolve to an absolute path, the file is searched for in the
library
- resolve to an absolute path, the file is searched for in the
-
- directories listed in
$:
.
- directories listed in
- */
+static VALUE
+rb_f_load_to(VALUE obj, VALUE fname, VALUE wrapper_mod)
+{
- rb_load_to(fname, 1, wrapper_mod);
- return Qtrue;
+}
VALUE ruby_dln_librefs;
static VALUE rb_features;
static st_table *loading_tbl;
@@ -7875,6 +7923,7 @@
rb_features = rb_ary_new();
rb_define_global_function("load", rb_f_load, -1);
- rb_define_global_function(“load_to”, rb_f_load_to, 2);
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?”, rb_mod_autoload_p, 1);