-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
atdcpp: new backend #404
atdcpp: new backend #404
Conversation
91f8cbd
to
ad61830
Compare
This issue is related to the way of how Exemple of that issue: type field =
{
field : string;
}
type 'a combinator =
{
integer : int;
list_of_things : 'a list;
}
type 'a query' =
[ Elt of 'a
| Or of 'a query' combinator
]
type fq = field query' test.hpp namespace FieldQuery {
namespace Types {
// Original type: _field_query = [ ... | Elt of ... | ... ]
struct Elt
{
typedefs::Field value;
static void to_json(const Elt &e, rapidjson::Writer<rapidjson::StringBuffer> &writer);
};
// Original type: _field_query = [ ... | Or of ... | ... ]
struct Or
{
typedefs::FieldQueryCombinator value;
static void to_json(const Or &e, rapidjson::Writer<rapidjson::StringBuffer> &writer);
};
}
typedefs::FieldQuery from_json(const rapidjson::Value &x);
// ...
}
struct FieldQueryCombinator {
int integer;
std::vector<typedefs::FieldQuery> list_of_things;
static FieldQueryCombinator from_json(const rapidjson::Value & doc);
// ...
}; As you can see, defining |
3cf12ec
to
fa3e2a6
Compare
I think this PR is now ready for review. I think the best way would be to add the install step to the CI, but I'm not sure about it. |
I assume we don't need rapidjson to compile the OCaml program |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the glance, the code generator and the generated code look fine to me. As long as there's good test coverage, it's great. I'm no C++ expert so if you're worried about some choices you made for the generated C++ code, you should find someone else.
I didn't say it but having C++ support is a massive achievement. Thank you! You should make a big announcement once it's in a usable state (I suggest as soon as it's available in opam or earlier). |
I made the necessary changes, I think it should be mergeable as is. |
New atd backend for C++
output_atd.hpp
andoutput_atd.cpp
for better readabilitytemplatize
annotation (wraps into a type templated by the previous type).<cpp namespace="my_namespace">
, will default toatd::
enum
repr for variants. Will still default tostd::variant
. Only works for sumtypes without fields.Solve issue where if you define multiple types with generics, that depend on each other, the order of c++ declarations will not necessarily be correct, and will prevent compilation unless header is manually edited