|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jruby.RubyBasicObject
org.jruby.RubyObject
public class RubyObject
RubyObject is the only implementation of the
IRubyObject
. Every Ruby object in JRuby
is represented by something that is an instance of RubyObject. In
some of the core class implementations, this means doing a subclass
that extends RubyObject, in other cases it means using a simple
RubyObject instance and the data field to store specific
information about the Ruby object.
Some care has been taken to make the implementation be as
monomorphic as possible, so that the Java Hotspot engine can
improve performance of it. That is the reason for several patterns
that might seem odd in this class.
The IRubyObject interface used to have lots of methods for
different things, but these have now mostly been refactored into
several interfaces that gives access to that specific part of the
object. This gives us the possibility to switch out that subsystem
without changing interfaces again. For example, instance variable
and internal variables are handled this way, but the implementation
in RubyObject only returns "this" in RubyBasicObject.getInstanceVariables()
and
RubyBasicObject.getInternalVariables()
.
Nested Class Summary | |
---|---|
static class |
RubyObject.Data
|
Nested classes/interfaces inherited from class org.jruby.RubyBasicObject |
---|
RubyBasicObject.Finalizer |
Field Summary | |
---|---|
static ObjectAllocator |
OBJECT_ALLOCATOR
Default allocator instance for all Ruby objects. |
static ObjectAllocator |
REIFYING_OBJECT_ALLOCATOR
|
Fields inherited from class org.jruby.RubyBasicObject |
---|
ALL_F, BASICOBJECT_ALLOCATOR, COMPARE_BY_IDENTITY_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, metaClass, NEVER, NIL_F, TAINTED_F, UNDEF, UNTRUSTED_F, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_F |
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject |
---|
NULL_ARRAY |
Constructor Summary | |
---|---|
|
RubyObject(RubyClass metaClass)
Path for objects that don't taint and don't enter objectspace. |
|
RubyObject(Ruby runtime,
RubyClass metaClass)
Standard path for object creation. |
protected |
RubyObject(Ruby runtime,
RubyClass metaClass,
boolean useObjectSpace)
|
protected |
RubyObject(Ruby runtime,
RubyClass metaClass,
boolean useObjectSpace,
boolean canBeTainted)
Path for objects who want to decide whether they don't want to be in ObjectSpace even when it is on. |
Method Summary | |
---|---|
void |
attachToObjectSpace()
Will make sure that this object is added to the current object space. |
void |
callInit(Block block)
Call the Ruby initialize method with the supplied arguments and block. |
void |
callInit(IRubyObject[] args,
Block block)
Call the Ruby initialize method with the supplied arguments and block. |
void |
callInit(IRubyObject arg0,
Block block)
Call the Ruby initialize method with the supplied arguments and block. |
void |
callInit(IRubyObject arg0,
IRubyObject arg1,
Block block)
Call the Ruby initialize method with the supplied arguments and block. |
void |
callInit(IRubyObject arg0,
IRubyObject arg1,
IRubyObject arg2,
Block block)
Call the Ruby initialize method with the supplied arguments and block. |
IRubyObject |
convertToType(RubyClass target,
int convertMethodIndex)
Deprecated. |
static RubyClass |
createObjectClass(Ruby runtime,
RubyClass objectClass)
Will create the Ruby class Object in the runtime specified. |
protected static boolean |
eqlInternal(ThreadContext context,
IRubyObject a,
IRubyObject b)
Helper method for checking equality, first using Java identity equality, and then calling the "eql?" method. |
protected static boolean |
equalInternal(ThreadContext context,
IRubyObject a,
IRubyObject b)
Helper method for checking equality, first using Java identity equality, and then calling the "==" method. |
boolean |
equals(java.lang.Object other)
This method is just a wrapper around the Ruby "==" method, provided so that RubyObjects can be used as keys in the Java HashMap object underlying RubyHash. |
int |
getNativeTypeIndex()
This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are. |
int |
hashCode()
Override the Object#hashCode method to make sure that the Ruby hash is actually used as the hashcode for Ruby objects. |
IRubyObject |
initialize()
|
IRubyObject |
op_eqq(ThreadContext context,
IRubyObject other)
rb_equal The Ruby "===" method is used by default in case/when statements. |
static void |
puts(java.lang.Object obj)
Simple helper to print any objects. |
IRubyObject |
specificEval(ThreadContext context,
RubyModule mod,
IRubyObject[] args,
Block block)
Deprecated. |
java.lang.String |
toString()
The default toString method is just a wrapper that calls the Ruby "to_s" method. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final ObjectAllocator OBJECT_ALLOCATOR
ObjectAllocator
public static final ObjectAllocator REIFYING_OBJECT_ALLOCATOR
Constructor Detail |
---|
public RubyObject(Ruby runtime, RubyClass metaClass)
public RubyObject(RubyClass metaClass)
protected RubyObject(Ruby runtime, RubyClass metaClass, boolean useObjectSpace, boolean canBeTainted)
protected RubyObject(Ruby runtime, RubyClass metaClass, boolean useObjectSpace)
Method Detail |
---|
public static RubyClass createObjectClass(Ruby runtime, RubyClass objectClass)
public IRubyObject initialize()
initialize
in class RubyBasicObject
public void attachToObjectSpace()
ObjectSpace
public int getNativeTypeIndex()
getNativeTypeIndex
in interface CoreObjectType
getNativeTypeIndex
in class RubyBasicObject
org.jruby.runtime.ClassInde
public static void puts(java.lang.Object obj)
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public final void callInit(IRubyObject[] args, Block block)
public final void callInit(Block block)
public final void callInit(IRubyObject arg0, Block block)
public final void callInit(IRubyObject arg0, IRubyObject arg1, Block block)
public final void callInit(IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block)
@Deprecated public final IRubyObject convertToType(RubyClass target, int convertMethodIndex)
@Deprecated public IRubyObject specificEval(ThreadContext context, RubyModule mod, IRubyObject[] args, Block block)
public IRubyObject op_eqq(ThreadContext context, IRubyObject other)
op_eqq
in interface IRubyObject
op_eqq
in class RubyBasicObject
protected static boolean equalInternal(ThreadContext context, IRubyObject a, IRubyObject b)
protected static boolean eqlInternal(ThreadContext context, IRubyObject a, IRubyObject b)
public int hashCode()
hashCode
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |