aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-04-22 07:04:24 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-04-22 07:04:24 +0000
commitc03a5095c11c18536d16cee9fb7b9be3fcfa04d0 (patch)
tree8d0dae2d5f9112cd005abefe29f75098c2587c38
parent9a8a0b7f8699a79fb6eabba4ada248bd9022a954 (diff)
downloadpaludis-c03a5095c11c18536d16cee9fb7b9be3fcfa04d0.tar.gz
paludis-c03a5095c11c18536d16cee9fb7b9be3fcfa04d0.tar.xz
Start using extern template, where available.
-rw-r--r--configure.ac38
-rw-r--r--paludis/util/action_queue.cc4
-rw-r--r--paludis/util/action_queue.hh7
-rw-r--r--paludis/util/config_file-fwd.hh31
-rw-r--r--paludis/util/config_file.cc8
-rw-r--r--paludis/util/config_file.hh17
-rw-r--r--paludis/util/damerau_levenshtein.cc2
-rw-r--r--paludis/util/damerau_levenshtein.hh4
-rw-r--r--paludis/util/dir_iterator-fwd.hh43
-rw-r--r--paludis/util/dir_iterator.cc3
-rw-r--r--paludis/util/dir_iterator.hh19
-rw-r--r--paludis/util/dir_iterator_TEST.cc1
-rw-r--r--paludis/util/files.m44
13 files changed, 156 insertions, 25 deletions
diff --git a/configure.ac b/configure.ac
index d88c338..ea96a82 100644
--- a/configure.ac
+++ b/configure.ac
@@ -500,6 +500,21 @@ if test "x$have_dirent_dtype" = "xyes"; then
fi
dnl }}}
+dnl {{{ check whether we can do extern template
+CAN_USE_EXTERN_TEMPLATE=
+AC_MSG_CHECKING([whether we can use extern template])
+AC_COMPILE_IFELSE([
+template <typename T_> struct S { };
+extern template struct S<int>;
+],
+ [AC_MSG_RESULT([yes])
+ CAN_USE_EXTERN_TEMPLATE=yes
+ PALUDIS_CXXFLAGS="${PALUDIS_CXXFLAGS} -DPALUDIS_HAVE_EXTERN_TEMPLATE=1"
+ PALUDIS_PC_CFLAGS="${PALUDIS_PC_CFLAGS} -DPALUDIS_HAVE_EXTERN_TEMPLATE=1"
+ ],
+ [AC_MSG_RESULT([no])])
+dnl }}}
+
dnl {{{ check for cxxflags
if test x = x"$LET_ME_RICE"
then
@@ -590,6 +605,8 @@ AC_DEFUN([CHECK_CXXFLAG], [
CXXFLAGS="$CXXFLAGS $PALUDIS_CXXFLAGS $1 -Werror"
AC_COMPILE_IFELSE([
#include <string>
+template <typename T_> struct S { };
+extern template struct S<int>;
#include <iostream>
int main(int, char **)
{
@@ -653,7 +670,6 @@ elif test "x${ac_cv_cxx_compiler_gnu}" = "xyes" ; then
if test "x$cxxflag_success" = "xyes" ; then
PALUDIS_CXXFLAGS_NO_WSHADOW=-Wno-shadow
fi
- PALUDIS_CXXFLAGS_WITHOUT_PEDANTIC=$PALUDIS_CXXFLAGS
CHECK_CXXFLAG([-Wlogical-op])
CHECK_CXXFLAG([-Wvla])
CHECK_CXXFLAG([-Wwrite-strings])
@@ -663,11 +679,29 @@ elif test "x${ac_cv_cxx_compiler_gnu}" = "xyes" ; then
PALUDIS_CXXFLAGS_NO_WWRITE_STRINGS=-Wno-write-strings
fi
CHECK_CXXFLAG([-Wno-ignored-qualifiers])
- CHECK_CXXFLAG([-pedantic])
+ PALUDIS_CXXFLAGS_WITHOUT_PEDANTIC=$PALUDIS_CXXFLAGS
else
CHECK_CXXFLAG([-Wall])
+ PALUDIS_CXXFLAGS_WITHOUT_PEDANTIC=$PALUDIS_CXXFLAGS
fi
AC_MSG_RESULT([${cxxflags_message}])
+
+if test x$CAN_USE_EXTERN_TEMPLATE = xyes ; then
+ AC_MSG_CHECKING([whether -pedantic works if we use extern template])
+ save_CXXFLAGS=$CXXFLAGS
+ CXXFLAGS="$CXXFLAGS -pedantic"
+ AC_COMPILE_IFELSE([
+template <typename T_> struct S { };
+extern template struct S<int>;
+],
+ [AC_MSG_RESULT([yes])
+ CHECK_CXXFLAG([-pedantic])],
+ [AC_MSG_RESULT([no])])
+else
+ CHECK_CXXFLAG([-pedantic])
+fi
+CXXFLAGS=$save_CXXFLAGS
+
AC_SUBST([PALUDIS_CXXFLAGS])
AC_SUBST([PALUDIS_CXXFLAGS_WITHOUT_PEDANTIC])
AC_SUBST([PALUDIS_CXXFLAGS_NO_WOLD_STYLE_CAST])
diff --git a/paludis/util/action_queue.cc b/paludis/util/action_queue.cc
index 95f229f..5dbcad9 100644
--- a/paludis/util/action_queue.cc
+++ b/paludis/util/action_queue.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 2008 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -30,6 +30,8 @@
using namespace paludis;
+template class PrivateImplementationPattern<ActionQueue>;
+
namespace paludis
{
template <>
diff --git a/paludis/util/action_queue.hh b/paludis/util/action_queue.hh
index d42eaca..3424cc3 100644
--- a/paludis/util/action_queue.hh
+++ b/paludis/util/action_queue.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 2008 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -67,6 +67,11 @@ namespace paludis
*/
unsigned number_of_threads() const;
};
+
+#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
+ extern template class PrivateImplementationPattern<ActionQueue>;
+#endif
+
}
#endif
diff --git a/paludis/util/config_file-fwd.hh b/paludis/util/config_file-fwd.hh
new file mode 100644
index 0000000..7f45d99
--- /dev/null
+++ b/paludis/util/config_file-fwd.hh
@@ -0,0 +1,31 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_UTIL_CONFIG_FILE_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_CONFIG_FILE_FWD_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <iosfwd>
+
+namespace paludis
+{
+#include <paludis/util/config_file-se.hh>
+}
+
+#endif
diff --git a/paludis/util/config_file.cc b/paludis/util/config_file.cc
index 0b11dcc..3f5f626 100644
--- a/paludis/util/config_file.cc
+++ b/paludis/util/config_file.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
* Copyright (c) 2006 Danny van Dyk
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -47,6 +47,12 @@ template class WrappedForwardIterator<KeyValueConfigFile::Defaults::ConstIterato
template class WrappedForwardIterator<KeyValueConfigFile::ConstIteratorTag,
const std::pair<const std::string, std::string> >;
+template class InstantiationPolicy<ConfigFile, instantiation_method::NonCopyableTag>;
+template class PrivateImplementationPattern<ConfigFile::Source>;
+template class PrivateImplementationPattern<LineConfigFile>;
+template class PrivateImplementationPattern<KeyValueConfigFile>;
+template class PrivateImplementationPattern<KeyValueConfigFile::Defaults>;
+
ConfigFileError::ConfigFileError(const std::string & f, const std::string & m) throw () :
ConfigurationError("Configuration file error: " + (f.empty() ? m : f + ": " + m))
{
diff --git a/paludis/util/config_file.hh b/paludis/util/config_file.hh
index bea1ae3..31f07bb 100644
--- a/paludis/util/config_file.hh
+++ b/paludis/util/config_file.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -20,12 +20,14 @@
#ifndef PALUDIS_GUARD_PALUDIS_CONFIG_FILE_HH
#define PALUDIS_GUARD_PALUDIS_CONFIG_FILE_HH 1
+#include <paludis/util/config_file-fwd.hh>
#include <paludis/util/map-fwd.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/options-fwd.hh>
#include <paludis/util/wrapped_forward_iterator-fwd.hh>
+#include <paludis/util/fs_entry-fwd.hh>
#include <iosfwd>
#include <string>
@@ -43,10 +45,6 @@
namespace paludis
{
-#include <paludis/util/config_file-se.hh>
-
- class FSEntry;
-
/**
* Raised if an error is encountered parsing a configuration file.
*
@@ -369,6 +367,15 @@ namespace paludis
*/
template<>
KeyValueConfigFile::Defaults::Defaults(tr1::shared_ptr<Map<std::string, std::string> >);
+
+#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
+ extern template class InstantiationPolicy<ConfigFile, instantiation_method::NonCopyableTag>;
+ extern template class PrivateImplementationPattern<ConfigFile::Source>;
+ extern template class PrivateImplementationPattern<LineConfigFile>;
+ extern template class PrivateImplementationPattern<KeyValueConfigFile>;
+ extern template class PrivateImplementationPattern<KeyValueConfigFile::Defaults>;
+#endif
+
}
#endif
diff --git a/paludis/util/damerau_levenshtein.cc b/paludis/util/damerau_levenshtein.cc
index 6c1e6b3..7e53819 100644
--- a/paludis/util/damerau_levenshtein.cc
+++ b/paludis/util/damerau_levenshtein.cc
@@ -24,6 +24,8 @@
using namespace paludis;
+template class PrivateImplementationPattern<DamerauLevenshtein>;
+
namespace paludis
{
template <>
diff --git a/paludis/util/damerau_levenshtein.hh b/paludis/util/damerau_levenshtein.hh
index d689995..5a4c8d2 100644
--- a/paludis/util/damerau_levenshtein.hh
+++ b/paludis/util/damerau_levenshtein.hh
@@ -53,6 +53,10 @@ namespace paludis
///\}
};
+
+#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
+ extern template class PrivateImplementationPattern<DamerauLevenshtein>;
+#endif
}
#endif
diff --git a/paludis/util/dir_iterator-fwd.hh b/paludis/util/dir_iterator-fwd.hh
new file mode 100644
index 0000000..32a006c
--- /dev/null
+++ b/paludis/util/dir_iterator-fwd.hh
@@ -0,0 +1,43 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_UTIL_DIR_ITERATOR_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_DIR_ITERATOR_FWD_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <paludis/util/options-fwd.hh>
+#include <iosfwd>
+
+namespace paludis
+{
+#include <paludis/util/dir_iterator-se.hh>
+
+ /**
+ * Options for a DirIterator.
+ *
+ * \see DirIteratorOption
+ * \see DirIterator
+ */
+ typedef Options<DirIteratorOption> DirIteratorOptions;
+
+ class DirOpenError;
+ class DirIterator;
+}
+
+#endif
diff --git a/paludis/util/dir_iterator.cc b/paludis/util/dir_iterator.cc
index bbed09a..8e59b52 100644
--- a/paludis/util/dir_iterator.cc
+++ b/paludis/util/dir_iterator.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
* Copyright (c) 2008 Fernando J. Pereda
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -36,6 +36,7 @@ using namespace paludis;
#include <paludis/util/dir_iterator-se.cc>
typedef std::multiset<std::pair<ino_t, FSEntry>, tr1::function<bool (std::pair<ino_t, FSEntry>, std::pair<ino_t, FSEntry>)> > EntrySet;
+template class PrivateImplementationPattern<DirIterator>;
namespace paludis
{
diff --git a/paludis/util/dir_iterator.hh b/paludis/util/dir_iterator.hh
index 4c5fdf6..ff58849 100644
--- a/paludis/util/dir_iterator.hh
+++ b/paludis/util/dir_iterator.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -20,10 +20,11 @@
#ifndef PALUDIS_GUARD_PALUDIS_DIR_ITERATOR_HH
#define PALUDIS_GUARD_PALUDIS_DIR_ITERATOR_HH 1
-#include <iterator>
+#include <paludis/util/dir_iterator-fwd.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/options.hh>
#include <paludis/util/private_implementation_pattern.hh>
+#include <iterator>
#ifdef PALUDIS_HAVE_CONCEPTS
# include <concepts>
@@ -60,16 +61,6 @@ namespace paludis
///\}
};
-#include <paludis/util/dir_iterator-se.hh>
-
- /**
- * Options for a DirIterator.
- *
- * \see DirIteratorOption
- * \see DirIterator
- */
- typedef Options<DirIteratorOption> DirIteratorOptions;
-
/**
* An iterator that iterates over the contents of a directory.
*
@@ -142,6 +133,10 @@ namespace paludis
///\}
};
+
+#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
+ extern template class PrivateImplementationPattern<DirIterator>;
+#endif
}
#ifdef PALUDIS_HAVE_CONCEPTS
diff --git a/paludis/util/dir_iterator_TEST.cc b/paludis/util/dir_iterator_TEST.cc
index 57d876f..2a7618f 100644
--- a/paludis/util/dir_iterator_TEST.cc
+++ b/paludis/util/dir_iterator_TEST.cc
@@ -18,6 +18,7 @@
*/
#include <paludis/util/dir_iterator.hh>
+#include <paludis/util/options.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index 20fcc54..cd29bca 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -11,14 +11,14 @@ dnl on this file at present...
add(`action_queue', `hh', `cc', `test')
add(`attributes', `hh')
add(`byte_swap', `hh', `test')
-add(`config_file', `hh', `cc', `se', `test', `testscript')
+add(`config_file', `hh', `cc', `fwd', `se', `test', `testscript')
add(`clone', `hh', `impl')
add(`condition_variable', `hh', `cc', `test')
add(`cookie', `hh', `cc')
add(`create_iterator', `hh', `fwd', `impl', `test')
add(`damerau_levenshtein', `hh', `cc', `test')
add(`destringify', `hh', `cc', `test')
-add(`dir_iterator', `hh', `cc', `se', `test', `testscript')
+add(`dir_iterator', `hh', `cc', `fwd', `se', `test', `testscript')
add(`exception', `hh', `cc')
add(`fast_unique_copy', `hh', `test')
add(`fd_output_stream', `hh')