Add and parse unexposed entity
This commit is contained in:
parent
d18070a799
commit
df684694cc
8 changed files with 94 additions and 2 deletions
|
|
@ -810,6 +810,13 @@ namespace
|
|||
generate_class(generator, templ.class_(), type_safe::ref(templ));
|
||||
}
|
||||
}
|
||||
|
||||
void generate_unexposed(code_generator& generator, const cpp_unexposed_entity& entity)
|
||||
{
|
||||
code_generator::output output(type_safe::ref(generator), type_safe::ref(entity), false);
|
||||
if (output)
|
||||
output << token_seq(entity.spelling());
|
||||
}
|
||||
}
|
||||
|
||||
void cppast::generate_code(code_generator& generator, const cpp_entity& e)
|
||||
|
|
@ -863,6 +870,10 @@ void cppast::generate_code(code_generator& generator, const cpp_entity& e)
|
|||
CPPAST_DETAIL_HANDLE(class_template)
|
||||
CPPAST_DETAIL_HANDLE(class_template_specialization)
|
||||
|
||||
case cpp_entity_kind::unexposed_t:
|
||||
generate_unexposed(generator, static_cast<const cpp_unexposed_entity&>(e));
|
||||
break;
|
||||
|
||||
#undef CPPAST_DETAIL_HANDLE
|
||||
|
||||
case cpp_entity_kind::count:
|
||||
|
|
|
|||
|
|
@ -4,10 +4,36 @@
|
|||
|
||||
#include <cppast/cpp_entity.hpp>
|
||||
|
||||
#include <cppast/cpp_entity_index.hpp>
|
||||
#include <cppast/cpp_entity_kind.hpp>
|
||||
|
||||
using namespace cppast;
|
||||
|
||||
cpp_entity_kind cpp_unexposed_entity::kind() noexcept
|
||||
{
|
||||
return cpp_entity_kind::unexposed_t;
|
||||
}
|
||||
|
||||
std::unique_ptr<cpp_entity> cpp_unexposed_entity::build(const cpp_entity_index& index,
|
||||
cpp_entity_id id, std::string name,
|
||||
std::string spelling)
|
||||
{
|
||||
std::unique_ptr<cpp_entity> result(
|
||||
new cpp_unexposed_entity(std::move(name), std::move(spelling)));
|
||||
index.register_forward_declaration(id, type_safe::ref(*result));
|
||||
return result;
|
||||
}
|
||||
|
||||
std::unique_ptr<cpp_entity> cpp_unexposed_entity::build(std::string spelling)
|
||||
{
|
||||
return std::unique_ptr<cpp_entity>(new cpp_unexposed_entity("", std::move(spelling)));
|
||||
}
|
||||
|
||||
cpp_entity_kind cpp_unexposed_entity::do_get_entity_kind() const noexcept
|
||||
{
|
||||
return kind();
|
||||
}
|
||||
|
||||
bool cppast::is_templated(const cpp_entity& e) noexcept
|
||||
{
|
||||
if (!e.parent())
|
||||
|
|
|
|||
|
|
@ -85,6 +85,9 @@ const char* cppast::to_string(cpp_entity_kind kind) noexcept
|
|||
case cpp_entity_kind::class_template_specialization_t:
|
||||
return "class tempalte specialization";
|
||||
|
||||
case cpp_entity_kind::unexposed_t:
|
||||
return "unexposed entity";
|
||||
|
||||
case cpp_entity_kind::count:
|
||||
break;
|
||||
}
|
||||
|
|
@ -130,6 +133,7 @@ bool cppast::is_type(cpp_entity_kind kind) noexcept
|
|||
case cpp_entity_kind::function_template_specialization_t:
|
||||
case cpp_entity_kind::class_template_t:
|
||||
case cpp_entity_kind::class_template_specialization_t:
|
||||
case cpp_entity_kind::unexposed_t:
|
||||
case cpp_entity_kind::count:
|
||||
break;
|
||||
}
|
||||
|
|
@ -175,6 +179,7 @@ bool cppast::is_function(cpp_entity_kind kind) noexcept
|
|||
case cpp_entity_kind::function_template_specialization_t:
|
||||
case cpp_entity_kind::class_template_t:
|
||||
case cpp_entity_kind::class_template_specialization_t:
|
||||
case cpp_entity_kind::unexposed_t:
|
||||
case cpp_entity_kind::count:
|
||||
break;
|
||||
}
|
||||
|
|
@ -220,6 +225,7 @@ bool cppast::is_parameter(cpp_entity_kind kind) noexcept
|
|||
case cpp_entity_kind::function_template_specialization_t:
|
||||
case cpp_entity_kind::class_template_t:
|
||||
case cpp_entity_kind::class_template_specialization_t:
|
||||
case cpp_entity_kind::unexposed_t:
|
||||
case cpp_entity_kind::count:
|
||||
break;
|
||||
}
|
||||
|
|
@ -264,6 +270,7 @@ bool cppast::is_template(cpp_entity_kind kind) noexcept
|
|||
case cpp_entity_kind::template_type_parameter_t:
|
||||
case cpp_entity_kind::non_type_template_parameter_t:
|
||||
case cpp_entity_kind::template_template_parameter_t:
|
||||
case cpp_entity_kind::unexposed_t:
|
||||
case cpp_entity_kind::count:
|
||||
break;
|
||||
}
|
||||
|
|
@ -309,6 +316,7 @@ bool cppast::is_template_specialization(cpp_entity_kind kind) noexcept
|
|||
case cpp_entity_kind::variable_template_t:
|
||||
case cpp_entity_kind::function_template_t:
|
||||
case cpp_entity_kind::class_template_t:
|
||||
case cpp_entity_kind::unexposed_t:
|
||||
case cpp_entity_kind::count:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,7 +148,16 @@ std::unique_ptr<cpp_entity> detail::parse_entity(const detail::parse_context& co
|
|||
context.logger->log("libclang parser",
|
||||
diagnostic{std::move(msg), detail::make_location(cur), severity::warning});
|
||||
|
||||
return nullptr;
|
||||
// build unexposed entity
|
||||
auto name = detail::get_cursor_name(cur);
|
||||
detail::tokenizer tokenizer(context.tu, context.file, cur);
|
||||
detail::token_stream stream(tokenizer, cur);
|
||||
auto spelling = detail::to_string(stream, stream.end());
|
||||
if (name.empty())
|
||||
return cpp_unexposed_entity::build(std::move(spelling));
|
||||
else
|
||||
return cpp_unexposed_entity::build(*context.idx, detail::get_entity_id(cur), name.c_str(),
|
||||
std::move(spelling));
|
||||
}
|
||||
catch (parse_error& ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ bool detail::visit(const cpp_entity& e, detail::visitor_callback_t cb, void* fun
|
|||
case cpp_entity_kind::destructor_t:
|
||||
case cpp_entity_kind::template_type_parameter_t:
|
||||
case cpp_entity_kind::non_type_template_parameter_t:
|
||||
case cpp_entity_kind::unexposed_t:
|
||||
return cb(functor, e, visitor_info::leaf_entity);
|
||||
|
||||
case cpp_entity_kind::count:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue