mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
2 changed files with 17 additions and 4 deletions
|
@ -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.
|
||||
|
||||
|
@ -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.
|
||||
|
||||
* file.c (stat_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.
|
||||
|
|
17
file.c
17
file.c
|
@ -180,6 +180,17 @@ rb_file_path(VALUE obj)
|
|||
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
|
||||
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 = *st;
|
||||
}
|
||||
return Data_Wrap_Struct(klass, NULL, -1, nst);
|
||||
return TypedData_Wrap_Struct(klass, &stat_data_type, nst);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -202,7 +213,7 @@ static struct stat*
|
|||
get_stat(VALUE self)
|
||||
{
|
||||
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");
|
||||
return st;
|
||||
}
|
||||
|
@ -679,7 +690,7 @@ rb_stat_inspect(VALUE self)
|
|||
};
|
||||
|
||||
struct stat* st;
|
||||
Data_Get_Struct(self, struct stat, st);
|
||||
TypedData_Get_Struct(self, struct stat, &stat_data_type, st);
|
||||
if (!st) {
|
||||
return rb_sprintf("#<%s: uninitialized>", rb_obj_classname(self));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue