reading double far pointers
This commit is contained in:
parent
c25b96fe83
commit
00cc63dfe8
3 changed files with 17 additions and 32 deletions
|
@ -1,28 +0,0 @@
|
|||
// Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
|
||||
// Licensed under the MIT License:
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
package org.capnproto.benchmark;
|
||||
|
||||
public class Benchmark {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("hello world");
|
||||
}
|
||||
}
|
|
@ -26,7 +26,6 @@ import org.scalatest.FunSuite
|
|||
import org.scalatest.Matchers._;
|
||||
|
||||
class EncodingSuite extends FunSuite {
|
||||
|
||||
test("AllTypes") {
|
||||
val message = new MessageBuilder();
|
||||
val allTypes = message.initRoot(TestAllTypes.factory);
|
||||
|
@ -86,6 +85,19 @@ class EncodingSuite extends FunSuite {
|
|||
}
|
||||
}
|
||||
|
||||
test("DoubleFarPointers") {
|
||||
val bytes = Array[Byte](2,0,0,0, 1,0,0,0, 2,0,0,0, 1,0,0,0,
|
||||
6,0,0,0, 1,0,0,0, 2,0,0,0, 2,0,0,0,
|
||||
0,0,0,0, 1,0,0,0, 1,7, -1, 127, 0,0,0,0);
|
||||
|
||||
val input = new ArrayInputStream (java.nio.ByteBuffer.wrap(bytes));
|
||||
val message = org.capnproto.Serialize.read(input);
|
||||
val root = message.getRoot(TestAllTypes.factory);
|
||||
root.getBoolField() should equal (true);
|
||||
root.getInt8Field() should equal (7);
|
||||
root.getInt16Field() should equal (32767);
|
||||
}
|
||||
|
||||
test("Generics") {
|
||||
val message = new MessageBuilder();
|
||||
val factory = TestGenerics.newFactory(TestAllTypes.factory, Text.factory);
|
||||
|
|
|
@ -143,7 +143,6 @@ final class WireHelpers {
|
|||
//# so there are no FAR pointers.
|
||||
if (segment != null && WirePointer.kind(ref) == WirePointer.FAR) {
|
||||
SegmentReader resultSegment = segment.arena.tryGetSegment(FarPointer.getSegmentId(ref));
|
||||
|
||||
int padOffset = FarPointer.positionInSegment(ref);
|
||||
long pad = resultSegment.get(padOffset);
|
||||
|
||||
|
@ -158,9 +157,11 @@ final class WireHelpers {
|
|||
//# Landing pad is another far pointer. It is
|
||||
//# followed by a tag describing the pointed-to
|
||||
//# object.
|
||||
throw new Error("unimplemented");
|
||||
}
|
||||
|
||||
long tag = resultSegment.get(padOffset + 1);
|
||||
resultSegment = resultSegment.arena.tryGetSegment(FarPointer.getSegmentId(pad));
|
||||
return new FollowFarsResult(FarPointer.positionInSegment(pad), tag, resultSegment);
|
||||
}
|
||||
} else {
|
||||
return new FollowFarsResult(refTarget, ref, segment);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue