Class AbstractMemoryIO
- java.lang.Object
-
- jnr.ffi.Pointer
-
- jnr.ffi.provider.AbstractMemoryIO
-
- Direct Known Subclasses:
AbstractArrayMemoryIO
,AbstractBufferMemoryIO
,BoundedMemoryIO
,InAccessibleMemoryIO
,ShareMemoryIO
,TransientNativeMemory
public abstract class AbstractMemoryIO extends Pointer
Base implementations of some MemoryIO operations.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractMemoryIO(Runtime runtime, long address, boolean isDirect)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkBounds(long offset, long size)
Checks that the memory region is within the bounds of this memory objectprotected static void
checkBounds(long size, long off, long len)
long
getAddress(long offset)
Reads a native memory address value at the given offset.long
getInt(Type type, long offset)
Reads an integer value of the given type, at the given offset.long
getLong(long offset)
Reads along
(64 bit) value at the given offset.long
getNativeLong(long offset)
Reads a nativelong
value at the given offset.int
indexOf(long offset, byte value)
Returns the location of a byte value within the memory area represented by thisPointer
.void
putAddress(long offset, long value)
Writes a native memory address value at the given offset.void
putAddress(long offset, Address value)
Writes a native memory address value at the given offset.void
putInt(Type type, long offset, long value)
Writes an integer of a specific type, at the given offset.void
putLong(long offset, long value)
Writes anative long
value at the given offset.void
putNativeLong(long offset, long value)
Writes a nativelong
value at the given offset.AbstractMemoryIO
slice(long offset)
Creates a newPointer
representing a sub-region of the memory referred to by thisPointer
.AbstractMemoryIO
slice(long offset, long size)
Creates a newPointer
representing a sub-region of the memory referred to by thisPointer
.void
transferFrom(long offset, Pointer other, long otherOffset, long count)
Bulk data transfer from one memory location to another.void
transferTo(long offset, Pointer other, long otherOffset, long count)
Bulk data transfer from one memory location to another.-
Methods inherited from class jnr.ffi.Pointer
address, array, arrayLength, arrayOffset, get, get, get, get, get, get, get, getByte, getDouble, getFloat, getInt, getLongLong, getNullTerminatedPointerArray, getNullTerminatedStringArray, getPointer, getPointer, getRuntime, getShort, getString, getString, hasArray, indexOf, isDirect, newIntPointer, put, put, put, put, put, put, put, putByte, putDouble, putFloat, putInt, putLongLong, putPointer, putShort, putString, setMemory, size, toString, wrap, wrap, wrap
-
-
-
-
Constructor Detail
-
AbstractMemoryIO
protected AbstractMemoryIO(Runtime runtime, long address, boolean isDirect)
-
-
Method Detail
-
checkBounds
protected static void checkBounds(long size, long off, long len)
-
indexOf
public int indexOf(long offset, byte value)
Description copied from class:Pointer
Returns the location of a byte value within the memory area represented by thisPointer
.- Specified by:
indexOf
in classPointer
- Parameters:
offset
- the offset from the start of the memory location thisPointer
represents to begin searching.value
- thebyte
value to locate.- Returns:
- the offset from the start of the search area (i.e. relative to the offset parameter), or -1 if not found.
-
getAddress
public long getAddress(long offset)
Description copied from class:Pointer
Reads a native memory address value at the given offset.A native address can be either 32 or 64 bits in size, depending on the cpu architecture.
- Specified by:
getAddress
in classPointer
- Parameters:
offset
- The offset from the start of the memory thisPointer
represents at which the value will be read.- Returns:
- the native address value contained in the memory at the offset
- See Also:
Address
-
putAddress
public void putAddress(long offset, long value)
Description copied from class:Pointer
Writes a native memory address value at the given offset.A native address can be either 32 or 64 bits in size, depending on the cpu architecture.
- Specified by:
putAddress
in classPointer
- Parameters:
offset
- The offset from the start of the memory thisPointer
represents at which the value will be written.value
- The native address value to be written.- See Also:
Address
-
checkBounds
public void checkBounds(long offset, long size)
Description copied from class:Pointer
Checks that the memory region is within the bounds of this memory object- Specified by:
checkBounds
in classPointer
- Parameters:
offset
- the starting point within this memory region.size
- the length of the memory region in bytes
-
putAddress
public void putAddress(long offset, Address value)
Description copied from class:Pointer
Writes a native memory address value at the given offset.A native address can be either 32 or 64 bits in size, depending on the cpu architecture.
- Specified by:
putAddress
in classPointer
- Parameters:
offset
- The offset from the start of the memory thisPointer
represents at which the value will be written.value
- The native address value to be written.- See Also:
Address
-
getNativeLong
public final long getNativeLong(long offset)
Description copied from class:Pointer
Reads a nativelong
value at the given offset.A native
long
can be either 32 or 64 bits in size, depending on the cpu architecture, and the C ABI in use.For windows, a long is always 32 bits (4 bytes) in size, but on unix systems, a long on a 32bit system is 32 bits, and on a 64bit system, is 64 bits.
- Specified by:
getNativeLong
in classPointer
- Parameters:
offset
- The offset from the start of the memory thisPointer
represents at which the value will be read.- Returns:
- the native
long
value at the offset. - See Also:
NativeLong
-
putNativeLong
public void putNativeLong(long offset, long value)
Description copied from class:Pointer
Writes a nativelong
value at the given offset.A native
long
can be either 32 or 64 bits in size, depending on the cpu architecture, and the C ABI in use.For windows, a long is always 32 bits (4 bytes) in size, but on unix systems, a long on a 32bit system is 32 bits, and on a 64bit system, is 64 bits.
- Specified by:
putNativeLong
in classPointer
- Parameters:
offset
- The offset from the start of the memory thisPointer
represents at which the value will be written.value
- the nativelong
value to be written.
-
getLong
public long getLong(long offset)
Description copied from class:Pointer
Reads along
(64 bit) value at the given offset.
-
putLong
public void putLong(long offset, long value)
Description copied from class:Pointer
Writes anative long
value at the given offset.
-
putInt
public void putInt(Type type, long offset, long value)
Description copied from class:Pointer
Writes an integer of a specific type, at the given offset.
-
getInt
public long getInt(Type type, long offset)
Description copied from class:Pointer
Reads an integer value of the given type, at the given offset.
-
slice
public AbstractMemoryIO slice(long offset)
Description copied from class:Pointer
Creates a newPointer
representing a sub-region of the memory referred to by thisPointer
.
-
slice
public AbstractMemoryIO slice(long offset, long size)
Description copied from class:Pointer
Creates a newPointer
representing a sub-region of the memory referred to by thisPointer
.
-
transferTo
public void transferTo(long offset, Pointer other, long otherOffset, long count)
Description copied from class:Pointer
Bulk data transfer from one memory location to another.- Specified by:
transferTo
in classPointer
- Parameters:
offset
- the offset from the start of the memory location thisPointer
represents to begin copying from.other
- the destination memory location to transfer data to.otherOffset
- the offset from the start of the memory location the destinationPointer
represents to begin copying to.count
- the number of bytes to transfer.
-
transferFrom
public void transferFrom(long offset, Pointer other, long otherOffset, long count)
Description copied from class:Pointer
Bulk data transfer from one memory location to another.- Specified by:
transferFrom
in classPointer
- Parameters:
offset
- the offset from the start of the memory location thisPointer
represents to begin copying to.other
- the destination memory location to transfer data from.otherOffset
- the offset from the start of the memory location the destinationPointer
represents to begin copying from.count
- the number of bytes to transfer.
-
-