Hi, I think what you want here is for pycapnp to be extended with some API that other Python extensions can use to interact with it in order to wrap and unwrap builders. pycapnp builders are actually wrapping a capnp::DynamicStruct::Builder under the hood, which is easy to cast back and forth to your native builder type. You just need pycapnp to give you access somehow.
I unfortunately do not know very much about how pycapnp and cython work, so I'm not sure I can help. This may be a question for Jason Paryani. By the way, if you guys are in the Bay Area, you should come to our Cap'n Proto 0.6 release party on May 18 at Cloudflare: https://www.meetup.com/Sandstorm-SF-Bay-Area/events/239341254/ -Kenton On Wed, Apr 26, 2017 at 2:40 PM, <[email protected]> wrote: > 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. > -- 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.
