public class ComplexArray extends Structure implements ArrayParameter
All objects in the array must have the same type.
Note: If a function takes an array as its parameter, you should take Pointer referencing that ComplexArray object, instead of direct taking the ComplexArray instance.
LICENSE_TYPE, V
Constructor and Description |
---|
ComplexArray(Parameter[] arr)
Constructs an array object taking a specified
Parameter
array. |
ComplexArray(Parameter sample,
int count)
Constructs an array 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.
|
static void |
arrayCopy(ComplexArray from,
ComplexArray to)
Copy ComplexArray content
|
java.lang.Object |
clone() |
void |
forceElementCount(int elementCount)
Sets a new array size without memory reallocation.
|
void |
fromParameterArray(Parameter[] params)
Sets array contents to the given values.
|
int |
getAlignmentRequirement() |
Parameter |
getElement(int i)
Returns an array item specified by an index.
|
int |
getElementCount()
Returns the number of elements in the array.
|
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(DataBuffer stackBuffer,
int offset,
boolean invokedByCallback)
Reads this parameter from a specified data source.
|
protected void |
setDataBuffer(DataBuffer newSource,
int newOffset,
boolean shouldRead)
Sets the data buffer this parameter should use to store data and an
offset in bytes within that buffer.
|
void |
setElement(int i,
Parameter elem)
Replaces an array item with the specified object.
|
void |
setElementCount(int elementCount)
Resizes this array to a given size.
|
Parameter[] |
toParameterArray()
Returns items as Java array.
|
java.lang.String |
toString() |
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.
|
addMembers, computeLength, equals, getDebugInfo, getFirstMemberSize, getLength, getMember, getMembers, getOffsets, init, init, initFrom
asReturnValue, dataBufferAssigned, getAlignedLength, getDataBuffer, getDataBufferOffset, hashCode, indent, read, read, toByteArray
public ComplexArray(Parameter[] arr)
Parameter
array.public ComplexArray(Parameter sample, int count)
sample
- a sample for items in the constructed arraycount
- count of items in the constructed arraypublic void write(byte[] arr, int offset)
Parameter
public Parameter getElement(int i)
ArrayParameter
getElement
in interface ArrayParameter
i
- index of a requested array itempublic void setElement(int i, Parameter elem)
ArrayParameter
setElement
in interface ArrayParameter
i
- index of an item to be replacedelem
- object to be set as array itemprotected void setDataBuffer(DataBuffer newSource, int newOffset, boolean shouldRead)
Parameter
setDataBuffer
in class Structure
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 Structure
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.public void write(DataBuffer stackBuffer, int offset, boolean invokedByCallback) throws MemoryAccessViolationException
Parameter
write
in class Structure
MemoryAccessViolationException
public void read(DataBuffer stackBuffer, int offset, boolean invokedByCallback) throws MemoryAccessViolationException
Parameter
read
in class Structure
MemoryAccessViolationException
public void push(DataBuffer stackBuffer, int offset, boolean invokedByCallback) throws MemoryAccessViolationException
Parameter
push
in class Structure
MemoryAccessViolationException
public void pop(DataBuffer stackBuffer, int offset, boolean invokedByCallback) throws MemoryAccessViolationException
Parameter
pop
in class Structure
MemoryAccessViolationException
public int getElementCount()
ArrayParameter
getElementCount
in interface ArrayParameter
public Parameter[] toParameterArray()
ArrayParameter
toParameterArray
in interface ArrayParameter
public void fromParameterArray(Parameter[] params)
ArrayParameter
fromParameterArray
in interface ArrayParameter
public java.lang.String toString()
toString
in class java.lang.Object
public void forceElementCount(int elementCount)
ArrayParameter
forceElementCount
in interface ArrayParameter
public void setElementCount(int elementCount)
ArrayParameter
setElementCount
in interface ArrayParameter
public static void arrayCopy(ComplexArray from, ComplexArray to)
from
- sourceto
- destinationpublic int getAlignmentRequirement()
getAlignmentRequirement
in class Structure