* variable.c (autoload_data_type): typed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-09-09 04:09:09 +00:00
Родитель fe963a4510
Коммит fb532ac7a9
2 изменённых файлов: 28 добавлений и 11 удалений

Просмотреть файл

@ -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. * 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. * 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> Wed Sep 9 11:11:33 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* include/ruby/ruby.h (rb_data_type_struct): constified dsize. * include/ruby/ruby.h (rb_data_type_struct): constified dsize.

Просмотреть файл

@ -292,7 +292,7 @@ rb_path_to_class(VALUE pathname)
VALUE VALUE
rb_path2class(const char *path) 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 void
@ -1357,18 +1357,33 @@ rb_mod_const_missing(VALUE klass, VALUE name)
return Qnil; /* not reached */ return Qnil; /* not reached */
} }
static struct st_table * static void
check_autoload_table(VALUE av) autoload_mark(void *ptr)
{ {
Check_Type(av, T_DATA); rb_mark_tbl((st_table *)ptr);
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);
} }
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 void
rb_autoload(VALUE mod, ID id, const char *file) rb_autoload(VALUE mod, ID id, const char *file)
{ {