fix some more bugs

This commit is contained in:
David Renshaw 2014-10-17 20:53:51 -04:00
parent fafb104401
commit 26942d46c8
3 changed files with 9 additions and 16 deletions

View file

@ -26,6 +26,7 @@ import org.scalatest.FunSuite
import org.scalatest.Matchers._;
class EncodingSuite extends FunSuite {
test("AllTypes") {
val message = new MessageBuilder();
val allTypes = message.initRoot(TestAllTypes.factory);
@ -46,19 +47,14 @@ class EncodingSuite extends FunSuite {
test("Setters") {
val message = new MessageBuilder();
val allTypes = message.initRoot(TestAllTypes.factory);
//TestUtil.initTestMessage(allTypes);
val structList = allTypes.initStructList(3);
TestUtil.initTestMessage(allTypes);
val message2 = new MessageBuilder();
val allTypes2 = message.initRoot(TestAllTypes.factory);
//allTypes2.setStructField(allTypes.asReader());
// ...
//TestUtil.checkTestMessage(allTypes);
//TestUtil.checkTestMessage(allTypes.asReader());
allTypes2.setStructField(allTypes.asReader());
val reader = allTypes2.asReader().getStructField();
//TestUtil.checkTestMessage(reader);
}
test("Defaults") {

View file

@ -51,7 +51,6 @@ object TestUtil {
builder.setTextField("foo");
builder.setDataField(data("bar"));
{
val subBuilder = builder.initStructField();
subBuilder.setVoidField(org.capnproto.Void.VOID);
subBuilder.setBoolField(true);
@ -103,7 +102,6 @@ object TestUtil {
val enumList = builder.initEnumList(2);
enumList.set(0, TestEnum.FOO);
enumList.set(1, TestEnum.GARPLY);
}

View file

@ -480,7 +480,6 @@ final class WireHelpers {
throw new DecodeException("Message is too deeply nested or contains cycles.");
}
int refTarget = WirePointer.target(refOffset, ref);
FollowFarsResult resolved = followFars(ref, refTarget, segment);
@ -507,13 +506,13 @@ final class WireHelpers {
int totalSize = dataSize + value.pointerCount * Constants.POINTER_SIZE_IN_WORDS;
AllocateResult allocation = allocate(refOffset, segment, totalSize, WirePointer.STRUCT);
StructPointer.set(allocation.segment.buffer, allocation.ptr,
StructPointer.set(allocation.segment.buffer, allocation.refOffset,
dataSize, value.pointerCount);
if (value.dataSize == 1) {
throw new Error("single bit case not handled");
} else {
memcpy(allocation.segment.buffer, allocation.refOffset * Constants.BYTES_PER_WORD,
memcpy(allocation.segment.buffer, allocation.ptr * Constants.BYTES_PER_WORD,
value.segment.buffer, value.data, value.dataSize / Constants.BITS_PER_BYTE);
}
@ -655,8 +654,8 @@ final class WireHelpers {
resolved.ptr,
elementCount,
wordsPerElement * Constants.BITS_PER_WORD,
StructPointer.dataSize(resolved.ref) * Constants.BITS_PER_WORD,
StructPointer.ptrCount(resolved.ref),
StructPointer.dataSize(tag) * Constants.BITS_PER_WORD,
StructPointer.ptrCount(tag),
nestingLimit - 1));
} else {
int dataSize = ElementSize.dataBitsPerElement(elementSize);