Re: [PATCH] bug 733085 - remove tr1



Hello,

Hubert Figuière <hub figuiere net> a écrit:

The attached patch remove tr1 since we require C++11.

Thanks.  I have added a more thorough ChangeLog part to it and pushed it
to master.

Thanks again!

Below is the final patch that I pushed,

Cheers,

commit bd59adfb0821461b829740d4a8d1e7c5ea895cb5
Author: Hubert Figuière <hub figuiere net>
Date:   Wed Nov 2 16:34:34 2016 +0100

    Bug 733085 - Remove tr1 since we require C++11
    
    Now that we are using c++11 we can throw tr1 behind us.  We can also
    throw many things from boost.  Yay.
    
            * configure.ac: remove detection of tr1/unordered_map,
            boost/tr1/unordered_map.hpp and tr1/tuple boost/tr1/tuple.hpp.
            * src/common/nmv-log-stream.cc: Include unordered_map directly
            rather than the one from tr1 or unordered_map.
            (__gnu_cxx::hash<std::string>): Remove this string hashing functor
            that is now useless.
            (typedef DomainMap): Adjust.
            * src/dbgengine/nmv-dbg-common.h: Include memory directly rather
            than the one from tr1 or unordered_map.
            (VarChange::m_priv): Adjust the
            shared_ptr type of this data member.
            (typedef VarChangePtr): Adjust.
            * src/langs/nmv-cpp-ast-utils.cc (get_declarator_id_as_string):
            Adjust.
            * src/langs/nmv-cpp-ast.h: Include c++11 memory rather than the
            one from tr1 or unordered_map.  Use std::shared_ptr rather than
            std::tr1::shared_ptr.
            * src/langs/nmv-cpp-parser.cc (Parser::parse_decl_specifier_seq):
            Adjust.
            * src/langs/nmv-cpp-parser.h: Include memory directly rather than
            the one from tr1 or boost.  Use std::shared_ptr rather
            than std::tr1::shared_ptr.
            * src/uicommon/nmv-terminal.cc: Include c++11 tuple rather than
            the one from tr1 or boost.
            (typedef TerminalPrivDataTuple): Adjust.
            (on_button_press_signal): Adjust.
    
    Signed-off-by: Dodji Seketeli <dodji seketeli org>

diff --git a/configure.ac b/configure.ac
index 86f7c97..cb1314c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -274,11 +274,6 @@ dnl detect if c++11 is required, because of glibmm-24 >= 2.46
 PKG_CHECK_EXISTS([glibmm-2.4 >= 2.46],
                  [CXX11_IS_REQUIRED=yes],
                 [CXX11_IS_REQUIRED=no])
-                
-dnl Check for tr1 headers
-AC_CHECK_HEADERS([tr1/unordered_map boost/tr1/unordered_map.hpp])
-AC_CHECK_HEADERS([tr1/memory boost/tr1/memory.hpp])
-AC_CHECK_HEADERS([tr1/tuple boost/tr1/tuple.hpp])
 
 dnl Check for pty.h and its alternatives
 dnl https://www.gnu.org/software/gnulib/manual/html_node/pty_002eh.html
diff --git a/src/common/nmv-log-stream.cc b/src/common/nmv-log-stream.cc
index dee70ba..ce51d7b 100644
--- a/src/common/nmv-log-stream.cc
+++ b/src/common/nmv-log-stream.cc
@@ -43,34 +43,14 @@
 #include "nmv-date-utils.h"
 #include "nmv-safe-ptr-utils.h"
 
-#if defined(HAVE_TR1_UNORDERED_MAP)
-#include <tr1/unordered_map>
-#elif defined(HAVE_BOOST_TR1_UNORDERED_MAP_HPP)
-#include <boost/tr1/unordered_map.hpp>
-#else
-#include <ext/hash_map>
-
-namespace __gnu_cxx {
-    template<>
-    struct hash<std::string> {
-        size_t operator() (const std::string& s) const
-        {
-            return hash<const char*>() (s.c_str ());
-        }
-    };
-}
-#endif
+#include <unordered_map>
 
 namespace nemiver {
 namespace common {
 
 using namespace std;
 
-#if defined(HAVE_TR1_UNORDERED_MAP) || defined(HAVE_BOOST_TR1_UNORDERED_MAP_HPP)
-typedef std::tr1::unordered_map<std::string, bool> DomainMap;
-#else
-typedef __gnu_cxx::hash_map<std::string, bool> DomainMap;
-#endif
+typedef std::unordered_map<std::string, bool> DomainMap;
 
 static enum LogStream::StreamType s_stream_type = LogStream::COUT_STREAM;
 static enum LogStream::LogLevel s_level_filter = LogStream::LOG_LEVEL_NORMAL;
diff --git a/src/dbgengine/nmv-dbg-common.h b/src/dbgengine/nmv-dbg-common.h
index 0edac7c..13b663b 100644
--- a/src/dbgengine/nmv-dbg-common.h
+++ b/src/dbgengine/nmv-dbg-common.h
@@ -27,11 +27,7 @@
 #ifndef __NMV_DBG_COMMON_H_H__
 #define __NMV_DBG_COMMON_H_H__
 #include "nmv-i-debugger.h"
-#if defined(HAVE_TR1_MEMORY)
-#include <tr1/memory>
-#elif defined(HAVE_BOOST_TR1_MEMORY_HPP)
-#include <boost/tr1/memory.hpp>
-#endif
+#include <memory>
 
 NEMIVER_BEGIN_NAMESPACE (nemiver)
 
@@ -41,7 +37,7 @@ NEMIVER_BEGIN_NAMESPACE (nemiver)
 /// of a variable value.
 class VarChange {
     struct Priv;
-    std::tr1::shared_ptr<Priv> m_priv;
+    std::shared_ptr<Priv> m_priv;
 
 public:
     VarChange ();
@@ -73,7 +69,7 @@ public:
     void apply_to_variable (IDebugger::VariableSafePtr a_var,
                            std::list<IDebugger::VariableSafePtr> &a_changed_vars);
 };
-typedef std::tr1::shared_ptr<VarChange> VarChangePtr;
+typedef std::shared_ptr<VarChange> VarChangePtr;
 
 /// Update variable a_to with new bits from a_from.  Note that only
 /// things that can reasonably change are updated here.
diff --git a/src/langs/nmv-cpp-ast-utils.cc b/src/langs/nmv-cpp-ast-utils.cc
index 4c429ff..c7cc7c6 100644
--- a/src/langs/nmv-cpp-ast-utils.cc
+++ b/src/langs/nmv-cpp-ast-utils.cc
@@ -47,7 +47,7 @@ get_declarator_id_as_string (const DeclaratorPtr a_decl, string &a_id)
             return true;
         case Declarator::ARRAY_DECLARATOR: {
             ArrayDeclaratorPtr decl;
-            decl = std::tr1::static_pointer_cast<ArrayDeclarator> (a_decl);
+            decl = std::static_pointer_cast<ArrayDeclarator> (a_decl);
             if (!decl->get_declarator ()) {
                 return false;
             }
diff --git a/src/langs/nmv-cpp-ast.h b/src/langs/nmv-cpp-ast.h
index 321f735..0f302f8 100644
--- a/src/langs/nmv-cpp-ast.h
+++ b/src/langs/nmv-cpp-ast.h
@@ -28,18 +28,14 @@
 #include "config.h"
 #include <string>
 #include <list>
-#if defined(HAVE_TR1_MEMORY)
-#include <tr1/memory>
-#elif defined(HAVE_BOOST_TR1_MEMORY_HPP)
-#include <boost/tr1/memory.hpp>
-#endif
+#include <memory>
 #include "common/nmv-namespace.h"
 #include "common/nmv-api-macros.h"
 
 NEMIVER_BEGIN_NAMESPACE (nemiver)
 NEMIVER_BEGIN_NAMESPACE (cpp)
 
-using std::tr1::shared_ptr;
+using std::shared_ptr;
 using std::list;
 using std::string;
 
diff --git a/src/langs/nmv-cpp-parser.cc b/src/langs/nmv-cpp-parser.cc
index a04a972..52c8c5b 100644
--- a/src/langs/nmv-cpp-parser.cc
+++ b/src/langs/nmv-cpp-parser.cc
@@ -1831,7 +1831,7 @@ Parser::parse_decl_specifier_seq (list<DeclSpecifierPtr> &a_result)
                 break;
             }
             TypeSpecifierPtr type_specifier =
-                std::tr1::static_pointer_cast<TypeSpecifier> (decl);
+                std::static_pointer_cast<TypeSpecifier> (decl);
             //— const or volatile can be combined with any other type-specifier.
             //  However, redundant cv-qualifiers are prohibited except
             if (type_specifier->is_cv_qualifier ()) {
@@ -1852,7 +1852,7 @@ Parser::parse_decl_specifier_seq (list<DeclSpecifierPtr> &a_result)
                 //— long can be combined with double.
                 //TODO: handle this
                 SimpleTypeSpecPtr simple_type_spec =
-                    std::tr1::static_pointer_cast<SimpleTypeSpec> (type_specifier);
+                    std::static_pointer_cast<SimpleTypeSpec> (type_specifier);
 
                 result.push_back (simple_type_spec);
                 string type_name_str = simple_type_spec->get_name_as_string ();
diff --git a/src/langs/nmv-cpp-parser.h b/src/langs/nmv-cpp-parser.h
index 16f0b9d..5d6f651 100644
--- a/src/langs/nmv-cpp-parser.h
+++ b/src/langs/nmv-cpp-parser.h
@@ -26,6 +26,7 @@
 #define __NMV_CPP_PARSER_H__
 
 #include <string>
+#include <memory>
 #include "nmv-cpp-ast.h"
 #include "common/nmv-namespace.h"
 #include "common/nmv-api-macros.h"
@@ -33,7 +34,7 @@
 NEMIVER_BEGIN_NAMESPACE (nemiver)
 NEMIVER_BEGIN_NAMESPACE (cpp)
 
-using std::tr1::shared_ptr;
+using std::shared_ptr;
 using std::string;
 
 class NEMIVER_API Parser {
diff --git a/src/uicommon/nmv-terminal.cc b/src/uicommon/nmv-terminal.cc
index 42408c7..51d8fd2 100644
--- a/src/uicommon/nmv-terminal.cc
+++ b/src/uicommon/nmv-terminal.cc
@@ -36,11 +36,7 @@
 #endif
 #include <unistd.h>
 #include <iostream>
-#if defined(HAVE_TR1_TUPLE)
-#include <tr1/tuple>
-#elif defined(HAVE_BOOST_TR1_TUPLE_HPP)
-#include <boost/tr1/tuple.hpp>
-#endif
+#include <tuple>
 #include <gtkmm/bin.h>
 #include <gtkmm/main.h>
 #include <gtkmm/window.h>
@@ -60,7 +56,7 @@ NEMIVER_BEGIN_NAMESPACE(nemiver)
 
 using namespace common;
 
-typedef std::tr1::tuple<VteTerminal*&,
+typedef std::tuple<VteTerminal*&,
                    Gtk::Menu*&,
                    Glib::RefPtr<Gtk::ActionGroup>&> TerminalPrivDataTuple;
 
@@ -76,9 +72,9 @@ on_button_press_signal (GtkWidget*,
     NEMIVER_TRY;
 
     THROW_IF_FAIL (a_tuple);
-    VteTerminal*& vte = std::tr1::get<0> (*a_tuple);
-    Gtk::Menu*& menu = std::tr1::get<1> (*a_tuple);
-    Glib::RefPtr<Gtk::ActionGroup>& action_group = std::tr1::get<2> (*a_tuple);
+    VteTerminal*& vte = std::get<0> (*a_tuple);
+    Gtk::Menu*& menu = std::get<1> (*a_tuple);
+    Glib::RefPtr<Gtk::ActionGroup>& action_group = std::get<2> (*a_tuple);
 
     THROW_IF_FAIL (vte);
     THROW_IF_FAIL (action_group);
-- 
                Dodji


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]