diff mbox series

[v3,02/21] Move libxml bits out of abg-sptr-utils.h.

Message ID 20200424092132.150547-3-gprocida@google.com
State Superseded
Headers show
Series Simplify regex and suppression parsing. | expand

Commit Message

Giuliano Procida April 24, 2020, 9:21 a.m. UTC
The header file abg-sptr-utils.h contains generic things relating to
shared pointers. It also contains shared pointer typedefs (in the
sptr_utils namespace) and template specialisations for XML types.

The last of these more naturally belong in abg-libxml-utils.h (and in
the xml namespace). This patch moves them.

There are no behavioural changes.

	* include/abg-sptr-utils.h: Remove reader_sptr and
	xml_char_sptr typedefs, from namespace
	sptr_utils. (build_sptr): Remove corresponding template
	function specialisations for these types.
	* include/abg-libxml-utils.h: Add reader_sptr and
	xml_char_sptr typedefs, to namespace xml. (build_sptr): Add
	corresponding template function specialisations for these
	types.

Signed-off-by: Giuliano Procida <gprocida@google.com>
---
 include/abg-libxml-utils.h | 21 +++++++++++++++++++--
 include/abg-sptr-utils.h   | 17 +----------------
 2 files changed, 20 insertions(+), 18 deletions(-)

Comments

Matthias Maennich April 27, 2020, 10:53 a.m. UTC | #1
On Fri, Apr 24, 2020 at 10:21:13AM +0100, Giuliano Procida wrote:
>The header file abg-sptr-utils.h contains generic things relating to
>shared pointers. It also contains shared pointer typedefs (in the
>sptr_utils namespace) and template specialisations for XML types.
>
>The last of these more naturally belong in abg-libxml-utils.h (and in
>the xml namespace). This patch moves them.
>
>There are no behavioural changes.
>
>	* include/abg-sptr-utils.h: Remove reader_sptr and
>	xml_char_sptr typedefs, from namespace
>	sptr_utils. (build_sptr): Remove corresponding template
>	function specialisations for these types.
>	* include/abg-libxml-utils.h: Add reader_sptr and
>	xml_char_sptr typedefs, to namespace xml. (build_sptr): Add
>	corresponding template function specialisations for these
>	types.
>
>Signed-off-by: Giuliano Procida <gprocida@google.com>

Reviewed-by: Matthias Maennich <maennich@google.com>

Cheers,
Matthias

>---
> include/abg-libxml-utils.h | 21 +++++++++++++++++++--
> include/abg-sptr-utils.h   | 17 +----------------
> 2 files changed, 20 insertions(+), 18 deletions(-)
>
>diff --git a/include/abg-libxml-utils.h b/include/abg-libxml-utils.h
>index 6331bde5..1e46d950 100644
>--- a/include/abg-libxml-utils.h
>+++ b/include/abg-libxml-utils.h
>@@ -23,7 +23,10 @@
> #ifndef __ABG_LIBXML_UTILS_H__
> #define __ABG_LIBXML_UTILS_H__
>
>+#include <libxml/xmlreader.h>
>+
> #include <istream>
>+
> #include "abg-sptr-utils.h"
> #include "abg-cxx-compat.h"
>
>@@ -36,8 +39,12 @@ namespace xml
>
> using sptr_utils::build_sptr;
> using abg_compat::shared_ptr;
>-using sptr_utils::reader_sptr;
>-using sptr_utils::xml_char_sptr;
>+
>+/// A convenience typedef for a shared pointer of xmlTextReader.
>+typedef shared_ptr<xmlTextReader> reader_sptr;
>+
>+/// A convenience typedef for a shared pointer of xmlChar.
>+typedef shared_ptr<xmlChar> xml_char_sptr;
>
> /// This functor is used to instantiate a shared_ptr for the
> /// xmlTextReader.
>@@ -121,5 +128,15 @@ std::string
> unescape_xml_comment(const std::string& str);
>
> }//end namespace xml
>+
>+/// Specialization of sptr_utils::build_sptr for xmlTextReader
>+template<>
>+xml::reader_sptr
>+sptr_utils::build_sptr<xmlTextReader>(xmlTextReader *p);
>+
>+/// Specialization of build_str for xmlChar.
>+template<>
>+xml::xml_char_sptr sptr_utils::build_sptr<xmlChar>(xmlChar *p);
>+
> }//end namespace abigail
> #endif //__ABG_LIBXML_UTILS_H__
>diff --git a/include/abg-sptr-utils.h b/include/abg-sptr-utils.h
>index 9737fe5f..2a12707b 100644
>--- a/include/abg-sptr-utils.h
>+++ b/include/abg-sptr-utils.h
>@@ -26,7 +26,7 @@
> #define __ABG_SPTR_UTILS_H__
>
> #include <regex.h>
>-#include <libxml/xmlreader.h>
>+
> #include "abg-cxx-compat.h"
>
> namespace abigail
>@@ -63,21 +63,6 @@ template<class T>
> shared_ptr<T>
> build_sptr();
>
>-/// A convenience typedef for a shared pointer of xmlTextReader.
>-typedef shared_ptr<xmlTextReader> reader_sptr;
>-
>-/// Specialization of sptr_utils::build_sptr for xmlTextReader
>-template<>
>-reader_sptr
>-build_sptr<xmlTextReader>(xmlTextReader *p);
>-
>-/// A convenience typedef for a shared pointer of xmlChar.
>-typedef shared_ptr<xmlChar> xml_char_sptr;
>-
>-/// Specialization of build_str for xmlChar.
>-template<>
>-xml_char_sptr build_sptr<xmlChar>(xmlChar *p);
>-
> /// A deleter for shared pointers that ... doesn't delete the object
> /// managed by the shared pointer.
> struct noop_deleter
>-- 
>2.26.2.303.gf8c07b1a785-goog
>
Dodji Seketeli April 29, 2020, 2:30 p.m. UTC | #2
Giuliano Procida <gprocida@google.com> a ?crit:

> The header file abg-sptr-utils.h contains generic things relating to
> shared pointers. It also contains shared pointer typedefs (in the
> sptr_utils namespace) and template specialisations for XML types.
>
> The last of these more naturally belong in abg-libxml-utils.h (and in
> the xml namespace). This patch moves them.
>
> There are no behavioural changes.
>
> 	* include/abg-sptr-utils.h: Remove reader_sptr and
> 	xml_char_sptr typedefs, from namespace
> 	sptr_utils. (build_sptr): Remove corresponding template
> 	function specialisations for these types.
> 	* include/abg-libxml-utils.h: Add reader_sptr and
> 	xml_char_sptr typedefs, to namespace xml. (build_sptr): Add
> 	corresponding template function specialisations for these
> 	types.

This looks good to me, and should go in after its previous one in the
series.

Thanks!

Cheers,
Dodji Seketeli May 4, 2020, 9:20 a.m. UTC | #3
Giuliano Procida <gprocida@google.com> a ?crit:

> The header file abg-sptr-utils.h contains generic things relating to
> shared pointers. It also contains shared pointer typedefs (in the
> sptr_utils namespace) and template specialisations for XML types.
>
> The last of these more naturally belong in abg-libxml-utils.h (and in
> the xml namespace). This patch moves them.
>
> There are no behavioural changes.
>
> 	* include/abg-sptr-utils.h: Remove reader_sptr and
> 	xml_char_sptr typedefs, from namespace
> 	sptr_utils. (build_sptr): Remove corresponding template
> 	function specialisations for these types.
> 	* include/abg-libxml-utils.h: Add reader_sptr and
> 	xml_char_sptr typedefs, to namespace xml. (build_sptr): Add
> 	corresponding template function specialisations for these
> 	types.

Applied to master, thanks!

Cheers,
diff mbox series

Patch

diff --git a/include/abg-libxml-utils.h b/include/abg-libxml-utils.h
index 6331bde5..1e46d950 100644
--- a/include/abg-libxml-utils.h
+++ b/include/abg-libxml-utils.h
@@ -23,7 +23,10 @@ 
 #ifndef __ABG_LIBXML_UTILS_H__
 #define __ABG_LIBXML_UTILS_H__
 
+#include <libxml/xmlreader.h>
+
 #include <istream>
+
 #include "abg-sptr-utils.h"
 #include "abg-cxx-compat.h"
 
@@ -36,8 +39,12 @@  namespace xml
 
 using sptr_utils::build_sptr;
 using abg_compat::shared_ptr;
-using sptr_utils::reader_sptr;
-using sptr_utils::xml_char_sptr;
+
+/// A convenience typedef for a shared pointer of xmlTextReader.
+typedef shared_ptr<xmlTextReader> reader_sptr;
+
+/// A convenience typedef for a shared pointer of xmlChar.
+typedef shared_ptr<xmlChar> xml_char_sptr;
 
 /// This functor is used to instantiate a shared_ptr for the
 /// xmlTextReader.
@@ -121,5 +128,15 @@  std::string
 unescape_xml_comment(const std::string& str);
 
 }//end namespace xml
+
+/// Specialization of sptr_utils::build_sptr for xmlTextReader
+template<>
+xml::reader_sptr
+sptr_utils::build_sptr<xmlTextReader>(xmlTextReader *p);
+
+/// Specialization of build_str for xmlChar.
+template<>
+xml::xml_char_sptr sptr_utils::build_sptr<xmlChar>(xmlChar *p);
+
 }//end namespace abigail
 #endif //__ABG_LIBXML_UTILS_H__
diff --git a/include/abg-sptr-utils.h b/include/abg-sptr-utils.h
index 9737fe5f..2a12707b 100644
--- a/include/abg-sptr-utils.h
+++ b/include/abg-sptr-utils.h
@@ -26,7 +26,7 @@ 
 #define __ABG_SPTR_UTILS_H__
 
 #include <regex.h>
-#include <libxml/xmlreader.h>
+
 #include "abg-cxx-compat.h"
 
 namespace abigail
@@ -63,21 +63,6 @@  template<class T>
 shared_ptr<T>
 build_sptr();
 
-/// A convenience typedef for a shared pointer of xmlTextReader.
-typedef shared_ptr<xmlTextReader> reader_sptr;
-
-/// Specialization of sptr_utils::build_sptr for xmlTextReader
-template<>
-reader_sptr
-build_sptr<xmlTextReader>(xmlTextReader *p);
-
-/// A convenience typedef for a shared pointer of xmlChar.
-typedef shared_ptr<xmlChar> xml_char_sptr;
-
-/// Specialization of build_str for xmlChar.
-template<>
-xml_char_sptr build_sptr<xmlChar>(xmlChar *p);
-
 /// A deleter for shared pointers that ... doesn't delete the object
 /// managed by the shared pointer.
 struct noop_deleter