Class: ObjectSpace::InternalObjectWrapper
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | ext/objspace/objspace.c |
Overview
InternalObjectWrapper wraps objects that are internal to
the CRuby implementation and usually not directly visible in Ruby code.
reachable_objects_from and
reachable_objects_from_root return instances of this class
when a reachable object is an internal object. Some other ::ObjectSpace
methods, such as internal_super_of, may also return wrapped
internal objects.
An InternalObjectWrapper is a debugging and introspection object. Do not use it in application code. The wrapped object and the exact details of this class are implementation specific and may change in future versions.
Instance Method Summary
-
#inspect
See
Object#inspect. -
#internal_object_id ⇒ Integer
Returns the
Object#object_idof the wrapped internal object. -
#type ⇒ Symbol
Returns the type of the wrapped internal object as a symbol.
Instance Method Details
#inspect
See Object#inspect.
# File 'ext/objspace/objspace.c', line 540
static VALUE
iow_inspect(VALUE self)
{
VALUE obj = (VALUE)DATA_PTR(self);
VALUE type = type2sym(BUILTIN_TYPE(obj));
return rb_sprintf("#<InternalObject:%p %"PRIsVALUE">", (void *)obj, rb_sym2str(type));
}
#internal_object_id ⇒ Integer
Returns the Object#object_id of the wrapped internal object.
This value identifies the wrapped internal object, not the
InternalObjectWrapper instance. Use it only for debugging and
introspection; object ids of internal objects are implementation specific.
# File 'ext/objspace/objspace.c', line 559
static VALUE
iow_internal_object_id(VALUE self)
{
VALUE obj = (VALUE)DATA_PTR(self);
return rb_obj_id(obj);
}
#type ⇒ Symbol
Returns the type of the wrapped internal object as a symbol.
For example, an included module is represented internally as a T_ICLASS
object:
require 'objspace'
module M; end
class A; include M; end
iclass = ObjectSpace.internal_super_of(A)
iclass.type # => :T_ICLASS
The exact set of returned symbols is implementation specific.
# File 'ext/objspace/objspace.c', line 532
static VALUE
iow_type(VALUE self)
{
VALUE obj = (VALUE)DATA_PTR(self);
return type2sym(BUILTIN_TYPE(obj));
}