From 2752d94e2a10e89e04b80c41d37aa5aae48afd98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20M=C3=BCller?= Date: Mon, 2 Oct 2017 17:32:46 +0200 Subject: [PATCH] Add ability to generate code from code_generator --- include/cppast/code_generator.hpp | 6 ++++++ src/code_generator.cpp | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/include/cppast/code_generator.hpp b/include/cppast/code_generator.hpp index 84f243f..39f24b7 100644 --- a/include/cppast/code_generator.hpp +++ b/include/cppast/code_generator.hpp @@ -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. diff --git a/src/code_generator.cpp b/src/code_generator.cpp index 557c411..eb88d96 100644 --- a/src/code_generator.cpp +++ b/src/code_generator.cpp @@ -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);