зеркало из https://github.com/github/ruby.git
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:
Родитель
a9ace57505
Коммит
b549d14c00
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;
|
||||
}
|
||||
|
||||
#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 *
|
||||
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)) ? \
|
||||
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) */
|
||||
#if defined HAVE_READLINK && defined RUBY_ENCODING_H
|
||||
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)) {
|
||||
iseq = rb_method_iseq(body);
|
||||
}
|
||||
else if (RB_TYPE_P(body, T_DATA) &&
|
||||
RTYPEDDATA_P(body) &&
|
||||
RTYPEDDATA_TYPE(body) == &iseqw_data_type) {
|
||||
else if (rb_typeddata_is_instance_of(body, &iseqw_data_type)) {
|
||||
return body;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче