-
Notifications
You must be signed in to change notification settings - Fork 564
Conversation
@@ -468,28 +468,24 @@ Sometimes the C libraries have function parameters or struct fields of | |||
platform-dependent type, e.g. `long` or `size_t`. Kotlin itself doesn't provide | |||
neither implicit integer casts nor C-style integer casts (e.g. | |||
`(size_t) intValue`), so to make writing portable code in such cases easier, | |||
the following methods are provided: | |||
`convert` method is provided: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not fit
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because fit
doesn't fit.
|
||
``` | ||
fun zeroMemory(buffer: COpaquePointer, size: Int) { | ||
memset(buffer, 0, size.signExtend<size_t>()) | ||
memset(buffer, 0, size.convert<size_t>()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is <size_t>
needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the refinement below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can convert be made an extension property at least?
inline operator fun <T : Double> CPointer<DoubleVarOf<T>>.get(index: Long): T = | ||
(this + index)!!.pointed.value | ||
|
||
@JvmName("set\$Double") | ||
inline operator fun <T : Double> CPointer<DoubleVarOf<T>>.set(index: Long, value: T) { | ||
(this + index)!!.pointed.value = value | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use Kotlin/Native proggy to generate definitions :)?
@@ -246,7 +246,7 @@ sealed class CPrimitiveVar(rawPtr: NativePtr) : CVariable(rawPtr) { | |||
} | |||
|
|||
interface CEnum { | |||
val value: Number | |||
val value: Any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed an unsigned types has no common supertype?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly.
@@ -79,3 +92,15 @@ private external fun getAddressOfElement(array: Any, index: Int): COpaquePointer | |||
@Suppress("NOTHING_TO_INLINE") | |||
private inline fun <P : CVariable> Pinned<*>.addressOfElement(index: Int): CPointer<P> = | |||
getAddressOfElement(this.get(), index).reinterpret() | |||
|
|||
@SymbolName("Kotlin_Arrays_getAddressOfElement") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe specialized versions here and above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe specialization would have any measurable effect here.
@@ -156,6 +156,12 @@ class StubGenerator( | |||
override fun getPackageFor(declaration: TypeDeclaration): String { | |||
return imports.getPackage(declaration.location) ?: pkgName | |||
} | |||
|
|||
override val useUnsignedTypes: Boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
check(s, x1, x2, x3, x4, x5, x6) | ||
|
||
assignReversed(s, x1 + 2, x2, (x3 + 8).toShort(), x4 - 16, x5 + 32, x6 + Long.MIN_VALUE) | ||
assignReversed(s, x1 + 2, x2, (x3 + 8u).toUShort(), x4 - 16u, x5 + 32, x6 + Long.MIN_VALUE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have unsigned in C ellipsis cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing unsigned types to C void foo(int, ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have supported it with this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In tests.
@@ -13,7 +13,7 @@ private val windowHeight = 480 | |||
|
|||
fun display() { | |||
// Clear Screen and Depth Buffer | |||
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) | |||
glClear((GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT).convert()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh.
next_out = pinned.addressOf(0) | ||
avail_out = buffer.size | ||
avail_in = 8u | ||
next_out = pinned.addressOf(0).reinterpret() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not UByteArray then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because buffer
is decoded to String
below.
val connectionIdString = "#${++connectionId}: ".cstr | ||
val connectionIdBytes = connectionIdString.ptr | ||
|
||
try { | ||
while (true) { | ||
val length = read(buffer, bufferLength) | ||
|
||
if (length == 0L) | ||
if (length == 0uL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we still cannot auto-assign 0uL?
72e7b5a
to
c2fb75f
Compare
e619950
to
7dc0ae5
Compare
No description provided.