/
InternalPlatformDsl.kt
64 lines (44 loc) · 1.41 KB
/
InternalPlatformDsl.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package io.mockk
import kotlin.coroutines.Continuation
import kotlin.reflect.KClass
expect object InternalPlatformDsl {
fun identityHashCode(obj: Any): Int
fun <T> runCoroutine(block: suspend () -> T): T
fun Any?.toStr(): String
fun deepEquals(obj1: Any?, obj2: Any?): Boolean
fun unboxChar(value: Any): Any
fun Any.toArray(): Array<*>
fun classForName(name: String): Any
fun dynamicCall(
self: Any,
methodName: String,
args: Array<out Any?>,
anyContinuationGen: () -> Continuation<*>
): Any?
fun dynamicGet(self: Any, name: String): Any?
fun dynamicSet(self: Any, name: String, value: Any?)
fun dynamicSetField(self: Any, name: String, value: Any?)
fun <T> threadLocal(initializer: () -> T): InternalRef<T>
fun counter(): InternalCounter
fun <T> coroutineCall(lambda: suspend () -> T): CoroutineCall<T>
/**
* Normally this simply casts [arg] to `T`
*
* However, if `T` is a `value class` (of type [cls]) this will construct a new instance of the
* value class, and set [arg] as the value.
*/
internal fun <T : Any> boxCast(
cls: KClass<*>,
arg: Any,
): T
}
interface CoroutineCall<T> {
fun callWithContinuation(continuation: Continuation<*>): T
}
interface InternalRef<T> {
val value: T
}
interface InternalCounter {
val value: Long
fun increment(): Long
}