capnproto-java-rpc/runtime/src/main/java/org/capnproto/StructPointer.java
2014-06-16 20:00:01 -04:00

22 lines
621 B
Java

package org.capnproto;
import java.nio.ByteBuffer;
final class StructPointer{
public static short dataSize(long ref) {
return (short)(WirePointer.upper32Bits(ref) & 0xffff);
}
public static short ptrCount(long ref) {
return (short)(WirePointer.upper32Bits(ref) >>> 16);
}
public static int wordSize(long ref) {
return (int)dataSize(ref) + (int)ptrCount(ref);
}
public static void setFromStructSize(ByteBuffer buffer, int offset, StructSize size) {
buffer.putShort(8 * offset + 4, size.data);
buffer.putShort(8 * offset + 6, size.pointers);
}
}