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));
| Access | Constructor and Description |
|---|---|
| public | |
| public | PointerByReference(Pointer
the initial pointer value value)Creates a new reference to a pointer value |
| Modifier and Type | Method and Description |
|---|---|
| public final void | fromNative(Runtime
The current runtime. runtime, Pointer the native memory buffer. memory, long The offset of the field. offset)Implements jnr. |
| public final int | nativeSize(Runtime
The current runtime. runtime)Implements jnr. |
| public final void | toNative(Runtime
The current runtime. runtime, Pointer The native memory buffer. memory, long The offset of the field. offset)Implements jnr. |
| PointerByReference | back to summary |
|---|---|
| public PointerByReference() Creates a new reference to a pointer value with a null default value. | |
| PointerByReference | back to summary |
|---|---|
| public PointerByReference(Pointer value) Creates a new reference to a pointer value
| |
| fromNative | back to summary |
|---|---|
| public final void fromNative(Runtime runtime, Pointer memory, long offset) Implements jnr. Doc from jnr. Copies the java value from native memory | |
| nativeSize | back to summary |
|---|---|
| public final int nativeSize(Runtime runtime) Implements jnr. Doc from jnr. Gets the size of the native buffer required to store the value
| |
| toNative | back to summary |
|---|---|
| public final void toNative(Runtime runtime, Pointer memory, long offset) Implements jnr. Doc from jnr. Copies the java value to native memory | |