Top Description Fields Constructors Methods
jnr.ffi.byref

public final Class PointerByReference

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

AddressByReference is used when the address of a pointer 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 PointerByReference ap);
}

and used like this

PointerByReference ap = new PointerByReference();
lib.get_a(ap);
Pointer ptr = ap.getValue();
System.out.println("ptr from lib=" + a.getValue());
System.out.println("ptr contents=" + ptr.getInt(0));

Field Summary

Inherited from jnr.ffi.byref.AbstractReference:
value

Constructor Summary

AccessConstructor and Description
public
PointerByReference()

Creates a new reference to a pointer value with a null default value.

public
PointerByReference(Pointer
the initial pointer value
value
)

Creates a new reference to a pointer value

Method Summary

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

Implements jnr.ffi.byref.ByReference.fromNative.

Copies the java value from native memory
public final int
nativeSize(Runtime
The current runtime.
runtime
)

Implements jnr.ffi.byref.ByReference.nativeSize.

Gets the size of the native buffer required to store the value
public final void
toNative(Runtime
The current runtime.
runtime
,
Pointer
The native memory buffer.
memory
,
long
The offset of the field.
offset
)

Implements jnr.ffi.byref.ByReference.toNative.

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

Constructor Detail

PointerByReferenceback to summary
public PointerByReference()

Creates a new reference to a pointer value with a null default value.

PointerByReferenceback to summary
public PointerByReference(Pointer value)

Creates a new reference to a pointer value

Parameters
value:Pointer

the initial pointer value

Method Detail

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

Implements jnr.ffi.byref.ByReference.fromNative.

Doc from jnr.ffi.byref.ByReference.fromNative.

Copies the java value from native memory

Parameters
runtime:Runtime

The current runtime.

memory:Pointer

the native memory buffer.

offset:long

The offset of the field.

nativeSizeback to summary
public final int nativeSize(Runtime runtime)

Implements jnr.ffi.byref.ByReference.nativeSize.

Doc from jnr.ffi.byref.ByReference.nativeSize.

Gets the size of the native buffer required to store the value

Parameters
runtime:Runtime

The current runtime.

Returns:int

the size in bytes of the native type

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

Implements jnr.ffi.byref.ByReference.toNative.

Doc from jnr.ffi.byref.ByReference.toNative.

Copies the java value to native memory

Parameters
runtime:Runtime

The current runtime.

memory:Pointer

The native memory buffer.

offset:long

The offset of the field.