|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object posix.CPtr
public class CPtr
Read and write memory reachable through a C ptr. Memory access is bounds checked to keep it within the size of region addressed by the C ptr. Only classes within the posix package can create CPtr objects, and the use of this class is completely safe at present. This is because we know the size of, for instance, shared memory segments or memory allocated with C malloc. At some future date, we may need the ability to dereference arbitrary C pointers - those dereferences will be unsafe.
We have not yet implemented the floating and 64-bit types for get/set due to a lack of need.
Nested Class Summary | |
---|---|
static class |
CPtr.Struct
Compute the offsets of a C struct one member at a time. |
Field Summary | |
---|---|
static int |
CBYTE_TYPE
Type codes for alignOf() and sizeOf() . |
static int |
CDBL_TYPE
Type codes for alignOf() and sizeOf() . |
static int |
CFLT_TYPE
Type codes for alignOf() and sizeOf() . |
static int |
CINT_TYPE
Type codes for alignOf() and sizeOf() . |
static int |
CLONG_TYPE
Type codes for alignOf() and sizeOf() . |
static int |
CPTR_TYPE
Type codes for alignOf() and sizeOf() . |
static int |
CSHORT_TYPE
Type codes for alignOf() and sizeOf() . |
Method Summary | |
---|---|
static int |
alignOf(int type)
Get the alignment of a C type. |
void |
copyIn(int off,
byte[] ba,
int pos,
int cnt)
Copy a Java byte array into C memory. |
void |
copyOut(int off,
byte[] ba,
int pos,
int cnt)
Copy bytes out of C memory into a Java byte array. |
byte |
getByte(int off)
|
int |
getCInt(int off)
|
int |
getCInt(int off,
int idx)
|
short |
getCShort(int off)
|
short |
getCShort(int off,
int idx)
|
int |
getInt(int off)
|
short |
getShort(int off)
|
void |
setByte(int off,
byte val)
|
void |
setCInt(int off,
int val)
|
void |
setCInt(int off,
int idx,
int val)
|
void |
setCShort(int off,
int idx,
short val)
|
void |
setCShort(int off,
short val)
|
void |
setInt(int off,
int val)
|
void |
setShort(int off,
short val)
|
static int |
sizeOf(int type)
Get the size of a C type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int CBYTE_TYPE
alignOf()
and sizeOf()
.
public static final int CSHORT_TYPE
alignOf()
and sizeOf()
.
public static final int CINT_TYPE
alignOf()
and sizeOf()
.
public static final int CLONG_TYPE
alignOf()
and sizeOf()
.
public static final int CFLT_TYPE
alignOf()
and sizeOf()
.
public static final int CDBL_TYPE
alignOf()
and sizeOf()
.
public static final int CPTR_TYPE
alignOf()
and sizeOf()
.
Method Detail |
---|
public static int alignOf(int type)
public static int sizeOf(int type)
public void copyOut(int off, byte[] ba, int pos, int cnt)
public void copyIn(int off, byte[] ba, int pos, int cnt)
public byte getByte(int off)
public void setByte(int off, byte val)
public short getShort(int off)
public void setShort(int off, short val)
public int getInt(int off)
public void setInt(int off, int val)
public short getCShort(int off, int idx)
public void setCShort(int off, int idx, short val)
public int getCInt(int off, int idx)
public void setCInt(int off, int idx, int val)
public short getCShort(int off)
public void setCShort(int off, short val)
public int getCInt(int off)
public void setCInt(int off, int val)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |