Support enum arguments and return values in interop variadic functions

This commit is contained in:
Svyatoslav Scherbina
2017-03-27 20:04:51 +03:00
committed by SvyatoslavScherbina
parent a6b89e3a0d
commit 757c306341
2 changed files with 5 additions and 5 deletions
@@ -64,6 +64,8 @@ private tailrec fun convertArgument(
FFI_TYPE_KIND_FLOAT FFI_TYPE_KIND_FLOAT
} }
is CEnum -> convertArgument(argument.value, isVariadic, location, additionalPlacement)
else -> throw Error("unsupported argument: $argument") else -> throw Error("unsupported argument: $argument")
} }
@@ -695,11 +695,8 @@ class StubGenerator(
} }
private fun FunctionDecl.generateAsFfiVarargs(): Boolean = (platform == KotlinPlatform.NATIVE && this.isVararg && private fun FunctionDecl.generateAsFfiVarargs(): Boolean = (platform == KotlinPlatform.NATIVE && this.isVararg &&
// Neither takes nor returns structs by value or enum-typed values: // Neither takes nor returns structs by value:
(this.parameters.map { it.type } + this.returnType).all { !this.returnsRecord() && this.parameters.all { it.type.unwrapTypedefs() !is RecordType })
val type = it.unwrapTypedefs()
type !is RecordType && type !is EnumType
})
/** /**
* Constructs [InValueBinding] for return value of Kotlin binding for given C function. * Constructs [InValueBinding] for return value of Kotlin binding for given C function.
@@ -873,6 +870,7 @@ class StubGenerator(
8 -> "FFI_TYPE_KIND_DOUBLE" 8 -> "FFI_TYPE_KIND_DOUBLE"
else -> TODO(unwrappedType.toString()) else -> TODO(unwrappedType.toString())
} }
is EnumType -> getFfiTypeKind(unwrappedType.def.baseType)
else -> TODO(unwrappedType.toString()) else -> TODO(unwrappedType.toString())
} }
} }