Native: add .alloc(value) for primitive types to interop runtime

^KT-50312 Fixed
This commit is contained in:
Svyatoslav Scherbina
2022-03-09 17:48:07 +03:00
parent 11fdd2e4fa
commit 42ed0c5fe6
4 changed files with 234 additions and 1 deletions
@@ -0,0 +1,87 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package kotlinx.cinterop
//
// NOTE: THIS FILE IS AUTO-GENERATED by the generators/nativeInteropRuntime/NativeInteropRuntimeGenerator.kt
//
/**
* Allocates variable with given value type and initializes it with given value.
*/
@Suppress("FINAL_UPPER_BOUND")
public fun <T : Boolean> NativePlacement.alloc(value: T): BooleanVarOf<T> =
alloc<BooleanVarOf<T>> { this.value = value }
/**
* Allocates variable with given value type and initializes it with given value.
*/
@Suppress("FINAL_UPPER_BOUND")
public fun <T : Byte> NativePlacement.alloc(value: T): ByteVarOf<T> =
alloc<ByteVarOf<T>> { this.value = value }
/**
* Allocates variable with given value type and initializes it with given value.
*/
@Suppress("FINAL_UPPER_BOUND")
public fun <T : Short> NativePlacement.alloc(value: T): ShortVarOf<T> =
alloc<ShortVarOf<T>> { this.value = value }
/**
* Allocates variable with given value type and initializes it with given value.
*/
@Suppress("FINAL_UPPER_BOUND")
public fun <T : Int> NativePlacement.alloc(value: T): IntVarOf<T> =
alloc<IntVarOf<T>> { this.value = value }
/**
* Allocates variable with given value type and initializes it with given value.
*/
@Suppress("FINAL_UPPER_BOUND")
public fun <T : Long> NativePlacement.alloc(value: T): LongVarOf<T> =
alloc<LongVarOf<T>> { this.value = value }
/**
* Allocates variable with given value type and initializes it with given value.
*/
@Suppress("FINAL_UPPER_BOUND")
public fun <T : UByte> NativePlacement.alloc(value: T): UByteVarOf<T> =
alloc<UByteVarOf<T>> { this.value = value }
/**
* Allocates variable with given value type and initializes it with given value.
*/
@Suppress("FINAL_UPPER_BOUND")
public fun <T : UShort> NativePlacement.alloc(value: T): UShortVarOf<T> =
alloc<UShortVarOf<T>> { this.value = value }
/**
* Allocates variable with given value type and initializes it with given value.
*/
@Suppress("FINAL_UPPER_BOUND")
public fun <T : UInt> NativePlacement.alloc(value: T): UIntVarOf<T> =
alloc<UIntVarOf<T>> { this.value = value }
/**
* Allocates variable with given value type and initializes it with given value.
*/
@Suppress("FINAL_UPPER_BOUND")
public fun <T : ULong> NativePlacement.alloc(value: T): ULongVarOf<T> =
alloc<ULongVarOf<T>> { this.value = value }
/**
* Allocates variable with given value type and initializes it with given value.
*/
@Suppress("FINAL_UPPER_BOUND")
public fun <T : Float> NativePlacement.alloc(value: T): FloatVarOf<T> =
alloc<FloatVarOf<T>> { this.value = value }
/**
* Allocates variable with given value type and initializes it with given value.
*/
@Suppress("FINAL_UPPER_BOUND")
public fun <T : Double> NativePlacement.alloc(value: T): DoubleVarOf<T> =
alloc<DoubleVarOf<T>> { this.value = value }