Add signature() to cpp_function_base
This commit is contained in:
parent
592eb0284f
commit
93d2c58f7f
8 changed files with 112 additions and 22 deletions
|
|
@ -9,6 +9,7 @@
|
|||
#include <cppast/cpp_entity.hpp>
|
||||
#include <cppast/cpp_entity_kind.hpp>
|
||||
#include <cppast/cpp_function_type.hpp>
|
||||
#include <cppast/cpp_type_alias.hpp>
|
||||
#include <cppast/cpp_template.hpp>
|
||||
|
||||
using namespace cppast;
|
||||
|
|
@ -545,3 +546,37 @@ void detail::write_type(code_generator::output& output, const cpp_type& type, st
|
|||
output << operator_ws << punctuation("...") << operator_ws;
|
||||
write_type_suffix(output, type);
|
||||
}
|
||||
|
||||
std::string detail::to_string(const cpp_type& type)
|
||||
{
|
||||
class to_string_generator : public code_generator
|
||||
{
|
||||
public:
|
||||
std::string get()
|
||||
{
|
||||
return std::move(result_);
|
||||
}
|
||||
|
||||
private:
|
||||
void do_indent() override
|
||||
{
|
||||
}
|
||||
|
||||
void do_unindent() override
|
||||
{
|
||||
}
|
||||
|
||||
void do_write_token_seq(string_view tokens) override
|
||||
{
|
||||
result_ += tokens.c_str();
|
||||
}
|
||||
|
||||
std::string result_;
|
||||
} generator;
|
||||
|
||||
// just a dummy type for the output
|
||||
static auto dummy_entity = cpp_type_alias::build("foo", cpp_builtin_type::build(cpp_int));
|
||||
to_string_generator::output output(type_safe::ref(generator), type_safe::ref(*dummy_entity));
|
||||
write_type(output, type, "");
|
||||
return generator.get();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue