2014-05-15 23:05:20 +00:00
|
|
|
package org.capnproto;
|
|
|
|
|
|
|
|
import java.nio.ByteBuffer;
|
|
|
|
|
|
|
|
final class StructPointer{
|
2014-06-17 00:00:01 +00:00
|
|
|
public static short dataSize(long ref) {
|
|
|
|
return (short)(WirePointer.upper32Bits(ref) & 0xffff);
|
2014-05-15 23:05:20 +00:00
|
|
|
}
|
|
|
|
|
2014-06-17 00:00:01 +00:00
|
|
|
public static short ptrCount(long ref) {
|
|
|
|
return (short)(WirePointer.upper32Bits(ref) >>> 16);
|
2014-05-15 23:05:20 +00:00
|
|
|
}
|
|
|
|
|
2014-06-17 00:00:01 +00:00
|
|
|
public static int wordSize(long ref) {
|
|
|
|
return (int)dataSize(ref) + (int)ptrCount(ref);
|
2014-05-15 23:05:20 +00:00
|
|
|
}
|
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
|
|
|
}
|
2014-05-15 23:05:20 +00:00
|
|
|
}
|