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

22 lines
554 B
Java
Raw Normal View History

2014-06-16 18:49:12 +00:00
package org.capnproto;
import java.nio.ByteBuffer;
final class FarPointer {
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);
}
}