Support Boolean in interop varargs and function pointers invocation
This commit is contained in:
committed by
SvyatoslavScherbina
parent
571fe47571
commit
99dd7227dc
@@ -5,8 +5,8 @@ val stdout
|
||||
get() = getStdout()
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
fprintf(stdout, "%s %s %d %d %d %lld %.1f %.1lf\n",
|
||||
"a", "b".cstr, (-1).toByte(), 2.toShort(), 3, Long.MAX_VALUE, 0.1.toFloat(), 0.2)
|
||||
fprintf(stdout, "%s %s %d %d %d %lld %.1f %.1lf %d %d\n",
|
||||
"a", "b".cstr, (-1).toByte(), 2.toShort(), 3, Long.MAX_VALUE, 0.1.toFloat(), 0.2, true, false)
|
||||
|
||||
memScoped {
|
||||
val aVar = alloc<IntVar>()
|
||||
|
||||
@@ -41,4 +41,14 @@ typedef int (*doubleToIntPtrType)(double);
|
||||
|
||||
static doubleToIntPtrType getDoubleToIntPtr() {
|
||||
return &__doubleToInt;
|
||||
}
|
||||
|
||||
static _Bool __isIntPositive(int x) {
|
||||
return x > 0;
|
||||
}
|
||||
|
||||
typedef _Bool (*isIntPositivePtrType)(int);
|
||||
|
||||
static isIntPositivePtrType getIsIntPositivePtr() {
|
||||
return &__isIntPositive;
|
||||
}
|
||||
@@ -18,4 +18,11 @@ fun main(args: Array<String>) {
|
||||
getAddPtr()!!(5.1, 12.2)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
val isIntPositivePtr = getIsIntPositivePtr()!!
|
||||
|
||||
printIntPtr(isIntPositivePtr(42).ifThenOneElseZero())
|
||||
printIntPtr(isIntPositivePtr(-42).ifThenOneElseZero())
|
||||
}
|
||||
|
||||
fun Boolean.ifThenOneElseZero() = if (this) 1 else 0
|
||||
Reference in New Issue
Block a user