Add getter to retrieve main entity being outputted
This commit is contained in:
parent
bb8a915279
commit
17ef990bb2
2 changed files with 14 additions and 2 deletions
|
|
@ -379,6 +379,12 @@ namespace cppast
|
||||||
return cur_output_.value();
|
return cur_output_.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \returns The entity whose code is being generated with [cppast::generate_code()]().
|
||||||
|
const cpp_entity& main_entity() const noexcept
|
||||||
|
{
|
||||||
|
return main_entity_.value();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// \returns The formatting options that should be used.
|
/// \returns The formatting options that should be used.
|
||||||
/// The base class version has no flags set.
|
/// The base class version has no flags set.
|
||||||
|
|
@ -498,7 +504,10 @@ namespace cppast
|
||||||
do_write_token_seq(" ");
|
do_write_token_seq(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
type_safe::optional_ref<const output> cur_output_;
|
type_safe::optional_ref<const output> cur_output_;
|
||||||
|
type_safe::optional_ref<const cpp_entity> main_entity_;
|
||||||
|
|
||||||
|
friend bool generate_code(code_generator& generator, const cpp_entity& e);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Generates code for the given entity.
|
/// Generates code for the given entity.
|
||||||
|
|
|
||||||
|
|
@ -1099,7 +1099,10 @@ namespace
|
||||||
|
|
||||||
bool cppast::generate_code(code_generator& generator, const cpp_entity& e)
|
bool cppast::generate_code(code_generator& generator, const cpp_entity& e)
|
||||||
{
|
{
|
||||||
return generate_code_impl(generator, e, cpp_public);
|
generator.main_entity_ = type_safe::ref(e);
|
||||||
|
auto result = generate_code_impl(generator, e, cpp_public);
|
||||||
|
generator.main_entity_ = nullptr;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void detail::write_template_arguments(
|
void detail::write_template_arguments(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue