From 7c24f119c9c63a4d88adf31795adcced5d909958 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 4 Mar 2010 00:44:53 -0800 Subject: [PATCH] Fixing build breakage with more proper autoconf usage. --- configure.ac | 24 +++++++++++ src/libnrtype/FontFactory.cpp | 4 +- src/libnrtype/FontInstance.cpp | 4 +- src/ui/tool/control-point-selection.h | 22 ++++++++--- src/ui/tool/multi-path-manipulator.cpp | 15 ++++++- src/util/Makefile_insert | 1 + src/util/set-types.h | 55 ++++++++++++++++++++++++++ 7 files changed, 114 insertions(+), 11 deletions(-) create mode 100644 src/util/set-types.h diff --git a/configure.ac b/configure.ac index 5613f49a8..8a8a5a702 100644 --- a/configure.ac +++ b/configure.ac @@ -125,6 +125,30 @@ if test "x$GXX" = "xyes"; then fi fi +# Test for various hash_set/unordered_set issues: +# This is a system header so we check it as soon as possible +AC_CHECK_HEADER(tr1/unordered_set, + AC_MSG_CHECKING([TR1 unordered_set usability]) + AC_COMPILE_IFELSE([ +#include +int main() { + std::tr1::unordered_set i, j; + i = j; + return 0; +} +], [unordered_set_broken=no], [unordered_set_broken=yet]) +if test "x$unordered_set_broken" = "xyes"; then + AC_MSG_RESULT([broken]) +else + AC_MSG_RESULT([ok]) + AC_DEFINE(HAVE_TR1_UNORDERED_SET, 1, [Has the standard TR1 unordered_set]) +fi +, []) + +AC_CHECK_HEADER(ext/hash_set, AC_DEFINE(HAVE_EXT_HASH_SET, 1, [Legacy ext/hash_set]), []) +AC_CHECK_HEADER(unordered_set, AC_DEFINE(HAVE_UNORDERED_SET, 1, [Legacy unordered_set]), []) + + # Test whether GCC emits a spurious warning when using boost::optional # If yes, turn off strict aliasing warnings to reduce noise # and allow the legitimate warnings to stand out diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index d6fc207b0..8ab2ee696 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -26,9 +26,9 @@ /* Freetype2 */ # include -#include +#include "util/set-types.h" -typedef boost::unordered_map FaceMapType; +typedef optim_map FaceMapType; // need to avoid using the size field size_t font_descr_hash::operator()( PangoFontDescription *const &x) const { diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index 557e9106e..61cd28190 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -29,7 +29,7 @@ # include FT_TRUETYPE_TABLES_H # include -#include +#include "util/set-types.h" struct font_style_hash : public std::unary_function { @@ -40,7 +40,7 @@ struct font_style_equal : public std::binary_function StyleMap; +typedef optim_map StyleMap; diff --git a/src/ui/tool/control-point-selection.h b/src/ui/tool/control-point-selection.h index b3c2f422b..6efb63b67 100644 --- a/src/ui/tool/control-point-selection.h +++ b/src/ui/tool/control-point-selection.h @@ -14,8 +14,7 @@ #include #include -#include -#include +#include "util/set-types.h" #include #include <2geom/forward.h> #include <2geom/point.h> @@ -34,6 +33,17 @@ class SelectableControlPoint; } } +#ifdef USE_GNU_HASHES +namespace __gnu_cxx { +template<> +struct hash { + size_t operator()(Inkscape::UI::SelectableControlPoint *p) const { + return reinterpret_cast(p); + } +}; +} // namespace __gnu_cxx +#endif // USE_GNU_HASHES + namespace Inkscape { namespace UI { @@ -41,7 +51,7 @@ class ControlPointSelection : public Manipulator, public sigc::trackable { public: ControlPointSelection(SPDesktop *d, SPCanvasGroup *th_group); ~ControlPointSelection(); - typedef boost::unordered_set< SelectableControlPoint * > set_type; + typedef optim_set< SelectableControlPoint * > set_type; typedef set_type Set; // convenience alias typedef set_type::iterator iterator; @@ -76,7 +86,9 @@ public: void erase(iterator first, iterator last); // find - iterator find(const key_type &k) { return _points.find(k); } + iterator find(const key_type &k) { + return _points.find(k); + } // Sometimes it is very useful to keep a list of all selectable points. set_type const &allPoints() const { return _all_points; } @@ -130,7 +142,7 @@ private: set_type _points; set_type _all_points; - boost::unordered_map _original_positions; + optim_map _original_positions; boost::optional _rot_radius; boost::optional _mouseover_rot_radius; Geom::OptRect _bounds; diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index 3b0852e6e..d86a7e9e0 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -8,7 +8,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#include "util/set-types.h" #include #include #include @@ -25,13 +25,24 @@ #include "ui/tool/multi-path-manipulator.h" #include "ui/tool/path-manipulator.h" +#ifdef USE_GNU_HASHES +namespace __gnu_cxx { +template<> +struct hash { + size_t operator()(Inkscape::UI::NodeList::iterator const &n) const { + return reinterpret_cast(n.ptr()); + } +}; +} // namespace __gnu_cxx +#endif // USE_GNU_HASHES + namespace Inkscape { namespace UI { namespace { typedef std::pair IterPair; typedef std::vector IterPairList; -typedef boost::unordered_set IterSet; +typedef optim_set IterSet; typedef std::multimap DistanceMap; typedef std::pair DistanceMapItem; diff --git a/src/util/Makefile_insert b/src/util/Makefile_insert index 87a974768..3d3c88940 100644 --- a/src/util/Makefile_insert +++ b/src/util/Makefile_insert @@ -16,6 +16,7 @@ ink_common_sources += \ util/map-list.h \ util/mathfns.h \ util/reverse-list.h \ + util/set-types.h \ util/share.h \ util/share.cpp \ util/tuple.h \ diff --git a/src/util/set-types.h b/src/util/set-types.h new file mode 100644 index 000000000..f6752fb64 --- /dev/null +++ b/src/util/set-types.h @@ -0,0 +1,55 @@ +#ifndef SEEN_SET_TYPES_H +#define SEEN_SET_TYPES_H + + +/** @file + * Simple wrapper to disambiguate hash/unordered lists & sets. + */ +/* Authors: + * Jon A. Cruz + * + * Copyright (C) 2010 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#if defined(HAVE_TR1_UNORDERED_SET) + +# include +# include +# define optim_set std::tr1::unordered_set +# define optim_map std::tr1::unordered_map + +// TODO test on platform with this detected: +//#elif defined(HAVE_UNORDERED_SET) +// +//# include +//# include +//#define optim_set std::unordered_set +//#define optim_map std::unordered_map + +#elif defined(HAVE_EXT_HASH_SET) + +# include +# include +# define optim_set __gnu_cxx::hash_set +# define optim_map __gnu_cxx::hash_map +# define USE_GNU_HASHES 1 + +#endif + + +#endif // SEEN_SET_TYPES_H +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : -- 2.30.2