From 023ce3e87cb3a2f2df0f9e77e29dea762ce23457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20M=C3=BCller?= Date: Sat, 21 Jan 2017 22:30:51 +0100 Subject: [PATCH] Remove cpp_scope --- ...cpp_scope.hpp => cpp_entity_container.hpp} | 33 ++----------------- include/cppast/cpp_entity_type.hpp | 4 --- include/cppast/cpp_file.hpp | 2 +- include/cppast/cpp_namespace.hpp | 7 ++-- src/cpp_entity_type.cpp | 18 ---------- 5 files changed, 8 insertions(+), 56 deletions(-) rename include/cppast/{cpp_scope.hpp => cpp_entity_container.hpp} (63%) diff --git a/include/cppast/cpp_scope.hpp b/include/cppast/cpp_entity_container.hpp similarity index 63% rename from include/cppast/cpp_scope.hpp rename to include/cppast/cpp_entity_container.hpp index 9f5b7b4..85c2ac8 100644 --- a/include/cppast/cpp_scope.hpp +++ b/include/cppast/cpp_entity_container.hpp @@ -2,8 +2,8 @@ // This file is subject to the license terms in the LICENSE file // found in the top-level directory of this distribution. -#ifndef CPPAST_CPP_SCOPE_HPP_INCLUDED -#define CPPAST_CPP_SCOPE_HPP_INCLUDED +#ifndef CPPAST_CPP_ENTITY_CONTAINER_HPP_INCLUDED +#define CPPAST_CPP_ENTITY_CONTAINER_HPP_INCLUDED #include @@ -54,33 +54,6 @@ namespace cppast private: detail::intrusive_list children_; }; - - /// Base class for all entities that add a scope. - /// - /// Examples are namespaces and classes, - /// or anything else that can appear followed by `::`. - class cpp_scope : public cpp_entity, public cpp_entity_container - { - public: - /// \returns The name of the scope. - /// By default, this is the same name as the entity, - /// but derived classes can override it. - std::string scope_name() const - { - return do_get_scope_name(); - } - - protected: - using cpp_entity::cpp_entity; - - private: - /// \returns The name of the new scope, - /// defaults to the name of the entity. - virtual std::string do_get_scope_name() const - { - return name(); - } - }; } // namespace cppast -#endif // CPPAST_CPP_SCOPE_HPP_INCLUDED +#endif // CPPAST_CPP_ENTITY_CONTAINER_HPP_INCLUDED diff --git a/include/cppast/cpp_entity_type.hpp b/include/cppast/cpp_entity_type.hpp index 4d15ed0..8fb0ea5 100644 --- a/include/cppast/cpp_entity_type.hpp +++ b/include/cppast/cpp_entity_type.hpp @@ -22,10 +22,6 @@ namespace cppast count, }; - /// \returns Whether or not a given entity type is one derived from [cppast::cpp_scope](). - /// One example is [cppast::cpp_entity_type::namespace_t](). - bool is_scope(cpp_entity_type type) noexcept; - /// \returns Whether or not a given entity type is a C++ type. bool is_type(cpp_entity_type type) noexcept; } // namespace cppast diff --git a/include/cppast/cpp_file.hpp b/include/cppast/cpp_file.hpp index 34d0a71..8d3ebf4 100644 --- a/include/cppast/cpp_file.hpp +++ b/include/cppast/cpp_file.hpp @@ -6,7 +6,7 @@ #define CPPAST_CPP_FILE_HPP_INCLUDED #include -#include +#include namespace cppast { diff --git a/include/cppast/cpp_namespace.hpp b/include/cppast/cpp_namespace.hpp index 302e202..f76cbe4 100644 --- a/include/cppast/cpp_namespace.hpp +++ b/include/cppast/cpp_namespace.hpp @@ -5,15 +5,16 @@ #ifndef CPPAST_CPP_NAMESPACE_HPP_INCLUDED #define CPPAST_CPP_NAMESPACE_HPP_INCLUDED +#include #include #include #include -#include namespace cppast { /// A [cppast::cpp_entity]() modelling a namespace. - class cpp_namespace final : public cpp_scope + class cpp_namespace final : public cpp_entity, + public cpp_entity_container { public: /// Builds a [cppast::cpp_namespace](). @@ -54,7 +55,7 @@ namespace cppast private: cpp_namespace(std::string name, bool is_inline) - : cpp_scope(std::move(name)), inline_(is_inline) + : cpp_entity(std::move(name)), inline_(is_inline) { } diff --git a/src/cpp_entity_type.cpp b/src/cpp_entity_type.cpp index cd841a5..4cc4ab6 100644 --- a/src/cpp_entity_type.cpp +++ b/src/cpp_entity_type.cpp @@ -6,24 +6,6 @@ using namespace cppast; -bool cppast::is_scope(cpp_entity_type type) noexcept -{ - switch (type) - { - case cpp_entity_type::namespace_t: - return true; - - case cpp_entity_type::file_t: - case cpp_entity_type::namespace_alias_t: - case cpp_entity_type::using_directive_t: - case cpp_entity_type::using_declaration_t: - case cpp_entity_type::count: - break; - } - - return false; -} - bool cppast::is_type(cpp_entity_type type) noexcept { switch (type)