// Copyright (C) 2017 Jonathan Müller // This file is subject to the license terms in the LICENSE file // found in the top-level directory of this distribution. #include #include #include #include using namespace cppast; cpp_scope_name::cpp_scope_name(type_safe::object_ref entity) : entity_(entity) { if (cppast::is_templated(*entity)) { auto& templ = static_cast(entity->parent().value()); if (!templ.parameters().empty()) templ_ = type_safe::ref(templ); } else if (is_template(entity->kind())) { auto& templ = static_cast(*entity); if (!templ.parameters().empty()) templ_ = type_safe::ref(templ); } } const std::string& cpp_scope_name::name() const noexcept { return entity_->name(); } detail::iteratable_intrusive_list cpp_scope_name::template_parameters() const noexcept { DEBUG_ASSERT(is_templated(), detail::precondition_error_handler{}); return templ_.value().parameters(); } cpp_entity_kind cpp_unexposed_entity::kind() noexcept { return cpp_entity_kind::unexposed_t; } std::unique_ptr cpp_unexposed_entity::build(const cpp_entity_index& index, cpp_entity_id id, std::string name, std::string spelling) { std::unique_ptr 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_unexposed_entity::build(std::string spelling) { return std::unique_ptr(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()) return false; else if (!is_template(e.parent().value().kind())) return false; return e.parent().value().name() == e.name(); }