Here is more complete C++ code snippet for my prior post:
PyObject* Network::_readPyRegion(const std::string& moduleName,
const std::string& className,
const RegionProto::Reader& proto)
{
capnp::AnyPointer::Reader implProto = proto.getRegionImpl();
PyRegionProto::Reader pyRegionImplProto =
implProto.getAs<PyRegionProto>(); // no copy here, right?
// Extract data bytes from reader to pass to python layer
capnp::MallocMessageBuilder builder;
builder.setRoot(pyRegionImplProto); // copy
auto array = capnp::messageToFlatArray(builder); // copy
// Copy from array to PyObject so that we can pass it to the Python layer
py::String pyRegionImplBytes((const char *)array.begin(),
sizeof(capnp::word)*array.size()); // copy
}
--
You received this message because you are subscribed to the Google Groups
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/capnproto.