Commit Graph

3 Commits

Author SHA1 Message Date
Dodji Seketeli
2c9fb3e70d Support new 'abi-corpus' native XML format (.abi)
* include/abg-reader.h (read_corpus_from_native_xml)
	(read_corpus_from_native_xml_file): Declare new entry points.
	* include/abg-writer.h (write_corpus_to_native_xml)
	(write_corpus_to_native_xml_file): Likewise.
	* src/abg-reader.cc (read_translation_unit_from_input): Renamed
	read_input into this.  Support new 'path' attribute for
	'abi-instr' XML element.
	(read_corpus_from_input): New static function.
	(read_translation_unit_from_file)
	(read_translation_unit_from_buffer)
	(read_translation_unit_from_istream): Update wrt read_input ->
	read_translation_unit_from_input.
	(read_corpus_from_native_xml, read_corpus_from_native_xml)
	(read_corpus_from_native_xml_file): Define new entry points.
	* src/abg-writer.cc (write_translation_unit): Write 'path'
	attribute into the 'abi-instr' xml element.
	(write_corpus_to_native_xml, write_corpus_to_native_xml_file):
	Define new entry points.
	* tools/abg-tools-utils.h (file_type::{FILE_TYPE_XML_CORPUS,
	FILE_TYPE_ZIP_CORPUS}): New enumerators.
	* tools/abg-tools-utils.cc (guess_file_type): Support detection of
	the new xml file format containing a document root 'abi-corpus'
	root element.
	* tools/bidiff.cc (main): Support diffing xml corpus-es and zip
	corpus-es.
	* tools/bidw.cc (main): Recognize elf files before reading them.
	* tools/bilint.cc (main): Support reading xml/zip corpus-es too.
	* tests/data/test-read-write/test[0-23].xml: Update 'path'
	attribute.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-07 14:12:26 +01:00
Dodji Seketeli
57d8b7da41 Support qualified types & Misc ancillary fixes
* 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.
2013-03-27 23:59:16 +01:00
Dodji Seketeli
4ef7b34387 Debug read-write of a type-decl in a namespace-decl
* 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.
2013-03-25 16:56:00 +01:00