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 |
mjambon
left a comment
There was a problem hiding this comment.
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. |
CHANGES: * atdgen: Breaking change, migrate from Bucklescript to Melange (ahrefs/atd#375) * atdd: Workaround d compiler bug regarding declaration order when using aliases (ahrefs/atd#393) Algebraic data types (SumType) now uses `alias this` syntax. * atdgen: Add support for `<json open_enum>` in Melange (ahrefs/atd#401) * atdcpp: Initial Release (ahrefs/atd#404) * atdcpp: Use `double` c++ type as default floating point type (ahrefs/atd#411) * atdgen: Fix JSON I/O for inline records (ahrefs/atd#419) * atdgen: The deprecated `atdgen` library is no longer available. Use `atdgen-runtime` instead (ahrefs/atd#421) * atddiff: To ensure that all the intended types are checked when new type definitions are added to an ATD file, an `--ignore` option is now available. It makes atddiff fail if some types are neither selected via `--types` nor ignored via `--ignore`.
New atd backend for C++
output_atd.hppandoutput_atd.cppfor better readabilitytemplatizeannotation (wraps into a type templated by the previous type).<cpp namespace="my_namespace">, will default toatd::enumrepr 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