Eliminate some warnings from Kotlin code
This commit is contained in:
committed by
SvyatoslavScherbina
parent
760de3cdad
commit
4a1b2721d8
@@ -233,9 +233,10 @@ private fun ffiCreateCif(returnType: ffi_type, paramTypes: List<ffi_type>): ffi_
|
||||
return interpretPointed(res)
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
private fun ffiFunImpl0(ffiCif: Long, ret: Long, args: Long, userData: Any) {
|
||||
ffiFunImpl(interpretPointed(ffiCif),
|
||||
interpretCPointer(ret)!!,
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
ffiFunImpl(interpretCPointer(ret)!!,
|
||||
interpretCPointer(args)!!,
|
||||
userData as UserData)
|
||||
}
|
||||
@@ -246,8 +247,7 @@ private fun ffiFunImpl0(ffiCif: Long, ret: Long, args: Long, userData: Any) {
|
||||
* @param ret pointer to memory to be filled with return value of the invoked native function
|
||||
* @param args pointer to array of pointers to arguments passed to the invoked native function
|
||||
*/
|
||||
private fun ffiFunImpl(ffiCif: ffi_cif, ret: COpaquePointer, args: CArrayPointer<COpaquePointerVar>,
|
||||
userData: UserData) {
|
||||
private fun ffiFunImpl(ret: COpaquePointer, args: CArrayPointer<COpaquePointerVar>, userData: UserData) {
|
||||
|
||||
userData.invoke(ret, args)
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package kotlinx.cinterop
|
||||
|
||||
import kotlin.reflect.companionObjectInstance
|
||||
import kotlin.reflect.primaryConstructor
|
||||
import kotlin.reflect.full.companionObjectInstance
|
||||
import kotlin.reflect.full.primaryConstructor
|
||||
|
||||
typealias NativePtr = Long
|
||||
val nativeNullPtr: NativePtr = 0L
|
||||
@@ -40,6 +40,7 @@ inline fun <reified T : NativePointed> interpretNullablePointed(ptr: NativePtr):
|
||||
if (primaryConstructor == null) {
|
||||
throw IllegalArgumentException("${kClass.simpleName} doesn't have a constructor")
|
||||
}
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return (primaryConstructor as (NativePtr) -> T)(ptr)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,26 +237,32 @@ abstract class CEnumVar : CPrimitiveVar()
|
||||
// generics below are used for typedef support
|
||||
// these classes are not supposed to be used directly, instead the typealiases are provided.
|
||||
|
||||
@Suppress("FINAL_UPPER_BOUND")
|
||||
class CInt8VarWithValueMappedTo<T : Byte>(override val rawPtr: NativePtr) : CPrimitiveVar() {
|
||||
companion object : Type(1)
|
||||
}
|
||||
|
||||
@Suppress("FINAL_UPPER_BOUND")
|
||||
class CInt16VarWithValueMappedTo<T : Short>(override val rawPtr: NativePtr) : CPrimitiveVar() {
|
||||
companion object : Type(2)
|
||||
}
|
||||
|
||||
@Suppress("FINAL_UPPER_BOUND")
|
||||
class CInt32VarWithValueMappedTo<T : Int>(override val rawPtr: NativePtr) : CPrimitiveVar() {
|
||||
companion object : Type(4)
|
||||
}
|
||||
|
||||
@Suppress("FINAL_UPPER_BOUND")
|
||||
class CInt64VarWithValueMappedTo<T : Long>(override val rawPtr: NativePtr) : CPrimitiveVar() {
|
||||
companion object : Type(8)
|
||||
}
|
||||
|
||||
@Suppress("FINAL_UPPER_BOUND")
|
||||
class CFloat32VarWithValueMappedTo<T : Float>(override val rawPtr: NativePtr) : CPrimitiveVar() {
|
||||
companion object : Type(4)
|
||||
}
|
||||
|
||||
@Suppress("FINAL_UPPER_BOUND")
|
||||
class CFloat64VarWithValueMappedTo<T : Double>(override val rawPtr: NativePtr) : CPrimitiveVar() {
|
||||
companion object : Type(8)
|
||||
}
|
||||
@@ -268,28 +274,34 @@ typealias CInt64Var = CInt64VarWithValueMappedTo<Long>
|
||||
typealias CFloat32Var = CFloat32VarWithValueMappedTo<Float>
|
||||
typealias CFloat64Var = CFloat64VarWithValueMappedTo<Double>
|
||||
|
||||
@Suppress("FINAL_UPPER_BOUND", "UNCHECKED_CAST")
|
||||
var <T : Byte> CInt8VarWithValueMappedTo<T>.value: T
|
||||
get() = nativeMemUtils.getByte(this) as T
|
||||
set(value) = nativeMemUtils.putByte(this, value)
|
||||
|
||||
@Suppress("FINAL_UPPER_BOUND", "UNCHECKED_CAST")
|
||||
var <T : Short> CInt16VarWithValueMappedTo<T>.value: T
|
||||
get() = nativeMemUtils.getShort(this) as T
|
||||
set(value) = nativeMemUtils.putShort(this, value)
|
||||
|
||||
@Suppress("FINAL_UPPER_BOUND", "UNCHECKED_CAST")
|
||||
var <T : Int> CInt32VarWithValueMappedTo<T>.value: T
|
||||
get() = nativeMemUtils.getInt(this) as T
|
||||
set(value) = nativeMemUtils.putInt(this, value)
|
||||
|
||||
@Suppress("FINAL_UPPER_BOUND", "UNCHECKED_CAST")
|
||||
var <T : Long> CInt64VarWithValueMappedTo<T>.value: T
|
||||
get() = nativeMemUtils.getLong(this) as T
|
||||
set(value) = nativeMemUtils.putLong(this, value)
|
||||
|
||||
// TODO: ensure native floats have the appropriate binary representation
|
||||
|
||||
@Suppress("FINAL_UPPER_BOUND", "UNCHECKED_CAST")
|
||||
var <T : Float> CFloat32VarWithValueMappedTo<T>.value: T
|
||||
get() = nativeMemUtils.getFloat(this) as T
|
||||
set(value) = nativeMemUtils.putFloat(this, value)
|
||||
|
||||
@Suppress("FINAL_UPPER_BOUND", "UNCHECKED_CAST")
|
||||
var <T : Double> CFloat64VarWithValueMappedTo<T>.value: T
|
||||
get() = nativeMemUtils.getDouble(this) as T
|
||||
set(value) = nativeMemUtils.putDouble(this, value)
|
||||
@@ -307,6 +319,7 @@ typealias CPointerVar<T> = CPointerVarWithValueMappedTo<CPointer<T>>
|
||||
/**
|
||||
* The value of this variable.
|
||||
*/
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
inline var <P : CPointer<*>> CPointerVarWithValueMappedTo<P>.value: P?
|
||||
get() = interpretCPointer<CPointed>(nativeMemUtils.getNativePtr(this)) as P?
|
||||
set(value) = nativeMemUtils.putNativePtr(this, value.rawValue)
|
||||
|
||||
Reference in New Issue
Block a user