diff --git a/compiler/src/main/cpp/capnpc-java.c++ b/compiler/src/main/cpp/capnpc-java.c++ index eb298c6..104fc0d 100644 --- a/compiler/src/main/cpp/capnpc-java.c++ +++ b/compiler/src/main/cpp/capnpc-java.c++ @@ -888,6 +888,8 @@ private: } else if (kind == FieldKind::BLOB) { + kj::String blobKind = typeBody.which() == schema::Type::TEXT ? kj::str("Text") : kj::str("Data"); + return FieldText { kj::strTree( kj::mv(unionDiscrim.readerIsDecl), @@ -898,7 +900,7 @@ private: spaces(indent), " public ", type, ".Reader", " get", titleCase, "() {\n", spaces(indent), " return _reader.getPointerField(", - offset, ").getText();\n", // XXX + offset, ").get", blobKind, " ();\n", // XXX spaces(indent), " }\n", "\n"), kj::strTree( @@ -911,7 +913,7 @@ private: spaces(indent), " }\n", spaces(indent), " public final void set", titleCase, "(", type, ".Reader value) {\n", unionDiscrim.set, - spaces(indent), " _builder.getPointerField(", offset, ").setText(value);\n", + spaces(indent), " _builder.getPointerField(", offset, ").set", blobKind, "(value);\n", spaces(indent), " }\n", spaces(indent), " public final ", type, ".Builder init", titleCase, "(int size) {\n", spaces(indent), " throw new Error();\n", diff --git a/compiler/src/test/schema/test.capnp b/compiler/src/test/schema/test.capnp index cb4705b..32557e0 100644 --- a/compiler/src/test/schema/test.capnp +++ b/compiler/src/test/schema/test.capnp @@ -29,6 +29,7 @@ struct TestAllTypes { float32Field @10 : Float32; float64Field @11 : Float64; textField @12 : Text; + dataField @13 : Data; # ... } diff --git a/runtime/src/main/java/org/capnproto/Data.java b/runtime/src/main/java/org/capnproto/Data.java new file mode 100644 index 0000000..91ad805 --- /dev/null +++ b/runtime/src/main/java/org/capnproto/Data.java @@ -0,0 +1,13 @@ +package org.capnproto; + +import java.nio.ByteBuffer; + +public final class Data { + + public static final class Reader { + } + + public static final class Builder { + } + +} diff --git a/runtime/src/main/java/org/capnproto/PointerBuilder.java b/runtime/src/main/java/org/capnproto/PointerBuilder.java index 4f40d24..d63671e 100644 --- a/runtime/src/main/java/org/capnproto/PointerBuilder.java +++ b/runtime/src/main/java/org/capnproto/PointerBuilder.java @@ -29,4 +29,8 @@ public final class PointerBuilder { WireHelpers.setTextPointer(this.pointer, this.segment, value); } + public final void setData(Data.Reader value) { + throw new Error("unimplemented"); + } + } diff --git a/runtime/src/main/java/org/capnproto/PointerReader.java b/runtime/src/main/java/org/capnproto/PointerReader.java index 7c37588..0e0bc78 100644 --- a/runtime/src/main/java/org/capnproto/PointerReader.java +++ b/runtime/src/main/java/org/capnproto/PointerReader.java @@ -46,4 +46,8 @@ public final class PointerReader { return WireHelpers.readTextPointer(this.segment, this.pointer); } + + public Data.Reader getData() { + throw new Error("unimplemented"); + } }