[Rcpp-commits] r4523 - in pkg/Rcpp: . inst/include inst/include/Rcpp inst/include/Rcpp/platform inst/include/Rcpp/traits
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Sep 20 01:02:24 CEST 2013
Author: romain
Date: 2013-09-20 01:02:23 +0200 (Fri, 20 Sep 2013)
New Revision: 4523
Added:
pkg/Rcpp/inst/include/Rcpp/longlong.h
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/inst/include/Rcpp/platform/compiler.h
pkg/Rcpp/inst/include/Rcpp/traits/r_sexptype_traits.h
pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h
pkg/Rcpp/inst/include/Rcpp/traits/wrap_type_traits.h
pkg/Rcpp/inst/include/RcppCommon.h
Log:
isolate handling of long long in a separate file. We might choose not to include this file by default
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2013-09-19 17:07:35 UTC (rev 4522)
+++ pkg/Rcpp/ChangeLog 2013-09-19 23:02:23 UTC (rev 4523)
@@ -1,3 +1,8 @@
+2013-09-20 Romain Francois <romain at r-enthusiasts.com>
+
+ * include/Rcpp/longlong.h: isolate all handling of long long
+ in a separate file which we might choose not to include by default
+
2013-09-19 Romain Francois <romain at r-enthusiasts.com>
* include/Rcpp/traits/r_sexptype_traits.h : unsigned int wrapped as REALSXP
Added: pkg/Rcpp/inst/include/Rcpp/longlong.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/longlong.h (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/longlong.h 2013-09-19 23:02:23 UTC (rev 4523)
@@ -0,0 +1,75 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
+//
+// longlong.h: Rcpp R/C++ interface class library -- long long support
+//
+// Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois
+//
+// This file is part of Rcpp.
+//
+// Rcpp is free software: you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// Rcpp 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 Rcpp. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef RCPP_LONG_LONG_H
+#define RCPP_LONG_LONG_H
+
+// long long and unssigned long long support.
+//
+// given the current restriction of what might go to CRAN
+// we can only use long long if we are running a gcc compatible (e.g. clang)
+// compiler and the type is actually available (hence the test for __LONG_LONG_MAX__)
+// even then, we cannot use long long as is, we first have to "hide" it
+// behind the __extension__ so that -pedantic stops giving warnings about
+// compliance with C++98
+//
+// client code may use the facilities we provide for long long (wrap, etc ...)
+// but not using long long directly, because then it is not CRAN proof.
+// So client code must use the rcpp_long_long_type and rcpp_ulong_long_type
+// types
+//
+// e.g. code like this is not good:
+//
+// long long x = 2 ;
+//
+// but code like this is CRAN proof
+//
+// rcpp_long_long_type x = 2 ;
+//
+// Note that if you don't distribute your code to CRAN and you don't use the
+// -pedantic option, then you can use long long
+#if defined(__GNUC__) && defined(__LONG_LONG_MAX__)
+ __extension__ typedef long long int rcpp_long_long_type;
+ __extension__ typedef unsigned long long int rcpp_ulong_long_type;
+ #define RCPP_HAS_LONG_LONG_TYPES
+#endif
+
+#if defined(RCPP_HAS_LONG_LONG_TYPES)
+
+namespace Rcpp{
+namespace traits{
+
+ template<> struct r_sexptype_traits<rcpp_long_long_type>{ enum{ rtype = REALSXP } ; } ;
+ template<> struct r_sexptype_traits<rcpp_ulong_long_type>{ enum{ rtype = REALSXP } ; } ;
+
+ template<> struct r_type_traits<rcpp_long_long_type>{ typedef r_type_primitive_tag r_category ; } ;
+ template<> struct r_type_traits< std::pair<const std::string,rcpp_long_long_type> >{ typedef r_type_primitive_tag r_category ; } ;
+ template<> struct r_type_traits<rcpp_ulong_long_type>{ typedef r_type_primitive_tag r_category ; } ;
+ template<> struct r_type_traits< std::pair<const std::string,rcpp_ulong_long_type> >{ typedef r_type_primitive_tag r_category ; } ;
+
+ template <> struct wrap_type_traits<rcpp_long_long_type> { typedef wrap_type_primitive_tag wrap_category; } ;
+ template <> struct wrap_type_traits<rcpp_ulong_long_type> { typedef wrap_type_primitive_tag wrap_category; } ;
+}
+}
+#endif
+
+
+#endif
Modified: pkg/Rcpp/inst/include/Rcpp/platform/compiler.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/platform/compiler.h 2013-09-19 17:07:35 UTC (rev 4522)
+++ pkg/Rcpp/inst/include/Rcpp/platform/compiler.h 2013-09-19 23:02:23 UTC (rev 4523)
@@ -177,34 +177,4 @@
#define RCPP_HAS_DEMANGLING
#endif
-// long long and unssigned long long support.
-//
-// given the current restriction of what might go to CRAN
-// we can only use long long if we are running a gcc compatible (e.g. clang)
-// compiler and the type is actually available (hence the test for __LONG_LONG_MAX__)
-// even then, we cannot use long long as is, we first have to "hide" it
-// behind the __extension__ so that -pedantic stops giving warnings about
-// compliance with C++98
-//
-// client code may use the facilities we provide for long long (wrap, etc ...)
-// but not using long long directly, because then it is not CRAN proof.
-// So client code must use the rcpp_long_long_type and rcpp_ulong_long_type
-// types
-//
-// e.g. code like this is not good:
-//
-// long long x = 2 ;
-//
-// but code like this is CRAN proof
-//
-// rcpp_long_long_type x = 2 ;
-//
-// Note that if you don't distribute your code to CRAN and you don't use the
-// -pedantic option, then you can use long long
-#if defined(__GNUC__) && defined(__LONG_LONG_MAX__)
- __extension__ typedef long long int rcpp_long_long_type;
- __extension__ typedef unsigned long long int rcpp_ulong_long_type;
- #define RCPP_HAS_LONG_LONG_TYPES
#endif
-
-#endif
Modified: pkg/Rcpp/inst/include/Rcpp/traits/r_sexptype_traits.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/r_sexptype_traits.h 2013-09-19 17:07:35 UTC (rev 4522)
+++ pkg/Rcpp/inst/include/Rcpp/traits/r_sexptype_traits.h 2013-09-19 23:02:23 UTC (rev 4523)
@@ -59,17 +59,10 @@
template<> struct r_sexptype_traits<short>{ enum{ rtype = INTSXP } ; } ;
template<> struct r_sexptype_traits<unsigned short>{ enum{ rtype = INTSXP } ; } ;
-/* long long int */
-#ifdef RCPP_HAS_LONG_LONG_TYPES
-template<> struct r_sexptype_traits<rcpp_long_long_type>{ enum{ rtype = REALSXP } ; } ;
-template<> struct r_sexptype_traits<rcpp_ulong_long_type>{ enum{ rtype = REALSXP } ; } ;
-#endif
-
/* std::complex */
template<> struct r_sexptype_traits< std::complex<double> >{ enum{ rtype = CPLXSXP } ; } ;
template<> struct r_sexptype_traits< std::complex<float> >{ enum{ rtype = CPLXSXP } ; } ;
-
/**
* Indicates if a primitive type needs a static_cast
*/
Modified: pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h 2013-09-19 17:07:35 UTC (rev 4522)
+++ pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h 2013-09-19 23:02:23 UTC (rev 4523)
@@ -178,14 +178,6 @@
template<> struct r_type_traits< std::complex<float> >{ typedef r_type_primitive_tag r_category ; } ;
template<> struct r_type_traits< std::pair<const std::string,std::complex<float> > >{ typedef r_type_primitive_tag r_category ; } ;
-/* long long int */
-#ifdef RCPP_HAS_LONG_LONG_TYPES
-template<> struct r_type_traits<rcpp_long_long_type>{ typedef r_type_primitive_tag r_category ; } ;
-template<> struct r_type_traits< std::pair<const std::string,rcpp_long_long_type> >{ typedef r_type_primitive_tag r_category ; } ;
-template<> struct r_type_traits<rcpp_ulong_long_type>{ typedef r_type_primitive_tag r_category ; } ;
-template<> struct r_type_traits< std::pair<const std::string,rcpp_ulong_long_type> >{ typedef r_type_primitive_tag r_category ; } ;
-#endif
-
} // traits
} // Rcpp
Modified: pkg/Rcpp/inst/include/Rcpp/traits/wrap_type_traits.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/wrap_type_traits.h 2013-09-19 17:07:35 UTC (rev 4522)
+++ pkg/Rcpp/inst/include/Rcpp/traits/wrap_type_traits.h 2013-09-19 23:02:23 UTC (rev 4523)
@@ -91,11 +91,6 @@
template <> struct wrap_type_traits<short> { typedef wrap_type_primitive_tag wrap_category; } ;
template <> struct wrap_type_traits<unsigned short> { typedef wrap_type_primitive_tag wrap_category; } ;
-#ifdef RCPP_HAS_LONG_LONG_TYPES
-template <> struct wrap_type_traits<rcpp_long_long_type> { typedef wrap_type_primitive_tag wrap_category; } ;
-template <> struct wrap_type_traits<rcpp_ulong_long_type> { typedef wrap_type_primitive_tag wrap_category; } ;
-#endif
-
template <typename T> struct wrap_type_traits< Rcpp::object<T> > { typedef wrap_type_module_object_pointer_tag wrap_category; } ;
Modified: pkg/Rcpp/inst/include/RcppCommon.h
===================================================================
--- pkg/Rcpp/inst/include/RcppCommon.h 2013-09-19 17:07:35 UTC (rev 4522)
+++ pkg/Rcpp/inst/include/RcppCommon.h 2013-09-19 23:02:23 UTC (rev 4523)
@@ -133,4 +133,6 @@
#include <Rcpp/iostream/Rstreambuf.h>
#include <Rcpp/iostream/Rostream.h>
+#include <Rcpp/longlong.h>
+
#endif
More information about the Rcpp-commits
mailing list