Add cpp_variable
This commit is contained in:
parent
4b69e823c8
commit
664b5a6d4e
5 changed files with 89 additions and 0 deletions
|
|
@ -30,6 +30,9 @@ const char* cppast::to_string(cpp_entity_kind kind) noexcept
|
|||
case cpp_entity_kind::enum_value_t:
|
||||
return "enum value";
|
||||
|
||||
case cpp_entity_kind::variable_t:
|
||||
return "variable";
|
||||
|
||||
case cpp_entity_kind::count:
|
||||
break;
|
||||
}
|
||||
|
|
@ -51,6 +54,7 @@ bool cppast::is_type(cpp_entity_kind kind) noexcept
|
|||
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::variable_t:
|
||||
case cpp_entity_kind::count:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
25
src/cpp_variable.cpp
Normal file
25
src/cpp_variable.cpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// 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_variable.hpp>
|
||||
|
||||
#include <cppast/cpp_entity_kind.hpp>
|
||||
|
||||
using namespace cppast;
|
||||
|
||||
std::unique_ptr<cpp_variable> cpp_variable::build(const cpp_entity_index& idx, cpp_entity_id id,
|
||||
std::string name, std::unique_ptr<cpp_type> type,
|
||||
std::unique_ptr<cpp_expression> def,
|
||||
cpp_variable_specifiers spec)
|
||||
{
|
||||
auto result = std::unique_ptr<cpp_variable>(
|
||||
new cpp_variable(std::move(name), std::move(type), std::move(def), spec));
|
||||
idx.register_entity(std::move(id), type_safe::cref(*result));
|
||||
return result;
|
||||
}
|
||||
|
||||
cpp_entity_kind cpp_variable::do_get_entity_kind() const noexcept
|
||||
{
|
||||
return cpp_entity_kind::variable_t;
|
||||
}
|
||||
|
|
@ -47,6 +47,7 @@ bool detail::visit(const cpp_entity& e, detail::visitor_callback_t cb, void* fun
|
|||
case cpp_entity_kind::using_declaration_t:
|
||||
case cpp_entity_kind::type_alias_t:
|
||||
case cpp_entity_kind::enum_value_t:
|
||||
case cpp_entity_kind::variable_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