On Tue, Jan 24, 2023 at 6:11 PM Carlo Contavalli <[email protected]>
wrote:

> Hello,
>
> On Tue, Jan 24, 2023 at 1:10 PM Kenton Varda <[email protected]>
> wrote:
>
>> You mean SchemaLoader::getType(), right?
>>
>
> Correct.
>
>
>> case schema::Type::LIST:
>> return ListSchema::of(getType(proto.getList().getElementType(), scope));
>>
>> So the returned type should not lose the fact that the type represents a
>> list (or list-of-lists, or list-of-list-of-lists, etc.).
>>
>> Do you have some code that doesn't work as you expect, that you could
>> share?
>>
>
> When looking at the code above, the recursion seemed to pretty much return
> a type representing List(struct) rather than
> List(List(struct)),
>

I don't think that's true. If you give it a representation of
List(List(struct)), it'll return ListSchema::of(ListSchema::of(struct
type)), which seems correct?


> I am not sure iterating over the DynamicList is doing the right thing. My
> code is crashing, so assumed I was doing something wrong.
>
> Let me work on a self contained example, don't have one handy.
>

Yes, I think that would help.


> Fundamentally... Once getType() returns, I have a capnp::Type that I can
> use to build a DynamicList, which I can use to iterate over the elements.
> Iterating over the elements is moving through the outer list, and returns
> a DynamicValue. Now I need to iterate over the elements on the inner list.
>
> To go from DynamicValue to another DynamicList... use getType() passing in
> getList().getElementType() (recursing inside once), and then
> DynamicValue.of<DynamicList<...>>?
>

You would use `dynamicValue.as<DynamicList>()`, which returns a
DynamicList::Reader for the inner list, which you can then iterate over.

-Kenton

>

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/capnproto/CAJouXQ%3D_Uf-OX9jDziJDizML%3DQz8Mh0o%3DxbSq%3DOsKW9wZnJ8Rw%40mail.gmail.com.

Reply via email to