Hi,

Since regionImpl is an AnyPointer, it doesn't have a direct setter.
Instead, do:

    regionProto.getRegionImpl().setAs<PyRegionProto>(_writePyRegion());

-Kenton

On Tue, Apr 25, 2017 at 11:17 AM, <[email protected]> wrote:

> Hi Kenton, I thought I was almost there, but got stuck here:
>
> One of the use cases involves a "Network" class in C++ python extension
> code that needs to serialize several subordinate "region" instances, some
> of which are implemented in C++ and some in Python. I am having a problem
> with the latter. To demonstrate that specific problem, I defined the
> following schemas:
>
> struct NetworkProto {
>   region @2 : RegionProto;
> }
>
> struct RegionProto {
>   # This stores the data for the RegionImpl. This will be a PyRegionProto
>   # instance if it is a PyRegion.
>   regionImpl @0 :AnyPointer;
> }
>
> struct PyRegionProto {
>   regionImpl @0 :AnyPointer;
> }
>
> As you recommended, we're passing byte buffers between the python and C++
> layers. In this case, I have the C++ method _writePyRegion in the extension
> that makes the call into the python layer and converts the bytes returned
> by the python layer into `PyRegionProto::Reader`: `PyRegionProto::Reader
> Network::_writePyRegion()`.
>
> Then, the following higher level method attempts to stuff the result of
> `Network::_writePyRegion` into "NetworkProto:: RegionProto:: regionImpl",
> but the compilation fails with "*error: **no member named 'setRegionImpl'
> in 'RegionProto::Builder'*":
>
> void Network::write(NetworkProto::Builder& proto) const
> {
>   // Serialize the python region
>   auto regionProto = proto.initRegion();
>   regionProto.setRegionImpl(_writePyRegion()); // 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.

Reply via email to