work on initTextPointer
This commit is contained in:
parent
d87672e8dc
commit
2ba6629c1b
4 changed files with 27 additions and 4 deletions
|
@ -15,7 +15,14 @@ final class ListPointer {
|
|||
return elementCount(elementSizeAndCount);
|
||||
}
|
||||
|
||||
public static void set(ByteBuffer buffer, int offset, byte elementSize, int elementCount) {
|
||||
// TODO length assertion
|
||||
buffer.putInt(8 * offset + 4,
|
||||
(elementCount << 3) | elementSize);
|
||||
}
|
||||
|
||||
public static void setInlineComposite(ByteBuffer buffer, int offset, int wordCount) {
|
||||
// TODO length assertion
|
||||
buffer.putInt(8 * offset + 4,
|
||||
(wordCount << 3) | FieldSize.INLINE_COMPOSITE);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ final class StructPointer{
|
|||
}
|
||||
|
||||
public static void setFromStructSize(ByteBuffer buffer, int offset, StructSize size) {
|
||||
// buffer.putInt(8 * offset + 4,
|
||||
throw new Error("unimplemented");
|
||||
buffer.putShort(8 * offset + 4, size.data);
|
||||
buffer.putShort(8 * offset + 6, size.pointers);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.nio.ByteBuffer;
|
|||
|
||||
public class Text {
|
||||
|
||||
public static class Reader {
|
||||
public static final class Reader {
|
||||
public final ByteBuffer buffer;
|
||||
public final int offset; // in bytes
|
||||
public final int size; // in bytes
|
||||
|
@ -42,4 +42,12 @@ public class Text {
|
|||
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
public final ByteBuffer buffer;
|
||||
|
||||
public Builder(ByteBuffer buffer) {
|
||||
this.buffer = buffer;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -52,8 +52,12 @@ final class WireHelpers {
|
|||
ListPointer.setInlineComposite(segment.buffer, refOffset, wordCount);
|
||||
WirePointer.setKindAndInlineCompositeListElementCount(segment.buffer, ptrOffset,
|
||||
WirePointer.STRUCT, elementCount);
|
||||
StructPointer.setFromStructSize(segment.buffer, ptrOffset, elementSize);
|
||||
|
||||
throw new Error("unimplemented");
|
||||
ptrOffset += 1;
|
||||
|
||||
return new ListBuilder(segment, ptrOffset, elementCount, wordsPerElement * 64,
|
||||
elementSize.data * 64, elementSize.pointers);
|
||||
}
|
||||
|
||||
// size is in bytes
|
||||
|
@ -63,8 +67,12 @@ final class WireHelpers {
|
|||
//# The byte list must include a NUL terminator.
|
||||
int byteSize = size + 1;
|
||||
|
||||
//# Allocate the space.
|
||||
int ptrOffset = allocate(refOffset, segment, roundBytesUpToWords(byteSize), WirePointer.LIST);
|
||||
|
||||
//# Initialize the pointer.
|
||||
ListPointer.set(segment.buffer, refOffset, FieldSize.BYTE, byteSize);
|
||||
|
||||
throw new Error("unimplemented");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue