class.c: rb_singleton_class_get
* class.c (rb_singleton_class_get): get the singleton class if exists, or nil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
111c791c37
commit
609c7420d7
@ -1,3 +1,8 @@
|
|||||||
|
Mon May 13 14:50:35 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* class.c (rb_singleton_class_get): get the singleton class if exists,
|
||||||
|
or nil.
|
||||||
|
|
||||||
Mon May 13 10:20:59 2013 Yuki Yugui Sonoda <yugui@google.com>
|
Mon May 13 10:20:59 2013 Yuki Yugui Sonoda <yugui@google.com>
|
||||||
|
|
||||||
* ext/openssl/ossl_ssl.c: Disabled OpenSSL::SSL::SSLSocket if
|
* ext/openssl/ossl_ssl.c: Disabled OpenSSL::SSL::SSLSocket if
|
||||||
|
20
class.c
20
class.c
@ -1448,6 +1448,26 @@ singleton_class_of(VALUE obj)
|
|||||||
return klass;
|
return klass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the singleton class of \a obj, or nil if obj is not a
|
||||||
|
* singleton object.
|
||||||
|
*
|
||||||
|
* \param obj an arbitrary object.
|
||||||
|
* \return the singleton class or nil.
|
||||||
|
*/
|
||||||
|
VALUE
|
||||||
|
rb_singleton_class_get(VALUE obj)
|
||||||
|
{
|
||||||
|
VALUE klass;
|
||||||
|
|
||||||
|
if (SPECIAL_CONST_P(obj)) {
|
||||||
|
return rb_special_singleton_class(obj);
|
||||||
|
}
|
||||||
|
klass = RBASIC(obj)->klass;
|
||||||
|
if (!FL_TEST(klass, FL_SINGLETON)) return Qnil;
|
||||||
|
if (rb_ivar_get(klass, id_attached) != obj) return Qnil;
|
||||||
|
return klass;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the singleton class of \a obj. Creates it if necessary.
|
* Returns the singleton class of \a obj. Creates it if necessary.
|
||||||
|
@ -96,6 +96,7 @@ VALUE rb_obj_public_methods(int argc, VALUE *argv, VALUE obj);
|
|||||||
int rb_obj_basic_to_s_p(VALUE);
|
int rb_obj_basic_to_s_p(VALUE);
|
||||||
VALUE rb_special_singleton_class(VALUE);
|
VALUE rb_special_singleton_class(VALUE);
|
||||||
VALUE rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach);
|
VALUE rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach);
|
||||||
|
VALUE rb_singleton_class_get(VALUE obj);
|
||||||
void Init_class_hierarchy(void);
|
void Init_class_hierarchy(void);
|
||||||
|
|
||||||
/* compar.c */
|
/* compar.c */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user