mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-19 16:30:04 +00:00
Pimplify the abigail::ir::scope_decl type
The abigail::ir::scope_decl still has its data member members be visible from its header file. This patch hides those data member using the pimpl idiom, just as what is done other types throughout the project. * include/abg-ir.h (scope_decl::{priv, priv_sptr}) Declare new types. (scope_decl::priv_): New pimpl data member. (scope_decl::{member_, member_scopes}): Move this as data member of the new scope_decl::priv type in the abg-ir.cc file. (scope_decl::{scope_decl, get_member_decls, get_member_scopes, is_empty}): Make these inline member functions be out-of-line. * src/abg-ir.cc (struct scope_decl::priv): Define new type. (scope_decl::{scope_decl, get_member_decls, get_member_scopes, is_empty}): Define these new member functions here. They were inline in the include/abg-ir.h header files before. (scope_decl::{add_member_decl, insert_member_decl, remove_member_decl}): Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
parent
e73c0ed0fb
commit
24b418795e
@ -1247,10 +1247,13 @@ public:
|
||||
typedef std::vector<function_type_sptr > function_types;
|
||||
/// Convenience typedef for a vector of @ref scope_decl_sptr.
|
||||
typedef std::vector<scope_decl_sptr> scopes;
|
||||
/// The type of the private data of @ref scope_decl.
|
||||
struct priv;
|
||||
/// A convenience typedef for a shared pointer to scope_decl::priv.
|
||||
typedef shared_ptr<priv> priv_sptr;
|
||||
|
||||
private:
|
||||
declarations members_;
|
||||
scopes member_scopes_;
|
||||
priv_sptr priv_;
|
||||
|
||||
scope_decl();
|
||||
|
||||
@ -1270,15 +1273,9 @@ public:
|
||||
|
||||
scope_decl(const environment* env,
|
||||
const string& name, const location& locus,
|
||||
visibility vis = VISIBILITY_DEFAULT)
|
||||
: type_or_decl_base(env),
|
||||
decl_base(env, name, locus, /*mangled_name=*/name, vis)
|
||||
{}
|
||||
visibility vis = VISIBILITY_DEFAULT);
|
||||
|
||||
scope_decl(const environment* env, location& l)
|
||||
: type_or_decl_base(env),
|
||||
decl_base(env, "", l)
|
||||
{}
|
||||
scope_decl(const environment* env, location& l);
|
||||
|
||||
virtual size_t
|
||||
get_hash() const;
|
||||
@ -1287,24 +1284,19 @@ public:
|
||||
operator==(const decl_base&) const;
|
||||
|
||||
const declarations&
|
||||
get_member_decls() const
|
||||
{return members_;}
|
||||
get_member_decls() const;
|
||||
|
||||
declarations&
|
||||
get_member_decls()
|
||||
{return members_;}
|
||||
get_member_decls();
|
||||
|
||||
scopes&
|
||||
get_member_scopes()
|
||||
{return member_scopes_;}
|
||||
get_member_scopes();
|
||||
|
||||
const scopes&
|
||||
get_member_scopes() const
|
||||
{return member_scopes_;}
|
||||
get_member_scopes() const;
|
||||
|
||||
bool
|
||||
is_empty() const
|
||||
{return get_member_decls().empty();}
|
||||
is_empty() const;
|
||||
|
||||
bool
|
||||
find_iterator_for_member(const decl_base*, declarations::iterator&);
|
||||
|
100
src/abg-ir.cc
100
src/abg-ir.cc
@ -4240,6 +4240,84 @@ maybe_update_types_lookup_map(scope_decl *scope,
|
||||
}
|
||||
}
|
||||
|
||||
// <scope_decl stuff>
|
||||
|
||||
struct scope_decl::priv
|
||||
{
|
||||
declarations members_;
|
||||
scopes member_scopes_;
|
||||
}; // end struct scope_decl::priv
|
||||
|
||||
/// Constructor of the @ref scope_decl type.
|
||||
///
|
||||
/// @param the environment to use for the new instance.
|
||||
///
|
||||
/// @param the name of the scope decl.
|
||||
///
|
||||
/// @param locus the source location where the scope_decl is defined.
|
||||
///
|
||||
/// @param vis the visibility of the declaration.
|
||||
scope_decl::scope_decl(const environment* env,
|
||||
const string& name,
|
||||
const location& locus,
|
||||
visibility vis)
|
||||
: type_or_decl_base(env),
|
||||
decl_base(env, name, locus, /*mangled_name=*/name, vis),
|
||||
priv_(new priv)
|
||||
{}
|
||||
|
||||
/// Constructor of the @ref scope_decl type.
|
||||
///
|
||||
/// @param the environment to use for the new instance.
|
||||
///
|
||||
/// @param l the source location where the scope_decl is defined.
|
||||
///
|
||||
/// @param vis the visibility of the declaration.
|
||||
scope_decl::scope_decl(const environment* env, location& l)
|
||||
: type_or_decl_base(env),
|
||||
decl_base(env, "", l),
|
||||
priv_(new priv)
|
||||
{}
|
||||
|
||||
/// Getter for the member declarations carried by the current @ref
|
||||
/// scope_decl.
|
||||
///
|
||||
/// @return the member declarations carried by the current @ref
|
||||
/// scope_decl.
|
||||
const scope_decl::declarations&
|
||||
scope_decl::get_member_decls() const
|
||||
{return priv_->members_;}
|
||||
|
||||
/// Getter for the member declarations carried by the current @ref
|
||||
/// scope_decl.
|
||||
///
|
||||
/// @return the member declarations carried by the current @ref
|
||||
/// scope_decl.
|
||||
scope_decl::declarations&
|
||||
scope_decl::get_member_decls()
|
||||
{return priv_->members_;}
|
||||
|
||||
/// Getter for the scopes carried by the current scope.
|
||||
///
|
||||
/// @return the scopes carried by the current scope.
|
||||
scope_decl::scopes&
|
||||
scope_decl::get_member_scopes()
|
||||
{return priv_->member_scopes_;}
|
||||
|
||||
/// Getter for the scopes carried by the current scope.
|
||||
///
|
||||
/// @return the scopes carried by the current scope.
|
||||
const scope_decl::scopes&
|
||||
scope_decl::get_member_scopes() const
|
||||
{return priv_->member_scopes_;}
|
||||
|
||||
/// Test if the current scope is empty.
|
||||
///
|
||||
/// @return true iff the current scope is empty.
|
||||
bool
|
||||
scope_decl::is_empty() const
|
||||
{return get_member_decls().empty();}
|
||||
|
||||
/// Add a member decl to this scope. Note that user code should not
|
||||
/// use this, but rather use add_decl_to_scope.
|
||||
///
|
||||
@ -4255,10 +4333,10 @@ scope_decl::add_member_decl(const decl_base_sptr member)
|
||||
assert(!has_scope(member));
|
||||
|
||||
member->set_scope(this);
|
||||
members_.push_back(member);
|
||||
priv_->members_.push_back(member);
|
||||
|
||||
if (scope_decl_sptr m = dynamic_pointer_cast<scope_decl>(member))
|
||||
member_scopes_.push_back(m);
|
||||
priv_->member_scopes_.push_back(m);
|
||||
|
||||
update_qualified_name(member);
|
||||
|
||||
@ -4296,10 +4374,10 @@ scope_decl::insert_member_decl(const decl_base_sptr member,
|
||||
assert(!member->get_scope());
|
||||
|
||||
member->set_scope(this);
|
||||
members_.insert(before, member);
|
||||
priv_->members_.insert(before, member);
|
||||
|
||||
if (scope_decl_sptr m = dynamic_pointer_cast<scope_decl>(member))
|
||||
member_scopes_.push_back(m);
|
||||
priv_-> member_scopes_.push_back(m);
|
||||
|
||||
update_qualified_name(member);
|
||||
|
||||
@ -4325,13 +4403,13 @@ scope_decl::insert_member_decl(const decl_base_sptr member,
|
||||
void
|
||||
scope_decl::remove_member_decl(const decl_base_sptr member)
|
||||
{
|
||||
for (declarations::iterator i = members_.begin();
|
||||
i != members_.end();
|
||||
for (declarations::iterator i = priv_->members_.begin();
|
||||
i != priv_->members_.end();
|
||||
++i)
|
||||
{
|
||||
if (**i == *member)
|
||||
{
|
||||
members_.erase(i);
|
||||
priv_->members_.erase(i);
|
||||
// Do not access i after this point as it's invalided by the
|
||||
// erase call.
|
||||
break;
|
||||
@ -4341,13 +4419,13 @@ scope_decl::remove_member_decl(const decl_base_sptr member)
|
||||
scope_decl_sptr scope = dynamic_pointer_cast<scope_decl>(member);
|
||||
if (scope)
|
||||
{
|
||||
for (scopes::iterator i = member_scopes_.begin();
|
||||
i != member_scopes_.end();
|
||||
for (scopes::iterator i = priv_->member_scopes_.begin();
|
||||
i != priv_->member_scopes_.end();
|
||||
++i)
|
||||
{
|
||||
if (**i == *member)
|
||||
{
|
||||
member_scopes_.erase(i);
|
||||
priv_->member_scopes_.erase(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -4740,6 +4818,8 @@ get_top_most_scope_under(const decl_base_sptr decl,
|
||||
const scope_decl_sptr scope)
|
||||
{return get_top_most_scope_under(decl, scope.get());}
|
||||
|
||||
// </scope_decl stuff>
|
||||
|
||||
/// Build and return a copy of the name of an ABI artifact that is
|
||||
/// either a type of a decl.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user