Commit Graph

5 Commits

Author SHA1 Message Date
Dodji Seketeli
165434a9d7 Change ir node visitor interface work on pointer to nodes
* include/abg-ir.h (ir_traversable_base): New type to be the base
	of IR nodes that are to be traversed.  Extends traversable_base.
	Its ir_traversable_base::traversable() method takes an
	ir_node_visitor&.
	(ir_node_visitor::visit): Change these virtual overloads to take
	pointers to IR nodes, rather than references.  This will be useful
	to e.g, store these IR nodes in containers on the side for some
	algorithms to work.  That is going to be useful later to,
	e.g. build symbol tables on the side, using the visitor interface.
	(class decl_base): Make this inherit ir_traversable_base.
	* src/abg-ir.cc (*::traverse): Adjust comments and the call the
	ir_node_visitor::visit call.  Use the ir_traversable_base type
	rather than traversable_base.
	(ir_traversable_base::traverse): Define.
	(ir_node_visitor::visit): Change these overloads to take pointers
	rather than reference to ir nodes.
	* tests/test-walker.cc (name_printing_visitor::visit): Adjust to
	take pointers rather than references.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-23 13:25:32 +01:00
Dodji Seketeli
6258b5f824 Prepare serialization API for multiple backends
* include/abg-reader.h: New file with abigail::xml_reader APIs.
	* include/abg-writer.h: New file with abigail::xml_writer APIs.
	* include/Makefile.am: Add the new files above to the source
	distribution.
	* src/abg-reader.cc: Update top-file comments.
	(namespace xml_reader): Rename namespace
	reader into this.
	(read_to_translation_unit, read_corpus_from_archive): New static
	functions.
	(read_translation_unit_from_file)
	(read_translation_unit_from_file, read_corpus_from_file): New
	entry points.
	(struct array_deleter): New functor.
	(translation_unit::read): Remove this.
	* src/abg-writer.cc: Update top file comments.
	(namespace xml_writer): Rename namespace
	writer into this.
	(struct archive_write_ctxt): New internal type.
	(create_archive_write_context, write_translation_unit_to_archive)
	(write_translation_unit, write_corpus_to_archive): New low level
	static functions overloads.
	(write_corpus_to_archive, write_translation_unit): Public higher
	level overloads.
	(translation_unit::write): Remove.
	(dump): Update for new xml_writer namespace.
	* include/abg-ir.h (translation_unit::{read, write}): Remove these
	serialization methods.
	* include/abg-corpus.h (corpus_sptr): New convenience typedef.
	(corpus::{read, write}): Remove these methods.
	* src/abg-corpus.cc (corpus::{read, write})
	(corpus::impl::{serialized_tus, archive}): Remove these members.
	(corpus::impl::{get_archive, close_archive, write_tu_to_archive,
	read_to_translation_unit}): Remove these methods.
	* tests/test-bidiff.cc (main): Update for usage of the new
	xml_reader API.
	* tests/test-read-write.cc (main): Likewise. Update for the usage
	of the new xml_writer API, too.
	* tests/test-walker.cc (main): Update for the usage of the new
	xml_reader API.
	* tests/test-write-read-archive.cc (main): Likewise.  And for the
	xml_writer API, too.
	* tools/biar.cc (add_tus_to_archive, extract_tus_from_archive): Likewise.
	* tools/bidiff.cc (main): Likewise, for xml_reader APIs.
	* tools/bilint.cc (main): Likewise, for xml_writer APIs, too.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-04 20:26:38 +01:00
Benjamin Kosnik
9c7f025ae9 Simplify interface for serializing/deserializing translation_units.
2013-08-06  Benjamin Kosnik  <bkoz@redhat.com>

	* include/abg-ir.h (translation_unit::read): New member function.
	(translation_unit::write): Same.
	* src/abg-reader.cc (translation_unit::read): Define.
	* src/abg-writer.cc (translation_unit::write): Define.

	* include/abg-reader.h: Remove.
	* include/abg-writer.h: Remove.
	* include/Makefile.am (headers): Same.
	* include/Makefile.in: Regenerate.
2013-08-14 15:07:18 +02:00
Benjamin Kosnik
32ce30a23c First pass clean reading API.
* include/abg-reader.h (read_file): Remove extraneous file parameter.
	* src/abg-reader.cc: Same.
	* tests/test-read-write.cc: Adjust.
2013-08-14 15:07:18 +02:00
Dodji Seketeli
95ec67b143 Implement a translation unit traversal API
* include/libabigail/abg-ir.h (struct ir_node_visitor, struct
	traversable): New interfaces.
	(translation_unit, scope_decl, type_decl, qualified_type_def)
	(pointer_type_def, reference_type_def, enum_type_decl)
	(typedef_decl, var_decl, function_decl, data_member)
	(member_function, member_function_template)
	(member_class_template): Implement the traversable interface,
	overload the traversable::traverse pure virtual function.
	* src/abg-ir.cc ({translation_unit, scope_decl, type_decl,
	namespace_decl, qualified_type_def, pointer_type_def,
	reference_type_def, enum_type_decl, typedef_decl, var_decl,
	function_decl, class_decl::member_function, class_decl,
	class_decl::data_member, class_decl::member_function_template,
	class_decl::member_class_template, function_template_decl,
	class_template_decl, }::traverse): Implement traversal.
	(ir_node_visitor::visit): New method, overloaded for the types
	above, which implement the traversable interface.
	* tests/test-walker.cc: New test case program to showcase how to
	use the new traversal API.
	* tests/makefile.am: Add test-walker.cc to the build system.
2013-07-23 23:13:56 +02:00