Yeah, I thought of that but it was too ugly. Also, I had some C# code which
worked on a CodeGenRequest lying around from an abandoned version of this.
There was another reason as well, though I don't remember it now...

If that method existed, I'd use it ;)

~John

On Thu, Jun 18, 2020 at 6:40 PM 'Kenton Varda' via Cap'n Proto <
[email protected]> wrote:

> `schema.getProto().getNestedNodes()` returns a list of
> `capnp::schema::Node::NestedNode`, which has `name` and `id` fields. So
> that gives you the names of the nested declarations, which you can get plug
> into `getNested()`.
>
> It's a little ugly, but in general, the C++ schema classes only have
> methods for things that aren't already easy to get from the underlying
> capnp struct.
>
> That said, I could be convinced that a `getAllNested()` that returns some
> sort of iterable would be worthwhile here.
>
> -Kenton
>
> On Thu, Jun 18, 2020 at 8:25 PM John Demme <[email protected]> wrote:
>
>> Hi Kenton-
>>
>> I only see:
>>
>>>   ParsedSchema getNested(kj::StringPtr name) const;
>>>   // Gets the nested node with the given name, or throws an exception if
>>> there is no such nested
>>>   // declaration.
>>>
>>
>> If there were a getNested() which returned a list of ParsedSchemas that'd
>> probably be sufficient. Knowing what file housed a particular node would be
>> nice, but not strictly necessary.
>>
>> I'm writing software which takes in a capnp schema along with a bunch of
>> other stuff. It's basically a message passing compiler which can #include
>> capnp schemas to use for message schemas. Only there's no language
>> associated with it, so a source-to-source translator (codegen) doesn't
>> apply.
>>
>> ~John
>>
>> On Thu, Jun 18, 2020 at 4:59 PM Kenton Varda <[email protected]>
>> wrote:
>>
>>> Hi John,
>>>
>>> `capnp::SchemaParser` will parse capnp files and give you a
>>> `capnp::ParsedSchema`, which is like `capnp::Schema` but also has the
>>> `getNested()` method which allows you to traverse the whole tree of child
>>> nodes. So it's not just the root node.
>>>
>>> That said, it's true that it's not super-convenient to construct a
>>> `CodeGeneratorRequest` from this. You would need to traverse the tree and
>>> flatten it into a list, which is easy enough, but filling in
>>> `requestedFiles` (especially `imports`) might be tricky.
>>>
>>> Out of curiosity, why do you need to construct a `CodeGeneratorRequest`?
>>>
>>> -Kenton
>>>
>>> On Thu, Jun 18, 2020 at 6:15 PM John Demme <[email protected]> wrote:
>>>
>>>> Hello all-
>>>>
>>>> I've spent a lot of time digging around the CapnProto C++ code base,
>>>> but I can't figure how to point a function to a textual capnp schema and
>>>> get out the CodeGenRequest. Parsing to a capnp::Schema is not sufficient as
>>>> that class only represents the root node with (AFAICT) no way to access the
>>>> other nodes and other information in the CodeGenRequest. I saw there was
>>>> infrastructure to do this in the compiler, but those header files aren't
>>>> distributed with the library code.
>>>>
>>>> ~John
>>>>
>>>> --
>>>> 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/d23c4480-ab9a-4b77-9a5d-02535698bc01o%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/capnproto/d23c4480-ab9a-4b77-9a5d-02535698bc01o%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
> 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/CAJouXQm5N5JwpyLN8MkUCcWRo4yfzouYdfhwEJN4mToER8D%3DwA%40mail.gmail.com
> <https://groups.google.com/d/msgid/capnproto/CAJouXQm5N5JwpyLN8MkUCcWRo4yfzouYdfhwEJN4mToER8D%3DwA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAOjmg%3DsVpaHGRzpbFpOv6vvrJmQxub_SMAx7_26%3DfiiOjt6LQQ%40mail.gmail.com.

Reply via email to