working on setTextPointer
This commit is contained in:
parent
bb7a437ce2
commit
d20aecb327
5 changed files with 51 additions and 1 deletions
|
@ -13,5 +13,8 @@ public final class PointerBuilder {
|
|||
return WireHelpers.initStructListPointer(this.pointer, this.segment, elementCount, elementSize);
|
||||
}
|
||||
|
||||
public final void setText(Text.Reader value) {
|
||||
WireHelpers.setTextPointer(this.pointer, this.segment, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,18 @@ package org.capnproto;
|
|||
import java.nio.ByteBuffer;
|
||||
|
||||
public class SegmentBuilder extends SegmentReader {
|
||||
public int pos = 0;
|
||||
|
||||
public SegmentBuilder(ByteBuffer buf) {
|
||||
super(buf);
|
||||
}
|
||||
|
||||
private final int currentSize() {
|
||||
throw new Error("unimplemented");
|
||||
}
|
||||
|
||||
public final int allocate(int amount) {
|
||||
throw new Error("unimplemented");
|
||||
// if (amount > ... this.currentSize()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,4 +35,8 @@ public final class StructBuilder {
|
|||
this.segment.buffer.putInt(this.data + offset * 4, value);
|
||||
}
|
||||
|
||||
public final PointerBuilder getPointerField(int index) {
|
||||
return new PointerBuilder(this.segment, this.pointers + index);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,19 @@ public class Text {
|
|||
this.size = size;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
public Reader(String value) {
|
||||
try {
|
||||
byte[] bytes = value.getBytes("UTF-8");
|
||||
this.buffer = ByteBuffer.wrap(bytes);
|
||||
this.offset = 0;
|
||||
this.size = bytes.length;
|
||||
} catch (java.io.UnsupportedEncodingException e) {
|
||||
throw new Error("UTF-8 is unsupported");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
byte[] bytes = new byte[this.size];
|
||||
|
||||
this.buffer.position(this.offset);
|
||||
|
@ -27,6 +39,7 @@ public class Text {
|
|||
return "unsupported encoding"; // XXX
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,13 @@ package org.capnproto;
|
|||
|
||||
final class WireHelpers {
|
||||
|
||||
public static int allocate(int ref,
|
||||
SegmentBuilder segment,
|
||||
int amount,
|
||||
byte kind) {
|
||||
throw new Error("unimplemented");
|
||||
}
|
||||
|
||||
public static ListBuilder initListPointer(int refOffset,
|
||||
SegmentBuilder segment,
|
||||
int elementCount,
|
||||
|
@ -24,6 +31,18 @@ final class WireHelpers {
|
|||
throw new Error("unimplemented");
|
||||
}
|
||||
|
||||
public static void initTextPointer(int refOffset,
|
||||
SegmentBuilder segment,
|
||||
int size) {
|
||||
throw new Error("unimplemented");
|
||||
}
|
||||
|
||||
public static void setTextPointer(int refOffset,
|
||||
SegmentBuilder segment,
|
||||
Text.Reader value) {
|
||||
throw new Error("unimplemented");
|
||||
}
|
||||
|
||||
public static StructReader readStructPointer(SegmentReader segment,
|
||||
int refOffset,
|
||||
int nestingLimit) {
|
||||
|
|
Loading…
Reference in a new issue