Package jnr.ffi.byref
Class AddressByReference
- All Implemented Interfaces:
ByReference<Address>
AddressByReference is used when the address of a primitive pointer value must be passed
as a parameter to a function.
For example, the following C code,
extern void get_a(void** ap);
void* foo(void) {
void* 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 AddressByReference ap);
}
and used like this
AddressByReference ap = new AddressByReference();
lib.get_a(ap);
System.out.println("a from lib=" + a.getValue());
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new reference to an integer valueAddressByReference
(Address value) Creates a new reference to an address value -
Method Summary
Modifier and TypeMethodDescriptionvoid
fromNative
(Runtime runtime, Pointer memory, long offset) Copies the address value from native memoryint
nativeSize
(Runtime runtime) Gets the native size of type of referencevoid
Copies the address value to native memoryMethods inherited from class jnr.ffi.byref.AbstractReference
checkNull, getValue
-
Constructor Details
-
AddressByReference
public AddressByReference()Creates a new reference to an integer value -
AddressByReference
Creates a new reference to an address value- Parameters:
value
- the initial native value
-
-
Method Details
-
toNative
Copies the address value to native memory- Parameters:
runtime
- The current runtime.memory
- The native memory bufferoffset
- The offset.
-
fromNative
Copies the address value from native memory- Parameters:
runtime
- The current runtime.memory
- The native memory buffer.offset
- The offset.
-
nativeSize
Gets the native size of type of reference- Parameters:
runtime
- The current runtime.- Returns:
- The size of the native type this reference points to
-