Implement CValuesRef in interop

* Represent pointer parameters of C functions as `CValuesRef`.
* Represent struct value parameters as `CValue`.
* Implement some helper methods to make the new approach more useful.
* Migrate some code to new interop approach for pointers and values.

Also do not map to `String?`:
- pointers to 8-bit integers;
- pointers to non-const chars.
This commit is contained in:
Svyatoslav Scherbina
2017-03-16 14:48:17 +07:00
committed by SvyatoslavScherbina
parent 7a876a3ccd
commit c9d8d4d57d
22 changed files with 2072 additions and 1557 deletions
@@ -38,7 +38,7 @@ class NativePointedBox(val value: NativePointed) {
fun boxNativePointed(value: NativePointed?) = if (value != null) NativePointedBox(value) else null
fun unboxNativePointed(box: NativePointedBox?) = box?.value
class CPointerBox(val value: CPointer<*>) {
class CPointerBox(val value: CPointer<CPointed>) : CValuesRef<CPointed>() {
override fun equals(other: Any?): Boolean {
if (other !is CPointerBox) {
return false
@@ -50,7 +50,9 @@ class CPointerBox(val value: CPointer<*>) {
override fun hashCode() = value.hashCode()
override fun toString() = value.toString()
override fun getPointer(placement: NativePlacement) = value.getPointer(placement)
}
fun boxCPointer(value: CPointer<*>?) = if (value != null) CPointerBox(value) else null
fun boxCPointer(value: CPointer<CPointed>?) = if (value != null) CPointerBox(value) else null
fun unboxCPointer(box: CPointerBox?) = box?.value