Top Description Fields Constructors Methods
jnr.ffi.byref

public final Class NativeLongByReference

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

NativeLongByReference is used when the address of a primitive C long must be passed as a parameter to a function.

For example, the following C code,

extern void get_a(long * ap);

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

and used like this

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

Field Summary

Inherited from jnr.ffi.byref.AbstractNumberReference:
value

Constructor Summary

AccessConstructor and Description
public
NativeLongByReference()

Creates a new reference to a native long value initialized to zero.

public
NativeLongByReference(NativeLong
the initial native value
value
)

Creates a new reference to a native long value

public
NativeLongByReference(long
the initial native value
value
)

Creates a new reference to a native long value

Method Summary

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

Implements jnr.ffi.byref.ByReference.fromNative.

Copies the long value from native memory
public final int

Returns:

the size of a byte in bytes
nativeSize
(Runtime
the current runtime.
runtime
)

Implements jnr.ffi.byref.ByReference.nativeSize.

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

Implements jnr.ffi.byref.ByReference.toNative.

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

Constructor Detail

NativeLongByReferenceback to summary
public NativeLongByReference()

Creates a new reference to a native long value initialized to zero.

NativeLongByReferenceback to summary
public NativeLongByReference(NativeLong value)

Creates a new reference to a native long value

Parameters
value:NativeLong

the initial native value

NativeLongByReferenceback to summary
public NativeLongByReference(long value)

Creates a new reference to a native long value

Parameters
value:long

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 long value from native memory

Parameters
runtime:Runtime

the current runtime.

memory:Pointer

the native memory buffer.

offset:long

the memory offset.

nativeSizeback to summary
public final int nativeSize(Runtime runtime)

Implements jnr.ffi.byref.ByReference.nativeSize.

Gets the native size of type of reference in bytes.

Parameters
runtime:Runtime

the current runtime.

Returns:int

the size of a byte in bytes

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

Implements jnr.ffi.byref.ByReference.toNative.

Copies the long value to native memory

Parameters
runtime:Runtime

the current runtime.

memory:Pointer

the native memory buffer.

offset:long

the memory offset.