From c3445f065c7f1eff068af343bd0c90efd9006895 Mon Sep 17 00:00:00 2001 From: randomdan Date: Fri, 23 Aug 2013 22:12:25 +0000 Subject: Tidy up fix/hack for conditional binding, gcc 4.6 compat --- libfusepp/fuseapp.h | 89 +++++++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 41 deletions(-) (limited to 'libfusepp/fuseapp.h') diff --git a/libfusepp/fuseapp.h b/libfusepp/fuseapp.h index bb18c02..d372655 100644 --- a/libfusepp/fuseapp.h +++ b/libfusepp/fuseapp.h @@ -56,51 +56,51 @@ class FuseAppBase { virtual int fallocate(const char *, int, off_t, off_t, struct fuse_file_info *); virtual int onError(const std::exception & err) throw(); -#define IFIMPL(func) typeid(&FuseAppBase::func) == typeid(&FuseApp::func) ? NULL : +#define GetHelper(func) getHelper<&FuseAppBase::func>(typeid(&FuseAppBase::func) != typeid(&FuseApp::func)) template static int run(int & argc, char** & argv, FuseApp * fa) { auto args = runint(argc, argv, fa); struct fuse_operations operations = { - IFIMPL(getattr) fuseCall::helper<&FuseAppBase::getattr>, - IFIMPL(readlink) fuseCall::helper<&FuseAppBase::readlink>, + fuseCall::GetHelper(getattr), + fuseCall::GetHelper(readlink), NULL, // getdir deprecated - IFIMPL(mknod) fuseCall::helper<&FuseAppBase::mknod>, - IFIMPL(mkdir) fuseCall::helper<&FuseAppBase::mkdir>, - IFIMPL(unlink) fuseCall::helper<&FuseAppBase::unlink>, - IFIMPL(rmdir) fuseCall::helper<&FuseAppBase::rmdir>, - IFIMPL(symlink) fuseCall::helper<&FuseAppBase::symlink>, - IFIMPL(rename) fuseCall::helper<&FuseAppBase::rename>, - IFIMPL(link) fuseCall::helper<&FuseAppBase::link>, - IFIMPL(chmod) fuseCall::helper<&FuseAppBase::chmod>, - IFIMPL(chown) fuseCall::helper<&FuseAppBase::chown>, - IFIMPL(truncate) fuseCall::helper<&FuseAppBase::truncate>, + NULL, //fuseCall::GetHelper(mknod), + fuseCall::GetHelper(mkdir), + fuseCall::GetHelper(unlink), + fuseCall::GetHelper(rmdir), + fuseCall::GetHelper(symlink), + fuseCall::GetHelper(rename), + fuseCall::GetHelper(link), + fuseCall::GetHelper(chmod), + fuseCall::GetHelper(chown), + fuseCall::GetHelper(truncate), NULL, // utime deprecated - IFIMPL(open) fuseCall::helper<&FuseAppBase::open>, - IFIMPL(read) fuseCall::helper<&FuseAppBase::read>, - IFIMPL(write) fuseCall::helper<&FuseAppBase::write>, - IFIMPL(statfs) fuseCall::helper<&FuseAppBase::statfs>, - IFIMPL(flush) fuseCall::helper<&FuseAppBase::flush>, - IFIMPL(release) fuseCall::helper<&FuseAppBase::release>, - IFIMPL(fsync) fuseCall::helper<&FuseAppBase::fsync>, - IFIMPL(setxattr) fuseCall::helper<&FuseAppBase::setxattr>, - IFIMPL(getxattr) fuseCall::helper<&FuseAppBase::getxattr>, - IFIMPL(listxattr) fuseCall::helper<&FuseAppBase::listxattr>, - IFIMPL(removexattr) fuseCall::helper<&FuseAppBase::removexattr>, - IFIMPL(opendir) fuseCall::helper<&FuseAppBase::opendir>, - IFIMPL(readdir) fuseCall::helper<&FuseAppBase::readdir>, - IFIMPL(releasedir) fuseCall::helper<&FuseAppBase::releasedir>, - IFIMPL(fsyncdir) fuseCall::helper<&FuseAppBase::fsyncdir>, + fuseCall::GetHelper(open), + fuseCall::GetHelper(read), + fuseCall::GetHelper(write), + fuseCall::GetHelper(statfs), + fuseCall::GetHelper(flush), + fuseCall::GetHelper(release), + fuseCall::GetHelper(fsync), + fuseCall::GetHelper(setxattr), + fuseCall::GetHelper(getxattr), + fuseCall::GetHelper(listxattr), + fuseCall::GetHelper(removexattr), + fuseCall::GetHelper(opendir), + fuseCall::GetHelper(readdir), + fuseCall::GetHelper(releasedir), + fuseCall::GetHelper(fsyncdir), fuseInit, fuseDestroy, - IFIMPL(access) fuseCall::helper<&FuseAppBase::access>, - IFIMPL(create) fuseCall::helper<&FuseAppBase::create>, - IFIMPL(fgetattr) fuseCall::helper<&FuseAppBase::ftruncate>, - IFIMPL(fgetattr) fuseCall::helper<&FuseAppBase::fgetattr>, + fuseCall::GetHelper(access), + fuseCall::GetHelper(create), + fuseCall::GetHelper(ftruncate), + fuseCall::GetHelper(fgetattr), #if (FUSE_MINOR_VERSION >= 6) - IFIMPL(lock) fuseCall::helper<&FuseAppBase::lock>, - IFIMPL(utimens) fuseCall::helper<&FuseAppBase::utimens>, - IFIMPL(bmap) fuseCall::helper<&FuseAppBase::bmap>, + fuseCall::GetHelper(lock), + fuseCall::GetHelper(utimens), + fuseCall::GetHelper(bmap), #if (FUSE_MINOR_VERSION >= 8) 0, // flag_nullpath_ok #if (FUSE_MINOR_VERSION >= 9) @@ -108,13 +108,13 @@ class FuseAppBase { 0, // flag_utime_omit_ok #endif 0, // flag_reserved - IFIMPL(ioctl) fuseCall::helper<&FuseAppBase::ioctl>, - IFIMPL(poll) fuseCall::helper<&FuseAppBase::poll>, + fuseCall::GetHelper(ioctl), + fuseCall::GetHelper(poll), #if (FUSE_MINOR_VERSION >= 9) - IFIMPL(write_buf) fuseCall::helper<&FuseAppBase::write_buf>, - IFIMPL(read_buf) fuseCall::helper<&FuseAppBase::read_buf>, - IFIMPL(flock) fuseCall::helper<&FuseAppBase::flock>, - IFIMPL(fallocate) fuseCall::helper<&FuseAppBase::fallocate>, + fuseCall::GetHelper(write_buf), + fuseCall::GetHelper(read_buf), + fuseCall::GetHelper(flock), + fuseCall::GetHelper(fallocate), #endif #endif #endif @@ -129,6 +129,13 @@ class FuseAppBase { template class fuseCall { public: + typedef int (*WrapperFunc)(Args...); + template + static WrapperFunc getHelper(bool implemented) + { + auto func = &helper; + return implemented ? func : NULL; + } template static int helper(Args ... a) { -- cgit v1.2.3