Moved NativePtr from interop to konan.internal

This commit is contained in:
Igor Chevdar
2017-04-26 12:56:24 +03:00
parent 0750626c29
commit adc1faa6c5
9 changed files with 75 additions and 36 deletions
@@ -89,8 +89,7 @@ abstract internal class CoroutineImpl(
// label == -1 when coroutine cannot be started (it is just a factory object) or has already finished execution
// label == 0 in initial part of the coroutine
// TODO: use IntPtr.
protected var label: Long = if (completion != null) 0L else -1L
protected var label: NativePtr = if (completion != null) NativePtr.NULL else NativePtr.NULL + (-1L)
private val _context: CoroutineContext? = completion?.context
@@ -0,0 +1,35 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package konan.internal
@Intrinsic external fun getNativeNullPtr(): NativePtr
class NativePtr private constructor() {
companion object {
val NULL = getNativeNullPtr()
}
@Intrinsic external operator fun plus(offset: Long): NativePtr
@Intrinsic 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() = "0x${this.toLong().toString(16)}"
}