[Rcpp-commits] r878 - in pkg/Rcpp: . inst inst/examples/FastLM src src/Rcpp/internal src/Rcpp/traits

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Mar 12 09:32:58 CET 2010


Author: romain
Date: 2010-03-12 09:32:57 +0100 (Fri, 12 Mar 2010)
New Revision: 878

Added:
   pkg/Rcpp/src/Rcpp/traits/is_convertible.h
   pkg/Rcpp/src/Rcpp/traits/same_type.h
Removed:
   pkg/Rcpp/src/Rcpp/internal/convertible.h
Modified:
   pkg/Rcpp/DESCRIPTION
   pkg/Rcpp/inst/ChangeLog
   pkg/Rcpp/inst/examples/FastLM/benchmark.r
   pkg/Rcpp/src/Rcpp/internal/wrap.h
   pkg/Rcpp/src/Rcpp/traits/r_sexptype_traits.h
   pkg/Rcpp/src/Rcpp/traits/r_type_traits.h
   pkg/Rcpp/src/Rcpp/traits/wrap_type_traits.h
   pkg/Rcpp/src/RcppCommon.h
Log:
fix compatbility with 64 bits and gcc 4.2

Modified: pkg/Rcpp/DESCRIPTION
===================================================================
--- pkg/Rcpp/DESCRIPTION	2010-03-11 17:30:33 UTC (rev 877)
+++ pkg/Rcpp/DESCRIPTION	2010-03-12 08:32:57 UTC (rev 878)
@@ -1,6 +1,6 @@
 Package: Rcpp
 Title: Rcpp R/C++ interface package
-Version: 0.7.8.1
+Version: 0.7.8.2
 Date: $Date$
 Author: Dirk Eddelbuettel and Romain Francois, with contributions 
  by Simon Urbanek and David Reiss; based on code written during 

Modified: pkg/Rcpp/inst/ChangeLog
===================================================================
--- pkg/Rcpp/inst/ChangeLog	2010-03-11 17:30:33 UTC (rev 877)
+++ pkg/Rcpp/inst/ChangeLog	2010-03-12 08:32:57 UTC (rev 878)
@@ -1,3 +1,14 @@
+2010-03-09  Romain Francois <romain at r-enthusiasts.com>
+
+	* src/Rcpp/traits/is_convertible.h: the detection is now performed without
+	the help of cxx0x or tr1 which makes it compatible with gcc 4.2
+	
+	* src/Rcpp/traits/is_same.h: new traits is_same to help detect if two types
+	are the same (not currently used)
+	
+	* src/Rcpp/traits/wrap_type_traits.h: use "unsigned int" instead of "size_t" 
+	in the template specializations (64 bit compatibility)
+
 2010-03-10  Dirk Eddelbuettel  <edd at debian.org>
 
 	* R/RcppLdPath.R: More specific about quote-protection of path on Windows

Modified: pkg/Rcpp/inst/examples/FastLM/benchmark.r
===================================================================
--- pkg/Rcpp/inst/examples/FastLM/benchmark.r	2010-03-11 17:30:33 UTC (rev 877)
+++ pkg/Rcpp/inst/examples/FastLM/benchmark.r	2010-03-12 08:32:57 UTC (rev 878)
@@ -23,7 +23,7 @@
 # along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
 
 source("lmArmadillo.R")
-source("lmGSL.R")
+# source("lmGSL.R")
 
 set.seed(42)
 n <- 25000
@@ -34,15 +34,17 @@
 
 N <- 100
 
-lmgsl <- lmGSL()
+# lmgsl <- lmGSL()
 lmarma <- lmArmadillo()
 
 tlm <- mean(replicate(N, system.time( lmfit <- lm(y ~ X - 1) )["elapsed"]), trim=0.05)
 tlmfit <- mean(replicate(N, system.time(lmfitfit <- lm.fit(X, y))["elapsed"]), trim=0.05)
-tlmgsl <- mean(replicate(N, system.time(lmgsl(y, X))["elapsed"]), trim=0.05)
+# tlmgsl <- mean(replicate(N, system.time(lmgsl(y, X))["elapsed"]), trim=0.05)
 tlmarma <- mean(replicate(N, system.time(lmarma(y, X))["elapsed"]), trim=0.05)
 
-res <- c(tlm, tlmfit, tlmgsl, tlmarma)
+res <- c(tlm, tlmfit, 
+	# tlmgsl, 
+	tlmarma)
 data <- t(data.frame(results=res, ratios=tlm/res))
 cat("For n=", n, " and k=", k, "\n", sep="")
 print(data)

Deleted: pkg/Rcpp/src/Rcpp/internal/convertible.h
===================================================================
--- pkg/Rcpp/src/Rcpp/internal/convertible.h	2010-03-11 17:30:33 UTC (rev 877)
+++ pkg/Rcpp/src/Rcpp/internal/convertible.h	2010-03-12 08:32:57 UTC (rev 878)
@@ -1,62 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-/* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */
-//
-// convertible.h: Rcpp R/C++ interface class library -- dispatch the 
-// implementation of is_convertible traits depending on whether we have
-// access to tr1 or c++0x
-//
-// Copyright (C) 2010	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_internal_is_convertible_h
-#define Rcpp_internal_is_convertible_h
-
-// this is a private header, do not include it directly
-
-#ifdef HAS_CXX0X
-// use the c++0x implementation
-#include <type_traits>
-namespace Rcpp{
-namespace internal{
-template <typename FROM, typename TO> struct is_convertible : 
-	public ::Rcpp::traits::integral_constant<bool,std::is_convertible<FROM,TO>::value>{} ;
-} // internal
-} // Rcpp
-#else
-#ifdef HAS_TR1
-#include <tr1/type_traits>
-// use the tr1 implementation
-namespace Rcpp{
-namespace internal{
-template <typename FROM, typename TO> struct is_convertible : 
-	public ::Rcpp::traits::integral_constant<bool,std::tr1::is_convertible<FROM,TO>::value>{} ;
-} // internal
-} // Rcpp
-#else
-// hope for the best
-namespace Rcpp{
-namespace internal{
-template <typename FROM, typename TO> struct is_convertible : 
-	public ::Rcpp::traits::true_type{} ;
-} // internal
-} // Rcpp
-#endif
-#endif
-
-
-
-#endif

Modified: pkg/Rcpp/src/Rcpp/internal/wrap.h
===================================================================
--- pkg/Rcpp/src/Rcpp/internal/wrap.h	2010-03-11 17:30:33 UTC (rev 877)
+++ pkg/Rcpp/src/Rcpp/internal/wrap.h	2010-03-12 08:32:57 UTC (rev 878)
@@ -506,7 +506,7 @@
  * The next step is to try implicit conversion to SEXP
  */
 template <typename T> SEXP wrap_dispatch_unknown_importable( const T& object, ::Rcpp::traits::false_type){
-	return wrap_dispatch_unknown( object, typename is_convertible<T,SEXP>::type() ) ;
+	return wrap_dispatch_unknown( object, typename ::Rcpp::traits::is_convertible<T,SEXP>::type() ) ;
 }
 
 /**

Added: pkg/Rcpp/src/Rcpp/traits/is_convertible.h
===================================================================
--- pkg/Rcpp/src/Rcpp/traits/is_convertible.h	                        (rev 0)
+++ pkg/Rcpp/src/Rcpp/traits/is_convertible.h	2010-03-12 08:32:57 UTC (rev 878)
@@ -0,0 +1,48 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
+/* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */
+//
+// is_convertible.h: Rcpp R/C++ interface class library -- type conversion detection
+//
+// Copyright (C) 2010	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__traits__is_convertible_h
+#define Rcpp__traits__is_convertible_h
+
+namespace Rcpp{
+namespace traits{
+
+	template<typename T, typename U> class is_convertible{
+		
+		typedef char Small ;
+		typedef struct { char dummy[2] ; } Big ;
+		static Small Test( const U& ) ;
+		static Big Test(...) ;
+		static T MakeT() ;
+		
+	public:
+		
+		typedef bool value_type ;
+		static const bool value = sizeof(Test(MakeT())) == sizeof(Small) ;
+		typedef integral_constant<bool,value> type ;
+		
+	} ;
+	
+}
+}
+
+#endif

Modified: pkg/Rcpp/src/Rcpp/traits/r_sexptype_traits.h
===================================================================
--- pkg/Rcpp/src/Rcpp/traits/r_sexptype_traits.h	2010-03-11 17:30:33 UTC (rev 877)
+++ pkg/Rcpp/src/Rcpp/traits/r_sexptype_traits.h	2010-03-12 08:32:57 UTC (rev 878)
@@ -38,7 +38,7 @@
 template<> struct r_sexptype_traits<Rcomplex>{ enum{ rtype = CPLXSXP } ; } ;
 template<> struct r_sexptype_traits<Rbyte>{ enum{ rtype = RAWSXP } ; } ;
 
-template<> struct r_sexptype_traits<size_t>{ enum{ rtype = INTSXP } ; } ;
+template<> struct r_sexptype_traits<unsigned int>{ enum{ rtype = INTSXP } ; } ;
 template<> struct r_sexptype_traits<float>{ enum{ rtype = REALSXP } ; } ;
 
 

Modified: pkg/Rcpp/src/Rcpp/traits/r_type_traits.h
===================================================================
--- pkg/Rcpp/src/Rcpp/traits/r_type_traits.h	2010-03-11 17:30:33 UTC (rev 877)
+++ pkg/Rcpp/src/Rcpp/traits/r_type_traits.h	2010-03-12 08:32:57 UTC (rev 878)
@@ -28,7 +28,7 @@
 
 /**
  * Identifies a primitive type that needs to special handling
- * int, double, size_t, Rbyte, Rcomplex
+ * int, double, Rbyte, Rcomplex
  */
 struct r_type_primitive_tag{} ;
 
@@ -76,7 +76,7 @@
 template<> struct r_type_traits< std::pair<const std::string,std::string> >{ typedef r_type_pairstring_string_tag r_category ; } ;
 template<> struct r_type_traits< std::pair<const std::string,char> >{ typedef r_type_pairstring_string_tag r_category ; } ;
 
-template<> struct r_type_traits< std::pair<const std::string,size_t> >{ typedef r_type_pairstring_primitive_tag r_category ; } ;
+template<> struct r_type_traits< std::pair<const std::string,unsigned int> >{ typedef r_type_pairstring_primitive_tag r_category ; } ;
 template<> struct r_type_traits< std::pair<const std::string,float> >{ typedef r_type_pairstring_primitive_tag r_category ; } ;
 
 template<> struct r_type_traits<int>{ typedef r_type_primitive_tag r_category ; } ;
@@ -87,7 +87,7 @@
 template<> struct r_type_traits<std::string>{ typedef r_type_string_tag r_category ; } ;
 template<> struct r_type_traits<char>{ typedef r_type_string_tag r_category ; } ;
 
-template<> struct r_type_traits<size_t>{ typedef r_type_primitive_tag r_category ; } ;
+template<> struct r_type_traits<unsigned int>{ typedef r_type_primitive_tag r_category ; } ;
 template<> struct r_type_traits<float>{ typedef r_type_primitive_tag r_category ; } ;
 template<> struct r_type_traits<const char*>{ typedef r_type_string_tag r_category ; } ;
 

Added: pkg/Rcpp/src/Rcpp/traits/same_type.h
===================================================================
--- pkg/Rcpp/src/Rcpp/traits/same_type.h	                        (rev 0)
+++ pkg/Rcpp/src/Rcpp/traits/same_type.h	2010-03-12 08:32:57 UTC (rev 878)
@@ -0,0 +1,35 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
+/* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */
+//
+// same_type.h: Rcpp R/C++ interface class library -- identifies if two types are the same
+//
+// Copyright (C) 2010	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__traits__same_type_traits__h
+#define Rcpp__traits__same_type_traits__h
+
+namespace Rcpp{
+namespace traits{
+
+	template <typename T, typename U> struct same_type : public false_type{} ;
+	template <typename T> struct same_type<T,T> : public true_type{} ;
+	
+}
+}
+
+#endif

Modified: pkg/Rcpp/src/Rcpp/traits/wrap_type_traits.h
===================================================================
--- pkg/Rcpp/src/Rcpp/traits/wrap_type_traits.h	2010-03-11 17:30:33 UTC (rev 877)
+++ pkg/Rcpp/src/Rcpp/traits/wrap_type_traits.h	2010-03-12 08:32:57 UTC (rev 878)
@@ -54,7 +54,7 @@
 template <> struct wrap_type_traits<double> { typedef wrap_type_primitive_tag wrap_category; } ;
 template <> struct wrap_type_traits<Rbyte> { typedef wrap_type_primitive_tag wrap_category; } ;
 template <> struct wrap_type_traits<Rcomplex> { typedef wrap_type_primitive_tag wrap_category; } ;
-template <> struct wrap_type_traits<size_t> { typedef wrap_type_primitive_tag wrap_category; } ;
+template <> struct wrap_type_traits<unsigned int> { typedef wrap_type_primitive_tag wrap_category; } ;
 template <> struct wrap_type_traits<bool> { typedef wrap_type_primitive_tag wrap_category; } ;
 template <> struct wrap_type_traits<std::string> { typedef wrap_type_primitive_tag wrap_category; } ;
 template <> struct wrap_type_traits<char> { typedef wrap_type_primitive_tag wrap_category; } ;

Modified: pkg/Rcpp/src/RcppCommon.h
===================================================================
--- pkg/Rcpp/src/RcppCommon.h	2010-03-11 17:30:33 UTC (rev 877)
+++ pkg/Rcpp/src/RcppCommon.h	2010-03-12 08:32:57 UTC (rev 878)
@@ -194,6 +194,8 @@
 
 // DO NOT CHANGE THE ORDER OF THESE INCLUDES
 #include <Rcpp/traits/integral_constant.h>
+#include <Rcpp/traits/same_type.h>
+#include <Rcpp/traits/is_convertible.h>
 #include <Rcpp/traits/has_iterator.h>
 #include <Rcpp/traits/has_na.h>
 #include <Rcpp/traits/storage_type.h>
@@ -204,7 +206,6 @@
 
 #include <Rcpp/internal/caster.h>
 #include <Rcpp/internal/r_vector.h>
-#include <Rcpp/internal/convertible.h>
 #include <Rcpp/r_cast.h>
 
 #include <Rcpp/internal/export.h>



More information about the Rcpp-commits mailing list