Package de.intarsys.nativec.type
Class NativeObject
java.lang.Object
de.intarsys.nativec.type.NativeObject
- All Implemented Interfaces:
INativeMemory,INativeObject
- Direct Known Subclasses:
NativeArray,NativeBuffer,NativeReference,NativeSimple,NativeString,NativeStruct,NativeWideString
An instance of an external (C memory) represented object. The C-object is
represented using the handle (the pointer to the object in C memory) and its
type
INativeType.
Supported data types are
- primitive types (char, byte, int, short, long, String...)
- byte buffer
- array types
- structures
- references
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic booleanDEBUG flagstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptioncast(INativeType declaration) This is a special form of the "createNative" signature, implementing a "type cast" on the same memory location.bytegetByte(int index) The byte at index as a byte.byte[]getByteArray(int index, int count) The element at index as an array of bytes with dimension count.abstract intThe number of bytes occupied by this.byte[]getBytes()The bytes copied from C-memory that represent this.longgetCLong(int index) The element at index as a native long.intgetInt(int index) The element at index as a native int.The C-Pointer where the associated memory is found.getNativeHandle(int index) abstract INativeTypeThe meta information and behavior for the NativeObject.shortgetShort(int index) The element at index as a native short.getString(int index) getWideString(int index) booleanisNull()Answertrueif this is "null".voidsetByte(int index, byte value) voidsetByteArray(int index, byte[] value, int valueOffset, int valueCount) voidsetCLong(int index, long value) voidsetInt(int index, int value) voidsetNativeHandle(int index, INativeHandle value) voidsetShort(int index, short value) voidvoidsetWideString(int index, String value) A string for debugging purposes.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.intarsys.nativec.type.INativeObject
getValue, setValue
-
Field Details
-
SIZE_BYTE
public static final int SIZE_BYTE- See Also:
-
SIZE_FLOAT
public static final int SIZE_FLOAT- See Also:
-
SIZE_INT
public static final int SIZE_INT- See Also:
-
SHIFT_INT
public static final int SHIFT_INT- See Also:
-
SIZE_LONGLONG
public static final int SIZE_LONGLONG- See Also:
-
SHIFT_LONGLONG
public static final int SHIFT_LONGLONG- See Also:
-
SIZE_LONG
public static final int SIZE_LONG -
SHIFT_LONG
public static final int SHIFT_LONG -
SIZE_PTR
public static final int SIZE_PTR -
SIZE_SHORT
public static final int SIZE_SHORT- See Also:
-
DEBUG
public static boolean DEBUGDEBUG flag
-
-
Method Details
-
cast
This is a special form of the "createNative" signature, implementing a "type cast" on the same memory location.- Parameters:
declaration- The new base declaration type.- Returns:
- The
INativeObjectat the same memory location as this, but of a different type.
-
createReference
-
getByte
public byte getByte(int index) The byte at index as a byte.- Parameters:
index- The index of the element to be reported.- Returns:
- The element at index as a native byte.
-
getByteArray
public byte[] getByteArray(int index, int count) The element at index as an array of bytes with dimension count. This is a lightweight optimization.- Parameters:
index- The index of the element to be reported.- Returns:
- The element at index as an array of native byte with dimension count.
-
getByteCount
public abstract int getByteCount()The number of bytes occupied by this.- Returns:
- The number of bytes occupied by this.
-
getBytes
public byte[] getBytes()The bytes copied from C-memory that represent this.- Specified by:
getBytesin interfaceINativeObject- Returns:
- The bytes copied from C-memory that represent this.
-
getCLong
public long getCLong(int index) The element at index as a native long. Only the "platform" number of bytes are read.- Parameters:
index- The index of the element to be reported.- Returns:
- The element at index as a native long.
-
getInt
public int getInt(int index) The element at index as a native int.- Parameters:
index- The index of the element to be reported.- Returns:
- The element at index as a native int.
-
getNativeHandle
The C-Pointer where the associated memory is found.- Specified by:
getNativeHandlein interfaceINativeMemory- Returns:
- The C-Pointer where the associated memory is found.
-
getNativeHandle
-
getNativeType
The meta information and behavior for the NativeObject.There is exactly one meta instance for all NativeObject instances of a certain type.
- Specified by:
getNativeTypein interfaceINativeObject- Returns:
- The meta information and behavior for the NativeObject.
-
getShort
public short getShort(int index) The element at index as a native short. This is a lightweight optimization.- Parameters:
index- The index of the element to be reported.- Returns:
- The element at index as a native short.
-
getString
-
getWideString
-
isNull
public boolean isNull()Answertrueif this is "null". This means the associated C-pointer is pointing to 0.- Returns:
- Answer
trueif this is "null".
-
setByte
public void setByte(int index, byte value) -
setByteArray
public void setByteArray(int index, byte[] value, int valueOffset, int valueCount) -
setCLong
public void setCLong(int index, long value) -
setInt
public void setInt(int index, int value) -
setNativeHandle
-
setShort
public void setShort(int index, short value) -
setString
-
setWideString
-
toNestedString
A string for debugging purposes.- Returns:
- A string for debugging purposes.
-