capnproto / capnproto-java

Cap'n Proto in pure Java
Other
391 stars 86 forks source link

Compatible with C++ spec v2? #137

Open sgammon opened 7 months ago

sgammon commented 7 months ago

I'm curious if this package has yet adopted the v2 branch of capnproto upstream. Say you have a message you have created in C++, like:

// message = ... is a builder of some kind
VectorOutputStream stream;
capnp::MallocMessageBuilder builder;
builder.setRoot(message.asReader());
capnp::writeMessage(stream, builder.getSegmentsForOutput());
ArrayPtr<byte> p_bytes = stream.getArray();

And now, you take those p_bytes and transport them to Java, and read them. Is this supported? If so, is that the right way to do it?

sgammon commented 7 months ago

cc / @dwrensha

dwrensha commented 7 months ago

I'm curious if this package has yet adopted the v2 branch of capnproto upstream.

The capnproto-c++ v2 branch may have breaking changes in its C++ API, but it does not change the wire protocol. So it might make the schema compiler plugin capnpc-java fail to compile (I haven't checked, but we can always stick to v1), but it won't make the generated java code nor the capnproto-java runtime obsolete.

And now, you take those p_bytes and transport them to Java, and read them. Is this supported? If so, is that the right way to do it?

Yes, you can put those bytes into an ArrayInputStream and then call Serialize.read() on it.

sgammon commented 7 months ago

Thanks for the quick response, I'll give it a try.