From: Matthias Maennich Date: Tue, 21 May 2019 04:39:17 +0000 (+0100) Subject: abg-writer: Refactor write_corpus_group API X-Git-Tag: upstream/1.7~95 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6aeed171c1ae4775b96666f17bb4f82a7ac80ea1;p=platform%2Fupstream%2Flibabigail.git abg-writer: Refactor write_corpus_group API Introduce a new call overload for write_corpus_group that follows the parameter order context, object (i.e. corpus_group), indent. Deprecate all other overloads that were part of the API and mostly forward them to the new overload. That effort is made to ensure write_context is always provided. write_context allows access to all options that influence the output format. * include/abg-writer.h (write_corpus_group): Introduce new overload write_corpus_group(ctxt, corpus_group, indent) and deprecate all others. * src/abg-writer.cc (write_corpus_group): Likewise for the definitions and adjust. * tools/abidw.cc (load_kernel_corpus_group_and_write_abixml): Migrate to new API of write_corpus_group() Signed-off-by: Matthias Maennich --- diff --git a/include/abg-writer.h b/include/abg-writer.h index d93cc69a..45303e42 100644 --- a/include/abg-writer.h +++ b/include/abg-writer.h @@ -102,21 +102,26 @@ write_corpus(const corpus_sptr corpus, const bool annotate = false); bool -write_corpus_group(const corpus_group_sptr& group, - unsigned indent, - write_context& ctxt); +write_corpus_group(write_context& ctx, + const corpus_group_sptr& group, + unsigned indent); -bool -write_corpus_group(const corpus_group_sptr& group, - unsigned indent, - std::ostream& out, - const bool annotate = false); +bool ABG_DEPRECATED +write_corpus_group(const corpus_group_sptr& group, + unsigned indent, + write_context& ctxt); -bool -write_corpus_group(const corpus_group_sptr& group, - unsigned indent, - const string& path, - const bool annotate = false); +bool ABG_DEPRECATED +write_corpus_group(const corpus_group_sptr& group, + unsigned indent, + std::ostream& out, + const bool annotate = false); + +bool ABG_DEPRECATED +write_corpus_group(const corpus_group_sptr& group, + unsigned indent, + const string& path, + const bool annotate = false); }// end namespace xml_writer }// end namespace abigail diff --git a/src/abg-writer.cc b/src/abg-writer.cc index 85f3aebc..8280e234 100644 --- a/src/abg-writer.cc +++ b/src/abg-writer.cc @@ -4204,17 +4204,17 @@ write_corpus(const corpus_sptr corpus, /// Serialize an ABI corpus group to a single native xml document. /// The root note of the resulting XML document is 'abi-corpus-group'. /// +/// @param ctxt the write context to use. +/// /// @param group the corpus group 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_group(const corpus_group_sptr& group, - unsigned indent, - write_context& ctxt) +write_corpus_group(write_context& ctxt, + const corpus_group_sptr& group, + unsigned indent) { if (!group) @@ -4253,6 +4253,27 @@ std::ostream& out = ctxt.get_ostream(); return true; } +/// Serialize an ABI corpus group to a single native xml document. +/// The root note of the resulting XML document is 'abi-corpus-group'. +/// +/// @param group the corpus group to serialize. +/// +/// @param indent the number of white space indentation to use. +/// +/// @param ctxt the write context to use. +/// +/// @deprecated use write_corpus_group(ctxt, corpus_group, indent) +/// +/// @return true upon successful completion, false otherwise. +bool ABG_DEPRECATED +write_corpus_group(const corpus_group_sptr& group, + unsigned indent, + write_context& ctxt) + +{ + return write_corpus_group(ctxt, group, indent); +} + /// Serialize an ABI corpus group to a single native xml document. /// The root note of the resulting XML document is 'abi-corpus-group'. /// @@ -4264,12 +4285,14 @@ std::ostream& out = ctxt.get_ostream(); /// /// @param annotate whether ABIXML output should be annotated. /// +/// @deprecated use write_corpus_group(ctxt, corpus_group, indent) +/// /// @return true upon successful completion, false otherwise. -bool -write_corpus_group(const corpus_group_sptr& group, - unsigned indent, - std::ostream& out, - const bool annotate) +bool ABG_DEPRECATED +write_corpus_group(const corpus_group_sptr& group, + unsigned indent, + std::ostream& out, + const bool annotate) { if (!group) @@ -4278,7 +4301,7 @@ write_corpus_group(const corpus_group_sptr& group, write_context ctxt(group->get_environment(), out); set_annotate(ctxt, annotate); - return write_corpus_group(group, indent, ctxt); + return write_corpus_group(ctxt, group, indent); } /// Serialize an ABI corpus to a single native xml document. The root diff --git a/tools/abidw.cc b/tools/abidw.cc index 45c0b862..d4708860 100644 --- a/tools/abidw.cc +++ b/tools/abidw.cc @@ -570,12 +570,18 @@ load_kernel_corpus_group_and_write_abixml(char* argv[], << opts.out_file_path << "'\n"; return 1; } - exit_code = !xml_writer::write_corpus_group(group, 0, of, - opts.annotate); + const write_context_sptr& ctxt + = create_write_context(group->get_environment(), of); + set_annotate(*ctxt, opts.annotate); + exit_code = !write_corpus_group(*ctxt, group, 0); } else - exit_code = !xml_writer::write_corpus_group(group, 0, cout, - opts.annotate); + { + const write_context_sptr& ctxt + = create_write_context(group->get_environment(), cout); + set_annotate(*ctxt, opts.annotate); + exit_code = !write_corpus_group(*ctxt, group, 0); + } } return exit_code;