org.jruby
Class IncludedModuleWrapper

java.lang.Object
  extended by org.jruby.RubyObject
      extended by org.jruby.RubyModule
          extended by org.jruby.RubyClass
              extended by org.jruby.IncludedModuleWrapper
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, InstanceVariables, InternalVariables, IRubyObject, CoreObjectType

public final class IncludedModuleWrapper
extends RubyClass

This class is used to provide an intermediate superclass for modules and classes that include other modules. It inserts itself as the immediate superClass of the includer, but defers all module methods to the actual superclass. Multiple of these intermediate superclasses can be added for multiple included modules. This allows the normal superclass-based searches (searchMethod, getConstant, etc) to traverse the superclass ancestors as normal while the included modules do not actually show up in direct inheritance traversal.

See Also:
RubyModule, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jruby.RubyModule
RubyModule.ConstantTableEntry, RubyModule.KindOf, RubyModule.MethodClumper, RubyModule.ModuleKernelMethods
 
Nested classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.Finalizer, RubyObject.ObjectMethods, RubyObject.VariableTableEntry
 
Field Summary
 
Fields inherited from class org.jruby.RubyClass
CLASS_ALLOCATOR, DEFAULT_OBJECT_MARSHAL, marshal
 
Fields inherited from class org.jruby.RubyModule
classId, CONSTANT_TABLE_DEFAULT_CAPACITY, CONSTANT_TABLE_LOAD_FACTOR, CONSTANT_TABLE_MAXIMUM_CAPACITY, constantTable, constantTableSize, constantTableThreshold, dispatcher, ERR_FROZEN_CONST_TYPE, ERR_FROZEN_CVAR_TYPE, ERR_INSECURE_SET_CLASS_VAR, ERR_INSECURE_SET_CONSTANT, id, index, kindOf, parent, superClass, variableWriteLock
 
Fields inherited from class org.jruby.RubyObject
ALL_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, metaClass, metaClassName, NEVER, NIL_F, OBJECT_ALLOCATOR, TAINTED_F, UNDEF, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, VARIABLE_TABLE_DEFAULT_CAPACITY, VARIABLE_TABLE_EMPTY_TABLE, VARIABLE_TABLE_LOAD_FACTOR, VARIABLE_TABLE_MAXIMUM_CAPACITY, variableTable, variableTableSize, variableTableThreshold
 
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY
 
Constructor Summary
IncludedModuleWrapper(Ruby runtime, RubyClass superClass, RubyModule delegate)
           
 
Method Summary
 void addMethod(java.lang.String name, DynamicMethod method)
           
protected  boolean constantTableContains(java.lang.String name)
           
protected  boolean constantTableFastContains(java.lang.String internedName)
           
protected  IRubyObject constantTableFastFetch(java.lang.String internedName)
           
protected  IRubyObject constantTableFastStore(java.lang.String internedName, IRubyObject value)
           
protected  IRubyObject constantTableFetch(java.lang.String name)
           
protected  java.util.Map constantTableGetMap()
          Deprecated. 
protected  java.util.Map constantTableGetMap(java.util.Map map)
          Deprecated. 
protected  int constantTableGetSize()
           
protected  RubyModule.ConstantTableEntry[] constantTableGetTable()
           
protected  IRubyObject constantTableRemove(java.lang.String name)
           
protected  IRubyObject constantTableStore(java.lang.String name, IRubyObject value)
           
protected  void constantTableSync(java.util.List<Variable<IRubyObject>> vars)
           
 java.util.Map<java.lang.String,DynamicMethod> getMethods()
           
 java.lang.String getName()
          Generate a fully-qualified class name or a #-style name for anonymous and singleton classes.
 RubyModule getNonIncludedClass()
           
 RubyClass getRealClass()
           
 IRubyObject id()
          We don't want to reveal ourselves to Ruby code, so delegate this operation.
 boolean isClass()
          Specifically polymorphic method that are meant to be overridden by classes to specify that they are classes in an easy way.
 boolean isImmediate()
          Is object immediate (def: Fixnum, Symbol, true, false, nil?).
 boolean isIncluded()
          Is this module one that in an included one (e.g.
 boolean isModule()
          Specifically polymorphic method that are meant to be overridden by modules to specify that they are modules in an easy way.
protected  boolean isSame(RubyModule module)
           
 IncludedModuleWrapper newIncludeClass(RubyClass superClass)
          Overridden newIncludeClass implementation to allow attaching future includes to the correct module (i.e.
 void setMetaClass(RubyClass newRubyClass)
          Makes it possible to change the metaclass of an object.
 void setMethods(java.util.Map newMethods)
           
protected  boolean variableTableContains(java.lang.String name)
          Checks if the variable table contains a variable of the specified name.
protected  boolean variableTableFastContains(java.lang.String internedName)
          Checks if the variable table contains the the variable of the specified name, where the precondition is that the name must be an interned Java String.
protected  IRubyObject variableTableFastFetch(java.lang.String internedName)
          Fetch an object from the variable table based on the name, where the name must be an interned Java String.
protected  IRubyObject variableTableFastStore(java.lang.String internedName, IRubyObject value)
          Will store the value under the specified name, where the name needs to be an interned Java String.
protected  IRubyObject variableTableFetch(java.lang.String name)
          Fetch an object from the variable table based on the name.
protected  java.util.Map variableTableGetMap()
          Deprecated. 
protected  java.util.Map variableTableGetMap(java.util.Map map)
          Deprecated. 
protected  int variableTableGetSize()
          Get the size of the variable table.
protected  RubyObject.VariableTableEntry[] variableTableGetTable()
          Get the actual table used to save variable entries.
protected  IRubyObject variableTableReadLocked(RubyObject.VariableTableEntry entry)
          Reads the value of the specified entry, locked on the current object.
protected  IRubyObject variableTableRemove(java.lang.String name)
          Removes the entry with the specified name from the variable table, and returning the removed value.
protected  IRubyObject variableTableStore(java.lang.String name, IRubyObject value)
          Store a value in the variable store under the specific name.
protected  void variableTableSync(java.util.List<Variable<IRubyObject>> vars)
          Synchronize the variable table with the argument.
 
Methods inherited from class org.jruby.RubyClass
addSubclass, allocate, checkInheritable, createBootstrapClass, createClassClass, getAllocator, getClassRuntime, getMarshal, getNativeTypeIndex, inherit, inherited, initialize_copy, initialize, invoke, invoke, invoke, invokeInherited, isSingleton, makeMetaClass, marshal, marshalTo, newClass, newClass, newInstance, setAllocator, setMarshal, subclasses, subclasses, superclass, unmarshal, unmarshalFrom
 
Methods inherited from class org.jruby.RubyModule
addClassProvider, addModuleFunction, alias_method, ancestors, append_features, attr_accessor, attr_accessor, attr_reader, attr_reader, attr_writer, attr, class_variable_defined_p, class_variable_get, class_variable_set, class_variables, cloneMethods, const_defined_p, const_get, const_missing, const_set, constants, createModuleClass, define_method, defineAlias, defineAliases, defineAnnotatedConstant, defineAnnotatedConstants, defineAnnotatedMethod, defineAnnotatedMethod, defineAnnotatedMethod, defineAnnotatedMethod, defineAnnotatedMethods, defineAnnotatedMethodsIndividually, defineClassUnder, defineConstant, defineFastMethod, defineFastMethod, defineFastModuleFunction, defineFastPrivateMethod, defineFastProtectedMethod, defineFastPublicModuleFunction, defineMethod, defineModuleFunction, defineModuleUnder, defineOrGetClassUnder, defineOrGetModuleUnder, definePrivateMethod, definePublicModuleFunction, deleteClassVariable, deleteConstant, ensureClassVariablesSettable, ensureConstantsSettable, executeUnder, exportMethod, extend_object, extended, fastFetchClassVariable, fastFetchConstant, fastGetClass, fastGetClassVar, fastGetConstant, fastGetConstantAt, fastGetConstantFrom, fastHasClassVariable, fastHasConstant, fastIsClassVarDefined, fastIsConstantDefined, fastSetClassVar, fastSetConstant, fastStoreClassVariable, fastStoreConstant, fetchClassVariable, fetchConstant, findImplementer, freeze, getAncestorList, getBaseName, getClass, getClassVar, getClassVariableList, getClassVariableNameList, getConstant, getConstantAt, getConstantFrom, getDispatcher, getParent, getStoredConstantList, getStoredConstantNameList, getSuperClass, getVariableCount, getVariableList, getVariableMap, getVariableNameList, hasClassVariable, hasConstant, hash, hashCode, hasInternalModuleVariable, hasModuleInHierarchy, hasVariables, include_p, include, included_modules, included, includeModule, initialize, instance_method, instance_methods, isClassVarDefined, isConstantDefined, isInstance, isKindOfModule, isMethodBound, marshalTo, method_added, method_defined_p, method_removed, method_undefined, module_eval, module_function, name, needsImplementer, nesting, newMethod, newModule, newModule, op_cmp, op_eqq, op_equal, op_ge, op_gt, op_le, op_lt, private_class_method, private_instance_methods, private_method_defined, protected_instance_methods, protected_method_defined, public_class_method, public_instance_methods, public_method_defined, rbPrivate, rbProtected, rbPublic, remove_class_variable, remove_const, remove_method, removeClassProvider, removeCvar, removeMethod, retrieveMethod, searchInternalModuleVariable, searchMethod, setBaseName, setClassVar, setConstant, setInternalModuleVariable, setMethodVisibility, setParent, setSuperClass, storeClassVariable, storeConstant, syncVariables, to_s, undef_method, undef, undefineMethod, validateClassVariable, validateConstant
 
Methods inherited from class org.jruby.RubyObject
addFinalizer, anyToString, asJavaString, asString, attachToObjectSpace, callInit, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkFrozen, checkStringType, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToString, convertToType, copySpecialInstanceVariables, createObjectClass, dataGetStruct, dataWrapStruct, display, dup, ensureInstanceVariablesSettable, eql_p, eql, eqlInternal, equal_p, equalInternal, equals, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, frozen_p, getFlag, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariableList, getInternalVariables, getJavaClass, getMetaClass, getRuntime, getSingletonClass, getSingletonClassClone, getType, hasInstanceVariable, hasInternalVariable, id_deprecated, infectBy, initialize, inspect, instance_eval, instance_exec, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, isFalse, isFrozen, isNil, isRubyVariable, isTaint, isTrue, kind_of_p, method, methods, nil_p, op_eqq, op_match, private_methods, protected_methods, public_methods, puts, rbClone, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respondsTo, send, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setTaint, singleton_methods, specificEval, taint, tainted_p, testFrozen, to_a, toString, type_deprecated, type, untaint, validateInstanceVariable, variableTableRehash
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IncludedModuleWrapper

public IncludedModuleWrapper(Ruby runtime,
                             RubyClass superClass,
                             RubyModule delegate)
Method Detail

newIncludeClass

public IncludedModuleWrapper newIncludeClass(RubyClass superClass)
Overridden newIncludeClass implementation to allow attaching future includes to the correct module (i.e. the one to which this is attached)

Overrides:
newIncludeClass in class RubyModule
Returns:
The module wrapper
See Also:
RubyModule.newIncludeClass(RubyClass)

isModule

public boolean isModule()
Description copied from class: RubyObject
Specifically polymorphic method that are meant to be overridden by modules to specify that they are modules in an easy way.

Specified by:
isModule in interface IRubyObject
Overrides:
isModule in class RubyClass
Returns:
true if an object is Ruby Module instance (note that it will return false for Ruby Classes). If is_a? semantics is required, use (someObject instanceof RubyModule) instead.

isClass

public boolean isClass()
Description copied from class: RubyObject
Specifically polymorphic method that are meant to be overridden by classes to specify that they are classes in an easy way.

Specified by:
isClass in interface IRubyObject
Overrides:
isClass in class RubyClass
Returns:
true if an object is Ruby Class instance (note that it will return false for Ruby singleton classes). If is_a? semantics is required, use (someObject instanceof RubyClass/MetaClass) instead.

isIncluded

public boolean isIncluded()
Description copied from class: RubyModule
Is this module one that in an included one (e.g. an IncludedModuleWrapper).

Overrides:
isIncluded in class RubyModule

isImmediate

public boolean isImmediate()
Description copied from class: RubyObject
Is object immediate (def: Fixnum, Symbol, true, false, nil?).

Specified by:
isImmediate in interface IRubyObject
Overrides:
isImmediate in class RubyObject
Returns:

setMetaClass

public void setMetaClass(RubyClass newRubyClass)
Description copied from class: RubyObject
Makes it possible to change the metaclass of an object. In practice, this is a simple version of Smalltalks Become, except that it doesn't work when we're dealing with subclasses. In practice it's used to change the singleton/meta class used, without changing the "real" inheritence chain.

Overrides:
setMetaClass in class RubyObject

getMethods

public java.util.Map<java.lang.String,DynamicMethod> getMethods()
Overrides:
getMethods in class RubyModule

addMethod

public void addMethod(java.lang.String name,
                      DynamicMethod method)
Overrides:
addMethod in class RubyModule

setMethods

public void setMethods(java.util.Map newMethods)

getName

public java.lang.String getName()
Description copied from class: RubyModule
Generate a fully-qualified class name or a #-style name for anonymous and singleton classes. Ruby C equivalent = "classname"

Overrides:
getName in class RubyModule
Returns:
The generated class name

getNonIncludedClass

public RubyModule getNonIncludedClass()
Overrides:
getNonIncludedClass in class RubyModule

getRealClass

public RubyClass getRealClass()
Overrides:
getRealClass in class RubyClass

isSame

protected boolean isSame(RubyModule module)
Overrides:
isSame in class RubyModule

id

public IRubyObject id()
We don't want to reveal ourselves to Ruby code, so delegate this operation.

Specified by:
id in interface IRubyObject
Overrides:
id in class RubyObject
Returns:

variableTableContains

protected boolean variableTableContains(java.lang.String name)
Description copied from class: RubyObject
Checks if the variable table contains a variable of the specified name.

Overrides:
variableTableContains in class RubyObject

variableTableFastContains

protected boolean variableTableFastContains(java.lang.String internedName)
Description copied from class: RubyObject
Checks if the variable table contains the the variable of the specified name, where the precondition is that the name must be an interned Java String.

Overrides:
variableTableFastContains in class RubyObject

variableTableFetch

protected IRubyObject variableTableFetch(java.lang.String name)
Description copied from class: RubyObject
Fetch an object from the variable table based on the name.

Overrides:
variableTableFetch in class RubyObject
Returns:
the object or null if not found

variableTableFastFetch

protected IRubyObject variableTableFastFetch(java.lang.String internedName)
Description copied from class: RubyObject
Fetch an object from the variable table based on the name, where the name must be an interned Java String.

Overrides:
variableTableFastFetch in class RubyObject
Returns:
the object or null if not found

variableTableStore

protected IRubyObject variableTableStore(java.lang.String name,
                                         IRubyObject value)
Description copied from class: RubyObject
Store a value in the variable store under the specific name.

Overrides:
variableTableStore in class RubyModule

variableTableFastStore

protected IRubyObject variableTableFastStore(java.lang.String internedName,
                                             IRubyObject value)
Description copied from class: RubyObject
Will store the value under the specified name, where the name needs to be an interned Java String.

Overrides:
variableTableFastStore in class RubyModule

variableTableRemove

protected IRubyObject variableTableRemove(java.lang.String name)
Description copied from class: RubyObject
Removes the entry with the specified name from the variable table, and returning the removed value.

Overrides:
variableTableRemove in class RubyModule

variableTableGetTable

protected RubyObject.VariableTableEntry[] variableTableGetTable()
Description copied from class: RubyObject
Get the actual table used to save variable entries.

Overrides:
variableTableGetTable in class RubyObject

variableTableGetSize

protected int variableTableGetSize()
Description copied from class: RubyObject
Get the size of the variable table.

Overrides:
variableTableGetSize in class RubyObject

variableTableSync

protected void variableTableSync(java.util.List<Variable<IRubyObject>> vars)
Description copied from class: RubyObject
Synchronize the variable table with the argument. In real terms this means copy all entries into a newly allocated table.

Overrides:
variableTableSync in class RubyModule

variableTableReadLocked

protected IRubyObject variableTableReadLocked(RubyObject.VariableTableEntry entry)
Description copied from class: RubyObject
Reads the value of the specified entry, locked on the current object.

Overrides:
variableTableReadLocked in class RubyModule

variableTableGetMap

@Deprecated
protected java.util.Map variableTableGetMap()
Deprecated. 

Method to help ease transition to new variables implementation. Will likely be deprecated in the near future.

Overrides:
variableTableGetMap in class RubyObject

variableTableGetMap

@Deprecated
protected java.util.Map variableTableGetMap(java.util.Map map)
Deprecated. 

Method to help ease transition to new variables implementation. Will likely be deprecated in the near future.

Overrides:
variableTableGetMap in class RubyObject

constantTableContains

protected boolean constantTableContains(java.lang.String name)
Overrides:
constantTableContains in class RubyModule

constantTableFastContains

protected boolean constantTableFastContains(java.lang.String internedName)
Overrides:
constantTableFastContains in class RubyModule

constantTableFetch

protected IRubyObject constantTableFetch(java.lang.String name)
Overrides:
constantTableFetch in class RubyModule

constantTableFastFetch

protected IRubyObject constantTableFastFetch(java.lang.String internedName)
Overrides:
constantTableFastFetch in class RubyModule

constantTableStore

protected IRubyObject constantTableStore(java.lang.String name,
                                         IRubyObject value)
Overrides:
constantTableStore in class RubyModule

constantTableFastStore

protected IRubyObject constantTableFastStore(java.lang.String internedName,
                                             IRubyObject value)
Overrides:
constantTableFastStore in class RubyModule

constantTableRemove

protected IRubyObject constantTableRemove(java.lang.String name)
Overrides:
constantTableRemove in class RubyModule

constantTableGetTable

protected RubyModule.ConstantTableEntry[] constantTableGetTable()
Overrides:
constantTableGetTable in class RubyModule

constantTableGetSize

protected int constantTableGetSize()
Overrides:
constantTableGetSize in class RubyModule

constantTableSync

protected void constantTableSync(java.util.List<Variable<IRubyObject>> vars)
Overrides:
constantTableSync in class RubyModule

constantTableGetMap

@Deprecated
protected java.util.Map constantTableGetMap()
Deprecated. 

Method to help ease transition to new variables implementation. Will likely be deprecated in the near future.

Overrides:
constantTableGetMap in class RubyModule

constantTableGetMap

@Deprecated
protected java.util.Map constantTableGetMap(java.util.Map map)
Deprecated. 

Method to help ease transition to new variables implementation. Will likely be deprecated in the near future.

Overrides:
constantTableGetMap in class RubyModule


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