summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--eval.c1
-rw-r--r--lib/tempfile.rb3
-rw-r--r--object.c59
4 files changed, 72 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 6e316eb189..2280aeb154 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Wed Mar 24 04:12:44 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_mod_cvar_get): new method Module#class_variable_get.
+
+ * object.c (rb_mod_cvar_set): ditto (Module#class_variable_set).
+
+Tue Mar 23 17:45:22 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_atfork): 1.9 warns no more for thread
+ termination. [ruby-dev:23212]
+
Tue Mar 23 14:46:10 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* Makefile.in, */Makefile.sub, common.mk (clean-local, distclean-local):
diff --git a/eval.c b/eval.c
index f2d8c9b667..ab55428754 100644
--- a/eval.c
+++ b/eval.c
@@ -12013,7 +12013,6 @@ rb_thread_atfork()
if (rb_thread_alone()) return;
FOREACH_THREAD(th) {
if (th != curr_thread) {
- rb_warn("fork terminates thread at %s:%d", th->node->nd_file, nd_line(th->node));
rb_thread_die(th);
}
}
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index f5dc801b21..2169a20ec5 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -77,7 +77,8 @@ class Tempfile < SimpleDelegator
def _close # :nodoc:
@tmpfile.close if @tmpfile
@data[1] = @tmpfile = nil
- end
+ @data = @tmpname = nil
+ end
protected :_close
# Closes the file. If the optional flag is true, unlinks the file
diff --git a/object.c b/object.c
index 0e7801fe77..284190b929 100644
--- a/object.c
+++ b/object.c
@@ -1951,6 +1951,63 @@ rb_obj_ivar_set(obj, iv, val)
return rb_ivar_set(obj, id, val);
}
+/*
+ * call-seq:
+ * mod.class_variable_get(symbol) => obj
+ *
+ * Returns the value of the given class variable (or throws a
+ * <code>NameError</code> exception). The <code>@@</code> part of the
+ * variable name should be included for regular class variables
+ *
+ * class Fred
+ * @@foo = 99
+ * end
+ * Fred.class_variable_get(:@foo) #=> 99
+ */
+
+static VALUE
+rb_mod_cvar_get(obj, iv)
+ VALUE obj, iv;
+{
+ ID id = rb_to_id(iv);
+
+ if (!rb_is_class_id(id)) {
+ rb_name_error(id, "`%s' is not allowed as an class variable name", rb_id2name(id));
+ }
+ return rb_cvar_get(obj, id);
+}
+
+
+/*
+ * call-seq:
+ * obj.class_variable_set(symbol, obj) => obj
+ *
+ * Sets the class variable names by <i>symbol</i> to
+ * <i>object</i>.
+ *
+ * class Fred
+ * @@foo = 99
+ * def foo
+ * @@foo
+ * end
+ * end
+ * Fred.class_variable_set(:@foo, 101) #=> 101
+ * Fred.new.foo #=> 101
+ */
+
+static VALUE
+rb_mod_cvar_set(obj, iv, val)
+ VALUE obj, iv, val;
+{
+ ID id = rb_to_id(iv);
+
+ if (!rb_is_class_id(id)) {
+ rb_name_error(id, "`%s' is not allowed as an class variable name", rb_id2name(id));
+ }
+ rb_cvar_set(obj, id, val, Qfalse);
+ return val;
+}
+
static VALUE
convert_type(val, tname, method, raise)
VALUE val;
@@ -2578,6 +2635,8 @@ Init_Object()
rb_mod_class_variables, 0); /* in variable.c */
rb_define_private_method(rb_cModule, "remove_class_variable",
rb_mod_remove_cvar, 1); /* in variable.c */
+ rb_define_private_method(rb_cModule, "class_variable_get", rb_mod_cvar_get, 1);
+ rb_define_private_method(rb_cModule, "class_variable_set", rb_mod_cvar_set, 2);
rb_define_method(rb_cClass, "allocate", rb_obj_alloc, 0);
rb_define_method(rb_cClass, "new", rb_class_new_instance, -1);