2014-06-16 18:49:12 +00:00
|
|
|
package org.capnproto;
|
|
|
|
|
|
|
|
import java.nio.ByteBuffer;
|
|
|
|
|
|
|
|
final class FarPointer {
|
2014-06-16 23:46:33 +00:00
|
|
|
public static int getSegmentId(long ref) {
|
|
|
|
return WirePointer.upper32Bits(ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int positionInSegment(long ref) {
|
|
|
|
return WirePointer.offsetAndKind(ref) >>> 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isDoubleFar(long ref) {
|
|
|
|
return ((WirePointer.offsetAndKind(ref) >>> 2) & 1) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void setSegmentId(ByteBuffer buffer, int offset, int segmentId) {
|
2014-06-16 18:49:12 +00:00
|
|
|
buffer.putInt(8 * offset + 4, segmentId);
|
|
|
|
}
|
2014-06-17 21:56:33 +00:00
|
|
|
|
|
|
|
public static void set(ByteBuffer buffer, int offset, boolean isDoubleFar, int pos) {
|
|
|
|
int idf = isDoubleFar ? 1 : 0;
|
|
|
|
WirePointer.setOffsetAndKind(buffer, offset, (pos << 3) | (idf << 2) | WirePointer.FAR);
|
|
|
|
}
|
2014-06-16 18:49:12 +00:00
|
|
|
}
|