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