Package jnr.ffi.byref
Class ByteByReference
- All Implemented Interfaces:
Serializable
,ByReference<Byte>
ByteByReference is used when the address of a primitive byte value must be passed
as a parameter to a function.
For example, the following C code,
extern void get_a(char *ap);
int foo(void) {
char a;
// pass a reference to 'a' so get_a() can fill it out
get_a(&a);
return a;
}
Would be declared in java as
interface Lib {
void get_a(@Out ByteByReference ap);
}
and used like this
ByteByReference ap = new ByteByReference(); lib.get_a(ap); System.out.printf("a from lib=%d\n", a.byteValue());
- See Also:
-
Field Summary
Fields inherited from class jnr.ffi.byref.AbstractNumberReference
value
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new reference to a byte value initialized to zero.ByteByReference
(byte value) Creates a new reference to a byte valueByteByReference
(Byte value) Creates a new reference to a byte value -
Method Summary
Modifier and TypeMethodDescriptionvoid
fromNative
(Runtime runtime, Pointer buffer, long offset) Copies the Byte value from native memoryfinal int
nativeSize
(Runtime runtime) Gets the native size of type of reference in bytes.void
Copies the Byte value to native memoryMethods inherited from class jnr.ffi.byref.AbstractNumberReference
byteValue, checkNull, doubleValue, floatValue, getValue, intValue, longValue, shortValue
-
Constructor Details
-
ByteByReference
public ByteByReference()Creates a new reference to a byte value initialized to zero. -
ByteByReference
Creates a new reference to a byte value- Parameters:
value
- the initial native value
-
ByteByReference
public ByteByReference(byte value) Creates a new reference to a byte value- Parameters:
value
- the initial native value
-
-
Method Details
-
toNative
Copies the Byte value to native memory- Parameters:
runtime
- The current runtime.buffer
- the native memory bufferoffset
- The offset of the field.
-
fromNative
Copies the Byte value from native memory- Parameters:
runtime
- The current runtime.buffer
- the native memory buffer.offset
- The offset of the field.
-
nativeSize
Gets the native size of type of reference in bytes.- Parameters:
runtime
- The current runtime.- Returns:
- the size of a byte in bytes
-