* src/abg-ir.h (class reference_type_def, struct pointer_type_def)
(struct reference_type_def): New declaration.
(type_base_hash::operator(), type_decl_hash::operator())
(scope_type_decl_hash::operator())
(qualified_type_def_hash::operator()): Include the typeid name in
the hash.
* src/abg-ir.cc (reference_type_def::reference_type_def)
(reference_type_def::operator==)
(reference_type_def::get_pointed_to_type)
(reference_type_def::is_lvalue)
(reference_type_def::~reference_type_def): New definitions.
(dynamic_type_hash::operator): Hash pointer_type_def and
reference_type_def instances.
* src/abg-reader.cc (read_context::finish_decl_creation)
(read_context::finish_type_decl_creation)
(handle_reference_type_def): New definitions.
(read_file): Handle "reference-type-def" elements.
(handle_type_decl, handle_namespace_decl)
(handle_qualified_type_decl, handle_pointer_type_def): Use the new
read_context::finish_type_decl_creation or
read_context::finish_decl_creation.
* src/abg-writer.cc (write_reference_type_def): New definition.
(write_decl): Supporting writing a pointer to an instance of
reference_type_def.
* tests/data/test-read-write/test5.xml: New test file.
* tests/test-read-write.cc: (De)Serialize it.
* tests/Makefile.am: Add it to the build system.
* src/abg-ir.h (location::{operator==, operator<})
(decl_base::operator==, scope_decl::operator==)
(type_base::operator==, struct type_shared_ptr_equal)
(type_decl::operator==, scope_type::operator==)
(qualified_type_def::operator==, class pointer_type_def): New
declarations..
* src/abg-ir.cc (decl_base::operator==, scope_decl::operator==)
(type_base::operator==, type_decl::operator==)
(scope_type_decl::operator==, namespace_decl::operator==)
(qualified_type_def::operator==)
(pointer_type_def::pointer_type_def, pointer_type_def::operator==)
(pointer_type_def::get_pointed_to_type)
(pointer_type_def::~pointer_type_def): New definitions.
* src/abg-reader.cc (handle_pointer_type_def): New definition.
(read_input): Handle pointer-type-def
elements.
* src/abg-writer.cc (type_shared_ptr_map): Make this map use the
use type_shared_ptr_equal predicate.
(write_pointer_type_def): New definition.
(write_decl): Improve logic. Support serializing a pointer to
pointer_type_def.
* tests/data/test-read-write/test4.xml: New test input file.
* tests/Makefile.am: Add tests/data/test-read-write/test4.xml to
the build system.
* tests/test-read-write.cc: (De)serialize the new test file.
* src/abg-ir.h (struct type_base_hash, struct dynamic_type_hash)
(struct type_shared_ptr_hash, struct scope_type_decl_hash, class
qualified_type_def, struct qualified_type_def_hash): New.
(decl_base_hash::operator()): Constify. Don't crash if the scope
of the decl we are hashing is null.
(class type_decl): Add comment at the end.
(type_decl_hash::operator()): Constify. Reuse the new
type_base_hash hasher.
(class namespace_decl): Add comment.
* src/abg-ir.cc (qualified_type_def::qualified_type_def)
(qualified_type_def::~qualified_type_def)
(qualified_type_def::get_cv_quals)
(qualified_type_def::set_cv_quals)
(qualified_type_def::get_underlying_type)
(dynamic_type_hash::operator()): New function definitions.
* src/abg-reader.cc (handle_qualified_type_decl): New.
(read_file): Handle elements named "qualified-type-def".
(read::context::add_type_decl): Assert that
the type being associated to the unique ID is non-null.
(handle_type_decl): Fix this in the process; don't crash if some
attributes are not present. Associate the unique id present in
the xml document with the type we just parsed.
(handle_namespace_decl): Add some comments. Don't crash if the
name attribute is not present.
* src/abg-writer.cc (write_context::get_id_for_type)
(write_context::m_type_id_map, write_decl_location)
(write_qualified_type_def): New.
(write_decl): Handle instances of qualified_type_def.
(write_type_decl): Use the new write_decl_location and
write_context::get_id_for_type.
* tests/data/test-read-write/test0.xml: Update id format since we
are now using the new write_context::get_id_for_type to generate
it.
* tests/data/test-read-write/test1.xml: Likewise.
* tests/data/test-read-write/test2.xml: Likewise.
* tests/data/test-read-write/test3.xml: New test.
* tests/test-read-write.cc: Test De-serializing
tests/data/test-read-write/test3.xml and serializing it back.
Also don't bail out if we fail on one input.
* tests/Makefile.am: Add tests/data/test-read-write/test3.xml to the
distribution.
* src/abg-reader.cc (read_context::get_cur_scope): Remove useless
const overload. Don't make this rely on m_cur_scope. Rather, use
the path to the current decl (from the root element) to compute
the cur scope.
(read_context::m_cur_scope, read_context::set_cur_scope): Remove
these.
(update_read_context): Re-think logic.
* tests/data/test-read-write/test2.xml: Add new test input.
* tests/Makefile.am: Add data/test-read-write/test2.xml to the
distribution.
* tests/test-read-write.cc: Add data/test-read-write/test2.xml to
the harness.
* abg-ir.{h,cc} (decl_base::decl_base, scope_decl::scope_decl)
(type_decl::type_decl, namespace_decl::namespace_decl): Do not
append a decl to its context from within its constructor. It's
better doing that in a function that takes shared_ptrs to decl and
context. That way we avoid memory management havoc.
(decl_base::set_scope): New private function.
(scope_decl::add_member_decl): Make this private.
(add_decl_to_scope): New function, friend of decl_base and
scope_decl.
* abg-reader.cc (read_context::get_cur_scope): Add a non-const
overload.
(handle_type_decl, handle_namespace_decl): Use add_decl_to_scope.
Adjust to new type_decl and namespace_decl constructor signature.
* src/abg-writer.cc (write_type): Emit 'id', not 'xml:id'.
(write_namespace_decl): Emit "namespace-decl", not
"namespace-decl-name", as the name of namespace element.
* tests/Makefile.am (test0.xml): Rename input0.xml into this.
(test1.xml): New test input.
* tests/data/test-read-write/test0.xml: Update to use 'id' as id
attribute, rather than xml:id.
* tests/data/test-read-write/test1.xml: New test.
* test-read-write.cc (struct InOutSpec): New
(main): Reorganize to give a list of input files to read and to
write to an output file, have the test read the input files, write
them, and diff the two.
* src/abg-ir.cc (namespace_decl::~namespace_decl): Add this
missing virtual constructor definition.
* src/abg-reader.cc (read_context::{get_cur_decl,pop_decl}):
Return a null pointer when the decls stack is empty.
(update_read_context): Don't try to de-reference a NULL cur_decl.
(read_input): Don't try to poke at file validity here. What was I
thinking. Really test for advance_cursor to return 1, expressing
success.
* src/abg-reader.h (read_file): Fix style.
* Makefile.am: Add tests sub-directory.
* configure.ac: Build with debugging-friendly options if the
ABIGAIL_DEBUG env variable is set. Generate tests/Makefile.
* tests/Makefile.am: New file.
* tests/test-read-write.cc: Likewise.
* tests/test-utils.{h,cc}: Likewise.
* tests/data/test-read-write/input0.xml: Likewise.