public class Pointer extends Parameter implements PointerParameter
Pointer type is defined by its referenced object. For example, an int pointer (int *
)
is a Pointer
to Int
.
Int value = new Int(); Pointer pValue = new Pointer(value); // this is int*
Modifier and Type | Class and Description |
---|---|
static class |
Pointer.Const
Represents a pointer to constant object.
|
static class |
Pointer.OutOnly
Represents a pointer to object with undefined initial value.
|
static class |
Pointer.Void
Represents a
void * . |
Modifier and Type | Field and Description |
---|---|
static int |
POINTER_LENGTH |
LICENSE_TYPE, V
Constructor and Description |
---|
Pointer(java.lang.Class parameterClass)
Constructs a new typified pointer.
|
Pointer(Parameter ref)
Constructs a new pointer to a given object.
|
Pointer(Parameter ref,
boolean isNull)
Constructs a new pointer to a given object.
|
Modifier and Type | Method and Description |
---|---|
protected void |
acceptIOPerformer(IOPerformer performer,
DataBuffer source,
int initialOffset,
boolean isReadOperation,
boolean invokedByCallback)
Implementation of a Visitor pattern for parameter IO.
|
void |
asTypedPointer(Pointer target)
Deprecated.
use
castTo(com.jniwrapper.Pointer) instead. |
void |
asVoidPointer(Pointer.Void target)
Deprecated.
use
castTo(com.jniwrapper.Pointer.Void) instead. |
void |
castTo(Pointer.Void target)
Casts this pointer to the given void pointer.
|
void |
castTo(Pointer target)
Assigns this pointer value to the typed pointer.
|
protected void |
checkMemHandleLength()
Checks that the memory block referred to by this pointer is big enough to hold
the referenced object and allocates a new one if required.
|
java.lang.Object |
clone() |
boolean |
equals(java.lang.Object obj)
Compares this
Parameter object to a given object. |
java.lang.String |
getDebugInfo()
Return debug info for JNIWrapper parameter.
|
int |
getLength()
Returns the length of the parameter in memory.
|
java.lang.Class |
getParameterClass()
Returns the parameter type of this pointer object.
|
long |
getPointerHandle()
Returns the value of pointer as used by the native side.
|
Parameter |
getReferencedObject()
Returns the referenced object of this pointer.
|
boolean |
isNull()
Tests if this pointer is null.
|
void |
pop(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
Default implementation that does nothing because most primitive types do
nothing on pop.
|
void |
push(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
Writes a parameter to a function stacks.
|
void |
read(byte[] arr,
int offset)
Reads the parameter value from a byte array.
|
void |
read(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
Reads this parameter from a specified data source.
|
protected void |
readPointer(DataBuffer stackBuffer,
int offset)
Reads this pointer handle part (not the referenced object) from the given data buffer.
|
protected void |
readReferencedObject(boolean invokedByCallback)
Reads the referenced object only.
|
protected void |
setExternalSource(long newHandle,
int length)
Makes this pointer use external (unmanaged) memory area.
|
void |
setNull(boolean isNull)
Sets a pointer null value.
|
void |
setReferencedObject(Parameter ref)
Changes the pointer referenced object.
|
void |
setReferencedObject(Parameter ref,
boolean isNull)
Changes the pointer referenced object.
|
void |
write(byte[] arr,
int offset)
Writes the parameter value to a byte array.
|
void |
write(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
Writes this parameter to a specified data source.
|
protected void |
writePointer(DataBuffer stackBuffer,
int offset)
Writes this pointer handle part (not the referenced object) to a given data buffer.
|
protected void |
writeReferencedObject(boolean invokedByCallback)
Writes the referenced object only.
|
asReturnValue, dataBufferAssigned, getAlignedLength, getAlignmentRequirement, getDataBuffer, getDataBufferOffset, hashCode, indent, read, setDataBuffer, toByteArray
public Pointer(Parameter ref)
ref
- referenced object.public Pointer(Parameter ref, boolean isNull)
ref
- referenced objectisNull
- if true
the constructed pointer is null.public Pointer(java.lang.Class parameterClass)
parameterClass
- defines the parameter type.public void asTypedPointer(Pointer target)
castTo(com.jniwrapper.Pointer)
instead.target
- typed pointer.public void castTo(Pointer target)
target
- typed pointer.public Parameter getReferencedObject()
public void setReferencedObject(Parameter ref)
public void setReferencedObject(Parameter ref, boolean isNull)
ref
- new referenced object.isNull
- if true
this pointer becomes null.public final boolean isNull()
isNull
in interface PointerParameter
public final void setNull(boolean isNull)
true
makes the
pointer to be null, setting to false
makes it to reference
its referenced object.public int getLength()
Parameter
sizeof()
operator.public void write(byte[] arr, int offset)
Parameter
public void read(byte[] arr, int offset)
Parameter
public long getPointerHandle()
public void write(DataBuffer stackBuffer, int offset, boolean invokedByCallback) throws MemoryAccessViolationException
Parameter
write
in class Parameter
MemoryAccessViolationException
protected void writePointer(DataBuffer stackBuffer, int offset) throws MemoryAccessViolationException
MemoryAccessViolationException
public void read(DataBuffer stackBuffer, int offset, boolean invokedByCallback) throws MemoryAccessViolationException
Parameter
read
in class Parameter
MemoryAccessViolationException
protected void readPointer(DataBuffer stackBuffer, int offset) throws MemoryAccessViolationException
MemoryAccessViolationException
public void asVoidPointer(Pointer.Void target)
castTo(com.jniwrapper.Pointer.Void)
instead.target
- target void pointerpublic void castTo(Pointer.Void target)
target
- the target void pointerprotected void setExternalSource(long newHandle, int length)
newHandle
- memory handlelength
- known allocated lengthpublic void push(DataBuffer stackBuffer, int offset, boolean invokedByCallback)
Parameter
public void pop(DataBuffer stackBuffer, int offset, boolean invokedByCallback) throws MemoryAccessViolationException
Parameter
pop
in class Parameter
MemoryAccessViolationException
protected void checkMemHandleLength()
protected void acceptIOPerformer(IOPerformer performer, DataBuffer source, int initialOffset, boolean isReadOperation, boolean invokedByCallback)
Parameter
performer
is responsible for reading and writing the
parameter. Users implementing a complex parameter from scratch (i.e. not
by extending a pre-existing class such as Structure
or
Pointer
) may wish to override this method to make a
performer visit object internal parts.acceptIOPerformer
in class Parameter
performer
- a visitor responsible for I/Oing the parameter.source
- data buffer for I/O operation.initialOffset
- I/O operation offset of this parameter in the
buffer.protected void writeReferencedObject(boolean invokedByCallback)
protected void readReferencedObject(boolean invokedByCallback)
public boolean equals(java.lang.Object obj)
Parameter
Parameter
object to a given object. Two
Parameter
objects are considered equal if their byte
representations are equal and they are of the same type. Subclasses may
override this method as appropriate.public java.lang.String getDebugInfo()
Parameter
getDebugInfo
in class Parameter
public java.lang.Class getParameterClass()