working on lists
This commit is contained in:
parent
366fda8daf
commit
6d22ad85f8
4 changed files with 46 additions and 0 deletions
2
Makefile
2
Makefile
|
@ -2,9 +2,11 @@ CXX=g++ -std=c++11
|
|||
|
||||
CAPNP_SOURCES=\
|
||||
src/capnp/ListPointer.java\
|
||||
src/capnp/ListReader.java\
|
||||
src/capnp/PointerReader.java\
|
||||
src/capnp/SegmentReader.java\
|
||||
src/capnp/StructReader.java\
|
||||
src/capnp/StructList.java\
|
||||
src/capnp/Text.java\
|
||||
src/capnp/WireHelpers.java\
|
||||
src/capnp/WirePointer.java\
|
||||
|
|
24
src/capnp/ListReader.java
Normal file
24
src/capnp/ListReader.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
package capnp;
|
||||
|
||||
public class ListReader {
|
||||
SegmentReader segment;
|
||||
int ptr; // byte offset to front of list
|
||||
int elementCount;
|
||||
int step;
|
||||
int structDataSize; // in bits
|
||||
short structPointerCount;
|
||||
int nestingLimit;
|
||||
|
||||
|
||||
public StructReader getStructElement(int index) {
|
||||
// TODO check nesting limit
|
||||
|
||||
int indexBit = index * this.step;
|
||||
|
||||
int structData = this.ptr + (indexBit / 8);
|
||||
int structPointers = structData + (this.structDataSize / 8);
|
||||
|
||||
return new StructReader(this.segment, structData, structPointers, this.structDataSize,
|
||||
this.structPointerCount, (byte)(indexBit % 8), this.nestingLimit - 1);
|
||||
}
|
||||
}
|
8
src/capnp/StructList.java
Normal file
8
src/capnp/StructList.java
Normal file
|
@ -0,0 +1,8 @@
|
|||
package capnp;
|
||||
|
||||
|
||||
public class StructList {
|
||||
public static class Reader<T> {
|
||||
public ListReader reader;
|
||||
}
|
||||
}
|
|
@ -11,6 +11,18 @@ public class StructReader {
|
|||
public int nestingLimit;
|
||||
|
||||
|
||||
public StructReader(SegmentReader segment, int data,
|
||||
int pointers, int dataSize, short pointerCount,
|
||||
byte bit0Offset, int nestingLimit) {
|
||||
this.segment = segment;
|
||||
this.data = data;
|
||||
this.pointers = pointers;
|
||||
this.dataSize = dataSize;
|
||||
this.pointerCount = pointerCount;
|
||||
this.bit0Offset = bit0Offset;
|
||||
this.nestingLimit = nestingLimit;
|
||||
}
|
||||
|
||||
public boolean getBoolField(int offset) {
|
||||
// XXX should use unsigned operations
|
||||
if (offset < this.dataSize) {
|
||||
|
|
Loading…
Reference in a new issue