Remove parameter children from e.g. cpp_function_base
Also template parameter children of cpp_template_template_parameter. Now accessible over named function, consistent with base classes, other template parameters etc.
This commit is contained in:
parent
599524a894
commit
c5d6df957c
9 changed files with 63 additions and 59 deletions
|
|
@ -5,8 +5,8 @@
|
|||
#ifndef CPPAST_CPP_FUNCTION_HPP_INCLUDED
|
||||
#define CPPAST_CPP_FUNCTION_HPP_INCLUDED
|
||||
|
||||
#include <cppast/detail/intrusive_list.hpp>
|
||||
#include <cppast/cpp_entity.hpp>
|
||||
#include <cppast/cpp_entity_container.hpp>
|
||||
#include <cppast/cpp_forward_declarable.hpp>
|
||||
#include <cppast/cpp_storage_class_specifiers.hpp>
|
||||
#include <cppast/cpp_variable_base.hpp>
|
||||
|
|
@ -64,12 +64,15 @@ namespace cppast
|
|||
/// Base class for all entities that are functions.
|
||||
///
|
||||
/// It contains arguments and common flags.
|
||||
class cpp_function_base
|
||||
: public cpp_entity,
|
||||
public cpp_entity_container<cpp_function_base, cpp_function_parameter>,
|
||||
public cpp_forward_declarable
|
||||
class cpp_function_base : public cpp_entity, public cpp_forward_declarable
|
||||
{
|
||||
public:
|
||||
/// \returns An iteratable object iterating over the [cppast::cpp_function__parameter]() entities.
|
||||
detail::iteratable_intrusive_list<cpp_function_parameter> parameters() const noexcept
|
||||
{
|
||||
return type_safe::ref(parameters_);
|
||||
}
|
||||
|
||||
/// \returns The [cppast::cpp_function_body_kind]().
|
||||
/// \notes This matches the [cppast::cpp_forward_declarable]() queries.
|
||||
cpp_function_body_kind body_kind() const noexcept
|
||||
|
|
@ -107,7 +110,9 @@ namespace cppast
|
|||
/// \effects Adds a parameter.
|
||||
void add_parameter(std::unique_ptr<cpp_function_parameter> parameter)
|
||||
{
|
||||
static_cast<cpp_function_base&>(*function).add_child(std::move(parameter));
|
||||
static_cast<cpp_function_base&>(*function).parameters_.push_back(*function,
|
||||
std::move(
|
||||
parameter));
|
||||
}
|
||||
|
||||
/// \effects Marks the function as variadic.
|
||||
|
|
@ -168,9 +173,10 @@ namespace cppast
|
|||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<cpp_expression> noexcept_expr_;
|
||||
cpp_function_body_kind body_;
|
||||
bool variadic_;
|
||||
detail::intrusive_list<cpp_function_parameter> parameters_;
|
||||
std::unique_ptr<cpp_expression> noexcept_expr_;
|
||||
cpp_function_body_kind body_;
|
||||
bool variadic_;
|
||||
};
|
||||
|
||||
/// A [cppast::cpp_entity]() modelling a C++ function.
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
#include <type_safe/optional.hpp>
|
||||
#include <type_safe/variant.hpp>
|
||||
|
||||
#include <cppast/detail/intrusive_list.hpp>
|
||||
#include <cppast/cpp_entity.hpp>
|
||||
#include <cppast/cpp_entity_container.hpp>
|
||||
#include <cppast/cpp_variable_base.hpp>
|
||||
|
||||
namespace cppast
|
||||
|
|
@ -170,9 +170,7 @@ namespace cppast
|
|||
using cpp_template_ref = basic_cpp_entity_ref<cpp_entity, detail::cpp_template_ref_predicate>;
|
||||
|
||||
/// A [cppast::cpp_entity]() modelling a C++ template template parameter.
|
||||
class cpp_template_template_parameter final
|
||||
: public cpp_template_parameter,
|
||||
public cpp_entity_container<cpp_template_template_parameter, cpp_template_parameter>
|
||||
class cpp_template_template_parameter final : public cpp_template_parameter
|
||||
{
|
||||
public:
|
||||
static cpp_entity_kind kind() noexcept;
|
||||
|
|
@ -197,7 +195,7 @@ namespace cppast
|
|||
/// \effects Adds a parameter to the template.
|
||||
void add_parameter(std::unique_ptr<cpp_template_parameter> param)
|
||||
{
|
||||
parameter_->add_child(std::move(param));
|
||||
parameter_->parameters_.push_back(*parameter_, std::move(param));
|
||||
}
|
||||
|
||||
/// \effects Sets the default template.
|
||||
|
|
@ -220,6 +218,12 @@ namespace cppast
|
|||
std::unique_ptr<cpp_template_template_parameter> parameter_;
|
||||
};
|
||||
|
||||
/// \returns An iteratable object containing the template parameters of the template template parameter.
|
||||
detail::iteratable_intrusive_list<cpp_template_parameter> parameters() const noexcept
|
||||
{
|
||||
return type_safe::ref(parameters_);
|
||||
}
|
||||
|
||||
/// \returns The keyword used in the template parameter.
|
||||
cpp_template_keyword keyword() const noexcept
|
||||
{
|
||||
|
|
@ -241,8 +245,9 @@ namespace cppast
|
|||
|
||||
cpp_entity_kind do_get_entity_kind() const noexcept override;
|
||||
|
||||
type_safe::optional<cpp_template_ref> default_;
|
||||
cpp_template_keyword keyword_;
|
||||
detail::intrusive_list<cpp_template_parameter> parameters_;
|
||||
type_safe::optional<cpp_template_ref> default_;
|
||||
cpp_template_keyword keyword_;
|
||||
};
|
||||
|
||||
/// An argument for a [cppast::cpp_template_parameter]().
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue