Package de.intarsys.nativec.api
Interface INativeHandle
- All Known Implementing Classes:
JnaNativeHandle
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 TypeMethodDescriptionlong
The start address of the memory chunkbyte
getByte
(int index) Marshal the data at byte offsetindex
from the start of the memory chunk to a byte.byte[]
getByteArray
(int index, int count) Marshal the data at byte offsetindex
from the start of the memory chunk to a byte array of lengthcount
.long
getCLong
(int index) Marshal the data at byte offsetindex
from the start of the memory chunk to a long.int
getInt
(int index) Marshal the data at byte offsetindex
from the start of the memory chunk to an int.long
getLong
(int index) Marshal the data at byte offsetindex
from the start of the memory chunk to a long value (which is always 8 byte).getNativeHandle
(int index) Marshal the data at byte offsetindex
from the start of the memory chunk to anINativeHandle
.short
getShort
(int index) Marshal the data at byte offsetindex
from the start of the memory chunk to a short.int
getSize()
The size for the handle in bytes.getString
(int index) Marshal the data at byte offsetindex
from the start of the memory chunk to a String.getWideString
(int index) Marshal the data at byte offsetindex
from the start of the memory chunk to a String using the platform wide character conversion.offset
(int offset) Create a newINativeHandle
, offset from this byoffset
bytes.void
setByte
(int index, byte value) Write a byte to the memory at byte offsetindex
from the start of the memory chunk.void
setByteArray
(int index, byte[] value, int valueOffset, int valueCount) Write a byte array to the memory at byte offsetindex
from the start of the memory chunk.void
setCLong
(int index, long value) Write a long to the memory at byte offsetindex
from the start of the memory chunk.void
setInt
(int index, int value) Write an int to the memory at byte offsetindex
from the start of the memory chunk.void
setLong
(int index, long value) Write a long to the memory at byte offsetindex
from the start of the memory chunk.void
setNativeHandle
(int index, INativeHandle valueHandle) Write anINativeHandle
to the memory at byte offsetindex
from the start of the memory chunk.void
setShort
(int index, short value) Write a short to the memory at byte offsetindex
from the start of the memory chunk.void
setSize
(int count) Set the valid size for the handle tocount
bytes.void
Write a String to the memory at byte offsetindex
from the start of the memory chunk.void
setWideString
(int index, String value) Write a String to the memory at byte offsetindex
from 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 offsetindex
from 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 offsetindex
from 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 offsetindex
from 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
-
getInt
int getInt(int index) Marshal the data at byte offsetindex
from 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 offsetindex
from 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 offsetindex
from the start of the memory chunk to anINativeHandle
.- Parameters:
index
- The byte offset from the start of the memory chunk- Returns:
- An
INativeHandle
marshaled from the memory chunk
-
getShort
short getShort(int index) Marshal the data at byte offsetindex
from 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 offsetindex
from 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 offsetindex
from 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 byoffset
bytes.- Parameters:
offset
- The byte offset from the start of the memory chunk- Returns:
- A new
INativeHandle
pointing to "getAddress() + offset".
-
setByte
void setByte(int index, byte value) Write a byte to the memory at byte offsetindex
from 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 offsetindex
from the start of the memory chunk. The method will writevalueCount
bytes fromvalue
starting 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 offsetindex
from 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.
-
setInt
void setInt(int index, int value) Write an int to the memory at byte offsetindex
from 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 offsetindex
from the start of the memory chunk.- Parameters:
index
- The byte offset from the start of the memory chunkvalue
- The value to write.
-
setNativeHandle
Write anINativeHandle
to the memory at byte offsetindex
from 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 offsetindex
from 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 tocount
bytes.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 offsetindex
from 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 offsetindex
from 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.
-