All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.linkedin.dex.spec.ClassDataItem.kt Maven / Gradle / Ivy

There is a newer version: 2.3.4
Show newest version
/**
 * Copyright (c) LinkedIn Corporation. All rights reserved. Licensed under the BSD-2 Clause license.
 * See LICENSE in the project root for license information.
 */
package com.linkedin.dex.spec

import java.nio.ByteBuffer

data class ClassDataItem(
        val staticFieldsSize: Int,
        val instanceFieldsSize: Int,
        val directMethodsSize: Int,
        val virtualMethodsSize: Int,
        val staticFields: Array,
        val instanceFields: Array,
        val directMethods: Array,
        val virtualMethods: Array
) {
    companion object {
        fun create(byteBuffer: ByteBuffer, offset: Int): ClassDataItem {
            byteBuffer.position(offset)

            val staticFieldsSize = Leb128.readUnsignedLeb128(byteBuffer)
            val instanceFieldsSize = Leb128.readUnsignedLeb128(byteBuffer)
            val directMethodsSize = Leb128.readUnsignedLeb128(byteBuffer)
            val virtualMethodsSize = Leb128.readUnsignedLeb128(byteBuffer)
            val staticFields = Array(staticFieldsSize, { EncodedField(byteBuffer) })
            val instanceFields = Array(instanceFieldsSize, { EncodedField(byteBuffer) })
            val directMethods = Array(directMethodsSize, { EncodedMethod(byteBuffer) })
            val virtualMethods = Array(virtualMethodsSize, { EncodedMethod(byteBuffer) })

            return ClassDataItem(
                    staticFieldsSize,
                    instanceFieldsSize,
                    directMethodsSize,
                    virtualMethodsSize,
                    staticFields,
                    instanceFields,
                    directMethods,
                    virtualMethods
            )
        }
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy