Fix methods inherited from Any in interop value types

This commit is contained in:
Svyatoslav Scherbina
2017-03-15 16:48:39 +07:00
committed by SvyatoslavScherbina
parent d1859dd280
commit c9b04bc0bb
7 changed files with 32 additions and 3 deletions
@@ -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