Rename cpp_entity_type -> cpp_entity_kind
This commit is contained in:
parent
6b658297d8
commit
87aba96c5b
13 changed files with 79 additions and 79 deletions
|
|
@ -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<cpp_entity>
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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 <cppast/detail/assert.hpp>
|
||||
|
||||
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
|
||||
|
|
@ -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))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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<cpp_expression> 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]().
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include <cppast/cpp_entity_container.hpp>
|
||||
#include <cppast/cpp_entity_index.hpp>
|
||||
#include <cppast/cpp_entity_ref.hpp>
|
||||
#include <cppast/cpp_entity_type.hpp>
|
||||
#include <cppast/cpp_entity_kind.hpp>
|
||||
|
||||
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<std::string> 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_;
|
||||
};
|
||||
|
|
|
|||
27
src/cpp_entity_kind.cpp
Normal file
27
src/cpp_entity_kind.cpp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright (C) 2017 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
|
||||
#include <cppast/cpp_entity_kind.hpp>
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
// Copyright (C) 2017 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
|
||||
#include <cppast/cpp_entity_type.hpp>
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
@ -4,18 +4,18 @@
|
|||
|
||||
#include <cppast/cpp_enum.hpp>
|
||||
|
||||
#include <cppast/cpp_entity_type.hpp>
|
||||
#include <cppast/cpp_entity_kind.hpp>
|
||||
|
||||
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<std::string> cpp_enum::do_get_scope_name() const
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@
|
|||
|
||||
#include <cppast/cpp_file.hpp>
|
||||
|
||||
#include <cppast/cpp_entity_type.hpp>
|
||||
#include <cppast/cpp_entity_kind.hpp>
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,31 +4,31 @@
|
|||
|
||||
#include <cppast/cpp_namespace.hpp>
|
||||
|
||||
#include <cppast/cpp_entity_type.hpp>
|
||||
#include <cppast/cpp_entity_kind.hpp>
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@
|
|||
|
||||
#include <cppast/cpp_array_type.hpp>
|
||||
#include <cppast/cpp_entity.hpp>
|
||||
#include <cppast/cpp_entity_type.hpp>
|
||||
#include <cppast/cpp_entity_kind.hpp>
|
||||
#include <cppast/cpp_function_types.hpp>
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include <cppast/visitor.hpp>
|
||||
|
||||
#include <cppast/cpp_entity.hpp>
|
||||
#include <cppast/cpp_entity_type.hpp>
|
||||
#include <cppast/cpp_entity_kind.hpp>
|
||||
#include <cppast/cpp_enum.hpp>
|
||||
#include <cppast/cpp_file.hpp>
|
||||
#include <cppast/cpp_namespace.hpp>
|
||||
|
|
@ -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<cpp_file>(e, cb, functor);
|
||||
case cpp_entity_type::namespace_t:
|
||||
case cpp_entity_kind::namespace_t:
|
||||
return handle_container<cpp_namespace>(e, cb, functor);
|
||||
case cpp_entity_type::enum_t:
|
||||
case cpp_entity_kind::enum_t:
|
||||
return handle_container<cpp_enum>(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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue