Implement methods for conversions between Long and CPointer
This commit is contained in:
committed by
SvyatoslavScherbina
parent
11ecf0c179
commit
20d95ae4c8
@@ -161,6 +161,10 @@ val CPointer<*>?.rawValue: NativePtr
|
||||
|
||||
fun <T : CPointed> CPointer<*>.reinterpret(): CPointer<T> = interpretCPointer(this.rawValue)!!
|
||||
|
||||
fun <T : CPointed> CPointer<T>?.toLong() = this.rawValue.toLong()
|
||||
|
||||
fun <T : CPointed> Long.toCPointer(): CPointer<T>? = interpretCPointer(nativeNullPtr + this)
|
||||
|
||||
/**
|
||||
* The [CPointed] without any specified interpretation.
|
||||
*/
|
||||
|
||||
@@ -78,7 +78,7 @@ fun callWithVarargs(codePtr: NativePtr, returnValuePtr: NativePtr, returnTypeKin
|
||||
// All supported arguments take at most 8 bytes each:
|
||||
val argumentsStorage = argumentsPlacement.allocArray<LongVar>(totalArgumentsNumber)
|
||||
val arguments = argumentsPlacement.allocArray<CPointerVar<*>>(totalArgumentsNumber)
|
||||
val types = argumentsPlacement.allocArray<CPointerVar<*>>(totalArgumentsNumber)
|
||||
val types = argumentsPlacement.allocArray<COpaquePointerVar>(totalArgumentsNumber)
|
||||
|
||||
var index = 0
|
||||
|
||||
@@ -87,7 +87,7 @@ fun callWithVarargs(codePtr: NativePtr, returnValuePtr: NativePtr, returnTypeKin
|
||||
val typeKind = convertArgument(argument, isVariadic = isVariadic,
|
||||
location = storage, additionalPlacement = argumentsPlacement)
|
||||
|
||||
types[index] = interpretCPointer<COpaque>(nativeNullPtr + typeKind.toLong())
|
||||
types[index] = typeKind.toLong().toCPointer()
|
||||
arguments[index] = storage
|
||||
|
||||
++index
|
||||
|
||||
Reference in New Issue
Block a user