diff --git a/include/cppast/cpp_entity.hpp b/include/cppast/cpp_entity.hpp index d6db60d..4a7d541 100644 --- a/include/cppast/cpp_entity.hpp +++ b/include/cppast/cpp_entity.hpp @@ -11,7 +11,7 @@ namespace cppast { - enum class cpp_entity_type; + enum class cpp_entity_kind; /// The base class for all entities in the C++ AST. class cpp_entity : detail::intrusive_list_node @@ -22,10 +22,10 @@ namespace cppast virtual ~cpp_entity() noexcept = default; - /// \returns The type of the entity. - cpp_entity_type type() const noexcept + /// \returns The kind of the entity. + cpp_entity_kind kind() const noexcept { - return do_get_entity_type(); + return do_get_entity_kind(); } /// \returns The name of the entity. @@ -55,8 +55,8 @@ namespace cppast } private: - /// \returns The type of the entity. - virtual cpp_entity_type do_get_entity_type() const noexcept = 0; + /// \returns The kind of the entity. + virtual cpp_entity_kind do_get_entity_kind() const noexcept = 0; /// \returns The name of the new scope created by the entity, if any. /// By default, there is no scope created. diff --git a/include/cppast/cpp_entity_type.hpp b/include/cppast/cpp_entity_kind.hpp similarity index 59% rename from include/cppast/cpp_entity_type.hpp rename to include/cppast/cpp_entity_kind.hpp index 12b8542..e5359d4 100644 --- a/include/cppast/cpp_entity_type.hpp +++ b/include/cppast/cpp_entity_kind.hpp @@ -2,15 +2,15 @@ // This file is subject to the license terms in the LICENSE file // found in the top-level directory of this distribution. -#ifndef CPPAST_CPP_ENTITY_TYPE_HPP_INCLUDED -#define CPPAST_CPP_ENTITY_TYPE_HPP_INCLUDED +#ifndef CPPAST_CPP_ENTITY_KIND_HPP_INCLUDED +#define CPPAST_CPP_ENTITY_KIND_HPP_INCLUDED #include namespace cppast { - /// All possible types of C++ entities. - enum class cpp_entity_type + /// All possible kinds of C++ entities. + enum class cpp_entity_kind { file_t, @@ -25,8 +25,8 @@ namespace cppast count, }; - /// \returns Whether or not a given entity type is a C++ type. - bool is_type(cpp_entity_type type) noexcept; + /// \returns Whether or not a given entity kind is a C++ type. + bool is_type(cpp_entity_kind type) noexcept; } // namespace cppast -#endif // CPPAST_CPP_ENTITY_TYPE_HPP_INCLUDED +#endif // CPPAST_CPP_ENTITY_KIND_HPP_INCLUDED diff --git a/include/cppast/cpp_entity_ref.hpp b/include/cppast/cpp_entity_ref.hpp index bf97f0c..c6d4e93 100644 --- a/include/cppast/cpp_entity_ref.hpp +++ b/include/cppast/cpp_entity_ref.hpp @@ -15,7 +15,7 @@ namespace cppast { public: /// \effects Creates it giving it the target id and name. - /// \requires An entity of matching type must eventually register in the [cppast::cpp_entity_index]() using that id. + /// \requires An entity of matching kind must eventually register in the [cppast::cpp_entity_index]() using that id. basic_cpp_entity_ref(cpp_entity_id target_id, std::string target_name) : target_(std::move(target_id)), name_(std::move(target_name)) { diff --git a/include/cppast/cpp_enum.hpp b/include/cppast/cpp_enum.hpp index 944def9..436b768 100644 --- a/include/cppast/cpp_enum.hpp +++ b/include/cppast/cpp_enum.hpp @@ -46,7 +46,7 @@ namespace cppast { } - cpp_entity_type do_get_entity_type() const noexcept override; + cpp_entity_kind do_get_entity_kind() const noexcept override; std::unique_ptr value_; }; @@ -104,7 +104,7 @@ namespace cppast { } - cpp_entity_type do_get_entity_type() const noexcept override; + cpp_entity_kind do_get_entity_kind() const noexcept override; /// \returns If the enum is scoped, the name of the enum, /// otherwise [ts::nullopt](). diff --git a/include/cppast/cpp_file.hpp b/include/cppast/cpp_file.hpp index 8d3ebf4..d40ca12 100644 --- a/include/cppast/cpp_file.hpp +++ b/include/cppast/cpp_file.hpp @@ -50,7 +50,7 @@ namespace cppast } /// \returns [cpp_entity_type::file_t](). - cpp_entity_type do_get_entity_type() const noexcept override; + cpp_entity_kind do_get_entity_kind() const noexcept override; }; } // namespace cppast diff --git a/include/cppast/cpp_namespace.hpp b/include/cppast/cpp_namespace.hpp index 021f378..a60e5f0 100644 --- a/include/cppast/cpp_namespace.hpp +++ b/include/cppast/cpp_namespace.hpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include namespace cppast { @@ -59,7 +59,7 @@ namespace cppast { } - cpp_entity_type do_get_entity_type() const noexcept override; + cpp_entity_kind do_get_entity_kind() const noexcept override; /// \returns The name of the namespace. type_safe::optional do_get_scope_name() const override @@ -110,7 +110,7 @@ namespace cppast { } - cpp_entity_type do_get_entity_type() const noexcept override; + cpp_entity_kind do_get_entity_kind() const noexcept override; cpp_namespace_ref target_; }; @@ -142,7 +142,7 @@ namespace cppast { } - cpp_entity_type do_get_entity_type() const noexcept override; + cpp_entity_kind do_get_entity_kind() const noexcept override; cpp_entity_id target_; }; @@ -174,7 +174,7 @@ namespace cppast { } - cpp_entity_type do_get_entity_type() const noexcept override; + cpp_entity_kind do_get_entity_kind() const noexcept override; cpp_entity_id target_; }; diff --git a/src/cpp_entity_kind.cpp b/src/cpp_entity_kind.cpp new file mode 100644 index 0000000..23e9bff --- /dev/null +++ b/src/cpp_entity_kind.cpp @@ -0,0 +1,27 @@ +// 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 + +using namespace cppast; + +bool cppast::is_type(cpp_entity_kind type) noexcept +{ + switch (type) + { + case cpp_entity_kind::enum_t: + return true; + + case cpp_entity_kind::file_t: + case cpp_entity_kind::namespace_t: + case cpp_entity_kind::namespace_alias_t: + case cpp_entity_kind::using_directive_t: + case cpp_entity_kind::using_declaration_t: + case cpp_entity_kind::enum_value_t: + case cpp_entity_kind::count: + break; + } + + return false; +} diff --git a/src/cpp_entity_type.cpp b/src/cpp_entity_type.cpp deleted file mode 100644 index 7fec11a..0000000 --- a/src/cpp_entity_type.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// 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 - -using namespace cppast; - -bool cppast::is_type(cpp_entity_type type) noexcept -{ - switch (type) - { - case cpp_entity_type::enum_t: - return true; - - case cpp_entity_type::file_t: - case cpp_entity_type::namespace_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::enum_value_t: - case cpp_entity_type::count: - break; - } - - return false; -} diff --git a/src/cpp_enum.cpp b/src/cpp_enum.cpp index 54c3f70..efe5640 100644 --- a/src/cpp_enum.cpp +++ b/src/cpp_enum.cpp @@ -4,18 +4,18 @@ #include -#include +#include using namespace cppast; -cpp_entity_type cpp_enum_value::do_get_entity_type() const noexcept +cpp_entity_kind cpp_enum_value::do_get_entity_kind() const noexcept { - return cpp_entity_type::enum_value_t; + return cpp_entity_kind::enum_value_t; } -cpp_entity_type cpp_enum::do_get_entity_type() const noexcept +cpp_entity_kind cpp_enum::do_get_entity_kind() const noexcept { - return cpp_entity_type::enum_t; + return cpp_entity_kind::enum_t; } type_safe::optional cpp_enum::do_get_scope_name() const diff --git a/src/cpp_file.cpp b/src/cpp_file.cpp index c814913..0181c17 100644 --- a/src/cpp_file.cpp +++ b/src/cpp_file.cpp @@ -4,11 +4,11 @@ #include -#include +#include using namespace cppast; -cpp_entity_type cpp_file::do_get_entity_type() const noexcept +cpp_entity_kind cpp_file::do_get_entity_kind() const noexcept { - return cpp_entity_type::file_t; + return cpp_entity_kind::file_t; } diff --git a/src/cpp_namespace.cpp b/src/cpp_namespace.cpp index 3476bf3..c53aeda 100644 --- a/src/cpp_namespace.cpp +++ b/src/cpp_namespace.cpp @@ -4,31 +4,31 @@ #include -#include +#include using namespace cppast; -cpp_entity_type cpp_namespace::do_get_entity_type() const noexcept +cpp_entity_kind cpp_namespace::do_get_entity_kind() const noexcept { - return cpp_entity_type::namespace_t; + return cpp_entity_kind::namespace_t; } bool detail::cpp_namespace_ref_predicate::operator()(const cpp_entity& e) { - return e.type() == cpp_entity_type::namespace_t; + return e.kind() == cpp_entity_kind::namespace_t; } -cpp_entity_type cpp_namespace_alias::do_get_entity_type() const noexcept +cpp_entity_kind cpp_namespace_alias::do_get_entity_kind() const noexcept { - return cpp_entity_type::namespace_alias_t; + return cpp_entity_kind::namespace_alias_t; } -cpp_entity_type cpp_using_directive::do_get_entity_type() const noexcept +cpp_entity_kind cpp_using_directive::do_get_entity_kind() const noexcept { - return cpp_entity_type::using_directive_t; + return cpp_entity_kind::using_directive_t; } -cpp_entity_type cpp_using_declaration::do_get_entity_type() const noexcept +cpp_entity_kind cpp_using_declaration::do_get_entity_kind() const noexcept { - return cpp_entity_type::using_declaration_t; + return cpp_entity_kind::using_declaration_t; } diff --git a/src/cpp_type.cpp b/src/cpp_type.cpp index 66c44f2..93407df 100644 --- a/src/cpp_type.cpp +++ b/src/cpp_type.cpp @@ -6,14 +6,14 @@ #include #include -#include +#include #include using namespace cppast; bool detail::cpp_type_ref_predicate::operator()(const cpp_entity& e) { - return is_type(e.type()); + return is_type(e.kind()); } namespace diff --git a/src/visitor.cpp b/src/visitor.cpp index 9590128..0bef5e4 100644 --- a/src/visitor.cpp +++ b/src/visitor.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include #include @@ -33,22 +33,22 @@ namespace bool detail::visit(const cpp_entity& e, detail::visitor_callback_t cb, void* functor) { - switch (e.type()) + switch (e.kind()) { - case cpp_entity_type::file_t: + case cpp_entity_kind::file_t: return handle_container(e, cb, functor); - case cpp_entity_type::namespace_t: + case cpp_entity_kind::namespace_t: return handle_container(e, cb, functor); - case cpp_entity_type::enum_t: + case cpp_entity_kind::enum_t: return handle_container(e, cb, functor); - 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::enum_value_t: + case cpp_entity_kind::namespace_alias_t: + case cpp_entity_kind::using_directive_t: + case cpp_entity_kind::using_declaration_t: + case cpp_entity_kind::enum_value_t: return cb(functor, e, visitor_info::leave_entity); - case cpp_entity_type::count: + case cpp_entity_kind::count: break; }