|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Number
jnr.ffi.byref.AbstractNumberReference<Number>
jnr.ffi.byref.NumberByReference
public class NumberByReference
NumberByReference is used when the address of a primitive integral value must be passed as a parameter to a function, but the exact type is system dependent.
For example, the following C code,
extern void get_size(ssize_t *sp);
ssize_t foo(void) {
ssize_t n;
// pass a reference to 'n' so get_size() can fill it out
get_size(&n);
return n;
}
Would be declared in java as
interface Lib {
void get_size(@Out NumberByReference ap);
}
and used like this
NumberByReference size = new NumberByReference(ssize_t);
lib.get_size(size);
System.out.printf("size from lib=%d\n", size.longValue());
| Constructor Summary | |
|---|---|
NumberByReference(TypeAlias typeAlias)
|
|
NumberByReference(TypeAlias typeAlias,
Number value)
|
|
| Method Summary | |
|---|---|
void |
fromNative(Runtime runtime,
Pointer memory,
long offset)
Copies the java value from native memory |
int |
nativeSize(Runtime runtime)
Gets the size of the native buffer required to store the value |
void |
toNative(Runtime runtime,
Pointer memory,
long offset)
Copies the java value to native memory |
| Methods inherited from class jnr.ffi.byref.AbstractNumberReference |
|---|
byteValue, checkNull, doubleValue, floatValue, getValue, intValue, longValue, shortValue |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NumberByReference(TypeAlias typeAlias,
Number value)
public NumberByReference(TypeAlias typeAlias)
| Method Detail |
|---|
public int nativeSize(Runtime runtime)
ByReference
public void toNative(Runtime runtime,
Pointer memory,
long offset)
ByReference
memory - the native memory buffer.
public void fromNative(Runtime runtime,
Pointer memory,
long offset)
ByReference
memory - the native memory buffer.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||