summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2017-12-13 00:57:03 -0800
committerPatrick Ohly <patrick.ohly@intel.com>2018-01-03 10:39:50 +0100
commit11e5e94ac2f0acb1eaf951ff125018c607904398 (patch)
treeb0027c2df1e86c1f5ef0397282ca7fdef4bd3907
parent4fe4b6dd1430529acbdcf38a30b128dfa0dc2278 (diff)
C++: avoid non-standard typeof
Building with recent Clang in C++ mode fails when using the non-standard typeof operator. We can't rely on the new(ish) decltype yet, so use the Boost implementation instead. Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
-rw-r--r--src/dbus/server/pim/individual-traits.cpp16
-rw-r--r--src/syncevo/GLibSupport.h7
-rw-r--r--src/syncevo/SyncContext.cpp5
-rw-r--r--src/syncevo/eds_abi_wrapper.cpp6
-rw-r--r--src/syncevolution.cpp6
-rw-r--r--test/ClientTest.cpp13
6 files changed, 31 insertions, 22 deletions
diff --git a/src/dbus/server/pim/individual-traits.cpp b/src/dbus/server/pim/individual-traits.cpp
index 03e558a0..71cd2822 100644
--- a/src/dbus/server/pim/individual-traits.cpp
+++ b/src/dbus/server/pim/individual-traits.cpp
@@ -26,6 +26,8 @@
#include "persona-details.h"
#include "folks.h"
+#include <boost/typeof/typeof.hpp>
+
SE_GLIB_TYPE(GDateTime, g_date_time)
SE_GOBJECT_TYPE(GTimeZone)
SE_GOBJECT_TYPE(GObject)
@@ -396,7 +398,7 @@ static void DBus2AbstractField(GDBusCXX::ExtractArgs &context,
typedef std::vector< std::pair< std::string, std::vector<std::string> > > Details_t;
Details_t value;
- GDBusCXX::dbus_traits<typeof(value)>::get(context, valueIter, value);
+ GDBusCXX::dbus_traits<BOOST_TYPEOF(value)>::get(context, valueIter, value);
GeeHashSetCXX set(gee_hash_set_new(detailType,
g_object_ref,
g_object_unref,
@@ -435,7 +437,7 @@ static void DBus2SimpleAbstractField(GDBusCXX::ExtractArgs &context,
typedef std::vector<std::string> Details_t;
Details_t value;
- GDBusCXX::dbus_traits<typeof(value)>::get(context, valueIter, value);
+ GDBusCXX::dbus_traits<BOOST_TYPEOF(value)>::get(context, valueIter, value);
GeeHashSetCXX set(gee_hash_set_new(detailType,
g_object_ref,
g_object_unref,
@@ -463,7 +465,7 @@ static void DBus2Role(GDBusCXX::ExtractArgs &context,
typedef std::vector<StringMap> Details_t;
Details_t value;
- GDBusCXX::dbus_traits<typeof(value)>::get(context, valueIter, value);
+ GDBusCXX::dbus_traits<BOOST_TYPEOF(value)>::get(context, valueIter, value);
GeeHashSetCXX set(gee_hash_set_new(FOLKS_TYPE_ROLE_FIELD_DETAILS,
g_object_ref,
g_object_unref,
@@ -502,7 +504,7 @@ static void DBus2Groups(GDBusCXX::ExtractArgs &context,
PersonaDetails &details)
{
std::list<std::string> value;
- GDBusCXX::dbus_traits<typeof(value)>::get(context, valueIter, value);
+ GDBusCXX::dbus_traits<BOOST_TYPEOF(value)>::get(context, valueIter, value);
GeeHashSetCXX set(gee_hash_set_new(G_TYPE_STRING, (GBoxedCopyFunc)g_strdup, g_free, NULL, NULL, NULL, NULL, NULL, NULL), TRANSFER_REF);
BOOST_FOREACH(const std::string &entry, value) {
gee_collection_add(GEE_COLLECTION(set.get()),
@@ -524,7 +526,7 @@ static void DBus2Addr(GDBusCXX::ExtractArgs &context,
typedef std::vector< std::pair< StringMap, std::vector<std::string> > > Details_t;
Details_t value;
- GDBusCXX::dbus_traits<typeof(value)>::get(context, valueIter, value);
+ GDBusCXX::dbus_traits<BOOST_TYPEOF(value)>::get(context, valueIter, value);
GeeHashSetCXX set(gee_hash_set_new(FOLKS_TYPE_POSTAL_ADDRESS_FIELD_DETAILS,
g_object_ref,
g_object_unref,
@@ -612,7 +614,7 @@ void DBus2PersonaDetails(GDBusCXX::ExtractArgs &context,
new GValueObjectCXX(g_file_icon_new(file.get()), TRANSFER_REF));
} else if (key == CONTACT_HASH_BIRTHDAY) {
boost::tuple<int, int, int> value;
- GDBusCXX::dbus_traits<typeof(value)>::get(context, valueIter, value);
+ GDBusCXX::dbus_traits<BOOST_TYPEOF(value)>::get(context, valueIter, value);
GDateTimeCXX local(g_date_time_new_local(value.get<0>(),
value.get<1>(),
value.get<2>(),
@@ -623,7 +625,7 @@ void DBus2PersonaDetails(GDBusCXX::ExtractArgs &context,
new GValueDateTimeCXX(g_date_time_to_utc(local.get()), TRANSFER_REF));
} else if (key == CONTACT_HASH_LOCATION) {
boost::tuple<double, double> value;
- GDBusCXX::dbus_traits<typeof(value)>::get(context, valueIter, value);
+ GDBusCXX::dbus_traits<BOOST_TYPEOF(value)>::get(context, valueIter, value);
FolksLocationCXX location(folks_location_new(value.get<0>(),
value.get<1>()),
TRANSFER_REF);
diff --git a/src/syncevo/GLibSupport.h b/src/syncevo/GLibSupport.h
index 2567e1ac..912ca810 100644
--- a/src/syncevo/GLibSupport.h
+++ b/src/syncevo/GLibSupport.h
@@ -43,6 +43,7 @@ typedef void *GMainLoop;
#include <boost/type_traits/function_traits.hpp>
#include <boost/utility/value_init.hpp>
#include <boost/lambda/lambda.hpp>
+#include <boost/typeof/typeof.hpp>
#include <iterator>
#include <memory>
@@ -937,9 +938,9 @@ template<class F, F *finish> struct GAsyncReady2<void, F, finish, GAsyncResult *
* first switch based on arity of the finish function, then on its type
*/
#define SYNCEVO_GLIB_CALL_ASYNC_CXX(_prepare) \
- GAsyncReadyCXX< boost::remove_pointer<typeof(_prepare ## _finish)>::type, \
+ GAsyncReadyCXX< boost::remove_pointer<BOOST_TYPEOF(_prepare ## _finish)>::type, \
& _prepare ## _finish, \
- boost::function_traits<boost::remove_pointer<typeof(_prepare ## _finish)>::type>::arity >
+ boost::function_traits<boost::remove_pointer<BOOST_TYPEOF(_prepare ## _finish)>::type>::arity >
/**
* Macro for asynchronous methods which use a GAsyncReadyCallback to
@@ -1042,7 +1043,7 @@ template<> class GAsyncReadyDoneCXX<void>
do { \
bool done = false; \
SYNCEVO_GLIB_CALL_ASYNC(_prepare, \
- GAsyncReadyDoneCXX<boost::function<typeof(_prepare ## _finish)>::result_type>::createCB(_res, _gerror, done), \
+ GAsyncReadyDoneCXX<boost::function<BOOST_TYPEOF(_prepare ## _finish)>::result_type>::createCB(_res, _gerror, done), \
_args); \
GRunWhile(! boost::lambda::var(done)); \
} while (false); \
diff --git a/src/syncevo/SyncContext.cpp b/src/syncevo/SyncContext.cpp
index 2d838105..8f3232bb 100644
--- a/src/syncevo/SyncContext.cpp
+++ b/src/syncevo/SyncContext.cpp
@@ -59,6 +59,7 @@ using namespace std;
#include <boost/bind.hpp>
#include <boost/utility.hpp>
#include <boost/lambda/bind.hpp>
+#include <boost/typeof/typeof.hpp>
#include <sys/stat.h>
#include <sys/wait.h>
@@ -3284,8 +3285,8 @@ void SyncContext::initMain(const char *appname)
typedef void (*LogFunc_t)(int level, const char *str);
void (*set_log_function)(LogFunc_t func);
- set_log_level = (typeof(set_log_level))dlsym(RTLD_DEFAULT, "gnutls_global_set_log_level");
- set_log_function = (typeof(set_log_function))dlsym(RTLD_DEFAULT, "gnutls_global_set_log_function");
+ set_log_level = (BOOST_TYPEOF(set_log_level))dlsym(RTLD_DEFAULT, "gnutls_global_set_log_level");
+ set_log_function = (BOOST_TYPEOF(set_log_function))dlsym(RTLD_DEFAULT, "gnutls_global_set_log_function");
if (set_log_level && set_log_function) {
set_log_level(atoi(gnutlsdbg));
diff --git a/src/syncevo/eds_abi_wrapper.cpp b/src/syncevo/eds_abi_wrapper.cpp
index 40d4e90a..6be2aa8a 100644
--- a/src/syncevo/eds_abi_wrapper.cpp
+++ b/src/syncevo/eds_abi_wrapper.cpp
@@ -26,6 +26,8 @@
#include <dlfcn.h>
#include <stdarg.h>
+#include <boost/typeof/typeof.hpp>
+
#include <syncevo/declarations.h>
namespace {
static std::string &getLookupDebug() { static std::string lookupDebug; return lookupDebug; }
@@ -100,10 +102,10 @@ dbus_connection_send_with_reply (void *connection,
void **pending_return,
int timeout_milliseconds)
{
- static typeof(dbus_connection_send_with_reply) *real_func;
+ static BOOST_TYPEOF(dbus_connection_send_with_reply) *real_func;
if (!real_func) {
- real_func = (typeof(dbus_connection_send_with_reply) *)dlsym(RTLD_NEXT, "dbus_connection_send_with_reply");
+ real_func = (BOOST_TYPEOF(dbus_connection_send_with_reply) *)dlsym(RTLD_NEXT, "dbus_connection_send_with_reply");
}
return real_func ?
real_func(connection, message, pending_return,
diff --git a/src/syncevolution.cpp b/src/syncevolution.cpp
index 801a5cf9..b768afca 100644
--- a/src/syncevolution.cpp
+++ b/src/syncevolution.cpp
@@ -54,6 +54,8 @@ using namespace GDBusCXX;
#endif
+#include <boost/typeof/typeof.hpp>
+
#include <syncevo/Cmdline.h>
#include <syncevo/SyncContext.h>
#include <syncevo/SuspendFlags.h>
@@ -74,10 +76,10 @@ SE_BEGIN_CXX
#undef e_contact_new_from_vcard
extern "C" EContact *e_contact_new_from_vcard(const char *vcard)
{
- static typeof(e_contact_new_from_vcard) *impl;
+ static BOOST_TYPEOF(e_contact_new_from_vcard) *impl;
if (!impl) {
- impl = (typeof(impl))dlsym(RTLD_NEXT, "e_contact_new_from_vcard");
+ impl = (BOOST_TYPEOF(impl))dlsym(RTLD_NEXT, "e_contact_new_from_vcard");
}
// Old versions of EDS-DBus parse_changes_array() call
diff --git a/test/ClientTest.cpp b/test/ClientTest.cpp
index 9a5a4e58..95bb46a1 100644
--- a/test/ClientTest.cpp
+++ b/test/ClientTest.cpp
@@ -69,6 +69,7 @@
#include <boost/lambda/if.hpp>
#include <boost/lambda/casts.hpp>
#include <boost/lambda/switch.hpp>
+#include <boost/typeof/typeof.hpp>
#include <pcrecpp.h>
@@ -3401,15 +3402,15 @@ void SyncTests::doRestartSync(SyncMode mode)
(boost::lambda::if_then(boost::lambda::var(needToConnect),
(boost::lambda::var(needToConnect) = false,
boost::lambda::bind(connectSourceSignal<SyncSource::Operations::StartDataRead_t,
- typeof(&SyncSource::Operations::StartDataRead_t::getPreSignal),
- typeof(start)>,
+ BOOST_TYPEOF(&SyncSource::Operations::StartDataRead_t::getPreSignal),
+ BOOST_TYPEOF(start)>,
boost::lambda::_1,
&SyncSource::Operations::m_startDataRead,
&SyncSource::Operations::StartDataRead_t::getPreSignal,
boost::cref(start)),
boost::lambda::bind(connectSourceSignal<SyncSource::Operations::EndDataWrite_t,
- typeof(&SyncSource::Operations::EndDataWrite_t::getPostSignal),
- typeof(end)>,
+ BOOST_TYPEOF(&SyncSource::Operations::EndDataWrite_t::getPostSignal),
+ BOOST_TYPEOF(end)>,
boost::lambda::_1,
&SyncSource::Operations::m_endDataWrite,
&SyncSource::Operations::EndDataWrite_t::getPostSignal,
@@ -3748,8 +3749,8 @@ void SyncTests::testManyRestarts()
(boost::lambda::if_then(boost::lambda::var(needToConnect),
(boost::lambda::var(needToConnect) = false,
boost::lambda::bind(connectSourceSignal<SyncSource::Operations::StartDataRead_t,
- typeof(&SyncSource::Operations::StartDataRead_t::getPreSignal),
- typeof(start)>,
+ BOOST_TYPEOF(&SyncSource::Operations::StartDataRead_t::getPreSignal),
+ BOOST_TYPEOF(start)>,
boost::lambda::_1,
&SyncSource::Operations::m_startDataRead,
&SyncSource::Operations::StartDataRead_t::getPreSignal,