CRuntime¶
-
public class
CRuntime
extends NativeRuntime¶ CRuntime.
NativeRuntime
implementation used for supporting C features like structures and callbacks.
Fields¶
NATIVE_LONG_SIZE¶
-
public static final int
NATIVE_LONG_SIZE
¶ Native size of a ‘native’ long in bytes.
Methods¶
allocBoolean¶
-
public static native long
allocBoolean
(int count)¶ Allocates boolean array of size
count
.Parameters: - count – The length of the array
Returns: The pointer
allocByte¶
-
public static native long
allocByte
(int count)¶ Allocates byte array of size
count
.Parameters: - count – The length of the array
Returns: The pointer
allocChar¶
-
public static native long
allocChar
(int count)¶ Allocates char array of size
count
.Parameters: - count – The length of the array
Returns: The pointer
allocDouble¶
-
public static native long
allocDouble
(int count)¶ Allocates double array of size
count
.Parameters: - count – The length of the array
Returns: The pointer
allocFloat¶
-
public static native long
allocFloat
(int count)¶ Allocates float array of size
count
.Parameters: - count – The length of the array
Returns: The pointer
allocInt¶
-
public static native long
allocInt
(int count)¶ Allocates int array of size
count
.Parameters: - count – The length of the array
Returns: The pointer
allocLong¶
-
public static native long
allocLong
(int count)¶ Allocates long array of size
count
.Parameters: - count – The length of the array
Returns: The pointer
allocNativeCallback¶
-
public static native long
allocNativeCallback
(Object instance, Method method, long[] extra)¶ Construct a native callback from a Java method.
Also documented in CRuntime.h
Parameters: - instance – The Java instance we want to create native callback for
- method – The Java method we want to create native callback from
- extra – The out parameter used for storing extra informations
Returns: The native callback
allocNativeObject¶
-
public static native long
allocNativeObject
(Class<? extends NativeObject> type, int count)¶ Allocate one continuous memory block with sufficient size for containing
count
instances oftype
.Also documented in CRuntime.h
Parameters: - type – Java class of native object
- count – Count of native object
Returns: The pointer of the newly allocated space
allocPointer¶
-
public static native long
allocPointer
(int count)¶ Allocates space for
count
pointer.Also documented in CRuntime.h
Parameters: - count – The length of the array we want to create
Returns: The pointer of the allocated space
allocShort¶
-
public static native long
allocShort
(int count)¶ Allocates short array of size
count
.Parameters: - count – The length of the array
Returns: The pointer
cast¶
-
public static <T extends OpaquePtr> T
cast
(ConstVoidPtr ptr, java.lang.Class<T> cls)¶ Casts a void pointer to an opaque pointer.
Parameters: - <T> – The opaque pointer type class to cast to
- ptr – The void pointer we want to cast
- cls – The desired type of the class
Returns: The new opaque pointer
cast¶
copyBooleanArray¶
-
public static native void
copyBooleanArray
(long dst, int startOffset, boolean[] array, int buffOffset, int length)¶ Copies boolean array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyByteArray¶
-
public static native void
copyByteArray
(long dst, int startOffset, byte[] array, int buffOffset, int length)¶ Copies byte array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyCharArray¶
-
public static native void
copyCharArray
(long dst, int startOffset, char[] array, int buffOffset, int length)¶ Copies char array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyDoubleArray¶
-
public static native void
copyDoubleArray
(long dst, int startOffset, double[] array, int buffOffset, int length)¶ Copies double array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyFloatArray¶
-
public static native void
copyFloatArray
(long dst, int startOffset, float[] array, int buffOffset, int length)¶ Copies float array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyFromNativeBooleanArray¶
-
public static native void
copyFromNativeBooleanArray
(boolean[] dst, int startOffset, long array, int buffOffset, int length)¶ Copies boolean array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyFromNativeByteArray¶
-
public static native void
copyFromNativeByteArray
(byte[] dst, int startOffset, long array, int buffOffset, int length)¶ Copies byte array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyFromNativeCharArray¶
-
public static native void
copyFromNativeCharArray
(char[] dst, int startOffset, long array, int buffOffset, int length)¶ Copies char array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyFromNativeDoubleArray¶
-
public static native void
copyFromNativeDoubleArray
(double[] dst, int startOffset, long array, int buffOffset, int length)¶ Copies double array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyFromNativeFloatArray¶
-
public static native void
copyFromNativeFloatArray
(float[] dst, int startOffset, long array, int buffOffset, int length)¶ Copies float array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyFromNativeIntArray¶
-
public static native void
copyFromNativeIntArray
(int[] dst, int startOffset, long array, int buffOffset, int length)¶ Copies int array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyFromNativeLongArray¶
-
public static native void
copyFromNativeLongArray
(long[] dst, int startOffset, long array, int buffOffset, int length)¶ Copies long array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyFromNativeShortArray¶
-
public static native void
copyFromNativeShortArray
(short[] dst, int startOffset, long array, int buffOffset, int length)¶ Copies short array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyIntArray¶
-
public static native void
copyIntArray
(long dst, int startOffset, int[] array, int buffOffset, int length)¶ Copies int array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyLongArray¶
-
public static native void
copyLongArray
(long dst, int startOffset, long[] array, int buffOffset, int length)¶ Copies long array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyNativeBooleanArray¶
-
public static native void
copyNativeBooleanArray
(long dst, int startOffset, long array, int buffOffset, int length)¶ Copies native boolean array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyNativeByteArray¶
-
public static native void
copyNativeByteArray
(long dst, int startOffset, long array, int buffOffset, int length)¶ Copies native byte array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyNativeCharArray¶
-
public static native void
copyNativeCharArray
(long dst, int startOffset, long array, int buffOffset, int length)¶ Copies native char array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyNativeDoubleArray¶
-
public static native void
copyNativeDoubleArray
(long dst, int startOffset, long array, int buffOffset, int length)¶ Copies native double array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyNativeFloatArray¶
-
public static native void
copyNativeFloatArray
(long dst, int startOffset, long array, int buffOffset, int length)¶ Copies native float array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyNativeIntArray¶
-
public static native void
copyNativeIntArray
(long dst, int startOffset, long array, int buffOffset, int length)¶ Copies native int array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyNativeLongArray¶
-
public static native void
copyNativeLongArray
(long dst, int startOffset, long array, int buffOffset, int length)¶ Copies native long array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyNativeObject¶
-
public static native void
copyNativeObject
(Class<? extends NativeObject> type, long dst, long src)¶ Copies one instance of
type
fromsrc
todst
.Also documented in CRuntime.h
Parameters: - type – The type of the native object
- dst – The pointer that points to the memory space to where we want to copy
- src – The pointer that points to the memory space from where we want to copy
copyNativeObjectArray¶
-
public static native <T extends NativeObject> long
copyNativeObjectArray
(T[] array)¶ Copies the native content of the NativeObject array to a new memory space.
Also documented in CRuntime.h
Parameters: - <T> – The element type of the Java array
- array – The array we want to copy
Returns: The pointer of the new native array
copyNativeShortArray¶
-
public static native void
copyNativeShortArray
(long dst, int startOffset, long array, int buffOffset, int length)¶ Copies native short array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
copyPointerArray¶
-
public static native void
copyPointerArray
(long dst, long[] array)¶ Copies the native content of the
array
todst
.Also documented in CRuntime.h
Parameters: - dst – Where we want to copy
- array – The array we want to copy
copyShortArray¶
-
public static native void
copyShortArray
(long dst, int startOffset, short[] array, int buffOffset, int length)¶ Copies short array.
Parameters: - dst – The pointer pointing to where we want to copy
- startOffset – The offset for the destination
- array – The array we want to copy
- buffOffset – The offset of the pointer we want to copy
- length – The length of the copy
createBooleanArray¶
-
public static native boolean[]
createBooleanArray
(long src, int length)¶ Creates a boolean array from a pointer.
Parameters: - src – The pointer we want to create Java array object from
- length – The length of the array
Returns: The Java array.
createByteArray¶
-
public static native byte[]
createByteArray
(long src, int length)¶ Creates a byte array from a pointer.
Parameters: - src – The pointer we want to create Java array object from
- length – The length of the array
Returns: The Java array.
createCharArray¶
-
public static native char[]
createCharArray
(long src, int length)¶ Creates a char array from a pointer.
Parameters: - src – The pointer we want to create Java array object from
- length – The length of the array
Returns: The Java array.
createDoubleArray¶
-
public static native double[]
createDoubleArray
(long src, int length)¶ Creates a double array from a pointer.
Parameters: - src – The pointer we want to create Java array object from
- length – The length of the array
Returns: The Java array.
createFloatArray¶
-
public static native float[]
createFloatArray
(long src, int length)¶ Creates a float array from a pointer.
Parameters: - src – The pointer we want to create Java array object from
- length – The length of the array
Returns: The Java array.
createIntArray¶
-
public static native int[]
createIntArray
(long src, int length)¶ Creates a int array from a pointer.
Parameters: - src – The pointer we want to create Java array object from
- length – The length of the array
Returns: The Java array.
createJavaCallback¶
-
public static native Object
createJavaCallback
(long extra)¶ Returns a Java instance from a given callback specified by it’s extra.
Works only with callbacks we create with
allocNativeCallback(Object,Method,long[])
.Also documented in CRuntime.h
Parameters: - extra – Extra info pointer
Returns: The Java instance
createJavaString¶
createLongArray¶
-
public static native long[]
createLongArray
(long src, int length)¶ Creates a long array from a pointer.
Parameters: - src – The pointer we want to create Java array object from
- length – The length of the array
Returns: The Java array.
createNativeString¶
createNativeStringArray¶
-
public static native long
createNativeStringArray
(String[] strings)¶ Constructs a native string array from a Java string array.
The C string array will be constructed into one continuous memory block: <ptr1>|<ptr2>|…|<first char of first string>|<second char of first string>|…| <first char of second string>|… Because of this we can release every C string array we created by doing so with only one free call.
Also documented in CRuntime.h
Parameters: - strings – Java string array we want to convert
Returns: The native string array
createShortArray¶
-
public static native short[]
createShortArray
(long src, int length)¶ Creates a short array from a pointer.
Parameters: - src – The pointer we want to create Java array object from
- length – The length of the array
Returns: The Java array.
createStrongPointer¶
deallocNativeCallback¶
-
public static native void
deallocNativeCallback
(long extra)¶ Releases a native callback specified by it’s extra.
Works only with callbacks we create with
allocNativeCallback(Object,Method,long[])
.Also documented in CRuntime.h
Parameters: - extra – Extra information needed for the callback
doRegistration¶
free¶
-
public static native void
free
(long peer)¶ Method for using C free function from java.
Also documented in CRuntime.h
Parameters: - peer – The memory space to release
getByteBufferPointer¶
-
public static native long
getByteBufferPointer
(ByteBuffer buffer)¶ Gets the native pointer from a ByteBuffer.
Parameters: - buffer – The buffer
Returns: The pointer
getCharBufferPointer¶
-
public static native long
getCharBufferPointer
(CharBuffer buffer)¶ Gets the native pointer from a CharBuffer.
Parameters: - buffer – The buffer
Returns: The pointer
getDefaultUnboxPolicy¶
-
public byte
getDefaultUnboxPolicy
()¶ Returns the default unbox policy for variadic arguments.
For C Runtime the policy is unboxing, because this runtime does not have any object types.
Returns: The default unbox policy.
getDoubleBufferPointer¶
-
public static native long
getDoubleBufferPointer
(DoubleBuffer buffer)¶ Gets the native pointer from a DoubleBuffer.
Parameters: - buffer – The buffer
Returns: The pointer
getFloatBufferPointer¶
-
public static native long
getFloatBufferPointer
(FloatBuffer buffer)¶ Gets the native pointer from a FloatBuffer.
Parameters: - buffer – The buffer
Returns: The pointer
getIntBufferPointer¶
getLongBufferPointer¶
-
public static native long
getLongBufferPointer
(LongBuffer buffer)¶ Gets the native pointer from a LongBuffer.
Parameters: - buffer – The buffer
Returns: The pointer
getShortBufferPointer¶
-
public static native long
getShortBufferPointer
(ShortBuffer buffer)¶ Gets the native pointer from a ShortBuffer.
Parameters: - buffer – The buffer
Returns: The pointer
loadBoolean¶
-
public static native boolean
loadBoolean
(long src, int idx)¶ Loads a boolean.
Parameters: - src – From we want to load
- idx – Index of the loading
Returns: The loaded boolean value
loadByte¶
-
public static native byte
loadByte
(long src, int idx)¶ Loads a byte.
Parameters: - src – From we want to load
- idx – Index of the loading
Returns: The loaded byte value
loadChar¶
-
public static native char
loadChar
(long src, int idx)¶ Loads a char.
Parameters: - src – From we want to load
- idx – Index of the loading
Returns: The loaded char value
loadDouble¶
-
public static native double
loadDouble
(long src, int idx)¶ Loads a double.
Parameters: - src – From we want to load
- idx – Index of the loading
Returns: The loaded double value
loadFloat¶
-
public static native float
loadFloat
(long src, int idx)¶ Loads a float.
Parameters: - src – From we want to load
- idx – Index of the loading
Returns: The loaded float value
loadInt¶
-
public static native int
loadInt
(long src, int idx)¶ Loads an int.
Parameters: - src – From we want to load
- idx – Index of the loading
Returns: The loaded int value
loadLong¶
-
public static native long
loadLong
(long src, int idx)¶ Loads a long.
Parameters: - src – From we want to load
- idx – Index of the loading
Returns: The loaded long value
loadPointer¶
-
public static native long
loadPointer
(long ptr, int idx)¶ Loads a pointer from
ptr
with indexidx
.Also documented in CRuntime.h
Parameters: - ptr – The pointer from where we want to load
- idx – The index we want to offset with
Returns: The loaded pointer.
loadShort¶
-
public static native short
loadShort
(long src, int idx)¶ Loads a short.
Parameters: - src – From we want to load
- idx – Index of the loading
Returns: The loaded short value
memcpy¶
-
public static native void
memcpy
(long dst, long src, int length)¶ Bride for native memcpy.
Also documented in CRuntime.java
Parameters: - dst – the pointer we want to copy to
- src – the pointer we want to copy from
- length – number of bytes to copy
memcpy¶
-
public static void
memcpy
(VoidPtr dst, ConstVoidPtr src, int length)¶ Bride for native memcpy.
Parameters: - dst – the pointer we want to copy to
- src – the pointer we want to copy from
- length – number of bytes to copy
memset¶
-
public static native void
memset
(long dst, int idx, int length, byte value)¶ Bride for native memset.
Also documented in CRuntime.java
Parameters: - dst – The pointer we want to do memset on
- idx – The offset of the memsetting
- length – The length of the memsetting
- value – The value by we want to overwrite
memset¶
sizeOfLong¶
-
public static native int
sizeOfLong
()¶ Returns the long size for the current architecture.
Also documented in CRuntime.h
Returns: The long size
sizeOfNativeObject¶
-
public static native long
sizeOfNativeObject
(Class<? extends NativeObject> type)¶ Returns the native size of a NativeObject.
Also documented in CRuntime.h
Parameters: - type – The NativeObject we want to get the size of
Returns: The size of the NativeObject
sizeOfPointer¶
-
public static native int
sizeOfPointer
()¶ Returns the pointer size for the current architecture.
Also documented in CRuntime.h
Returns: The pointer size
sizeOfWCharT¶
-
public static native int
sizeOfWCharT
()¶ Returns the wchar_t size for the current architecture.
Also documented in CRuntime.h
Returns: The wchar_t size
storeBoolean¶
-
public static native void
storeBoolean
(long dst, int idx, boolean value)¶ Stores a boolean value.
Parameters: - dst – The pointer pointing to where we want to store
- idx – The index of the storing
- value – The boolean value we want to store
storeByte¶
-
public static native void
storeByte
(long dst, int idx, byte value)¶ Stores a byte value.
Parameters: - dst – The pointer pointing to where we want to store
- idx – The index of the storing
- value – The byte value we want to store
storeChar¶
-
public static native void
storeChar
(long dst, int idx, char value)¶ Stores a char value.
Parameters: - dst – The pointer pointing to where we want to store
- idx – The index of the storing
- value – The char value we want to store
storeDouble¶
-
public static native void
storeDouble
(long dst, int idx, double value)¶ Stores a double value.
Parameters: - dst – The pointer pointing to where we want to store
- idx – The index of the storing
- value – The double value we want to store
storeFloat¶
-
public static native void
storeFloat
(long dst, int idx, float value)¶ Stores a float value.
Parameters: - dst – The pointer pointing to where we want to store
- idx – The index of the storing
- value – The float value we want to store
storeInt¶
-
public static native void
storeInt
(long dst, int idx, int value)¶ Stores an int value.
Parameters: - dst – The pointer pointing to where we want to store
- idx – The index of the storing
- value – The int value we want to store
storeLong¶
-
public static native void
storeLong
(long dst, int idx, long value)¶ Stores a long value.
Parameters: - dst – The pointer pointing to where we want to store
- idx – The index of the storing
- value – The long value we want to store
storePointer¶
-
public static native void
storePointer
(long dst, int idx, long value)¶ Stores
value
toptr
with indexidx
.Also documented in CRuntime.h
Parameters: - dst – The pointer to where we want to store
- idx – The index we want to offset with
- value – The value we want to store