Handle lambda argument of staticCFunction
This commit is contained in:
committed by
SvyatoslavScherbina
parent
c6ad4c3307
commit
ea2d7cbf01
@@ -11,7 +11,12 @@ fun main(args: Array<String>) {
|
||||
values[3] = 13
|
||||
values[4] = 8
|
||||
|
||||
cstdlib.qsort(values, count.toLong(), IntVar.size, staticCFunction(::comparator))
|
||||
cstdlib.qsort(values, count.toLong(), IntVar.size, staticCFunction { a, b ->
|
||||
val aValue = a!!.reinterpret<IntVar>()[0]
|
||||
val bValue = b!!.reinterpret<IntVar>()[0]
|
||||
|
||||
(aValue - bValue)
|
||||
})
|
||||
|
||||
for (i in 0 .. count - 1) {
|
||||
print(values[i])
|
||||
@@ -20,10 +25,3 @@ fun main(args: Array<String>) {
|
||||
println()
|
||||
}
|
||||
}
|
||||
|
||||
private fun comparator(a: COpaquePointer?, b: COpaquePointer?): Int {
|
||||
val aValue = a!!.reinterpret<IntVar>()[0]
|
||||
val bValue = b!!.reinterpret<IntVar>()[0]
|
||||
|
||||
return (aValue - bValue)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user