public final class PointerByReference extends AbstractReference<Pointer>
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 and Description |
---|
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
|
Modifier and Type | Method and Description |
---|---|
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
|
checkNull, getValue
public PointerByReference()
public PointerByReference(Pointer value)
value
- the initial pointer valuepublic 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
Copyright © 2013. All Rights Reserved.