Package de.intarsys.nativec.api
Interface INativeHandle
public interface INativeHandle
A "handle" to a piece of memory (in c space).
The handle combines an address and a memory chunk of a specified size.
-
Method Summary
Modifier and TypeMethodDescriptionlongThe start address of the memory chunkbytegetByte(int index) Marshal the data at byte offsetindexfrom the start of the memory chunk to a byte.byte[]getByteArray(int index, int count) Marshal the data at byte offsetindexfrom the start of the memory chunk to a byte array of lengthcount.longgetCLong(int index) Marshal the data at byte offsetindexfrom the start of the memory chunk to a long.floatgetFloat(int index) intgetInt(int index) Marshal the data at byte offsetindexfrom the start of the memory chunk to an int.longgetLong(int index) Marshal the data at byte offsetindexfrom the start of the memory chunk to a long value (which is always 8 byte).getNativeHandle(int index) Marshal the data at byte offsetindexfrom the start of the memory chunk to anINativeHandle.shortgetShort(int index) Marshal the data at byte offsetindexfrom the start of the memory chunk to a short.intgetSize()The size for the handle in bytes.getString(int index) Marshal the data at byte offsetindexfrom the start of the memory chunk to a String.getWideString(int index) Marshal the data at byte offsetindexfrom the start of the memory chunk to a String using the platform wide character conversion.offset(int offset) Create a newINativeHandle, offset from this byoffsetbytes.voidsetByte(int index, byte value) Write a byte to the memory at byte offsetindexfrom the start of the memory chunk.voidsetByteArray(int index, byte[] value, int valueOffset, int valueCount) Write a byte array to the memory at byte offsetindexfrom the start of the memory chunk.voidsetCLong(int index, long value) Write a long to the memory at byte offsetindexfrom the start of the memory chunk.voidsetFloat(int index, float value) voidsetInt(int index, int value) Write an int to the memory at byte offsetindexfrom the start of the memory chunk.voidsetLong(int index, long value) Write a long to the memory at byte offsetindexfrom the start of the memory chunk.voidsetNativeHandle(int index, INativeHandle valueHandle) Write anINativeHandleto the memory at byte offsetindexfrom the start of the memory chunk.voidsetShort(int index, short value) Write a short to the memory at byte offsetindexfrom the start of the memory chunk.voidsetSize(int count) Set the valid size for the handle tocountbytes.voidWrite a String to the memory at byte offsetindexfrom the start of the memory chunk.voidsetWideString(int index, String value) Write a String to the memory at byte offsetindexfrom the start of the memory chunk using the platform wide character conversion.
-
Method Details
-
getAddress
long getAddress()The start address of the memory chunk- Returns:
- The start address of the memory chunk
-
getByte
byte getByte(int index) Marshal the data at byte offsetindexfrom the start of the memory chunk to a byte.- Parameters:
index- The byte offset from the start of the memory chunk- Returns:
- A byte marshaled from the memory chunk
-
getByteArray
byte[] getByteArray(int index, int count) Marshal the data at byte offsetindexfrom the start of the memory chunk to a byte array of lengthcount.- Parameters:
index- The byte offset from the start of the memory chunkcount- The size of the byte array- Returns:
- A byte array marshaled from the memory chunk
-
getCLong
long getCLong(int index) Marshal the data at byte offsetindexfrom the start of the memory chunk to a long. Get only the "platform" number of bytes.- Parameters:
index- The byte offset from the start of the memory chunk- Returns:
- A long marshaled from the memory chunk
-
getFloat
float getFloat(int index) -
getInt
int getInt(int index) Marshal the data at byte offsetindexfrom the start of the memory chunk to an int.- Parameters:
index- The byte offset from the start of the memory chunk- Returns:
- An int marshaled from the memory chunk
-
getLong
long getLong(int index) Marshal the data at byte offsetindexfrom the start of the memory chunk to a long value (which is always 8 byte).- Parameters:
index- The byte offset from the start of the memory chunk- Returns:
- A long marshaled from the memory chunk
-
getNativeHandle
Marshal the data at byte offsetindexfrom the start of the memory chunk to anINativeHandle.- Parameters:
index- The byte offset from the start of the memory chunk- Returns:
- An
INativeHandlemarshaled from the memory chunk
-
getShort
short getShort(int index) Marshal the data at byte offsetindexfrom the start of the memory chunk to a short.- Parameters:
index- The byte offset from the start of the memory chunk- Returns:
- A short marshaled from the memory chunk
-
getSize
int getSize()The size for the handle in bytes.You can not access bytes from outside the range defined by getAdddress + size.
-
getString
Marshal the data at byte offsetindexfrom the start of the memory chunk to a String.- Parameters:
index- The byte offset from the start of the memory chunk- Returns:
- A String marshaled from the memory chunk
-
getWideString
Marshal the data at byte offsetindexfrom the start of the memory chunk to a String using the platform wide character conversion.- Parameters:
index- The byte offset from the start of the memory chunk- Returns:
- A String marshaled from the memory chunk
-
offset
Create a newINativeHandle, offset from this byoffsetbytes.- Parameters:
offset- The byte offset from the start of the memory chunk- Returns:
- A new
INativeHandlepointing to "getAddress() + offset".
-
setByte
void setByte(int index, byte value) Write a byte to the memory at byte offsetindexfrom the start of the memory chunk.- Parameters:
index- The byte offset from the start of the memory chunkvalue- The value to write.
-
setByteArray
void setByteArray(int index, byte[] value, int valueOffset, int valueCount) Write a byte array to the memory at byte offsetindexfrom the start of the memory chunk. The method will writevalueCountbytes fromvaluestarting atvalueOffset.- Parameters:
index- The byte offset from the start of the memory chunkvalue- The value to write.
-
setCLong
void setCLong(int index, long value) Write a long to the memory at byte offsetindexfrom the start of the memory chunk. Write only the "platform" number of bytes. The caller is responsible for observing the value range.- Parameters:
index- The byte offset from the start of the memory chunkvalue- The value to write.
-
setFloat
void setFloat(int index, float value) -
setInt
void setInt(int index, int value) Write an int to the memory at byte offsetindexfrom the start of the memory chunk.- Parameters:
index- The byte offset from the start of the memory chunkvalue- The value to write.
-
setLong
void setLong(int index, long value) Write a long to the memory at byte offsetindexfrom the start of the memory chunk.- Parameters:
index- The byte offset from the start of the memory chunkvalue- The value to write.
-
setNativeHandle
Write anINativeHandleto the memory at byte offsetindexfrom the start of the memory chunk.- Parameters:
index- The byte offset from the start of the memory chunkvalueHandle- The value to write.
-
setShort
void setShort(int index, short value) Write a short to the memory at byte offsetindexfrom the start of the memory chunk.- Parameters:
index- The byte offset from the start of the memory chunkvalue- The value to write.
-
setSize
void setSize(int count) Set the valid size for the handle tocountbytes.You can not access bytes from outside the range defined by getAdddress + size.
- Parameters:
count- The size of the memory managed by theINativeHandle
-
setString
Write a String to the memory at byte offsetindexfrom the start of the memory chunk.- Parameters:
index- The byte offset from the start of the memory chunkvalue- The value to write.
-
setWideString
Write a String to the memory at byte offsetindexfrom the start of the memory chunk using the platform wide character conversion.- Parameters:
index- The byte offset from the start of the memory chunkvalue- The value to write.
-