capnproto-java-rpc/runtime/src/main/java/org/capnproto/StructPointer.java

23 lines
621 B
Java
Raw Normal View History

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);
}
2014-05-17 20:04:51 +00:00
public static void setFromStructSize(ByteBuffer buffer, int offset, StructSize size) {
2014-05-17 20:57:13 +00:00
buffer.putShort(8 * offset + 4, size.data);
buffer.putShort(8 * offset + 6, size.pointers);
2014-05-17 20:04:51 +00:00
}
}