* file.c (stat_data_type): typed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
355047fb49
commit
23c95ef6c7
@ -1,4 +1,4 @@
|
|||||||
Wed Sep 9 11:55:07 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Sep 9 12:01:36 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* dir.c (dir_data_type): typed.
|
* dir.c (dir_data_type): typed.
|
||||||
|
|
||||||
@ -7,6 +7,8 @@ Wed Sep 9 11:55:07 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|||||||
|
|
||||||
* error.c (name_err_mesg_data_type): typed.
|
* error.c (name_err_mesg_data_type): typed.
|
||||||
|
|
||||||
|
* file.c (stat_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.
|
||||||
|
17
file.c
17
file.c
@ -180,6 +180,17 @@ rb_file_path(VALUE obj)
|
|||||||
return rb_obj_taint(rb_str_dup(fptr->pathv));
|
return rb_obj_taint(rb_str_dup(fptr->pathv));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
stat_memsize(const void *p)
|
||||||
|
{
|
||||||
|
return p ? sizeof(struct stat) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const rb_data_type_t stat_data_type = {
|
||||||
|
"stat",
|
||||||
|
NULL, RUBY_TYPED_DEFAULT_FREE, stat_memsize,
|
||||||
|
};
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
stat_new_0(VALUE klass, struct stat *st)
|
stat_new_0(VALUE klass, struct stat *st)
|
||||||
{
|
{
|
||||||
@ -189,7 +200,7 @@ stat_new_0(VALUE klass, struct stat *st)
|
|||||||
nst = ALLOC(struct stat);
|
nst = ALLOC(struct stat);
|
||||||
*nst = *st;
|
*nst = *st;
|
||||||
}
|
}
|
||||||
return Data_Wrap_Struct(klass, NULL, -1, nst);
|
return TypedData_Wrap_Struct(klass, &stat_data_type, nst);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -202,7 +213,7 @@ static struct stat*
|
|||||||
get_stat(VALUE self)
|
get_stat(VALUE self)
|
||||||
{
|
{
|
||||||
struct stat* st;
|
struct stat* st;
|
||||||
Data_Get_Struct(self, struct stat, st);
|
TypedData_Get_Struct(self, struct stat, &stat_data_type, st);
|
||||||
if (!st) rb_raise(rb_eTypeError, "uninitialized File::Stat");
|
if (!st) rb_raise(rb_eTypeError, "uninitialized File::Stat");
|
||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
@ -679,7 +690,7 @@ rb_stat_inspect(VALUE self)
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct stat* st;
|
struct stat* st;
|
||||||
Data_Get_Struct(self, struct stat, st);
|
TypedData_Get_Struct(self, struct stat, &stat_data_type, st);
|
||||||
if (!st) {
|
if (!st) {
|
||||||
return rb_sprintf("#<%s: uninitialized>", rb_obj_classname(self));
|
return rb_sprintf("#<%s: uninitialized>", rb_obj_classname(self));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user