Top Description Fields Constructors Methods
jnr.ffi.byref

public Class NumberByReference

extends AbstractNumberReference<Number>
Class Inheritance
Imports
jnr.ffi.Pointer, .Runtime, .TypeAlias

NumberByReference is used when the address of a primitive integral value must be passed as a parameter to a function, but the exact type is system dependent.

For example, the following C code,

extern void get_size(ssize_t *sp);

ssize_t foo(void) {
    ssize_t n;
    // pass a reference to 'n' so get_size() can fill it out
    get_size(&n);

    return n;
}

Would be declared in java as

interface Lib {
    void get_size(@Out NumberByReference ap);
}


and used like this

NumberByReference size = new NumberByReference(ssize_t);
lib.get_size(size);
System.out.printf("size from lib=%d\n", size.longValue());


Field Summary

Modifier and TypeField and Description
private final TypeAlias
Inherited from jnr.ffi.byref.AbstractNumberReference:
value

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public 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 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 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.AbstractNumberReference:
byteValuecheckNulldoubleValuefloatValuegetValueintValuelongValueshortValue

Field Detail

typeAliasback to summary
private final TypeAlias typeAlias

Constructor Detail

NumberByReferenceback to summary
public NumberByReference(TypeAlias typeAlias, Number value)
NumberByReferenceback to summary
public NumberByReference(TypeAlias typeAlias)

Method Detail

fromNativeback to summary
public 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.

Annotations
@Override
nativeSizeback to summary
public 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

Annotations
@Override
toNativeback to summary
public 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.

Annotations
@Override