Top Description Fields Constructors Methods
jnr.ffi.byref

public final Class AddressByReference

extends AbstractReference<Address>
Class Inheritance
Imports
jnr.ffi.Address, .Pointer, .Runtime

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());


Field Summary

Inherited from jnr.ffi.byref.AbstractReference:
value

Constructor Summary

AccessConstructor and Description
public
AddressByReference()

Creates a new reference to an integer value

public
AddressByReference(Address
the initial native value
value
)

Creates a new reference to an address value

Method Summary

Modifier and TypeMethod and Description
public void
fromNative(Runtime
The current runtime.
runtime
,
Pointer
The native memory buffer.
memory
,
long
The offset.
offset
)

Implements jnr.ffi.byref.ByReference.fromNative.

Copies the address value from native memory
public int

Returns:

The size of the native type this reference points to
nativeSize
(Runtime
The current runtime.
runtime
)

Implements jnr.ffi.byref.ByReference.nativeSize.

Gets the native size of type of reference
public void
toNative(Runtime
The current runtime.
runtime
,
Pointer
The native memory buffer
memory
,
long
The offset.
offset
)

Implements jnr.ffi.byref.ByReference.toNative.

Copies the address value to native memory
Inherited from jnr.ffi.byref.AbstractReference:
checkNullgetValue

Constructor Detail

AddressByReferenceback to summary
public AddressByReference()

Creates a new reference to an integer value

AddressByReferenceback to summary
public AddressByReference(Address value)

Creates a new reference to an address value

Parameters
value:Address

the initial native value

Method Detail

fromNativeback to summary
public void fromNative(Runtime runtime, Pointer memory, long offset)

Implements jnr.ffi.byref.ByReference.fromNative.

Copies the address value from native memory

Parameters
runtime:Runtime

The current runtime.

memory:Pointer

The native memory buffer.

offset:long

The offset.

nativeSizeback to summary
public int nativeSize(Runtime runtime)

Implements jnr.ffi.byref.ByReference.nativeSize.

Gets the native size of type of reference

Parameters
runtime:Runtime

The current runtime.

Returns:int

The size of the native type this reference points to

toNativeback to summary
public void toNative(Runtime runtime, Pointer memory, long offset)

Implements jnr.ffi.byref.ByReference.toNative.

Copies the address value to native memory

Parameters
runtime:Runtime

The current runtime.

memory:Pointer

The native memory buffer

offset:long

The offset.