Generate code/embedded schema that uses Cap'n'Proto

31 views
Skip to first unread message

Mark Li

unread,
Feb 23, 2023, 10:48:19 PM2/23/23
to Cap'n Proto
Hi, Capnp community

I have a DSL and a compiler that takes the DSL and generates cpp code. For example, the generated cpp code could look like:

```
class A {
  public:
    A(int foo): foo(foo) {};
    int foo;
    static constexpr int foo_field_id = 0;
};
```

My goal is to also generate capnp functions that serialize object of class `A`.

Of course I can also have my compiler to also generate .capnp interface which then be sent to `capnp` to generate the cpp code that serializes object of class `A`, but is it possible for me to change *my compiler* to generate code that uses cap'n'proto more directly? Is it possible to generate an "embedded" schema which can be used to construct cap'n'proto message, so that everything is all in only one file?

Thanks ahead!


Kindly,
Mark
 
Reply all
Reply to author
Forward
0 new messages