Support enum arguments and return values in interop variadic functions
This commit is contained in:
committed by
SvyatoslavScherbina
parent
a6b89e3a0d
commit
757c306341
@@ -64,6 +64,8 @@ private tailrec fun convertArgument(
|
||||
FFI_TYPE_KIND_FLOAT
|
||||
}
|
||||
|
||||
is CEnum -> convertArgument(argument.value, isVariadic, location, additionalPlacement)
|
||||
|
||||
else -> throw Error("unsupported argument: $argument")
|
||||
}
|
||||
|
||||
|
||||
+3
-5
@@ -695,11 +695,8 @@ class StubGenerator(
|
||||
}
|
||||
|
||||
private fun FunctionDecl.generateAsFfiVarargs(): Boolean = (platform == KotlinPlatform.NATIVE && this.isVararg &&
|
||||
// Neither takes nor returns structs by value or enum-typed values:
|
||||
(this.parameters.map { it.type } + this.returnType).all {
|
||||
val type = it.unwrapTypedefs()
|
||||
type !is RecordType && type !is EnumType
|
||||
})
|
||||
// Neither takes nor returns structs by value:
|
||||
!this.returnsRecord() && this.parameters.all { it.type.unwrapTypedefs() !is RecordType })
|
||||
|
||||
/**
|
||||
* Constructs [InValueBinding] for return value of Kotlin binding for given C function.
|
||||
@@ -873,6 +870,7 @@ class StubGenerator(
|
||||
8 -> "FFI_TYPE_KIND_DOUBLE"
|
||||
else -> TODO(unwrappedType.toString())
|
||||
}
|
||||
is EnumType -> getFfiTypeKind(unwrappedType.def.baseType)
|
||||
else -> TODO(unwrappedType.toString())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user