summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--variable.c35
2 files changed, 28 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 61adce1d8..b2fab4ac0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,4 @@
-Wed Sep 9 12:56:56 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Sep 9 13:09:07 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* dir.c (dir_data_type): typed.
@@ -16,6 +16,8 @@ Wed Sep 9 12:56:56 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* transcode.c (econv_data_type): typed.
+ * variable.c (autoload_data_type): typed.
+
Wed Sep 9 11:11:33 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* include/ruby/ruby.h (rb_data_type_struct): constified dsize.
diff --git a/variable.c b/variable.c
index 65f0484cb..dfda427ca 100644
--- a/variable.c
+++ b/variable.c
@@ -292,7 +292,7 @@ rb_path_to_class(VALUE pathname)
VALUE
rb_path2class(const char *path)
{
- return rb_path_to_class(rb_usascii_str_new_cstr(path));
+ return rb_path_to_class(rb_str_new_cstr(path));
}
void
@@ -1357,18 +1357,33 @@ rb_mod_const_missing(VALUE klass, VALUE name)
return Qnil; /* not reached */
}
-static struct st_table *
-check_autoload_table(VALUE av)
+static void
+autoload_mark(void *ptr)
{
- Check_Type(av, T_DATA);
- if (RDATA(av)->dmark != (RUBY_DATA_FUNC)rb_mark_tbl ||
- RDATA(av)->dfree != (RUBY_DATA_FUNC)st_free_table) {
- VALUE desc = rb_inspect(av);
- rb_raise(rb_eTypeError, "wrong autoload table: %s", RSTRING_PTR(desc));
- }
- return (struct st_table *)DATA_PTR(av);
+ rb_mark_tbl((st_table *)ptr);
+}
+
+static void
+autoload_free(void *ptr)
+{
+ st_free_table((st_table *)ptr);
}
+static size_t
+autoload_memsize(const void *ptr)
+{
+ const st_table *tbl = ptr;
+ return st_memsize(tbl);
+}
+
+static const rb_data_type_t autoload_data_type = {
+ "autoload",
+ autoload_mark, autoload_free, autoload_memsize,
+};
+
+#define check_autoload_table(av) \
+ (struct st_table *)rb_check_typeddata(av, &autoload_data_type)
+
void
rb_autoload(VALUE mod, ID id, const char *file)
{