Package jnr.ffi.byref
Class ShortByReference
- java.lang.Object
-
- java.lang.Number
-
- jnr.ffi.byref.AbstractNumberReference<java.lang.Short>
-
- jnr.ffi.byref.ShortByReference
-
- All Implemented Interfaces:
java.io.Serializable
,ByReference<java.lang.Short>
public final class ShortByReference extends AbstractNumberReference<java.lang.Short>
ShortByReference is used when the address of a primitive short value must be passed as a parameter to a function.For example, the following C code,
extern void get_a(short * ap); short foo(void) { short 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 ShortByReference ap); }
and used like this
ShortByReference ap = new ShortByReference(); lib.get_a(ap); System.out.printf("a from lib=%d\n", a.getValue());
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ShortByReference()
Creates a new reference to a short value initialized to zero.ShortByReference(short value)
Creates a new reference to a short value.ShortByReference(java.lang.Short value)
Creates a new reference to a short value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
fromNative(Runtime runtime, Pointer buffer, long offset)
Copies the short value from native memoryint
nativeSize(Runtime runtime)
Gets the native size of type of reference in bytes.void
toNative(Runtime runtime, Pointer buffer, long offset)
Copies the short value to native memory-
Methods inherited from class jnr.ffi.byref.AbstractNumberReference
byteValue, checkNull, doubleValue, floatValue, getValue, intValue, longValue, shortValue
-
-
-
-
Constructor Detail
-
ShortByReference
public ShortByReference()
Creates a new reference to a short value initialized to zero.
-
ShortByReference
public ShortByReference(java.lang.Short value)
Creates a new reference to a short value.- Parameters:
value
- the initial native value
-
ShortByReference
public ShortByReference(short value)
Creates a new reference to a short value.- Parameters:
value
- the initial native value
-
-
Method Detail
-
toNative
public void toNative(Runtime runtime, Pointer buffer, long offset)
Copies the short 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 short value from native memory- Parameters:
runtime
- the current runtime.buffer
- 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
-
-