Package jnr.ffi
Class Struct
- java.lang.Object
-
- jnr.ffi.Struct
-
-
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 Enum<T>>classStruct.Enum16<E extends Enum<E>>classStruct.Enum32<E extends Enum<E>>classStruct.Enum64<E extends Enum<E>>classStruct.Enum8<E extends Enum<E>>An 8 bit enum field.protected classStruct.EnumField<E>Base for all the Enum fields.classStruct.EnumLong<E extends Enum<E>>classStruct.FloatclassStruct.fsblkcnt_tclassStruct.fsfilcnt_tclassStruct.Function<T>classStruct.gid_tclassStruct.id_tclassStruct.in_addr_tclassStruct.in_port_tclassStruct.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
-
Constructor Summary
Constructors Modifier Constructor Description protectedStruct(Runtime runtime)Creates a newStruct.protectedStruct(Runtime runtime, boolean isUnion)Creates a newStruct.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 static intalignment(Struct struct)protected Struct.Address[]array(Struct.Address[] array)Creates an array ofAddressinstances.protected Struct.Double[]array(Struct.Double[] array)Creates an array ofDoubleinstances.protected <T extends Enum<T>>
Struct.Enum<T>[]array(Struct.Enum<T>[] array, Class<T> enumClass)Creates an array ofEnuminstances.protected <T extends Enum<T>>
Struct.Enum16<T>[]array(Struct.Enum16<T>[] array, Class<T> enumClass)Creates an array ofEnum16instances.protected <T extends Enum<T>>
Struct.Enum32<T>[]array(Struct.Enum32<T>[] array, Class<T> enumClass)Creates an array ofEnum32instances.protected <T extends Enum<T>>
Struct.Enum64<T>[]array(Struct.Enum64<T>[] array, Class<T> enumClass)Creates an array ofEnum64instances.protected <T extends Enum<T>>
Struct.Enum8<T>[]array(Struct.Enum8<T>[] array, Class<T> enumClass)Creates an array ofEnum8instances.protected Struct.Float[]array(Struct.Float[] array)Creates an array ofFloatinstances.protected Struct.Pointer[]array(Struct.Pointer[] array)Creates an array ofPointerinstances.protected Struct.Signed16[]array(Struct.Signed16[] array)Creates an array ofSigned16instances.protected Struct.Signed32[]array(Struct.Signed32[] array)Creates an array ofSigned32instances.protected Struct.Signed64[]array(Struct.Signed64[] array)Creates an array ofSigned64instances.protected Struct.Signed8[]array(Struct.Signed8[] array)Creates an array ofSigned8instances.protected Struct.SignedLong[]array(Struct.SignedLong[] array)Creates an array ofSignedLonginstances.protected Struct.Unsigned16[]array(Struct.Unsigned16[] array)Creates an array ofUnsigned16instances.protected Struct.Unsigned32[]array(Struct.Unsigned32[] array)Creates an array ofUnsigned32instances.protected Struct.Unsigned64[]array(Struct.Unsigned64[] array)Creates an array ofUnsigned64instances.protected Struct.Unsigned8[]array(Struct.Unsigned8[] array)Creates an array ofUnsigned8instances.protected Struct.UnsignedLong[]array(Struct.UnsignedLong[] array)Creates an array ofUnsignedLonginstances.protected Struct.UTF8String[]array(Struct.UTF8String[] array, int stringLength)Creates an array ofUTF8Stringinstances.protected <T extends Struct.Member>
T[]array(T[] array)Creates an array ofMemberinstances.protected voidarrayBegin()Starts an array construction sessionprotected voidarrayEnd()Ends an array construction sessionstatic <T extends Struct>
T[]arrayOf(Runtime runtime, Class<T> type, int length)protected <T> Struct.Function<T>function(Class<T> closureClass)static PointergetMemory(Struct struct)static PointergetMemory(Struct struct, int flags)RuntimegetRuntime()protected <T extends Struct>
Tinner(Class<T> structClass)Creates inner Structs in Struct definitions.protected <T extends Struct>
Tinner(T struct)Creates inner Structs in Struct definitions.static booleanisDirect(Struct struct)static <T extends Struct>
intsize(Class<T> structClass)Gets the size of a Struct type in bytesstatic <T extends Struct>
intsize(Class<T> structClass, Runtime runtime)Gets the size of a Struct type in bytesstatic intsize(Struct struct)Gets the size of a Struct instance in bytesStringtoString()Returns a human readableStringrepresentation of the structure.voiduseMemory(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)
Gets the size of a Struct instance in bytes- Parameters:
struct- the Struct instance- Returns:
- the size of the Struct in bytes
-
size
public static <T extends Struct> int size(Class<T> structClass, Runtime runtime)
Gets the size of a Struct type in bytes
-
size
public static <T extends Struct> int size(Class<T> structClass)
Gets the size of a Struct type in bytes- Type Parameters:
T- the Struct type- Parameters:
structClass- theClassof the Struct- Returns:
- the size of the Struct in bytes
-
alignment
public static int alignment(Struct struct)
-
isDirect
public static boolean isDirect(Struct struct)
-
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 ofMemberinstances.- Type Parameters:
T- The type of theMembersubclass to create.- Parameters:
array- the array to store the instances in- Returns:
- the array that was passed in
-
array
protected <T extends Enum<T>> Struct.Enum8<T>[] array(Struct.Enum8<T>[] array, Class<T> enumClass)
Creates an array ofEnum8instances.- Type Parameters:
T- The type of thejava.lang.Enum- Parameters:
array- the array to store the instances inenumClass- class ofjava.lang.Enum, theseEnum8instances will represent- Returns:
- the array that was passed in
-
array
protected <T extends Enum<T>> Struct.Enum16<T>[] array(Struct.Enum16<T>[] array, Class<T> enumClass)
Creates an array ofEnum16instances.- Type Parameters:
T- The type of thejava.lang.Enum- Parameters:
array- the array to store the instances inenumClass- class ofjava.lang.Enum, theseEnum16instances will represent- Returns:
- the array that was passed in
-
array
protected <T extends Enum<T>> Struct.Enum32<T>[] array(Struct.Enum32<T>[] array, Class<T> enumClass)
Creates an array ofEnum32instances.- Type Parameters:
T- The type of thejava.lang.Enum- Parameters:
array- the array to store the instances inenumClass- class ofjava.lang.Enum, theseEnum32instances will represent- Returns:
- the array that was passed in
-
array
protected <T extends Enum<T>> Struct.Enum64<T>[] array(Struct.Enum64<T>[] array, Class<T> enumClass)
Creates an array ofEnum64instances.- Type Parameters:
T- The type of thejava.lang.Enum- Parameters:
array- the array to store the instances inenumClass- class ofjava.lang.Enum, theseEnum64instances will represent- Returns:
- the array that was passed in
-
array
protected <T extends Enum<T>> Struct.Enum<T>[] array(Struct.Enum<T>[] array, Class<T> enumClass)
Creates an array ofEnuminstances.- Type Parameters:
T- The type of thejava.lang.Enum- Parameters:
array- the array to store the instances inenumClass- class ofjava.lang.Enum, theseEnuminstances will represent- Returns:
- the array that was passed in
-
array
protected <T extends Struct> T[] array(T[] array)
Creates an array ofStructinstances.- 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 ofSigned8instances.- 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 ofUnsigned8instances.- 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 ofSigned16instances.- 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 ofUnsigned16instances.- 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 ofSigned32instances.- 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 ofUnsigned32instances.- 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 ofSigned64instances.- 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 ofUnsigned64instances.- 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 ofSignedLonginstances.- 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 ofUnsignedLonginstances.- 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 ofFloatinstances.- 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 ofDoubleinstances.- 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 ofAddressinstances.- 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 ofPointerinstances.- 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 ofUTF8Stringinstances.- 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)
Creates inner Structs in Struct definitions. Example:public class InnerStruct extends Struct { public final Signed32 innerInt32 = new Signed32(); public final Double innerDouble = new Double(); public InnerStruct(Runtime runtime) {super(runtime);} } public class MyStruct extends Struct { public final Signed32 myInt32 = new Signed32(); public final InnerStruct myInnerStruct = inner(new InnerStruct()); public MyStruct(Runtime runtime) {super(runtime);} }- Type Parameters:
T- the type of the inner Struct- Parameters:
struct- an instance of the inner Struct- Returns:
- the instance of the inner Struct of type
Struct
-
inner
protected final <T extends Struct> T inner(Class<T> structClass)
Creates inner Structs in Struct definitions. Example:public class InnerStruct extends Struct { public final Signed32 innerInt32 = new Signed32(); public final Double innerDouble = new Double(); public InnerStruct(Runtime runtime) {super(runtime);} } public class MyStruct extends Struct { public final Signed32 myInt32 = new Signed32(); public final InnerStruct myInnerStruct = inner(InnerStruct.class); public MyStruct(Runtime runtime) {super(runtime);} }
-
function
protected final <T> Struct.Function<T> function(Class<T> closureClass)
-
-