|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjnr.ffi.byref.AbstractReference<Pointer>
jnr.ffi.byref.PointerByReference
public final class PointerByReference
AddressByReference is used when the address of a pointer must be passed as a parameter to a function.
For example, the following C code,
extern void get_a(void** ap); void* foo(void) { void* 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 PointerByReference ap); }
and used like this
PointerByReference ap = new PointerByReference();
lib.get_a(ap);
Pointer ptr = ap.getValue();
System.out.println("ptr from lib=" + a.getValue());
System.out.println("ptr contents=" + ptr.getInt(0));
| Constructor Summary | |
|---|---|
PointerByReference()
Creates a new reference to a pointer value with a null default value. |
|
PointerByReference(Pointer value)
Creates a new reference to a pointer value |
|
| Method Summary | |
|---|---|
void |
marshal(Pointer memory,
long offset)
Copies the java value to native memory |
int |
nativeSize(Runtime runtime)
Gets the size of the native buffer required to store the value |
void |
unmarshal(Pointer memory,
long offset)
Copies the java value from native memory |
| Methods inherited from class jnr.ffi.byref.AbstractReference |
|---|
checkNull, getValue |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PointerByReference()
public PointerByReference(Pointer value)
value - the initial pointer value| Method Detail |
|---|
public final void marshal(Pointer memory,
long offset)
ByReference
memory - the native memory buffer.
public final void unmarshal(Pointer memory,
long offset)
ByReference
memory - the native memory buffer.public final int nativeSize(Runtime runtime)
ByReference
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||