fix WirePointer.target()

This commit is contained in:
David Renshaw 2014-05-11 08:27:24 -04:00
parent 6047cd72c9
commit 1f1a5bfd9a
3 changed files with 6 additions and 5 deletions

View file

@ -10,7 +10,10 @@ public class AddressbookMain {
capnp.MessageReader message = capnp.InputStreamMessageReader.create(System.in); capnp.MessageReader message = capnp.InputStreamMessageReader.create(System.in);
Addressbook.AddressBook.Reader addressbook = message.getRoot(Addressbook.AddressBook.Reader.factory); Addressbook.AddressBook.Reader addressbook = message.getRoot(Addressbook.AddressBook.Reader.factory);
capnp.StructList.Reader<Addressbook.Person> people = addressbook.getPeople(); capnp.StructList.Reader<Addressbook.Person> people = addressbook.getPeople();
System.out.println("there are " + people.size() + "people"); int size = people.size();
for(int ii = 0; ii < size; ++ii) {
people.get(ii);
}
} }
public static void usage() { public static void usage() {

View file

@ -45,8 +45,6 @@ class WireHelpers {
int size = tag.inlineCompositeListElementCount(); int size = tag.inlineCompositeListElementCount();
System.out.println("size = " + size);
StructPointer structPtr = new StructPointer(tag); StructPointer structPtr = new StructPointer(tag);
int wordsPerElement = structPtr.wordSize(); int wordsPerElement = structPtr.wordSize();

View file

@ -22,7 +22,7 @@ class WirePointer {
} }
public int offset_and_kind() { public int offset_and_kind() {
return this.buffer.getInt(buffer_offset * 2); return this.buffer.getInt(buffer_offset * 8);
} }
public byte kind() { public byte kind() {
@ -31,7 +31,7 @@ class WirePointer {
public WordPointer target() { public WordPointer target() {
return new WordPointer(buffer, return new WordPointer(buffer,
1 + (this.offset_and_kind() >> 2)); this.buffer_offset + 1 + (this.offset_and_kind() >> 2));
} }
public int inlineCompositeListElementCount() { public int inlineCompositeListElementCount() {