Package jnr.ffi
Class Struct
- java.lang.Object
-
- jnr.ffi.Struct
-
- Direct Known Subclasses:
Union
public abstract class Struct extends java.lang.ObjectRepresentation of C structures in java. Note: This class is not threadsafe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classStruct.AbstractBooleanBase class for Boolean fieldsprotected classStruct.AbstractMemberBase implementation of MemberclassStruct.AddressRepresents a native memory address.static classStruct.AlignmentclassStruct.AsciiStringclassStruct.AsciiStringRefclassStruct.blkcnt_tclassStruct.blksize_tclassStruct.BOOL16classStruct.BooleanA normal C boolean - 1 byte in sizeclassStruct.BYTEclassStruct.caddr_tclassStruct.cc_tclassStruct.clock_tclassStruct.dev_tclassStruct.DoubleclassStruct.DWORDclassStruct.Enum<T extends java.lang.Enum<T>>classStruct.Enum16<E extends java.lang.Enum<E>>classStruct.Enum32<E extends java.lang.Enum<E>>classStruct.Enum64<E extends java.lang.Enum<E>>classStruct.Enum8<E extends java.lang.Enum<E>>An 8 bit enum field.protected classStruct.EnumField<E>Base for all the Enum fields.classStruct.EnumLong<E extends java.lang.Enum<E>>classStruct.FloatclassStruct.fsblkcnt_tclassStruct.fsfilcnt_tclassStruct.Function<T>classStruct.gid_tclassStruct.id_tclassStruct.in_addr_tclassStruct.in_port_t(package private) static classStruct.InfoclassStruct.ino_tclassStruct.ino64_tclassStruct.int16_tclassStruct.int32_tclassStruct.int64_tclassStruct.int8_tclassStruct.IntegerAliasclassStruct.intptr_tclassStruct.key_tclassStruct.LONGprotected classStruct.MemberInterface all Struct members must implement.classStruct.mode_tclassStruct.nlink_tclassStruct.NumberFieldBase class for all Number structure fields.classStruct.off_tstatic classStruct.Offsetprotected classStruct.PaddingSpecialized padding fields for structs.classStruct.pid_tclassStruct.PointerRepresents a native memory address.classStruct.PointerFieldclassStruct.rlim_tclassStruct.sa_family_tclassStruct.Signed16A 16 bit signed integer field.classStruct.Signed32A 32 bit signed integer field.classStruct.Signed64A 64 bit signed integer field.classStruct.Signed8An 8 bit signed integerclassStruct.SignedLongA native long integer field.classStruct.size_tclassStruct.socklen_tclassStruct.speed_tclassStruct.ssize_tclassStruct.StringclassStruct.StructRef<T extends Struct>Represents a reference to a Struct or and array of StructsclassStruct.swblk_tclassStruct.tcflag_tclassStruct.time_tclassStruct.u_int16_tclassStruct.u_int32_tclassStruct.u_int64_tclassStruct.u_int8_tclassStruct.uid_tclassStruct.uintptr_tclassStruct.Unsigned16A 16 bit signed integer field.classStruct.Unsigned32A 32 bit signed integer field.classStruct.Unsigned64A 64 bit unsigned integer field.classStruct.Unsigned8An 8 bit unsigned integerclassStruct.UnsignedLongA native long integer field.classStruct.UTF8StringclassStruct.UTF8StringRefclassStruct.UTFStringclassStruct.UTFStringRefclassStruct.WBOOLA Windows BOOL - 4 bytesclassStruct.WORD
-
Field Summary
Fields Modifier and Type Field Description (package private) Struct.Info__info(package private) static java.nio.charset.CharsetASCII(package private) static java.nio.charset.CharsetUTF8
-
Constructor Summary
Constructors Modifier Constructor Description protectedStruct(Runtime runtime)Creates a newStruct.protectedStruct(Runtime runtime, boolean isUnion)Creates a new Struct.protectedStruct(Runtime runtime, Struct enclosing)protectedStruct(Runtime runtime, Struct.Alignment alignment)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static intalign(int offset, int align)static intalignment(Struct struct)protected Struct.Address[]array(Struct.Address[] array)Creates an array of Address instances.protected Struct.Double[]array(Struct.Double[] array)Creates an array of Double instances.protected <T extends java.lang.Enum<T>>
Struct.Enum<T>[]array(Struct.Enum<T>[] array, java.lang.Class<T> enumClass)Creates an array of Enum instances.protected <T extends java.lang.Enum<T>>
Struct.Enum16<T>[]array(Struct.Enum16<T>[] array, java.lang.Class<T> enumClass)Creates an array of Enum16 instances.protected <T extends java.lang.Enum<T>>
Struct.Enum32<T>[]array(Struct.Enum32<T>[] array, java.lang.Class<T> enumClass)Creates an array of Enum32 instances.protected <T extends java.lang.Enum<T>>
Struct.Enum64<T>[]array(Struct.Enum64<T>[] array, java.lang.Class<T> enumClass)Creates an array of Enum64 instances.protected <T extends java.lang.Enum<T>>
Struct.Enum8<T>[]array(Struct.Enum8<T>[] array, java.lang.Class<T> enumClass)Creates an array of Enum8 instances.protected Struct.Float[]array(Struct.Float[] array)Creates an array of Float instances.protected Struct.Pointer[]array(Struct.Pointer[] array)Creates an array of Pointer instances.protected Struct.Signed16[]array(Struct.Signed16[] array)Creates an array of Signed16 instances.protected Struct.Signed32[]array(Struct.Signed32[] array)Creates an array of Signed32 instances.protected Struct.Signed64[]array(Struct.Signed64[] array)Creates an array of Signed64 instances.protected Struct.Signed8[]array(Struct.Signed8[] array)Creates an array of Signed8 instances.protected Struct.SignedLong[]array(Struct.SignedLong[] array)Creates an array of SignedLong instances.protected Struct.Unsigned16[]array(Struct.Unsigned16[] array)Creates an array of Unsigned16 instances.protected Struct.Unsigned32[]array(Struct.Unsigned32[] array)Creates an array of Unsigned32 instances.protected Struct.Unsigned64[]array(Struct.Unsigned64[] array)Creates an array of Unsigned64 instances.protected Struct.Unsigned8[]array(Struct.Unsigned8[] array)Creates an array of Unsigned8 instances.protected Struct.UnsignedLong[]array(Struct.UnsignedLong[] array)Creates an array of UnsignedLong instances.protected Struct.UTF8String[]array(Struct.UTF8String[] array, int stringLength)Creates an array of UTF8String instances.protected <T extends Struct.Member>
T[]array(T[] array)Creates an array of Member instances.protected voidarrayBegin()Starts an array construction sessionprotected voidarrayEnd()Ends an array construction sessionstatic <T extends Struct>
T[]arrayOf(Runtime runtime, java.lang.Class<T> type, int length)protected <T> Struct.Function<T>function(java.lang.Class<T> closureClass)static PointergetMemory(Struct struct)static PointergetMemory(Struct struct, int flags)RuntimegetRuntime()protected <T extends Struct>
Tinner(T struct)static booleanisDirect(Struct struct)static intsize(Struct struct)java.lang.StringtoString()Returns a human readableStringrepresentation of the structure.voiduseMemory(Pointer address)Uses the specified memory address as the backing store for this structure.
-
-
-
Field Detail
-
ASCII
static final java.nio.charset.Charset ASCII
-
UTF8
static final java.nio.charset.Charset UTF8
-
__info
final Struct.Info __info
-
-
Constructor Detail
-
Struct
protected Struct(Runtime runtime)
Creates a newStruct.- Parameters:
runtime- The current runtime.
-
Struct
protected Struct(Runtime runtime, Struct.Alignment alignment)
-
Struct
protected Struct(Runtime runtime, boolean isUnion)
Creates a new Struct.- Parameters:
isUnion- if this Struct is a Union
-
-
Method Detail
-
getRuntime
public final Runtime getRuntime()
-
useMemory
public final void useMemory(Pointer address)
Uses the specified memory address as the backing store for this structure.- Parameters:
address- the native memory area.
-
size
public static int size(Struct struct)
-
alignment
public static int alignment(Struct struct)
-
isDirect
public static boolean isDirect(Struct struct)
-
align
private static int align(int offset, int align)
-
arrayOf
public static <T extends Struct> T[] arrayOf(Runtime runtime, java.lang.Class<T> type, int length)
-
toString
public java.lang.String toString()
Returns a human readableStringrepresentation of the structure.- Overrides:
toStringin classjava.lang.Object- Returns:
- a
Stringrepresentation of this structure.
-
arrayBegin
protected final void arrayBegin()
Starts an array construction session
-
arrayEnd
protected final void arrayEnd()
Ends an array construction session
-
array
protected <T extends Struct.Member> T[] array(T[] array)
Creates an array of Member instances.- Type Parameters:
T- The type of the Member subclass to create.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
protected <T extends java.lang.Enum<T>> Struct.Enum8<T>[] array(Struct.Enum8<T>[] array, java.lang.Class<T> enumClass)
Creates an array of Enum8 instances.- Type Parameters:
T- The type of the java.lang.Enum- Parameters:
array- the array to store the instances inenumClass- class of java.lang.Enum, these Enum8 instances will represent- Returns:
- the array that was passed in
-
array
protected <T extends java.lang.Enum<T>> Struct.Enum16<T>[] array(Struct.Enum16<T>[] array, java.lang.Class<T> enumClass)
Creates an array of Enum16 instances.- Type Parameters:
T- The type of the java.lang.Enum- Parameters:
array- the array to store the instances inenumClass- class of java.lang.Enum, these Enum16 instances will represent- Returns:
- the array that was passed in
-
array
protected <T extends java.lang.Enum<T>> Struct.Enum32<T>[] array(Struct.Enum32<T>[] array, java.lang.Class<T> enumClass)
Creates an array of Enum32 instances.- Type Parameters:
T- The type of the java.lang.Enum- Parameters:
array- the array to store the instances inenumClass- class of java.lang.Enum, these Enum32 instances will represent- Returns:
- the array that was passed in
-
array
protected <T extends java.lang.Enum<T>> Struct.Enum64<T>[] array(Struct.Enum64<T>[] array, java.lang.Class<T> enumClass)
Creates an array of Enum64 instances.- Type Parameters:
T- The type of the java.lang.Enum- Parameters:
array- the array to store the instances inenumClass- class of java.lang.Enum, these Enum64 instances will represent- Returns:
- the array that was passed in
-
array
protected <T extends java.lang.Enum<T>> Struct.Enum<T>[] array(Struct.Enum<T>[] array, java.lang.Class<T> enumClass)
Creates an array of Enum instances.- Type Parameters:
T- The type of the java.lang.Enum- Parameters:
array- the array to store the instances inenumClass- class of java.lang.Enum, these Enum instances will represent- Returns:
- the array that was passed in
-
array
protected <T extends Struct> T[] array(T[] array)
Creates an array of Struct instances.- Type Parameters:
T- the type of Struct- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
protected final Struct.Signed8[] array(Struct.Signed8[] array)
Creates an array of Signed8 instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
protected final Struct.Unsigned8[] array(Struct.Unsigned8[] array)
Creates an array of Unsigned8 instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
protected final Struct.Signed16[] array(Struct.Signed16[] array)
Creates an array of Signed16 instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
protected final Struct.Unsigned16[] array(Struct.Unsigned16[] array)
Creates an array of Unsigned16 instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
protected final Struct.Signed32[] array(Struct.Signed32[] array)
Creates an array of Signed32 instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
protected final Struct.Unsigned32[] array(Struct.Unsigned32[] array)
Creates an array of Unsigned32 instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
protected final Struct.Signed64[] array(Struct.Signed64[] array)
Creates an array of Signed64 instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
protected final Struct.Unsigned64[] array(Struct.Unsigned64[] array)
Creates an array of Unsigned64 instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
protected final Struct.SignedLong[] array(Struct.SignedLong[] array)
Creates an array of SignedLong instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
protected final Struct.UnsignedLong[] array(Struct.UnsignedLong[] array)
Creates an array of UnsignedLong instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
protected final Struct.Float[] array(Struct.Float[] array)
Creates an array of Float instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
protected final Struct.Double[] array(Struct.Double[] array)
Creates an array of Double instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
protected final Struct.Address[] array(Struct.Address[] array)
Creates an array of Address instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
protected final Struct.Pointer[] array(Struct.Pointer[] array)
Creates an array of Pointer instances.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
protected Struct.UTF8String[] array(Struct.UTF8String[] array, int stringLength)
Creates an array of UTF8String instances.- Parameters:
array- the array to store the instances instringLength- length of each string in array- Returns:
- the array that was passed in
-
inner
protected final <T extends Struct> T inner(T struct)
-
function
protected final <T> Struct.Function<T> function(java.lang.Class<T> closureClass)
-
-