public class VariableTableManager
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private VariableAccessorField |
cextHandleVariableAccessorField
a lazy accessor for C ext handle
|
private static java.lang.String[] |
EMPTY_STRING_ARRAY
an empty array of String
|
private VariableAccessorField |
ffiHandleVariableAccessorField
a lazy accessor for FFI handle
|
private int |
fieldVariables
whether objects associated with this table use fields
|
private boolean |
hasObjectID
whether a slot has been allocated to object_id
|
private VariableAccessorField |
objectGroupVariableAccessorField
a lazy accessor for object group
|
private VariableAccessorField |
objectIdVariableAccessorField
a lazy accessor for object_id
|
private RubyClass |
realClass
the "real" class associated with this table
|
private java.util.Map<java.lang.String,VariableAccessor> |
variableAccessors
a map from strings to accessors for this table
|
private java.lang.String[] |
variableNames
an array of all registered variable names
|
| Constructor and Description |
|---|
VariableTableManager(RubyClass realClass)
Construct a new VariableTable Manager for the given "real" class.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) VariableAccessor |
allocateVariableAccessor(java.lang.String name)
Allocate a new VariableAccessor for the named variable.
|
(package private) VariableAccessor |
allocateVariableAccessorForVar(java.lang.String name,
int index) |
java.lang.Object |
clearVariable(RubyBasicObject object,
java.lang.String name) |
void |
deserializeVariables(RubyBasicObject object,
java.io.ObjectInputStream ois) |
java.lang.Object |
getFFIHandle(RubyBasicObject self)
Retrieve the FFI ext handle for the given object.
|
VariableAccessorField |
getFFIHandleAccessorField()
Retrieve the lazy accessor (VariableAccessorField) for FFI handle.
|
VariableAccessor |
getFFIHandleAccessorForRead()
Retrieve the read accessor for FFI handle.
|
VariableAccessor |
getFFIHandleAccessorForWrite()
Retrieve the write accessor for FFI handle.
|
java.lang.Object |
getNativeHandle(RubyBasicObject self)
Retrieve the C ext handle for the given object.
|
VariableAccessorField |
getNativeHandleAccessorField()
Retrieve the lazy accessor (VariableAccessorField) for C ext handle.
|
VariableAccessor |
getNativeHandleAccessorForRead()
Retrieve the read accessor for C ext handle.
|
VariableAccessor |
getNativeHandleAccessorForWrite()
Retrieve the write accessor for C ext handle.
|
VariableAccessorField |
getObjectGroupAccessorField()
Retrieve the lazy accessor (VariableAccessorField) for object group.
|
VariableAccessor |
getObjectGroupAccessorForRead()
Retrieve the read accessor for object group.
|
VariableAccessor |
getObjectGroupAccessorForWrite()
Retrieve the write accessor for object group.
|
long |
getObjectId(RubyBasicObject self)
Get the object_id from a given RubyBasicObject, possibly allocating
space for it.
|
VariableAccessorField |
getObjectIdAccessorField()
Retrieve the lazy accessor (VariableAccessorField) for object_id.
|
VariableAccessor |
getVariableAccessorForRead(java.lang.String name)
Get the variable accessor for the given name with intent to use it for
reading.
|
VariableAccessor |
getVariableAccessorForVar(java.lang.String name,
int index) |
VariableAccessor |
getVariableAccessorForWrite(java.lang.String name)
Get the variable accessor for the given name with intent to use it for
writing.
|
java.util.Map<java.lang.String,VariableAccessor> |
getVariableAccessorsForRead()
Get the map of all current variable accessors with intent to read from it.
|
java.lang.String[] |
getVariableNames()
Get an array of all the known instance variable names.
|
java.util.Map<java.lang.String,VariableAccessor> |
getVariableTableCopy()
Get a Map representing all variables registered in the variable table.
|
int |
getVariableTableSize()
Get the size of the variable table, excluding extra vars (object_id,
etc).
|
int |
getVariableTableSizeWithExtras()
Get the size of the variable table, including extra vars (object_etc,
etc).
|
boolean |
hasObjectID()
Whether this table has been used to allocate space for an object_id.
|
boolean |
hasVariables(RubyBasicObject object)
Returns true if object has any variables, defined as:
instance variables
class variables
constants
internal variables, such as those used when marshaling Ranges and Exceptions
|
private long |
initObjectId(RubyBasicObject self,
VariableAccessor objectIdAccessor)
We lazily stand up the object ID since it forces us to stand up
per-object state for a given object.
|
private static java.lang.Object[] |
makeSyncedTable(java.lang.Object[] currentTable,
java.lang.Object[] otherTable,
int objectIdIdx)
Make a new variable table based on the values in a current and other
(incoming) table, excluding object_id at specified index.
|
void |
serializeVariables(RubyBasicObject object,
java.io.ObjectOutputStream oos) |
void |
setFFIHandle(RubyBasicObject self,
java.lang.Object value)
Set the FFI handle for the given object.
|
void |
setNativeHandle(RubyBasicObject self,
java.lang.Object value)
Set the C ext handle for the given object.
|
private static void |
setObjectId(RubyClass realClass,
RubyBasicObject self,
int index,
long value)
Update object_id with the given value.
|
void |
setVariableInternal(RubyBasicObject self,
int index,
java.lang.Object value)
Virtual entry point for setting a variable into an object.
|
static void |
setVariableInternal(RubyClass realClass,
RubyBasicObject self,
int index,
java.lang.Object value)
Static entry point for setting a variable in an object.
|
void |
syncVariables(RubyBasicObject self,
IRubyObject other)
Sync one this object's variables with other's - this is used to make
rbClone work correctly.
|
private final RubyClass realClass
private static java.lang.String[] EMPTY_STRING_ARRAY
private java.util.Map<java.lang.String,VariableAccessor> variableAccessors
private volatile java.lang.String[] variableNames
private volatile boolean hasObjectID
private volatile int fieldVariables
private final VariableAccessorField objectIdVariableAccessorField
private final VariableAccessorField cextHandleVariableAccessorField
private final VariableAccessorField ffiHandleVariableAccessorField
private final VariableAccessorField objectGroupVariableAccessorField
public VariableTableManager(RubyClass realClass)
realClass - the "real" class associated with this tablepublic java.util.Map<java.lang.String,VariableAccessor> getVariableAccessorsForRead()
public boolean hasObjectID()
public long getObjectId(RubyBasicObject self)
self - the object from which to get object_idpublic void setVariableInternal(RubyBasicObject self, int index, java.lang.Object value)
self - the object into which to set the valueindex - the index allocated for the valuevalue - the valuepublic static void setVariableInternal(RubyClass realClass, RubyBasicObject self, int index, java.lang.Object value)
realClass - the "real" class of the objectself - the object into which to set the variableindex - the index allocated for the variablevalue - the value of the variablepublic VariableAccessor getVariableAccessorForWrite(java.lang.String name)
name - the name of the variablepublic VariableAccessor getVariableAccessorForVar(java.lang.String name, int index)
public VariableAccessor getVariableAccessorForRead(java.lang.String name)
name - the name of the variablepublic VariableAccessorField getObjectIdAccessorField()
public VariableAccessorField getNativeHandleAccessorField()
public VariableAccessor getNativeHandleAccessorForRead()
public VariableAccessor getNativeHandleAccessorForWrite()
public VariableAccessorField getFFIHandleAccessorField()
public VariableAccessor getFFIHandleAccessorForRead()
public VariableAccessor getFFIHandleAccessorForWrite()
public VariableAccessorField getObjectGroupAccessorField()
public VariableAccessor getObjectGroupAccessorForRead()
public VariableAccessor getObjectGroupAccessorForWrite()
public final java.lang.Object getNativeHandle(RubyBasicObject self)
self - the objectpublic final void setNativeHandle(RubyBasicObject self, java.lang.Object value)
self - the objectvalue - the object's C ext handlepublic final java.lang.Object getFFIHandle(RubyBasicObject self)
self - the objectpublic final void setFFIHandle(RubyBasicObject self, java.lang.Object value)
self - the objectself - the object's FFI handlepublic int getVariableTableSize()
public int getVariableTableSizeWithExtras()
public java.util.Map<java.lang.String,VariableAccessor> getVariableTableCopy()
public java.lang.String[] getVariableNames()
public void syncVariables(RubyBasicObject self, IRubyObject other)
self - the object into which to sync variablesother - the object from which to sync variablespublic boolean hasVariables(RubyBasicObject object)
public void serializeVariables(RubyBasicObject object, java.io.ObjectOutputStream oos) throws java.io.IOException
java.io.IOExceptionpublic void deserializeVariables(RubyBasicObject object, java.io.ObjectInputStream ois) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOExceptionjava.lang.ClassNotFoundExceptionpublic java.lang.Object clearVariable(RubyBasicObject object, java.lang.String name)
private long initObjectId(RubyBasicObject self, VariableAccessor objectIdAccessor)
objectIdAccessor - The variable accessor to use for storing the
generated object IDprivate static void setObjectId(RubyClass realClass, RubyBasicObject self, int index, long value)
self - the object into which to set object_idindex - the index allocated to store object_idvalue - the value of object_idprivate static java.lang.Object[] makeSyncedTable(java.lang.Object[] currentTable,
java.lang.Object[] otherTable,
int objectIdIdx)
currentTable - the current tableotherTable - the other (incoming) tableobjectIdIdx - the index of object_id to excludefinal VariableAccessor allocateVariableAccessor(java.lang.String name)
name - the name of the variablefinal VariableAccessor allocateVariableAccessorForVar(java.lang.String name, int index)