Fix methods inherited from Any in interop value types
This commit is contained in:
committed by
SvyatoslavScherbina
parent
d1859dd280
commit
c9b04bc0bb
@@ -5,6 +5,8 @@ package kotlinx.cinterop
|
||||
* Subtypes are supposed to represent interpretations of the pointed data or code.
|
||||
*
|
||||
* This interface is likely to be handled by compiler magic and shouldn't be subtyped by arbitrary classes.
|
||||
*
|
||||
* TODO: the behavior of [equals], [hashCode] and [toString] differs on Native and JVM backends.
|
||||
*/
|
||||
interface NativePointed {
|
||||
val rawPtr: NativePtr
|
||||
|
||||
@@ -4,6 +4,14 @@ import konan.internal.Intrinsic
|
||||
|
||||
class NativePtr private constructor() {
|
||||
@Intrinsic external operator fun plus(offset: Long): NativePtr
|
||||
|
||||
@Intrinsic private external fun toLong(): Long
|
||||
|
||||
override fun equals(other: Any?) = (other is NativePtr) && konan.internal.areEqualByValue(this, other)
|
||||
|
||||
override fun hashCode() = this.toLong().hashCode()
|
||||
|
||||
override fun toString() = this.toLong().toString() // TODO: format as hex.
|
||||
}
|
||||
|
||||
inline val nativeNullPtr: NativePtr
|
||||
|
||||
Reference in New Issue
Block a user