mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add rb_typeddata_is_instance_of
Similar to rb_typeddata_is_kind_of, except for that inherited type is not an instance. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a9ace57505
commit
b549d14c00
3 changed files with 15 additions and 3 deletions
7
error.c
7
error.c
|
@ -830,6 +830,13 @@ rb_typeddata_is_kind_of(VALUE obj, const rb_data_type_t *data_type)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef rb_typeddata_is_instance_of
|
||||||
|
int
|
||||||
|
rb_typeddata_is_instance_of(VALUE obj, const rb_data_type_t *data_type)
|
||||||
|
{
|
||||||
|
return rb_typeddata_is_instance_of_inline(obj, data_type);
|
||||||
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
rb_check_typeddata(VALUE obj, const rb_data_type_t *data_type)
|
rb_check_typeddata(VALUE obj, const rb_data_type_t *data_type)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2266,6 +2266,13 @@ NORETURN(void rb_unexpected_type(VALUE,int));
|
||||||
((t) == RUBY_T_DATA && RTYPEDDATA_P(v)) ? \
|
((t) == RUBY_T_DATA && RTYPEDDATA_P(v)) ? \
|
||||||
rb_unexpected_type((VALUE)(v), (t)) : (void)0)
|
rb_unexpected_type((VALUE)(v), (t)) : (void)0)
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
rb_typeddata_is_instance_of_inline(VALUE obj, const rb_data_type_t *data_type)
|
||||||
|
{
|
||||||
|
return RB_TYPE_P(obj, T_DATA) && RTYPEDDATA_P(obj) && (RTYPEDDATA_TYPE(obj) == data_type);
|
||||||
|
}
|
||||||
|
#define rb_typeddata_is_instance_of rb_typeddata_is_instance_of_inline
|
||||||
|
|
||||||
/* file.c (export) */
|
/* file.c (export) */
|
||||||
#if defined HAVE_READLINK && defined RUBY_ENCODING_H
|
#if defined HAVE_READLINK && defined RUBY_ENCODING_H
|
||||||
VALUE rb_readlink(VALUE path, rb_encoding *enc);
|
VALUE rb_readlink(VALUE path, rb_encoding *enc);
|
||||||
|
|
4
iseq.c
4
iseq.c
|
@ -2329,9 +2329,7 @@ iseqw_s_of(VALUE klass, VALUE body)
|
||||||
else if (rb_obj_is_method(body)) {
|
else if (rb_obj_is_method(body)) {
|
||||||
iseq = rb_method_iseq(body);
|
iseq = rb_method_iseq(body);
|
||||||
}
|
}
|
||||||
else if (RB_TYPE_P(body, T_DATA) &&
|
else if (rb_typeddata_is_instance_of(body, &iseqw_data_type)) {
|
||||||
RTYPEDDATA_P(body) &&
|
|
||||||
RTYPEDDATA_TYPE(body) == &iseqw_data_type) {
|
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue