Top Description Fields Constructors Methods
jnr.ffi.byref

public final Class IntByReference

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

IntByReference is used when the address of a primitive int must be passed as a parameter to a function.

For example, the following C code,

extern void get_a(int * ap);

int foo(void) {
    int 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 IntByReference ap);
}

and used like this

IntByReference ap = new IntByReference();
lib.get_a(ap);
System.out.printf("a from lib=%d\n", a.intValue());

Field Summary

Inherited from jnr.ffi.byref.AbstractNumberReference:
value

Constructor Summary

AccessConstructor and Description
public
IntByReference()

Creates a new reference to an integer value initialized to zero.

public
IntByReference(Integer
the initial native value
value
)

Creates a new reference to an integer value

public
IntByReference(int
the initial native value
value
)

Creates a new reference to an integer value

Method Summary

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

Implements jnr.ffi.byref.ByReference.fromNative.

Copies the integer value from native memory
public int

Returns:

Integer.SIZE
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.
buffer
,
long
the memory offset.
offset
)

Implements jnr.ffi.byref.ByReference.toNative.

Copies the integer value to native memory
Inherited from jnr.ffi.byref.AbstractNumberReference:
byteValuecheckNulldoubleValuefloatValuegetValueintValuelongValueshortValue

Constructor Detail

IntByReferenceback to summary
public IntByReference()

Creates a new reference to an integer value initialized to zero.

IntByReferenceback to summary
public IntByReference(Integer value)

Creates a new reference to an integer value

Parameters
value:Integer

the initial native value

IntByReferenceback to summary
public IntByReference(int value)

Creates a new reference to an integer value

Parameters
value:int

the initial native value

Method Detail

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

Implements jnr.ffi.byref.ByReference.fromNative.

Copies the integer value from native memory

Parameters
runtime:Runtime

the current runtime.

buffer:Pointer

the native memory buffer.

offset:long

the memory 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

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

The current runtime.

Returns:int

Integer.SIZE

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

Implements jnr.ffi.byref.ByReference.toNative.

Copies the integer value to native memory

Parameters
runtime:Runtime

the current runtime.

buffer:Pointer

the native memory buffer.

offset:long

the memory offset.