mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-15 04:54:05 +09:00
found a bug on uiFixture and the only solution would be creating a cut-down copy of the original ui
This commit is contained in:
@@ -58,6 +58,20 @@ internal object UnsafeHelper {
|
||||
* @return offset from the array's base memory address (aka pointer) that the actual data begins.
|
||||
*/
|
||||
fun getArrayOffset(obj: Any) = unsafe.arrayBaseOffset(obj.javaClass).toLong()
|
||||
|
||||
|
||||
fun addressOf(o: Any): Long {
|
||||
val array = arrayOf(o)
|
||||
|
||||
val baseOffset = unsafe.arrayBaseOffset(Array<Any>::class.java).toLong()
|
||||
val addressSize = unsafe.addressSize()
|
||||
val objectAddress = when (addressSize) {
|
||||
4 -> unsafe.getInt(array, baseOffset).toLong()
|
||||
8 -> unsafe.getLong(array, baseOffset)
|
||||
else -> throw Error("unsupported address size: $addressSize")
|
||||
}
|
||||
return (objectAddress)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user