Top Fields Constructors Methods
org.jruby.ext.ffi

public Class Struct

extends MemoryObject
implements Storage
Class Inheritance
All Implemented Interfaces
org.jruby.ext.ffi.StructLayout.Storage
Annotations
@JRubyClass
name:FFI::Struct
parent:Object
Imports
java.nio.ByteOrder, java.util.concurrent.atomic.AtomicReferenceFieldUpdater, org.jruby.*, org.jruby.anno.JRubyClass, .JRubyMethod, org.jruby.api.Access, org.jruby.runtime.ObjectAllocator, .ThreadContext, org.jruby.runtime.builtin.IRubyObject, org.jruby.util.cli.Options

Field Summary

Modifier and TypeField and Description
private StructLayout
private AbstractMemory
private volatile Object[]
private static final AtomicReferenceFieldUpdater<Struct, Object[]>
private volatile IRubyObject[]
private static final AtomicReferenceFieldUpdater<Struct, IRubyObject[]>

Constructor Summary

AccessConstructor and Description
pack-priv
Struct(Ruby
The runtime for the StructLayout
runtime
)

Creates a new StructLayout instance using defaults.

public
Struct(Ruby
The runtime for the StructLayout
runtime
,
RubyClass
the ruby class to use for the StructLayout
klass
)

Creates a new StructLayout instance.

pack-priv
Struct(Ruby
The runtime for the StructLayout
runtime
,
RubyClass
the ruby class to use for the StructLayout
klass
,
StructLayout layout, IRubyObject memory)

Creates a new StructLayout instance.

Method Summary

Modifier and TypeMethod and Description
public static IRubyObject
alignment(ThreadContext context, IRubyObject structClass)

public IRubyObject
public static IRubyObject
public static IRubyObject
allocateIn(ThreadContext context, IRubyObject klass, IRubyObject clearArg)

public static IRubyObject
public static IRubyObject
protected final MemoryIO
public static IRubyObject
public static IRubyObject
private static final Struct
allocateStruct(ThreadContext context, IRubyObject klass, int flags)

public IRubyObject
public static RubyClass

Returns:

The new class
createStructClass
(ThreadContext
the current thread context
context
,
RubyModule
reference to FFI module
FFI
)

Registers the StructLayout class in the JRuby runtime.

public final IRubyObject
public IRubyObject
public IRubyObject
public final AbstractMemory
private Object[]
pack-priv static final StructLayout
pack-priv static final int
getStructSize(ThreadContext context, IRubyObject structClass)

private IRubyObject[]
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
initialize_copy(ThreadContext
the thread context
context
,
IRubyObject
the original
other
)

Overrides org.jruby.RubyBasicObject.initialize_copy.

Initializes this object as a copy of the original, that is the parameter to this object.

private Object[]
private IRubyObject[]
pack-priv static final boolean
public static IRubyObject
members(ThreadContext context, IRubyObject structClass)

public IRubyObject
public IRubyObject
public static IRubyObject
offset_of(ThreadContext context, IRubyObject structClass, IRubyObject fieldName)

public IRubyObject
offset_of(ThreadContext context, IRubyObject fieldName)

public static IRubyObject
offsets(ThreadContext context, IRubyObject structClass)

public IRubyObject
public final IRubyObject
public final IRubyObject
order(ThreadContext context, IRubyObject byte_order)

public IRubyObject
public final void
public void
public static IRubyObject
set_layout(ThreadContext context, IRubyObject structClass, IRubyObject layout)

public IRubyObject
setFieldValue(ThreadContext context, IRubyObject fieldName, IRubyObject fieldValue)

public static IRubyObject
size(ThreadContext context, IRubyObject structClass)

public IRubyObject
public IRubyObject
Inherited from org.jruby.ext.ffi.MemoryObject:
getMemoryIOsetMemoryIO

Field Detail

layoutback to summary
private StructLayout layout
memoryback to summary
private AbstractMemory memory

Hides org.jruby.ext.ffi.MemoryObject.memory.

referenceCacheback to summary
private volatile Object[] referenceCache
referenceCacheUpdaterback to summary
private static final AtomicReferenceFieldUpdater<Struct, Object[]> referenceCacheUpdater
valueCacheback to summary
private volatile IRubyObject[] valueCache
valueCacheUpdaterback to summary
private static final AtomicReferenceFieldUpdater<Struct, IRubyObject[]> valueCacheUpdater

Constructor Detail

Structback to summary
pack-priv Struct(Ruby runtime)

Creates a new StructLayout instance using defaults.

Parameters
runtime:Ruby

The runtime for the StructLayout

Structback to summary
public Struct(Ruby runtime, RubyClass klass)

Creates a new StructLayout instance.

Parameters
runtime:Ruby

The runtime for the StructLayout

klass:RubyClass

the ruby class to use for the StructLayout

Structback to summary
pack-priv Struct(Ruby runtime, RubyClass klass, StructLayout layout, IRubyObject memory)

Creates a new StructLayout instance.

Parameters
runtime:Ruby

The runtime for the StructLayout

klass:RubyClass

the ruby class to use for the StructLayout

Method Detail

alignmentback to summary
public static IRubyObject alignment(ThreadContext context, IRubyObject structClass)
Annotations
@JRubyMethod
name:alignment
meta:true
alignmentback to summary
public IRubyObject alignment(ThreadContext context)
Annotations
@JRubyMethod
name:alignment
allocateInback to summary
public static IRubyObject allocateIn(ThreadContext context, IRubyObject klass)
Annotations
@JRubyMethod
name:new_in, alloc_in
meta:true
allocateInback to summary
public static IRubyObject allocateIn(ThreadContext context, IRubyObject klass, IRubyObject clearArg)
Annotations
@JRubyMethod
name:new_in, alloc_in
meta:true
allocateInOutback to summary
public static IRubyObject allocateInOut(ThreadContext context, IRubyObject klass)
Annotations
@JRubyMethod
name:new_inout, alloc_inout
meta:true
allocateInOutback to summary
public static IRubyObject allocateInOut(ThreadContext context, IRubyObject klass, IRubyObject clearArg)
Annotations
@JRubyMethod
name:new_inout, alloc_inout
meta:true
allocateMemoryIOback to summary
protected final MemoryIO allocateMemoryIO()

Implements abstract org.jruby.ext.ffi.MemoryObject.allocateMemoryIO.

allocateOutback to summary
public static IRubyObject allocateOut(ThreadContext context, IRubyObject klass)
Annotations
@JRubyMethod
name:new_out, alloc_out
meta:true
allocateOutback to summary
public static IRubyObject allocateOut(ThreadContext context, IRubyObject klass, IRubyObject clearArg)
Annotations
@JRubyMethod
name:new_out, alloc_out
meta:true
allocateStructback to summary
private static final Struct allocateStruct(ThreadContext context, IRubyObject klass, int flags)
clearback to summary
public IRubyObject clear(ThreadContext context)
Annotations
@JRubyMethod
name:clear
createStructClassback to summary
public static RubyClass createStructClass(ThreadContext context, RubyModule FFI)

Registers the StructLayout class in the JRuby runtime.

Parameters
context:ThreadContext

the current thread context

FFI:RubyModule

reference to FFI module

Returns:RubyClass

The new class

getCachedValueback to summary
public final IRubyObject getCachedValue(StructLayout.Member member)

Implements org.jruby.ext.ffi.StructLayout.Storage.getCachedValue.

getFieldValueback to summary
public IRubyObject getFieldValue(ThreadContext context, IRubyObject fieldName)
Annotations
@JRubyMethod
name:[]
getLayoutback to summary
public IRubyObject getLayout(ThreadContext context)
Annotations
@JRubyMethod
name:cspec, layout
getMemoryback to summary
public final AbstractMemory getMemory()
getReferenceCacheback to summary
private Object[] getReferenceCache()
getStructLayoutback to summary
pack-priv static final StructLayout getStructLayout(ThreadContext context, IRubyObject structClass)
getStructSizeback to summary
pack-priv static final int getStructSize(ThreadContext context, IRubyObject structClass)
getValueCacheForWriteback to summary
private IRubyObject[] getValueCacheForWrite()
initializeback to summary
public IRubyObject initialize(ThreadContext context)

Overrides org.jruby.RubyBasicObject.initialize.

Annotations
@Override
@JRubyMethod
name:initialize
visibility:PRIVATE
initializeback to summary
public IRubyObject initialize(ThreadContext context, IRubyObject ptr)
Annotations
@JRubyMethod
name:initialize
visibility:PRIVATE
initializeback to summary
public IRubyObject initialize(ThreadContext context, IRubyObject[] args)
Annotations
@JRubyMethod
name:initialize
visibility:PRIVATE
rest:true
initialize_copyback to summary
public IRubyObject initialize_copy(ThreadContext context, IRubyObject other)

Overrides org.jruby.RubyBasicObject.initialize_copy.

Doc from org.jruby.RubyBasicObject.initialize_copy.

Initializes this object as a copy of the original, that is the parameter to this object. Will make sure that the argument actually has the same real class as this object. It shouldn't be possible to initialize an object with something totally different.

Parameters
context:ThreadContext

the thread context

other:IRubyObject

the original

Returns:IRubyObject

a copy unless the same thing

Annotations
@JRubyMethod
name:initialize_copy
visibility:PRIVATE
initReferenceCacheback to summary
private Object[] initReferenceCache()
initValueCacheback to summary
private IRubyObject[] initValueCache()
isStructback to summary
pack-priv static final boolean isStruct(ThreadContext context, RubyClass klass)
membersback to summary
public static IRubyObject members(ThreadContext context, IRubyObject structClass)
Annotations
@JRubyMethod
name:members
meta:true
membersback to summary
public IRubyObject members(ThreadContext context)
Annotations
@JRubyMethod
name:members
null_pback to summary
public IRubyObject null_p(ThreadContext context)
Annotations
@JRubyMethod
name:null?
offset_ofback to summary
public static IRubyObject offset_of(ThreadContext context, IRubyObject structClass, IRubyObject fieldName)
Annotations
@JRubyMethod
name:offset_of
meta:true
offset_ofback to summary
public IRubyObject offset_of(ThreadContext context, IRubyObject fieldName)
Annotations
@JRubyMethod
name:offset_of
offsetsback to summary
public static IRubyObject offsets(ThreadContext context, IRubyObject structClass)
Annotations
@JRubyMethod
name:offsets
meta:true
offsetsback to summary
public IRubyObject offsets(ThreadContext context)
Annotations
@JRubyMethod
name:offsets
orderback to summary
public final IRubyObject order(ThreadContext context)
Annotations
@JRubyMethod
name:order
orderback to summary
public final IRubyObject order(ThreadContext context, IRubyObject byte_order)
Annotations
@JRubyMethod
name:order
pointerback to summary
public IRubyObject pointer(ThreadContext context)
Annotations
@JRubyMethod
name:pointer, to_ptr
putCachedValueback to summary
public final void putCachedValue(StructLayout.Member member, IRubyObject value)

Implements org.jruby.ext.ffi.StructLayout.Storage.putCachedValue.

putReferenceback to summary
public void putReference(StructLayout.Member member, Object value)

Implements org.jruby.ext.ffi.StructLayout.Storage.putReference.

set_layoutback to summary
public static IRubyObject set_layout(ThreadContext context, IRubyObject structClass, IRubyObject layout)
Annotations
@JRubyMethod
name:layout=
meta:true
setFieldValueback to summary
public IRubyObject setFieldValue(ThreadContext context, IRubyObject fieldName, IRubyObject fieldValue)
Annotations
@JRubyMethod
name:[]=
sizeback to summary
public static IRubyObject size(ThreadContext context, IRubyObject structClass)
Annotations
@JRubyMethod
name:size
meta:true
sizeback to summary
public IRubyObject size(ThreadContext context)
Annotations
@JRubyMethod
name:size
valuesback to summary
public IRubyObject values(ThreadContext context)
Annotations
@JRubyMethod
name:values