work on initTextPointer

This commit is contained in:
David Renshaw 2014-05-17 16:57:13 -04:00
parent d87672e8dc
commit 2ba6629c1b
4 changed files with 27 additions and 4 deletions

View file

@ -15,7 +15,14 @@ final class ListPointer {
return elementCount(elementSizeAndCount); 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) { public static void setInlineComposite(ByteBuffer buffer, int offset, int wordCount) {
// TODO length assertion
buffer.putInt(8 * offset + 4, buffer.putInt(8 * offset + 4,
(wordCount << 3) | FieldSize.INLINE_COMPOSITE); (wordCount << 3) | FieldSize.INLINE_COMPOSITE);
} }

View file

@ -16,7 +16,7 @@ final class StructPointer{
} }
public static void setFromStructSize(ByteBuffer buffer, int offset, StructSize size) { public static void setFromStructSize(ByteBuffer buffer, int offset, StructSize size) {
// buffer.putInt(8 * offset + 4, buffer.putShort(8 * offset + 4, size.data);
throw new Error("unimplemented"); buffer.putShort(8 * offset + 6, size.pointers);
} }
} }

View file

@ -4,7 +4,7 @@ import java.nio.ByteBuffer;
public class Text { public class Text {
public static class Reader { public static final class Reader {
public final ByteBuffer buffer; public final ByteBuffer buffer;
public final int offset; // in bytes public final int offset; // in bytes
public final int size; // 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;
}
}
} }

View file

@ -52,8 +52,12 @@ final class WireHelpers {
ListPointer.setInlineComposite(segment.buffer, refOffset, wordCount); ListPointer.setInlineComposite(segment.buffer, refOffset, wordCount);
WirePointer.setKindAndInlineCompositeListElementCount(segment.buffer, ptrOffset, WirePointer.setKindAndInlineCompositeListElementCount(segment.buffer, ptrOffset,
WirePointer.STRUCT, elementCount); 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 // size is in bytes
@ -63,8 +67,12 @@ final class WireHelpers {
//# The byte list must include a NUL terminator. //# The byte list must include a NUL terminator.
int byteSize = size + 1; int byteSize = size + 1;
//# Allocate the space.
int ptrOffset = allocate(refOffset, segment, roundBytesUpToWords(byteSize), WirePointer.LIST); int ptrOffset = allocate(refOffset, segment, roundBytesUpToWords(byteSize), WirePointer.LIST);
//# Initialize the pointer.
ListPointer.set(segment.buffer, refOffset, FieldSize.BYTE, byteSize);
throw new Error("unimplemented"); throw new Error("unimplemented");
} }