ImmutableBinaryBlob.asCPointer: fix + test (#1879)
This commit is contained in:
committed by
Nikolay Igotti
parent
a4a235be42
commit
5ad0012ab1
@@ -2734,6 +2734,12 @@ task interop4(type: RunInteropKonanTest) {
|
||||
interop = 'cstdio'
|
||||
}
|
||||
|
||||
task interop5(type: RunStandaloneKonanTest) {
|
||||
disabled = (project.testTarget == 'wasm32') // No interop for wasm yet.
|
||||
goldValue = "Hello!\n"
|
||||
source = "interop/basics/5.kt"
|
||||
}
|
||||
|
||||
task interop_bitfields(type: RunInteropKonanTest) {
|
||||
disabled = (project.testTarget == 'wasm32') // No interop for wasm yet.
|
||||
expectedFail = (project.testTarget == 'linux_mips32') // fails because of big-endiannes
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import platform.posix.printf
|
||||
|
||||
val golden = immutableBinaryBlobOf(0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x21, 0x00).asCPointer(0)
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
printf("%s\n", golden)
|
||||
}
|
||||
@@ -61,8 +61,7 @@ public fun ImmutableBinaryBlob.toByteArray() = toByteArray(0, size)
|
||||
|
||||
// Returns stable C pointer to data at certain offset, useful as a way to pass resource
|
||||
// to C API.
|
||||
public external fun ImmutableBinaryBlob.asCPointer(offset: Int) =
|
||||
interpretCPointer<ByteVar>(asCPointerImpl(offset))
|
||||
public fun ImmutableBinaryBlob.asCPointer(offset: Int) = interpretCPointer<ByteVar>(asCPointerImpl(offset))
|
||||
@SymbolName("Kotlin_ImmutableBinaryBlob_asCPointerImpl")
|
||||
private external fun ImmutableBinaryBlob.asCPointerImpl(offset: Int): konan.internal.NativePtr
|
||||
|
||||
|
||||
Reference in New Issue
Block a user