Code

Replace std::tr1::unordered_(map|set) with __gnu_cxx::hash_(map|set),
authorKrzysztof Kosiński <tweenk.pl@gmail.com>
Thu, 14 Jan 2010 22:38:54 +0000 (23:38 +0100)
committerKrzysztof Kosiński <tweenk.pl@gmail.com>
Thu, 14 Jan 2010 22:38:54 +0000 (23:38 +0100)
to work around broken headers in some GCC versions.

src/libnrtype/FontFactory.cpp
src/libnrtype/FontInstance.cpp
src/preferences-skeleton.h
src/ui/tool/control-point-selection.h
src/ui/tool/multi-path-manipulator.cpp
src/ui/tool/path-manipulator.cpp
src/util/hash.h

index a63f70d758819033586bc66dd0237501519ef7ec..afce4d8491058d602e3e9c6da97e795f43b67202 100644 (file)
 /* Freetype2 */
 # include <pango/pangoft2.h>
 
-#include <tr1/unordered_map>
+//#include <tr1/unordered_map>
+#include <ext/hash_map>
 
 
-typedef std::tr1::unordered_map<PangoFontDescription*, font_instance*, font_descr_hash, font_descr_equal> FaceMapType;
+typedef __gnu_cxx::hash_map<PangoFontDescription*, font_instance*, font_descr_hash, font_descr_equal> FaceMapType;
 
 // need to avoid using the size field
 size_t font_descr_hash::operator()( PangoFontDescription *const &x) const {
index 6b0725b34a92d604a364be1bbde2139757b56678..8b8eb8bbe714d3f982399f5b845f844432cc8269 100644 (file)
@@ -29,7 +29,8 @@
 # include FT_TRUETYPE_TABLES_H
 # include <pango/pangoft2.h>
 
-#include <tr1/unordered_map>
+//#include <tr1/unordered_map>
+#include <ext/hash_map>
 
 
 // the various raster_font in use at a given time are held in a hash_map whose indices are the
@@ -43,7 +44,7 @@ struct font_style_equal : public std::binary_function<font_style, font_style, bo
 };
 
 
-typedef std::tr1::unordered_map<font_style, raster_font*, font_style_hash, font_style_equal> StyleMap;
+typedef __gnu_cxx::hash_map<font_style, raster_font*, font_style_hash, font_style_equal> StyleMap;
 
 
 
index 90fc85757ac758f5e632b8a3a802567ef01dc9ea..0c58a05f453782e036f479114f5c26fae2e2155c 100644 (file)
@@ -113,7 +113,7 @@ static char const preferences_skeleton[] =
 "                       font_sample=\"AaBbCcIiPpQq12369$\342\202\254\302\242?.;/()\"\n"
 "                       show_sample_in_list=\"1\"\n"
 "                  style=\"fill:black;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;font-style:normal;font-weight:normal;font-size:40px;\" selcue=\"1\"/>\n"
-"    <eventcontext id=\"nodes\" selcue=\"1\" gradientdrag=\"1\" highlight_color=\"4278190335\" pathflash_enabled=\"1\" pathflash_unselected=\"0\" pathflash_timeout=\"500\" show_handles=\"1\" show_outline=\"0\" sculpting_profile=\"1\" />\n"
+"    <eventcontext id=\"nodes\" selcue=\"1\" gradientdrag=\"1\" highlight_color=\"4278190335\" pathflash_enabled=\"1\" pathflash_unselected=\"0\" pathflash_timeout=\"500\" show_handles=\"1\" show_outline=\"0\" sculpting_profile=\"1\" single_node_transform_handles=\"0\" show_transform_handles=\"0\" />\n"
 "    <eventcontext id=\"tweak\" selcue=\"0\" gradientdrag=\"0\" show_handles=\"0\" width=\"0.2\" force=\"0.2\" fidelity=\"0.5\" usepressure=\"1\" style=\"fill:red;stroke:none;\" usecurrent=\"0\"/>\n"
 "    <eventcontext id=\"spray\" selcue=\"0\" gradientdrag=\"0\" show_handles=\"0\" width=\"0.2\" force=\"0.2\" fidelity=\"0.5\" usepressure=\"1\" style=\"fill:red;stroke:none;\" usecurrent=\"0\"/>\n"
 "    <eventcontext id=\"gradient\" selcue=\"1\"/>\n"
index 7a83b529064bb5860440536c6e284d059efe5c03..dce68557589b4448063cbf9abe08a1007817c309 100644 (file)
 #define SEEN_UI_TOOL_NODE_SELECTION_H
 
 #include <memory>
-#include <tr1/unordered_map>
-#include <tr1/unordered_set>
+// those are broken beyond hope on OSX.
+//#include <tr1/unordered_map>
+//#include <tr1/unordered_set>
+#include <ext/hash_map>
+#include <ext/hash_set>
 #include <boost/shared_ptr.hpp>
 #include <boost/weak_ptr.hpp>
 #include <boost/optional.hpp>
 #include "ui/tool/commit-events.h"
 #include "ui/tool/manipulator.h"
 
-namespace std { using namespace tr1; }
+namespace std { using namespace __gnu_cxx; }
 
 class SPDesktop;
 
 namespace Inkscape {
 namespace UI {
-
 class TransformHandleSet;
 class SelectableControlPoint;
+}
+}
+
+namespace __gnu_cxx {
+template<>
+struct hash<Inkscape::UI::SelectableControlPoint*> {
+    size_t operator()(Inkscape::UI::SelectableControlPoint *p) const {
+        return reinterpret_cast<size_t>(p);
+    }
+};
+} // namespace __gnu_cxx
+
+namespace Inkscape {
+namespace UI {
 
 class ControlPointSelection : public Manipulator {
 public:
     ControlPointSelection(SPDesktop *d, SPCanvasGroup *th_group);
     ~ControlPointSelection();
     typedef std::list<sigc::connection> connlist_type;
-    typedef std::unordered_map< SelectableControlPoint *,
+    typedef std::hash_map< SelectableControlPoint *,
         boost::shared_ptr<connlist_type> > map_type;
-    typedef std::unordered_set< SelectableControlPoint * > set_type;
+    typedef std::hash_set< SelectableControlPoint * > set_type;
     typedef set_type Set; // convenience alias
 
     typedef map_type::iterator iterator;
index 3ae7e4d2495264cb8c3f4a32fc870d4d4c7faa6b..818bdaedcf4c35940c18c6e033e3f29ada4389b6 100644 (file)
@@ -8,7 +8,8 @@
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
 
-#include <tr1/unordered_set>
+//#include <tr1/unordered_set>
+#include <ext/hash_set>
 #include <boost/shared_ptr.hpp>
 #include <glib.h>
 #include <glibmm/i18n.h>
 #include "ui/tool/multi-path-manipulator.h"
 #include "ui/tool/path-manipulator.h"
 
-namespace std { using namespace tr1; }
+namespace std { using namespace __gnu_cxx; }
+
+namespace __gnu_cxx {
+template<>
+struct hash<Inkscape::UI::NodeList::iterator> {
+    size_t operator()(Inkscape::UI::NodeList::iterator const &n) const {
+        return reinterpret_cast<size_t>(n.ptr());
+    }
+};
+}
 
 namespace Inkscape {
 namespace UI {
@@ -33,7 +43,7 @@ namespace UI {
 namespace {
 typedef std::pair<NodeList::iterator, NodeList::iterator> IterPair;
 typedef std::vector<IterPair> IterPairList;
-typedef std::unordered_set<NodeList::iterator> IterSet;
+typedef std::hash_set<NodeList::iterator> IterSet;
 typedef std::multimap<double, IterPair> DistanceMap;
 typedef std::pair<double, IterPair> DistanceMapItem;
 
index 9889eb787cd3a96c33d467885ea3cc4f9db95578..9eabd899227498b816033a4a33f8b8b896d1bf61 100644 (file)
@@ -1157,17 +1157,24 @@ bool PathManipulator::_nodeClicked(Node *n, GdkEventButton *event)
 {
     // cycle between node types on ctrl+click
     if (event->button != 1 || !held_control(*event)) return false;
-    if (n->isEndNode()) {
-        if (n->type() == NODE_CUSP) {
-            n->setType(NODE_SMOOTH);
+    /*if (held_alt(*event)) {
+        // TODO delete nodes with Ctrl+Alt+click
+        n->list()->erase(NodeList::get_iterator(n));
+        update();
+        _commit(_("Delete node"));
+    } else*/ {
+        if (n->isEndNode()) {
+            if (n->type() == NODE_CUSP) {
+                n->setType(NODE_SMOOTH);
+            } else {
+                n->setType(NODE_CUSP);
+            }
         } else {
-            n->setType(NODE_CUSP);
+            n->setType(static_cast<NodeType>((n->type() + 1) % NODE_LAST_REAL_TYPE));
         }
-    } else {
-        n->setType(static_cast<NodeType>((n->type() + 1) % NODE_LAST_REAL_TYPE));
+        update();
+        _commit(_("Cycle node type"));
     }
-    update();
-    _commit(_("Cycle node type"));
     return true;
 }
 
index d5abeff5a7bdc11ca08fde6d1aa967498e0dbfeb..33af9222da0e0e6f1d7b5c2a7e09d76e08dfe3db 100644 (file)
@@ -13,8 +13,7 @@
 
 #include <boost/shared_ptr.hpp>
 
-namespace std {
-namespace tr1 {
+namespace __gnu_cxx {
 
 /** Hash function for Boost shared pointers */
 template <typename T>
@@ -24,8 +23,7 @@ struct hash< boost::shared_ptr<T> > : public std::unary_function<boost::shared_p
     }
 };
 
-} // namespace tr1
-} // namespace std
+} // namespace __gnu_cxx
 
 #endif