Package jnr.ffi
Class Struct
- java.lang.Object
-
- jnr.ffi.Struct
-
- Direct Known Subclasses:
Union
public abstract class Struct extends java.lang.Object
Representation of C structures in java. Note: This class is not threadsafe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
Struct.AbstractBoolean
Base class for Boolean fieldsprotected class
Struct.AbstractMember
Base implementation of Memberclass
Struct.Address
Represents a native memory address.static class
Struct.Alignment
class
Struct.AsciiString
class
Struct.AsciiStringRef
class
Struct.blkcnt_t
class
Struct.blksize_t
class
Struct.BOOL16
class
Struct.Boolean
A normal C boolean - 1 byte in sizeclass
Struct.BYTE
class
Struct.caddr_t
class
Struct.cc_t
class
Struct.clock_t
class
Struct.dev_t
class
Struct.Double
class
Struct.DWORD
class
Struct.Enum<T extends java.lang.Enum<T>>
class
Struct.Enum16<E extends java.lang.Enum<E>>
class
Struct.Enum32<E extends java.lang.Enum<E>>
class
Struct.Enum64<E extends java.lang.Enum<E>>
class
Struct.Enum8<E extends java.lang.Enum<E>>
An 8 bit enum field.protected class
Struct.EnumField<E>
Base for all the Enum fields.class
Struct.EnumLong<E extends java.lang.Enum<E>>
class
Struct.Float
class
Struct.fsblkcnt_t
class
Struct.fsfilcnt_t
class
Struct.Function<T>
class
Struct.gid_t
class
Struct.id_t
class
Struct.in_addr_t
class
Struct.in_port_t
class
Struct.ino_t
class
Struct.ino64_t
class
Struct.int16_t
class
Struct.int32_t
class
Struct.int64_t
class
Struct.int8_t
class
Struct.IntegerAlias
class
Struct.intptr_t
class
Struct.key_t
class
Struct.LONG
protected class
Struct.Member
Interface all Struct members must implement.class
Struct.mode_t
class
Struct.nlink_t
class
Struct.NumberField
Base class for all Number structure fields.class
Struct.off_t
static class
Struct.Offset
protected class
Struct.Padding
Specialized padding fields for structs.class
Struct.pid_t
class
Struct.Pointer
Represents a native memory address.class
Struct.PointerField
class
Struct.rlim_t
class
Struct.sa_family_t
class
Struct.Signed16
A 16 bit signed integer field.class
Struct.Signed32
A 32 bit signed integer field.class
Struct.Signed64
A 64 bit signed integer field.class
Struct.Signed8
An 8 bit signed integerclass
Struct.SignedLong
A native long integer field.class
Struct.size_t
class
Struct.socklen_t
class
Struct.speed_t
class
Struct.ssize_t
class
Struct.String
class
Struct.StructRef<T extends Struct>
Represents a reference to a Struct or and array of Structsclass
Struct.swblk_t
class
Struct.tcflag_t
class
Struct.time_t
class
Struct.u_int16_t
class
Struct.u_int32_t
class
Struct.u_int64_t
class
Struct.u_int8_t
class
Struct.uid_t
class
Struct.uintptr_t
class
Struct.Unsigned16
A 16 bit signed integer field.class
Struct.Unsigned32
A 32 bit signed integer field.class
Struct.Unsigned64
A 64 bit unsigned integer field.class
Struct.Unsigned8
An 8 bit unsigned integerclass
Struct.UnsignedLong
A native long integer field.class
Struct.UTF8String
class
Struct.UTF8StringRef
class
Struct.UTFString
class
Struct.UTFStringRef
class
Struct.WBOOL
A Windows BOOL - 4 bytesclass
Struct.WORD
-
Constructor Summary
Constructors Modifier Constructor Description protected
Struct(Runtime runtime)
Creates a newStruct
.protected
Struct(Runtime runtime, boolean isUnion)
Creates a newStruct
.protected
Struct(Runtime runtime, Struct enclosing)
protected
Struct(Runtime runtime, Struct.Alignment alignment)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
alignment(Struct struct)
protected Struct.Address[]
array(Struct.Address[] array)
Creates an array ofAddress
instances.protected Struct.Double[]
array(Struct.Double[] array)
Creates an array ofDouble
instances.protected <T extends java.lang.Enum<T>>
Struct.Enum<T>[]array(Struct.Enum<T>[] array, java.lang.Class<T> enumClass)
Creates an array ofEnum
instances.protected <T extends java.lang.Enum<T>>
Struct.Enum16<T>[]array(Struct.Enum16<T>[] array, java.lang.Class<T> enumClass)
Creates an array ofEnum16
instances.protected <T extends java.lang.Enum<T>>
Struct.Enum32<T>[]array(Struct.Enum32<T>[] array, java.lang.Class<T> enumClass)
Creates an array ofEnum32
instances.protected <T extends java.lang.Enum<T>>
Struct.Enum64<T>[]array(Struct.Enum64<T>[] array, java.lang.Class<T> enumClass)
Creates an array ofEnum64
instances.protected <T extends java.lang.Enum<T>>
Struct.Enum8<T>[]array(Struct.Enum8<T>[] array, java.lang.Class<T> enumClass)
Creates an array ofEnum8
instances.protected Struct.Float[]
array(Struct.Float[] array)
Creates an array ofFloat
instances.protected Struct.Pointer[]
array(Struct.Pointer[] array)
Creates an array ofPointer
instances.protected Struct.Signed16[]
array(Struct.Signed16[] array)
Creates an array ofSigned16
instances.protected Struct.Signed32[]
array(Struct.Signed32[] array)
Creates an array ofSigned32
instances.protected Struct.Signed64[]
array(Struct.Signed64[] array)
Creates an array ofSigned64
instances.protected Struct.Signed8[]
array(Struct.Signed8[] array)
Creates an array ofSigned8
instances.protected Struct.SignedLong[]
array(Struct.SignedLong[] array)
Creates an array ofSignedLong
instances.protected Struct.Unsigned16[]
array(Struct.Unsigned16[] array)
Creates an array ofUnsigned16
instances.protected Struct.Unsigned32[]
array(Struct.Unsigned32[] array)
Creates an array ofUnsigned32
instances.protected Struct.Unsigned64[]
array(Struct.Unsigned64[] array)
Creates an array ofUnsigned64
instances.protected Struct.Unsigned8[]
array(Struct.Unsigned8[] array)
Creates an array ofUnsigned8
instances.protected Struct.UnsignedLong[]
array(Struct.UnsignedLong[] array)
Creates an array ofUnsignedLong
instances.protected Struct.UTF8String[]
array(Struct.UTF8String[] array, int stringLength)
Creates an array ofUTF8String
instances.protected <T extends Struct.Member>
T[]array(T[] array)
Creates an array ofMember
instances.protected void
arrayBegin()
Starts an array construction sessionprotected void
arrayEnd()
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 Pointer
getMemory(Struct struct)
static Pointer
getMemory(Struct struct, int flags)
Runtime
getRuntime()
protected <T extends Struct>
Tinner(T struct)
static boolean
isDirect(Struct struct)
static int
size(Struct struct)
java.lang.String
toString()
Returns a human readableString
representation of the structure.void
useMemory(Pointer address)
Uses the specified memory address as the backing store for this structure.
-
-
-
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 newStruct
.- Parameters:
runtime
- the current jnr-ffi runtimeisUnion
- 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)
-
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 readableString
representation of the structure.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a
String
representation 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 ofMember
instances.- Type Parameters:
T
- The type of theMember
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 ofEnum8
instances.- Type Parameters:
T
- The type of thejava.lang.Enum
- Parameters:
array
- the array to store the instances inenumClass
- class ofjava.lang.Enum
, theseEnum8
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 ofEnum16
instances.- Type Parameters:
T
- The type of thejava.lang.Enum
- Parameters:
array
- the array to store the instances inenumClass
- class ofjava.lang.Enum
, theseEnum16
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 ofEnum32
instances.- Type Parameters:
T
- The type of thejava.lang.Enum
- Parameters:
array
- the array to store the instances inenumClass
- class ofjava.lang.Enum
, theseEnum32
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 ofEnum64
instances.- Type Parameters:
T
- The type of thejava.lang.Enum
- Parameters:
array
- the array to store the instances inenumClass
- class ofjava.lang.Enum
, theseEnum64
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 ofEnum
instances.- Type Parameters:
T
- The type of thejava.lang.Enum
- Parameters:
array
- the array to store the instances inenumClass
- class ofjava.lang.Enum
, theseEnum
instances will represent- Returns:
- the array that was passed in
-
array
protected <T extends Struct> T[] array(T[] array)
Creates an array ofStruct
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 ofSigned8
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 ofUnsigned8
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 ofSigned16
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 ofUnsigned16
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 ofSigned32
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 ofUnsigned32
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 ofSigned64
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 ofUnsigned64
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 ofSignedLong
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 ofUnsignedLong
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 ofFloat
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 ofDouble
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 ofAddress
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 ofPointer
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 ofUTF8String
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)
-
-