a bit of work on copyPointer

This commit is contained in:
David Renshaw 2014-10-15 18:34:05 -04:00
parent 2d7816fae4
commit 1ab3601bf0
2 changed files with 20 additions and 4 deletions

View file

@ -25,6 +25,7 @@ import java.nio.ByteBuffer;
final class StructPointer{ final class StructPointer{
public static short dataSize(long ref) { public static short dataSize(long ref) {
// in words.
return (short)(WirePointer.upper32Bits(ref) & 0xffff); return (short)(WirePointer.upper32Bits(ref) & 0xffff);
} }

View file

@ -551,8 +551,13 @@ final class WireHelpers {
throw new DecodeException("Message is too deeply nested or contains cycles. See org.capnproto.ReaderOptions."); throw new DecodeException("Message is too deeply nested or contains cycles. See org.capnproto.ReaderOptions.");
} }
resolved.segment.arena.checkReadLimit(StructPointer.wordSize(resolved.ref)); resolved.segment.arena.checkReadLimit(StructPointer.wordSize(resolved.ref));
// TODO return setStructPointer(dstSegment, dstOffset,
//return setStructPointer(dstSegment, dstOffset, ...); new StructReader(srcSegment,
resolved.ptr,
resolved.ptr + StructPointer.dataSize(resolved.ref),
StructPointer.dataSize(resolved.ref) * Constants.BITS_PER_WORD,
StructPointer.ptrCount(resolved.ref),
(byte) 0, nestingLimit - 1));
case WirePointer.LIST : case WirePointer.LIST :
byte elementSize = ListPointer.elementSize(resolved.ref); byte elementSize = ListPointer.elementSize(resolved.ref);
if (nestingLimit <= 0) { if (nestingLimit <= 0) {
@ -560,9 +565,19 @@ final class WireHelpers {
} }
if (elementSize == ElementSize.INLINE_COMPOSITE) { if (elementSize == ElementSize.INLINE_COMPOSITE) {
int wordCount = ListPointer.inlineCompositeWordCount(resolved.ref); int wordCount = ListPointer.inlineCompositeWordCount(resolved.ref);
//long tag = long tag = WirePointer.get(resolved.segment.buffer, resolved.ptr);
} else { int ptr = resolved.ptr + 1;
resolved.segment.arena.checkReadLimit(wordCount + 1);
if (WirePointer.kind(tag) != WirePointer.STRUCT) {
throw new DecodeException("INLINE_COMPOSITE lists of non-STRUCT type are not supported.");
}
int elementCount = WirePointer.inlineCompositeListElementCount(tag);
// ...
} else {
// ...
} }
case WirePointer.FAR : case WirePointer.FAR :