org.jruby.ext.ffi
Class StructLayout.Member

java.lang.Object
  extended by org.jruby.ext.ffi.StructLayout.Member
Enclosing class:
StructLayout

public abstract static class StructLayout.Member
extends java.lang.Object

A struct member. This defines the offset within a chunk of memory to use when reading/writing the member, as well as how to convert between the native representation of the member and the JRuby representation.


Field Summary
protected  int index
          The index of this member within the struct
protected  long offset
          The offset within the memory area of this member
protected  Type type
          The Type of this member.
 
Constructor Summary
protected StructLayout.Member(Type type, int index, long offset)
          Initializes a new Member instance
 
Method Summary
 boolean equals(java.lang.Object obj)
           
abstract  IRubyObject get(Ruby runtime, StructLayout.Storage cache, IRubyObject ptr)
          Reads a ruby value from the struct member.
 NativeType getNativeType()
           
 int hashCode()
           
protected  boolean isCacheable()
          Gets the cacheable status of this Struct member
protected  boolean isValueReferenceNeeded()
          Checks if a reference to the ruby object assigned to this field needs to be stored
abstract  void put(Ruby runtime, StructLayout.Storage cache, IRubyObject ptr, IRubyObject value)
          Writes a ruby value to the native struct member as the appropriate native value.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

protected final Type type
The Type of this member.


offset

protected final long offset
The offset within the memory area of this member


index

protected final int index
The index of this member within the struct

Constructor Detail

StructLayout.Member

protected StructLayout.Member(Type type,
                              int index,
                              long offset)
Initializes a new Member instance

Method Detail

getNativeType

public final NativeType getNativeType()

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

put

public abstract void put(Ruby runtime,
                         StructLayout.Storage cache,
                         IRubyObject ptr,
                         IRubyObject value)
Writes a ruby value to the native struct member as the appropriate native value.

Parameters:
runtime - The ruby runtime
cache - The value cache
ptr - The struct memory area.
value - The ruby value to write to the native struct member.

get

public abstract IRubyObject get(Ruby runtime,
                                StructLayout.Storage cache,
                                IRubyObject ptr)
Reads a ruby value from the struct member.

Parameters:
cache - The cache used to store
ptr - The struct memory area.
Returns:
A ruby object equivalent to the native member value.

isCacheable

protected boolean isCacheable()
Gets the cacheable status of this Struct member

Returns:
true if this member type is cacheable

isValueReferenceNeeded

protected boolean isValueReferenceNeeded()
Checks if a reference to the ruby object assigned to this field needs to be stored

Returns:
true if this member type requires the ruby value to be stored.


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