const bool annotate = false);
bool
-write_corpus(const corpus_sptr corpus,
- unsigned indent,
- write_context& ctxt);
+write_corpus(write_context& ctxt, const corpus_sptr& corpus, unsigned indent);
-bool
-write_corpus(const corpus_sptr corpus,
- unsigned indent,
- std::ostream& out,
- const bool annotate = false);
+bool ABG_DEPRECATED
+write_corpus(const corpus_sptr& corpus, unsigned indent, write_context& ctxt);
-bool
-write_corpus(const corpus_sptr corpus,
- unsigned indent,
- const string& path,
- const bool annotate = false);
+bool ABG_DEPRECATED
+write_corpus(const corpus_sptr corpus,
+ unsigned indent,
+ std::ostream& out,
+ const bool annotate = false);
+
+bool ABG_DEPRECATED
+write_corpus(const corpus_sptr corpus,
+ unsigned indent,
+ const string& path,
+ const bool annotate = false);
bool
write_corpus_group(const corpus_group_sptr& group,
/// Serialize an ABI corpus to a single native xml document. The root
/// note of the resulting XML document is 'abi-corpus'.
///
+/// @param ctxt the write context to use.
+///
/// @param corpus the corpus to serialize.
///
/// @param indent the number of white space indentation to use.
///
-/// @param ctxt the write context to use.
-///
/// @return true upon successful completion, false otherwise.
bool
-write_corpus(const corpus_sptr corpus,
- unsigned indent,
- write_context& ctxt)
+write_corpus(write_context& ctxt, const corpus_sptr& corpus, unsigned indent)
{
if (!corpus)
return false;
}
/// Serialize an ABI corpus to a single native xml document. The root
-/// note of the resulting XML document is 'abi-corpus'.
+/// node of the resulting XML document is 'abi-corpus'.
+///
+/// @param corpus the corpus to serialize.
+///
+/// @param indent the number of white space indentation to use.
+///
+/// @param ctxt the write context to use.
+///
+/// @deprecated: use write_corpus(ctxt, corpus, indent)
+///
+/// @return true upon successful completion, false otherwise.
+bool ABG_DEPRECATED
+write_corpus(const corpus_sptr& corpus, unsigned indent, write_context& ctxt)
+{
+ return write_corpus(ctxt, corpus, indent);
+}
+
+/// Serialize an ABI corpus to a single native xml document. The root
+/// node of the resulting XML document is 'abi-corpus'.
///
/// @param corpus the corpus to serialize.
///
///
/// @param annotate whether ABIXML output should be annotated.
///
+/// @deprecated: use write_corpus(ctxt, corpus, indent)
+///
/// @return true upon successful completion, false otherwise.
-bool
-write_corpus(const corpus_sptr corpus,
- unsigned indent,
- std::ostream& out,
- const bool annotate)
+bool ABG_DEPRECATED
+write_corpus(const corpus_sptr corpus,
+ unsigned indent,
+ std::ostream& out,
+ const bool annotate)
{
if (!corpus)
return false;
write_context ctxt(corpus->get_environment(), out);
set_annotate(ctxt, annotate);
- return write_corpus(corpus, indent, ctxt);
+ return write_corpus(ctxt, corpus, indent);
}
/// Serialize an ABI corpus group to a single native xml document.
group->get_corpora().begin();
c != group->get_corpora().end();
++c)
- write_corpus(*c, get_indent_to_level(ctxt, indent, 1), ctxt);
+ write_corpus(ctxt, *c, get_indent_to_level(ctxt, indent, 1));
do_indent_to_level(ctxt, indent, 0);
out << "</abi-corpus-group>\n";
///
/// @param annotate whether ABIXML output should be annotated.
///
+/// @deprecated: use write_corpus(ctxt, corpus, indent)
+///
/// @return true upon successful completion, false otherwise.
-bool
-write_corpus(const corpus_sptr corpus,
- unsigned indent,
- const string& path,
- const bool annotate)
+bool ABG_DEPRECATED
+write_corpus(const corpus_sptr corpus,
+ unsigned indent,
+ const string& path,
+ const bool annotate)
{
bool result = true;
return false;
}
- if (!write_corpus(corpus, indent, of, annotate))
+ const write_context_sptr& ctxt
+ = create_write_context(corpus->get_environment(), of);
+ ctxt->set_annotate(annotate);
+ if (!write_corpus(*ctxt, corpus, indent))
{
cerr << "failed to access " << path << "\n";
result = false;
using abigail::dwarf_reader::read_context;
using abigail::dwarf_reader::read_context_sptr;
using abigail::dwarf_reader::create_read_context;
+using abigail::xml_writer::create_write_context;
+using abigail::xml_writer::write_context_sptr;
+using abigail::xml_writer::write_corpus;
/// This is an aggregate that specifies where a test shall get its
/// input from, and where it shall write its ouput to.
is_ok = false;
return;
}
- is_ok =
- abigail::xml_writer::write_corpus(corp, /*indent=*/0, of);
+ const write_context_sptr write_ctxt
+ = create_write_context(corp->get_environment(), of);
+ is_ok = write_corpus(*write_ctxt, corp, /*indent=*/0);
of.close();
string abidw = string(get_build_dir()) + "/tools/abidw";
using abigail::comparison::compute_diff;
using abigail::comparison::diff_context_sptr;
using abigail::comparison::diff_context;
+using abigail::xml_writer::create_write_context;
+using abigail::xml_writer::write_context_sptr;
using abigail::xml_writer::write_corpus;
using abigail::xml_reader::read_corpus_from_native_xml_file;
using abigail::dwarf_reader::read_context;
// it back, and compare the ABI of what we've read back
// against the ABI of the input ELF file.
temp_file_sptr tmp_file = temp_file::create();
- write_corpus(corp, 0, tmp_file->get_stream(), opts.annotate);
+ const write_context_sptr& write_ctxt = create_write_context(
+ corp->get_environment(), tmp_file->get_stream());
+ set_annotate(*write_ctxt, opts.annotate);
+ write_corpus(*write_ctxt, corp, 0);
tmp_file->get_stream().flush();
corpus_sptr corp2 =
read_corpus_from_native_xml_file(tmp_file->get_path(),
<< opts.out_file_path << "'\n";
return 1;
}
- abigail::xml_writer::write_context_sptr write_ctxt =
- abigail::xml_writer::create_write_context(corp->get_environment(),
- of);
- abigail::xml_writer::set_show_locs(*write_ctxt, opts.show_locs);
- abigail::xml_writer::set_annotate(*write_ctxt, opts.annotate);
- abigail::xml_writer::write_corpus(corp, 0, *write_ctxt);
+ const write_context_sptr& write_ctxt
+ = create_write_context(corp->get_environment(), of);
+ set_show_locs(*write_ctxt, opts.show_locs);
+ set_annotate(*write_ctxt, opts.annotate);
+ write_corpus(*write_ctxt, corp, 0);
of.close();
return 0;
}
else
{
- abigail::xml_writer::write_context_sptr write_ctxt =
- abigail::xml_writer::create_write_context(corp->get_environment(),
- cout);
- abigail::xml_writer::set_show_locs(*write_ctxt, opts.show_locs);
- abigail::xml_writer::set_annotate(*write_ctxt, opts.annotate);
- exit_code = !abigail::xml_writer::write_corpus(corp, 0, *write_ctxt);
+ write_context_sptr write_ctxt
+ = create_write_context(corp->get_environment(), cout);
+ set_show_locs(*write_ctxt, opts.show_locs);
+ set_annotate(*write_ctxt, opts.annotate);
+ exit_code = !write_corpus(*write_ctxt, corp, 0);
}
}
set_suppressions(*ctxt, opts);
corpus_sptr corp = abigail::xml_reader::read_corpus_from_input(*ctxt);
if (!opts.noout)
- write_corpus(corp, /*indent=*/0, cout);
+ {
+ const write_context_sptr& ctxt
+ = create_write_context(corp->get_environment(), cout);
+ write_corpus(*ctxt, corp, /*indent=*/0);
+ }
return 0;
}
}
return 1;
}
- std::iostream& of = tmp_file->get_stream();
- bool r = true;
+ std::ostream& of = opts.diff ? tmp_file->get_stream() : cout;
+ const abigail::ir::environment* env
+ = tu ? tu->get_environment() : corp->get_environment();
+ const write_context_sptr ctxt = create_write_context(env, of);
+
+ bool is_ok = true;
if (tu)
{
- if (opts.diff)
- {
- const write_context_sptr& ctxt = create_write_context(
- tu->get_environment(), tmp_file->get_stream());
- r = write_translation_unit(*ctxt, *tu, 0);
- }
- if (!opts.noout && !opts.diff)
- {
- const write_context_sptr& ctxt
- = create_write_context(tu->get_environment(), cout);
- r &= write_translation_unit(*ctxt, *tu, 0);
- }
+ if (!opts.noout)
+ is_ok = write_translation_unit(*ctxt, *tu, 0);
}
else
{
- r = true;
- if (type == abigail::tools_utils::FILE_TYPE_XML_CORPUS)
+ if (type == abigail::tools_utils::FILE_TYPE_XML_CORPUS
+ || type == abigail::tools_utils::FILE_TYPE_ELF)
{
- if (opts.diff)
- r = write_corpus(corp, /*indent=*/0, of);
-
- if (!opts.noout && !opts.diff)
- r &= write_corpus(corp, /*indent=*/0, cout);
+ if (!opts.noout)
+ is_ok = write_corpus(*ctxt, corp, 0);
}
else if (type == abigail::tools_utils::FILE_TYPE_ZIP_CORPUS)
{
#ifdef WITH_ZIP_ARCHIVE
if (!opts.noout)
- r = write_corpus_to_archive(*corp, tmp_file->get_path());
+ is_ok = write_corpus_to_archive(*corp, tmp_file->get_path());
#endif //WITH_ZIP_ARCHIVE
}
- else if (type == abigail::tools_utils::FILE_TYPE_ELF)
- {
- if (!opts.noout)
- r = write_corpus(corp, /*indent=*/0, cout);
- }
}
- bool is_ok = r;
-
if (!is_ok)
{
string output =