Add support for forward declarations

This commit is contained in:
Jonathan Müller 2017-03-11 15:36:51 +01:00
commit 210fcf2c36
12 changed files with 332 additions and 64 deletions

View file

@ -7,6 +7,7 @@
#include <cppast/cpp_entity.hpp>
#include <cppast/cpp_entity_container.hpp>
#include <cppast/cpp_forward_declarable.hpp>
#include <cppast/cpp_type.hpp>
namespace cppast
@ -112,7 +113,13 @@ namespace cppast
};
/// A [cppast::cpp_entity]() modelling a C++ class.
class cpp_class final : public cpp_entity, public cpp_entity_container<cpp_class, cpp_entity>
///
/// This can either be a definition or just a forward declaration.
/// If it is just a forward declaration,
/// everything except the class type will not be available.
class cpp_class final : public cpp_entity,
public cpp_entity_container<cpp_class, cpp_entity>,
public cpp_forward_declarable
{
public:
static cpp_entity_kind kind() noexcept;
@ -164,6 +171,15 @@ namespace cppast
std::unique_ptr<cpp_class> finish(const cpp_entity_index& idx,
cpp_entity_id id) noexcept;
/// \effects Marks the class as forward declaration.
/// \returns The finished class.
/// \notes It will not be registered, as it is not the main definition.
std::unique_ptr<cpp_class> finish_declaration(cpp_entity_id definition_id) noexcept
{
class_->set_definition(definition_id);
return std::move(class_);
}
private:
std::unique_ptr<cpp_class> class_;
};