getWritableStructPointer
This commit is contained in:
parent
bbd0333077
commit
d1e938130f
4 changed files with 27 additions and 6 deletions
|
@ -929,7 +929,8 @@ private:
|
||||||
spaces(indent), " }\n",
|
spaces(indent), " }\n",
|
||||||
spaces(indent), " public final ", type, ".Builder get", titleCase, "() {\n",
|
spaces(indent), " public final ", type, ".Builder get", titleCase, "() {\n",
|
||||||
spaces(indent), " return ", type,
|
spaces(indent), " return ", type,
|
||||||
".Builder.factory.fromStructBuilder(_builder.getPointerField(", offset, ").getStruct());\n",
|
".Builder.factory.fromStructBuilder(_builder.getPointerField(", offset, ").getStruct(",
|
||||||
|
type, ".STRUCT_SIZE", "));\n",
|
||||||
spaces(indent), " }\n",
|
spaces(indent), " }\n",
|
||||||
spaces(indent), " public final void set", titleCase, "(", type, ".Reader value) {\n",
|
spaces(indent), " public final void set", titleCase, "(", type, ".Reader value) {\n",
|
||||||
unionDiscrim.set,
|
unionDiscrim.set,
|
||||||
|
|
|
@ -56,7 +56,7 @@ object TestUtil {
|
||||||
//assert(builder.getTextField().toString() == "foo");
|
//assert(builder.getTextField().toString() == "foo");
|
||||||
|
|
||||||
{
|
{
|
||||||
// val subBuilder = builder.getStructField();
|
val subBuilder = builder.getStructField();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,8 @@ public final class PointerBuilder {
|
||||||
return this.segment.buffer.getLong(this.pointer) == 0;
|
return this.segment.buffer.getLong(this.pointer) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final StructBuilder getStruct() {
|
public final StructBuilder getStruct(StructSize size) {
|
||||||
throw new Error();
|
return WireHelpers.getWritableStructPointer(this.pointer, this.segment, size);
|
||||||
// return WireHelpers.getWritableStructPointer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final StructBuilder initStruct(StructSize size) {
|
public final StructBuilder initStruct(StructSize size) {
|
||||||
|
|
|
@ -37,7 +37,28 @@ final class WireHelpers {
|
||||||
public static StructBuilder getWritableStructPointer(int refOffset,
|
public static StructBuilder getWritableStructPointer(int refOffset,
|
||||||
SegmentBuilder segment,
|
SegmentBuilder segment,
|
||||||
StructSize size) {
|
StructSize size) {
|
||||||
|
long ref = WirePointer.get(segment.buffer, refOffset);
|
||||||
|
int target = WirePointer.target(refOffset, ref);
|
||||||
|
if (WirePointer.isNull(ref)) {
|
||||||
|
return initStructPointer(refOffset, segment, size);
|
||||||
|
}
|
||||||
|
long oldRef = ref;
|
||||||
|
SegmentBuilder oldSegment = segment;
|
||||||
|
// TODO follow fars.
|
||||||
|
int oldPtrOffset = target;
|
||||||
|
|
||||||
|
short oldDataSize = StructPointer.dataSize(WirePointer.structPointer(oldRef));
|
||||||
|
short oldPointerCount = StructPointer.ptrCount(WirePointer.structPointer(oldRef));
|
||||||
|
int oldPointerSectionOffset = oldPtrOffset + oldDataSize;
|
||||||
|
|
||||||
|
if (oldDataSize < size.data || oldPointerCount < size.pointers) {
|
||||||
throw new Error("unimplemented");
|
throw new Error("unimplemented");
|
||||||
|
} else {
|
||||||
|
return new StructBuilder(oldSegment, oldPtrOffset * 8,
|
||||||
|
oldPointerSectionOffset, oldDataSize * 64,
|
||||||
|
oldPointerCount, (byte)0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ListBuilder initListPointer(int refOffset,
|
public static ListBuilder initListPointer(int refOffset,
|
||||||
|
|
Loading…
Reference in a new issue