Add ability to generate code from code_generator

This commit is contained in:
Jonathan Müller 2017-10-02 17:32:46 +02:00
commit 2752d94e2a
2 changed files with 11 additions and 0 deletions

View file

@ -358,6 +358,12 @@ namespace cppast
return main_entity_.value();
}
/// \effects Generates the code for the specified entity.
/// It can be used to generate additional entities while generating another one.
/// \returns Whether or not any code was generated.
/// \notes This does not affect the main entity, but otherwise behaves just like [cppast::generate_code()]().
bool generate_code(const cpp_entity& entity);
private:
/// \returns The formatting options that should be used.
/// The base class version has no flags set.

View file

@ -1103,6 +1103,11 @@ namespace
}
}
bool code_generator::generate_code(const cpp_entity& entity)
{
return generate_code_impl(*this, entity, cpp_public);
}
bool cppast::generate_code(code_generator& generator, const cpp_entity& e)
{
generator.main_entity_ = type_safe::ref(e);