Package org.jruby.ext.ffi
Class InvalidMemoryIO
java.lang.Object
org.jruby.ext.ffi.MemoryIO
org.jruby.ext.ffi.InvalidMemoryIO
- Direct Known Subclasses:
CodeMemoryIO,FreedMemoryIO,NullMemoryIO
An implementation of MemoryIO that throws an exception on any access.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInvalidMemoryIO(Ruby runtime, boolean isDirect, long address, String message) -
Method Summary
Modifier and TypeMethodDescriptionarray()intintCreates a view of this memory object as a java NIO byte buffer.final voidclear()dup()Duplicates thisMemoryIO, including its contents.protected RaiseExceptionex()final voidget(long offset, byte[] dst, int off, int len) Reads an array of bytes from the memory area at the specified offset.final voidget(long offset, double[] dst, int off, int len) Reads an array of doubles from the memory area at the specified offset.final voidget(long offset, float[] dst, int off, int len) Reads an array of floats from the memory area at the specified offset.final voidget(long offset, int[] dst, int off, int len) Reads an array of ints from the memory area at the specified offset.final voidget(long offset, long[] dst, int off, int len) Reads an array of longs from the memory area at the specified offset.final voidget(long offset, short[] dst, int off, int len) Reads an array of shorts from the memory area at the specified offset.final longgetAddress(long offset) Reads a pointer value at the specified offset within the memory area.final bytegetByte(long offset) Reads an 8 bit integer value from the memory area.final doublegetDouble(long offset) Reads a double value from the memory area.protected RubyClassgetErrorClass(Ruby runtime) final floatgetFloat(long offset) Reads a float value from the memory area.final intgetInt(long offset) Reads a 32 bit integer value from the memory area.final longgetLong(long offset) Reads a 64 bit integer value from the memory area.final MemoryIOgetMemoryIO(long offset) Reads a pointer value at the specified offset within the memory area, and wraps it in an abstract memory accessor.final longgetNativeLong(long offset) Reads a native long integer value from the memory area.final shortgetShort(long offset) Reads a 16 bit integer value from the memory area.byte[]getZeroTerminatedByteArray(long offset) Reads a zero terminated byte array (e.g.byte[]getZeroTerminatedByteArray(long offset, int maxlen) Reads a zero terminated byte array (e.g.final intindexOf(long offset, byte value) Gets the first index within the memory area of a particular 8 bit value.final intindexOf(long offset, byte value, int maxlen) Gets the first index within the memory area of a particular 8 bit value.order()Gets theByteOrderthisMemoryIOinstance will read/write values to memory in.final voidput(long offset, byte[] src, int off, int len) Writes an array of bytes to the memory area at the specified offset.final voidput(long offset, double[] src, int off, int len) Writes an array of doubles to the memory area at the specified offset.final voidput(long offset, float[] src, int off, int len) Writes an array of floats to the memory area at the specified offset.final voidput(long offset, int[] src, int off, int len) Writes an array of ints to the memory area at the specified offset.final voidput(long offset, long[] src, int off, int len) Writes an array of longs to the memory area at the specified offset.final voidput(long offset, short[] src, int off, int len) Writes an array of shorts to the memory area at the specified offset.final voidputAddress(long offset, long value) Writes a pointer value to the memory area at the specified offset.final voidputByte(long offset, byte value) Writes an 8 bit integer value to the memory area at the specified offset.final voidputDouble(long offset, double value) Writes a 64 bit float value to the memory area at the specified offset.final voidputFloat(long offset, float value) Writes a 32 bit float value to the memory area at the specified offset.final voidputInt(long offset, int value) Writes a 32 bit integer value to the memory area at the specified offset.final voidputLong(long offset, long value) Writes a 64 bit integer value to the memory area at the specified offset.final voidputMemoryIO(long offset, MemoryIO value) Writes a pointer value to the memory area at the specified offset.final voidputNativeLong(long offset, long value) Writes a native long integer value to the memory area at the specified offset.final voidputShort(long offset, short value) Writes a 16 bit integer value to the memory area at the specified offset.voidputZeroTerminatedByteArray(long offset, byte[] bytes, int off, int len) Writes a byte array to memory, and appends a zero terminatorfinal voidsetMemory(long offset, long size, byte value) Sets the contents of the memory area to the value.slice(long offset) Creates a new MemoryIO pointing to a subset of the memory area of thisMemoryIO.slice(long offset, long size) Creates a new MemoryIO pointing to a subset of the memory area of thisMemoryIO.
-
Field Details
-
runtime
-
-
Constructor Details
-
InvalidMemoryIO
-
-
Method Details
-
getErrorClass
-
ex
-
order
Description copied from class:MemoryIOGets theByteOrderthisMemoryIOinstance will read/write values to memory in. -
slice
Description copied from class:MemoryIOCreates a new MemoryIO pointing to a subset of the memory area of thisMemoryIO. -
slice
Description copied from class:MemoryIOCreates a new MemoryIO pointing to a subset of the memory area of thisMemoryIO. -
dup
Description copied from class:MemoryIODuplicates thisMemoryIO, including its contents. -
asByteBuffer
Description copied from class:MemoryIOCreates a view of this memory object as a java NIO byte buffer.- Specified by:
asByteBufferin classMemoryIO- Returns:
- A ByteBuffer instance
-
getByte
public final byte getByte(long offset) Description copied from class:MemoryIOReads an 8 bit integer value from the memory area. -
getShort
public final short getShort(long offset) Description copied from class:MemoryIOReads a 16 bit integer value from the memory area. -
getInt
public final int getInt(long offset) Description copied from class:MemoryIOReads a 32 bit integer value from the memory area. -
getLong
public final long getLong(long offset) Description copied from class:MemoryIOReads a 64 bit integer value from the memory area. -
getNativeLong
public final long getNativeLong(long offset) Description copied from class:MemoryIOReads a native long integer value from the memory area.A native long is 32bits on either ILP32 or LLP64 architectures, and 64 bits on an LP64 architecture.
This means that it will always read a 32bit value on Windows, but on Unix systems such as MacOS or Linux, it will read a 32bit value on 32bit systems, and a 64bit value on 64bit systems.
- Specified by:
getNativeLongin classMemoryIO- Parameters:
offset- The offset within the memory area to read the value.- Returns:
- The native long value read from
offset
-
getFloat
public final float getFloat(long offset) Description copied from class:MemoryIOReads a float value from the memory area. -
getDouble
public final double getDouble(long offset) Description copied from class:MemoryIOReads a double value from the memory area. -
getMemoryIO
Description copied from class:MemoryIOReads a pointer value at the specified offset within the memory area, and wraps it in an abstract memory accessor.- Specified by:
getMemoryIOin classMemoryIO- Parameters:
offset- The offset within the memory area to read the value.- Returns:
- A
DirectMemoryIOaccessor that can be used to access the memory pointed to by the address.
-
getAddress
public final long getAddress(long offset) Description copied from class:MemoryIOReads a pointer value at the specified offset within the memory area.- Specified by:
getAddressin classMemoryIO- Parameters:
offset- The offset within the memory area to read the value.- Returns:
- A
longvalue that represents the address.
-
putByte
public final void putByte(long offset, byte value) Description copied from class:MemoryIOWrites an 8 bit integer value to the memory area at the specified offset. -
putShort
public final void putShort(long offset, short value) Description copied from class:MemoryIOWrites a 16 bit integer value to the memory area at the specified offset. -
putInt
public final void putInt(long offset, int value) Description copied from class:MemoryIOWrites a 32 bit integer value to the memory area at the specified offset. -
putLong
public final void putLong(long offset, long value) Description copied from class:MemoryIOWrites a 64 bit integer value to the memory area at the specified offset. -
putNativeLong
public final void putNativeLong(long offset, long value) Description copied from class:MemoryIOWrites a native long integer value to the memory area at the specified offset.- Specified by:
putNativeLongin classMemoryIO- Parameters:
offset- The offset within the memory area to write the value.value- The native long integer value to write to the memory location.
-
putFloat
public final void putFloat(long offset, float value) Description copied from class:MemoryIOWrites a 32 bit float value to the memory area at the specified offset. -
putDouble
public final void putDouble(long offset, double value) Description copied from class:MemoryIOWrites a 64 bit float value to the memory area at the specified offset. -
putMemoryIO
Description copied from class:MemoryIOWrites a pointer value to the memory area at the specified offset.- Specified by:
putMemoryIOin classMemoryIO- Parameters:
offset- The offset within the memory area to write the value.value- The pointer value to write to the memory location.
-
putAddress
public final void putAddress(long offset, long value) Description copied from class:MemoryIOWrites a pointer value to the memory area at the specified offset.- Specified by:
putAddressin classMemoryIO- Parameters:
offset- The offset within the memory area to write the value.value- The pointer value to write to the memory location.
-
get
public final void get(long offset, byte[] dst, int off, int len) Description copied from class:MemoryIOReads an array of bytes from the memory area at the specified offset. -
put
public final void put(long offset, byte[] src, int off, int len) Description copied from class:MemoryIOWrites an array of bytes to the memory area at the specified offset. -
get
public final void get(long offset, short[] dst, int off, int len) Description copied from class:MemoryIOReads an array of shorts from the memory area at the specified offset. -
put
public final void put(long offset, short[] src, int off, int len) Description copied from class:MemoryIOWrites an array of shorts to the memory area at the specified offset. -
get
public final void get(long offset, int[] dst, int off, int len) Description copied from class:MemoryIOReads an array of ints from the memory area at the specified offset. -
put
public final void put(long offset, int[] src, int off, int len) Description copied from class:MemoryIOWrites an array of ints to the memory area at the specified offset. -
get
public final void get(long offset, long[] dst, int off, int len) Description copied from class:MemoryIOReads an array of longs from the memory area at the specified offset. -
put
public final void put(long offset, long[] src, int off, int len) Description copied from class:MemoryIOWrites an array of longs to the memory area at the specified offset. -
get
public final void get(long offset, float[] dst, int off, int len) Description copied from class:MemoryIOReads an array of floats from the memory area at the specified offset. -
put
public final void put(long offset, float[] src, int off, int len) Description copied from class:MemoryIOWrites an array of floats to the memory area at the specified offset. -
get
public final void get(long offset, double[] dst, int off, int len) Description copied from class:MemoryIOReads an array of doubles from the memory area at the specified offset. -
put
public final void put(long offset, double[] src, int off, int len) Description copied from class:MemoryIOWrites an array of doubles to the memory area at the specified offset. -
indexOf
public final int indexOf(long offset, byte value) Description copied from class:MemoryIOGets the first index within the memory area of a particular 8 bit value. -
indexOf
public final int indexOf(long offset, byte value, int maxlen) Description copied from class:MemoryIOGets the first index within the memory area of a particular 8 bit value. -
setMemory
public final void setMemory(long offset, long size, byte value) Description copied from class:MemoryIOSets the contents of the memory area to the value. -
clear
public final void clear() -
getZeroTerminatedByteArray
public byte[] getZeroTerminatedByteArray(long offset) Description copied from class:MemoryIOReads a zero terminated byte array (e.g. an ascii or utf-8 string)- Specified by:
getZeroTerminatedByteArrayin classMemoryIO- Parameters:
offset- The offset within the memory area of the start of the string.- Returns:
- A byte array containing a copy of the data.
-
getZeroTerminatedByteArray
public byte[] getZeroTerminatedByteArray(long offset, int maxlen) Description copied from class:MemoryIOReads a zero terminated byte array (e.g. an ascii or utf-8 string)- Specified by:
getZeroTerminatedByteArrayin classMemoryIO- Parameters:
offset- The offset within the memory area of the start of the string.maxlen- The maximum length to search for the zero byte terminator.- Returns:
- A byte array containing a copy of the data.
-
putZeroTerminatedByteArray
public void putZeroTerminatedByteArray(long offset, byte[] bytes, int off, int len) Description copied from class:MemoryIOWrites a byte array to memory, and appends a zero terminator- Specified by:
putZeroTerminatedByteArrayin classMemoryIO- Parameters:
offset- The offset within the memory area of the start of the string.bytes- The byte array to write to the memory.off- The offset with the byte array to start copying.len- The number of bytes of the byte array to write to the memory area. (not including zero byte)
-
array
-
arrayOffset
public int arrayOffset()- Specified by:
arrayOffsetin classMemoryIO
-
arrayLength
public int arrayLength()- Specified by:
arrayLengthin classMemoryIO
-