June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -0,0 +1,8 @@
|
|||
#include <stdio.h>
|
||||
/* gcc -shared -fPIC -nostartfiles fakeimglib.c -o fakeimglib.so */
|
||||
int openimage(const char *s)
|
||||
{
|
||||
static int handle = 100;
|
||||
fprintf(stderr, "opening %s\n", s);
|
||||
return handle++;
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
// Kotlin Native version 0.5
|
||||
|
||||
import kotlinx.cinterop.*
|
||||
import platform.posix.*
|
||||
import platform.linux.*
|
||||
|
||||
typealias Func = (String)-> Int
|
||||
|
||||
var handle = 0
|
||||
|
||||
fun myOpenImage(s: String): Int {
|
||||
fprintf(stderr, "internal openImage opens %s...\n", s)
|
||||
return handle++
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
var imgHandle: Int
|
||||
val imglib = dlopen("./fakeimglib.so", RTLD_LAZY)
|
||||
if (imglib != null) {
|
||||
val fp = dlsym(imglib, "openimage")
|
||||
if (fp != null) {
|
||||
val extOpenImage: CPointer<CFunction<Func>> = fp.reinterpret()
|
||||
imgHandle = extOpenImage("fake.img")
|
||||
}
|
||||
else {
|
||||
imgHandle = myOpenImage("fake.img")
|
||||
}
|
||||
dlclose(imglib)
|
||||
}
|
||||
else {
|
||||
imgHandle = myOpenImage("fake.img")
|
||||
}
|
||||
println("opened with handle $imgHandle")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue