org.jruby.runtime.builtin
Interface IRubyObject

All Known Subinterfaces:
JavaProxyMethod
All Known Implementing Classes:
JavaProxyClass.ProxyMethodImpl, RubyObject, RubyUndef

public interface IRubyObject

Object is the parent class of all classes in Ruby. Its methods are therefore available to all objects unless explicitly overridden.

Author:
jpetersen

Field Summary
static IRubyObject[] NULL_ARRAY
           
 
Method Summary
 void addFinalizer(RubyProc finalizer)
           
 IRubyObject anyToString()
           
 RubyString asString()
          rb_obj_as_string
 java.lang.String asSymbol()
          Convert the object into a symbol name if possible.
 IRubyObject callMethod(ThreadContext context, int methodIndex, java.lang.String string)
           
 IRubyObject callMethod(ThreadContext context, int methodIndex, java.lang.String name, IRubyObject arg)
           
 IRubyObject callMethod(ThreadContext context, int methodIndex, java.lang.String name, IRubyObject[] args)
           
 IRubyObject callMethod(ThreadContext context, int methodIndex, java.lang.String name, IRubyObject[] args, CallType callType)
           
 IRubyObject callMethod(ThreadContext context, RubyModule rubyclass, int methodIndex, java.lang.String name, IRubyObject[] args, CallType callType, Block block)
           
 IRubyObject callMethod(ThreadContext context, RubyModule rubyclass, java.lang.String name, IRubyObject[] args, CallType callType, Block block)
           
 IRubyObject callMethod(ThreadContext context, java.lang.String string)
           
 IRubyObject callMethod(ThreadContext context, java.lang.String string, Block aBlock)
           
 IRubyObject callMethod(ThreadContext context, java.lang.String string, IRubyObject arg)
           
 IRubyObject callMethod(ThreadContext context, java.lang.String method, IRubyObject[] rubyArgs)
           
 IRubyObject callMethod(ThreadContext context, java.lang.String method, IRubyObject[] rubyArgs, Block block)
           
 IRubyObject callMethod(ThreadContext context, java.lang.String name, IRubyObject[] args, CallType callType)
           
 IRubyObject callMethod(ThreadContext context, java.lang.String name, IRubyObject[] args, CallType callType, Block block)
           
 IRubyObject callSuper(ThreadContext context, IRubyObject[] args, Block block)
           
 IRubyObject checkArrayType()
           
 IRubyObject checkStringType()
           
 IRubyObject compilerCallMethod(ThreadContext context, java.lang.String name, IRubyObject[] args, IRubyObject caller, CallType callType, Block block)
           
 IRubyObject compilerCallMethodWithIndex(ThreadContext context, int methodIndex, java.lang.String name, IRubyObject[] args, IRubyObject caller, CallType callType, Block block)
           
 RubyArray convertToArray()
          Methods which perform to_xxx if the object has such a method
 RubyFloat convertToFloat()
           
 RubyHash convertToHash()
           
 RubyInteger convertToInteger()
           
 RubyString convertToString()
           
 IRubyObject convertToType(RubyClass targetType, int convertMethodIndex, java.lang.String convertMethod, boolean raiseOnError)
          Converts this object to type 'targetType' using 'convertMethod' method (MRI: convert_type).
 IRubyObject convertToType(RubyClass targetType, int convertMethodIndex, java.lang.String convertMethod, boolean raiseOnMissingMethod, boolean raiseOnWrongTypeResult, boolean allowNilThrough)
           
 IRubyObject convertToTypeWithCheck(RubyClass targetType, int convertMethodIndex, java.lang.String convertMethod)
          Higher level conversion utility similiar to convertToType but it can throw an additional TypeError during conversion (MRI: rb_check_convert_type).
 java.lang.Object dataGetStruct()
          Our version of Data_Get_Struct.
 void dataWrapStruct(java.lang.Object obj)
          Our version of Data_Wrap_Struct.
 IRubyObject dup()
          RubyMethod dup.
 boolean eql(IRubyObject other)
           
 boolean eqlInternal(ThreadContext context, IRubyObject other)
           
 IRubyObject equal(IRubyObject other)
           
 IRubyObject equalInternal(ThreadContext context, IRubyObject other)
           
 IRubyObject evalSimple(ThreadContext context, IRubyObject evalString, java.lang.String file)
          Evaluate the given string.
 IRubyObject evalWithBinding(ThreadContext context, IRubyObject evalString, IRubyObject binding, java.lang.String file, int lineNumber)
          Evaluate the given string under the specified binding object.
 IRubyObject getInstanceVariable(java.lang.String string)
          RubyMethod getInstanceVar.
 java.util.Map getInstanceVariables()
           
 java.util.Map getInstanceVariablesSnapshot()
           
 java.lang.Class getJavaClass()
          RubyMethod getJavaClass.
 RubyClass getMetaClass()
          RubyMethod getRubyClass.
 int getNativeTypeIndex()
          Return the ClassIndex value for the native type this object was constructed from.
 Ruby getRuntime()
          RubyMethod getRuntime.
 RubyClass getSingletonClass()
          RubyMethod getSingletonClass.
 RubyClass getType()
          RubyMethod getType.
 RubyFixnum id()
           
 IRubyObject infectBy(IRubyObject obj)
          Infect this object using the taint of another object
 IRubyObject inspect()
          RubyMethod inspect.
 java.util.Iterator instanceVariableNames()
           
 boolean isFrozen()
          RubyMethod isFrozen.
 boolean isImmediate()
           
 boolean isKindOf(RubyModule rubyClass)
          RubyMethod isKindOf.
 boolean isNil()
          RubyMethod isNil.
 boolean isSingleton()
           
 boolean isTaint()
          RubyMethod isTaint.
 boolean isTrue()
           
 IRubyObject rbClone(Block unusedBlock)
          RubyMethod rbClone.
 void removeFinalizers()
           
 boolean respondsTo(java.lang.String string)
          RubyMethod respondsTo.
 java.util.Map safeGetInstanceVariables()
          Gets a copy of the instance variables for this object, if any exist.
 boolean safeHasInstanceVariables()
          Returns true if the object has any instance variables, false otherwise.
 void setFrozen(boolean b)
          RubyMethod setFrozen.
 IRubyObject setInstanceVariable(java.lang.String string, IRubyObject rubyObject)
          RubyMethod setInstanceVar.
 void setInstanceVariables(java.util.Map instanceVariables)
           
 void setMetaClass(RubyClass metaClass)
           
 void setTaint(boolean b)
          RubyMethod setTaint.
 

Field Detail

NULL_ARRAY

public static final IRubyObject[] NULL_ARRAY
Method Detail

getNativeTypeIndex

public int getNativeTypeIndex()
Return the ClassIndex value for the native type this object was constructed from. Particularly useful for determining marshalling format. All instances of subclasses of Hash, for example are of Java type RubyHash, and so should utilize RubyHash marshalling logic in addition to user-defined class marshalling logic.

Returns:
the ClassIndex of the native type this object was constructed from

safeGetInstanceVariables

public java.util.Map safeGetInstanceVariables()
Gets a copy of the instance variables for this object, if any exist. Returns null if this object has no instance variables. "safe" in that it doesn't cause the instance var map to be created.

Returns:
A snapshot of the instance vars, or null if none.

safeHasInstanceVariables

public boolean safeHasInstanceVariables()
Returns true if the object has any instance variables, false otherwise. "safe" in that it doesn't cause the instance var map to be created.

Returns:
true if the object has instance variables, false otherwise.

getInstanceVariable

public IRubyObject getInstanceVariable(java.lang.String string)
RubyMethod getInstanceVar.

Parameters:
string -
Returns:
RubyObject

setInstanceVariable

public IRubyObject setInstanceVariable(java.lang.String string,
                                       IRubyObject rubyObject)
RubyMethod setInstanceVar.

Parameters:
string -
rubyObject -
Returns:
RubyObject

getInstanceVariables

public java.util.Map getInstanceVariables()
Returns:

setInstanceVariables

public void setInstanceVariables(java.util.Map instanceVariables)
Parameters:
instanceVariables -

getInstanceVariablesSnapshot

public java.util.Map getInstanceVariablesSnapshot()
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              RubyModule rubyclass,
                              java.lang.String name,
                              IRubyObject[] args,
                              CallType callType,
                              Block block)
Parameters:
context -
rubyclass -
name -
args -
callType -
block -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              RubyModule rubyclass,
                              int methodIndex,
                              java.lang.String name,
                              IRubyObject[] args,
                              CallType callType,
                              Block block)
Parameters:
context -
rubyclass -
methodIndex -
name -
args -
callType -
block -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              int methodIndex,
                              java.lang.String name,
                              IRubyObject arg)
Parameters:
context -
methodIndex -
name -
arg -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              int methodIndex,
                              java.lang.String name,
                              IRubyObject[] args)
Parameters:
context -
methodIndex -
name -
args -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              int methodIndex,
                              java.lang.String name,
                              IRubyObject[] args,
                              CallType callType)
Parameters:
context -
methodIndex -
name -
args -
callType -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              java.lang.String name,
                              IRubyObject[] args,
                              CallType callType)
Parameters:
context -
name -
args -
callType -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              java.lang.String name,
                              IRubyObject[] args,
                              CallType callType,
                              Block block)
Parameters:
context -
name -
args -
callType -
block -
Returns:

compilerCallMethod

public IRubyObject compilerCallMethod(ThreadContext context,
                                      java.lang.String name,
                                      IRubyObject[] args,
                                      IRubyObject caller,
                                      CallType callType,
                                      Block block)
Parameters:
context -
name -
args -
caller -
callType -
block -
Returns:

compilerCallMethodWithIndex

public IRubyObject compilerCallMethodWithIndex(ThreadContext context,
                                               int methodIndex,
                                               java.lang.String name,
                                               IRubyObject[] args,
                                               IRubyObject caller,
                                               CallType callType,
                                               Block block)
Parameters:
context -
methodIndex -
name -
args -
caller -
callType -
block -
Returns:

callSuper

public IRubyObject callSuper(ThreadContext context,
                             IRubyObject[] args,
                             Block block)
Parameters:
context -
args -
block -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              java.lang.String string)
Parameters:
context -
string -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              int methodIndex,
                              java.lang.String string)
Parameters:
context -
string -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              java.lang.String string,
                              Block aBlock)
Parameters:
context -
string -
aBlock -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              java.lang.String string,
                              IRubyObject arg)
Parameters:
context -
string -
arg -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              java.lang.String method,
                              IRubyObject[] rubyArgs)
Parameters:
context -
method -
rubyArgs -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              java.lang.String method,
                              IRubyObject[] rubyArgs,
                              Block block)
Parameters:
context -
method -
rubyArgs -
block -
Returns:

isNil

public boolean isNil()
RubyMethod isNil.

Returns:
boolean

isTrue

public boolean isTrue()
Returns:

isTaint

public boolean isTaint()
RubyMethod isTaint.

Returns:
boolean

setTaint

public void setTaint(boolean b)
RubyMethod setTaint.

Parameters:
b -

isFrozen

public boolean isFrozen()
RubyMethod isFrozen.

Returns:
boolean

setFrozen

public void setFrozen(boolean b)
RubyMethod setFrozen.

Parameters:
b -

isImmediate

public boolean isImmediate()
Returns:

isKindOf

public boolean isKindOf(RubyModule rubyClass)
RubyMethod isKindOf.

Parameters:
rubyClass -
Returns:
boolean

infectBy

public IRubyObject infectBy(IRubyObject obj)
Infect this object using the taint of another object

Parameters:
obj -
Returns:

getMetaClass

public RubyClass getMetaClass()
RubyMethod getRubyClass.

Returns:

setMetaClass

public void setMetaClass(RubyClass metaClass)
Parameters:
metaClass -

getSingletonClass

public RubyClass getSingletonClass()
RubyMethod getSingletonClass.

Returns:
RubyClass

getType

public RubyClass getType()
RubyMethod getType.

Returns:
RubyClass

respondsTo

public boolean respondsTo(java.lang.String string)
RubyMethod respondsTo.

Parameters:
string -
Returns:
boolean

getRuntime

public Ruby getRuntime()
RubyMethod getRuntime.

Returns:

getJavaClass

public java.lang.Class getJavaClass()
RubyMethod getJavaClass.

Returns:
Class

evalWithBinding

public IRubyObject evalWithBinding(ThreadContext context,
                                   IRubyObject evalString,
                                   IRubyObject binding,
                                   java.lang.String file,
                                   int lineNumber)
Evaluate the given string under the specified binding object. If the binding is not a Proc or Binding object (RubyProc or RubyBinding) throw an appropriate type error.

Parameters:
context - TODO
evalString - The string containing the text to be evaluated
binding - The binding object under which to perform the evaluation
file - The filename to use when reporting errors during the evaluation
lineNumber - is the line number to pretend we are starting from
Returns:
An IRubyObject result from the evaluation

evalSimple

public IRubyObject evalSimple(ThreadContext context,
                              IRubyObject evalString,
                              java.lang.String file)
Evaluate the given string.

Parameters:
context - TODO
evalString - The string containing the text to be evaluated
file - The filename to use when reporting errors during the evaluation
Returns:
An IRubyObject result from the evaluation

asSymbol

public java.lang.String asSymbol()
Convert the object into a symbol name if possible.

Returns:
String the symbol name

asString

public RubyString asString()
rb_obj_as_string

Returns:

convertToArray

public RubyArray convertToArray()
Methods which perform to_xxx if the object has such a method

Returns:

convertToHash

public RubyHash convertToHash()
Returns:

convertToFloat

public RubyFloat convertToFloat()
Returns:

convertToInteger

public RubyInteger convertToInteger()
Returns:

convertToString

public RubyString convertToString()
Returns:

convertToType

public IRubyObject convertToType(RubyClass targetType,
                                 int convertMethodIndex,
                                 java.lang.String convertMethod,
                                 boolean raiseOnError)
Converts this object to type 'targetType' using 'convertMethod' method (MRI: convert_type).

Parameters:
targetType - is the type we are trying to convert to
convertMethod - is the method to be called to try and convert to targeType
raiseOnError - will throw an Error if conversion does not work
Returns:
the converted value

convertToTypeWithCheck

public IRubyObject convertToTypeWithCheck(RubyClass targetType,
                                          int convertMethodIndex,
                                          java.lang.String convertMethod)
Higher level conversion utility similiar to convertToType but it can throw an additional TypeError during conversion (MRI: rb_check_convert_type).

Parameters:
targetType - is the type we are trying to convert to
convertMethod - is the method to be called to try and convert to targeType
Returns:
the converted value

convertToType

public IRubyObject convertToType(RubyClass targetType,
                                 int convertMethodIndex,
                                 java.lang.String convertMethod,
                                 boolean raiseOnMissingMethod,
                                 boolean raiseOnWrongTypeResult,
                                 boolean allowNilThrough)
Parameters:
targetType -
convertMethod -
raiseOnMissingMethod -
raiseOnWrongTypeResult -
allowNilThrough -
Returns:

anyToString

public IRubyObject anyToString()
Returns:

checkStringType

public IRubyObject checkStringType()
Returns:

checkArrayType

public IRubyObject checkArrayType()
Returns:

dup

public IRubyObject dup()
RubyMethod dup.

Returns:

inspect

public IRubyObject inspect()
RubyMethod inspect.

Returns:
String

rbClone

public IRubyObject rbClone(Block unusedBlock)
RubyMethod rbClone.

Returns:
IRubyObject

isSingleton

public boolean isSingleton()
Returns:

instanceVariableNames

public java.util.Iterator instanceVariableNames()
Returns:

dataWrapStruct

public void dataWrapStruct(java.lang.Object obj)
Our version of Data_Wrap_Struct. This method will just set a private pointer to the object provided. This pointer is transient and will not be accessible from Ruby.

Parameters:
obj - the object to wrap

dataGetStruct

public java.lang.Object dataGetStruct()
Our version of Data_Get_Struct. Returns a wrapped data value if there is one, otherwise returns null.

Returns:
the object wrapped.

id

public RubyFixnum id()
Returns:

equal

public IRubyObject equal(IRubyObject other)

equalInternal

public IRubyObject equalInternal(ThreadContext context,
                                 IRubyObject other)

eql

public boolean eql(IRubyObject other)

eqlInternal

public boolean eqlInternal(ThreadContext context,
                           IRubyObject other)

addFinalizer

public void addFinalizer(RubyProc finalizer)

removeFinalizers

public void removeFinalizers()


Copyright © 2002-2007 JRuby Team. All Rights Reserved.