2014-05-15 23:05:20 +00:00
|
|
|
package org.capnproto;
|
|
|
|
|
|
|
|
public final class MessageBuilder {
|
2014-05-24 14:12:44 +00:00
|
|
|
|
|
|
|
private final BuilderArena arena;
|
|
|
|
|
|
|
|
public MessageBuilder() {
|
|
|
|
this.arena = new BuilderArena();
|
|
|
|
}
|
|
|
|
|
2014-05-15 23:05:20 +00:00
|
|
|
public <T> T getRoot(FromStructBuilder<T> factory) {
|
|
|
|
throw new Error("unimplemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
public <T> T initRoot(FromStructBuilder<T> factory) {
|
2014-05-24 14:12:44 +00:00
|
|
|
SegmentBuilder rootSegment = this.arena.segments.get(0);
|
|
|
|
int location = rootSegment.allocate(1);
|
|
|
|
if (location == SegmentBuilder.FAILED_ALLOCATION) {
|
|
|
|
throw new Error("could not allocate root pointer");
|
|
|
|
}
|
|
|
|
|
|
|
|
AnyPointer.Builder ptr = new AnyPointer.Builder(PointerBuilder.getRoot(rootSegment, location));
|
|
|
|
return ptr.initAsStruct(factory);
|
2014-05-15 23:05:20 +00:00
|
|
|
}
|
2014-05-24 14:45:55 +00:00
|
|
|
|
|
|
|
//public final getSegmentsForOutput()
|
2014-05-15 23:05:20 +00:00
|
|
|
}
|