Package jnr.ffi.byref
Class NativeLongByReference
- java.lang.Object
-
- java.lang.Number
-
- jnr.ffi.byref.AbstractNumberReference<NativeLong>
-
- jnr.ffi.byref.NativeLongByReference
-
- All Implemented Interfaces:
java.io.Serializable
,ByReference<NativeLong>
public final class NativeLongByReference extends AbstractNumberReference<NativeLong>
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());
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description NativeLongByReference()
Creates a new reference to a native long value initialized to zero.NativeLongByReference(long value)
Creates a new reference to a native long valueNativeLongByReference(NativeLong value)
Creates a new reference to a native long value
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
fromNative(Runtime runtime, Pointer memory, long offset)
Copies the long value from native memoryint
nativeSize(Runtime runtime)
Gets the native size of type of reference in bytes.void
toNative(Runtime runtime, Pointer memory, long offset)
Copies the long value to native memory-
Methods inherited from class jnr.ffi.byref.AbstractNumberReference
byteValue, checkNull, doubleValue, floatValue, getValue, intValue, longValue, shortValue
-
-
-
-
Constructor Detail
-
NativeLongByReference
public NativeLongByReference()
Creates a new reference to a native long value initialized to zero.
-
NativeLongByReference
public NativeLongByReference(NativeLong value)
Creates a new reference to a native long value- Parameters:
value
- the initial native value
-
NativeLongByReference
public NativeLongByReference(long value)
Creates a new reference to a native long value- Parameters:
value
- the initial native value
-
-
Method Detail
-
toNative
public void toNative(Runtime runtime, Pointer memory, long offset)
Copies the long value to native memory- Parameters:
runtime
- the current runtime.memory
- the native memory buffer.offset
- the memory offset.
-
fromNative
public void fromNative(Runtime runtime, Pointer memory, long offset)
Copies the long value from native memory- Parameters:
runtime
- the current runtime.memory
- the native memory buffer.offset
- the memory offset.
-
nativeSize
public final int nativeSize(Runtime runtime)
Gets the native size of type of reference in bytes.- Parameters:
runtime
- the current runtime.- Returns:
- the size of a byte in bytes
-
-