[Rcpp-commits] r3286 - in pkg/Rcpp/inst: include include/Rcpp/traits unitTests unitTests/testRcppModule/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Nov 5 09:21:50 CET 2011
Author: romain
Date: 2011-11-05 09:21:49 +0100 (Sat, 05 Nov 2011)
New Revision: 3286
Modified:
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
pkg/Rcpp/inst/unitTests/runit.macros.R
pkg/Rcpp/inst/unitTests/testRcppModule/src/stdVector.cpp
Log:
attempt
Modified: pkg/Rcpp/inst/include/Rcpp/traits/r_sexptype_traits.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/r_sexptype_traits.h 2011-11-05 03:29:51 UTC (rev 3285)
+++ pkg/Rcpp/inst/include/Rcpp/traits/r_sexptype_traits.h 2011-11-05 08:21:49 UTC (rev 3286)
@@ -42,10 +42,10 @@
template<> struct r_sexptype_traits<unsigned int>{ enum{ rtype = INTSXP } ; } ;
template<> struct r_sexptype_traits<float>{ enum{ rtype = REALSXP } ; } ;
-/* long are represented as numeric vectors which allows more precision
- to be preserved than int */
-template<> struct r_sexptype_traits<long>{ enum{ rtype = REALSXP } ; } ;
-template<> struct r_sexptype_traits<unsigned long>{ enum{ rtype = REALSXP } ; } ;
+// /* long are represented as numeric vectors which allows more precision
+// to be preserved than int */
+// template<> struct r_sexptype_traits<long>{ enum{ rtype = REALSXP } ; } ;
+// template<> struct r_sexptype_traits<unsigned long>{ enum{ rtype = REALSXP } ; } ;
/* long double are represented as numeric vectors because we cannot do better in R
some precision will be lost though
@@ -57,11 +57,11 @@
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
+// /* 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 } ; } ;
Modified: pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h 2011-11-05 03:29:51 UTC (rev 3285)
+++ pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h 2011-11-05 08:21:49 UTC (rev 3286)
@@ -95,14 +95,7 @@
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 ; } ;
-/* long */
-template<> struct r_type_traits<long>{ typedef r_type_primitive_tag r_category ; } ;
-template<> struct r_type_traits< std::pair<const std::string,long> >{ typedef r_type_primitive_tag r_category ; } ;
-/* unsigned long */
-template<> struct r_type_traits<unsigned long>{ typedef r_type_primitive_tag r_category ; } ;
-template<> struct r_type_traits< std::pair<const std::string,unsigned long> >{ typedef r_type_primitive_tag r_category ; } ;
-
/* long double */
template<> struct r_type_traits<long double>{ typedef r_type_primitive_tag r_category ; } ;
template<> struct r_type_traits< std::pair<const std::string,long double> >{ typedef r_type_primitive_tag r_category ; } ;
@@ -114,7 +107,7 @@
/* unsigned short */
template<> struct r_type_traits<unsigned short>{ typedef r_type_primitive_tag r_category ; } ;
template<> struct r_type_traits< std::pair<const std::string,unsigned short> >{ typedef r_type_primitive_tag r_category ; } ;
-
+
/* std::complex<double> */
template<> struct r_type_traits< std::complex<double> >{ typedef r_type_primitive_tag r_category ; } ;
template<> struct r_type_traits< std::pair<const std::string,std::complex<double> > >{ typedef r_type_primitive_tag r_category ; } ;
@@ -131,9 +124,21 @@
// template<> struct r_type_traits< std::pair<const std::string,rcpp_ulong_long_type> >{ typedef r_type_primitive_tag r_category ; } ;
// #endif
+// /* long */
+// template<> struct r_type_traits<long>{ typedef r_type_primitive_tag r_category ; } ;
+// template<> struct r_type_traits< std::pair<const std::string,long> >{ typedef r_type_primitive_tag r_category ; } ;
+//
+// /* unsigned long */
+// template<> struct r_type_traits<unsigned long>{ typedef r_type_primitive_tag r_category ; } ;
+// template<> struct r_type_traits< std::pair<const std::string,unsigned long> >{ typedef r_type_primitive_tag r_category ; } ;
+
+
+
+
template<> struct r_type_traits<int64_t>{ typedef r_type_int64_tag r_category; } ;
template<> struct r_type_traits<uint64_t>{ typedef r_type_int64_tag r_category ; } ;
+
} // traits
} // Rcpp
Modified: pkg/Rcpp/inst/include/Rcpp/traits/wrap_type_traits.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/wrap_type_traits.h 2011-11-05 03:29:51 UTC (rev 3285)
+++ pkg/Rcpp/inst/include/Rcpp/traits/wrap_type_traits.h 2011-11-05 08:21:49 UTC (rev 3286)
@@ -49,12 +49,12 @@
*
* The default is "wrap_type_unknown_tag" and this is specialized
* for primitive types
- */
+ */
template <typename T> struct wrap_type_traits { typedef wrap_type_unknown_tag wrap_category; } ;
/**
* Total specialization for primitive types
- */
+ */
template <> struct wrap_type_traits<int> { typedef wrap_type_primitive_tag wrap_category; } ;
template <> struct wrap_type_traits<const int> { typedef wrap_type_primitive_tag wrap_category; } ;
@@ -70,13 +70,13 @@
template <> struct wrap_type_traits< std::complex<float> > { typedef wrap_type_primitive_tag wrap_category; } ;
template <> struct wrap_type_traits< std::complex<double> > { typedef wrap_type_primitive_tag wrap_category; } ;
-// FIXME : sometimes long = int64_t
-template <> struct wrap_type_traits<long> {
- typedef wrap_type_primitive_tag wrap_category;
-} ;
-template <> struct wrap_type_traits<unsigned long> {
- typedef wrap_type_primitive_tag wrap_category;
-} ;
+// // FIXME : sometimes long = int64_t
+// template <> struct wrap_type_traits<long> {
+// typedef wrap_type_primitive_tag wrap_category;
+// } ;
+// template <> struct wrap_type_traits<unsigned long> {
+// typedef wrap_type_primitive_tag wrap_category;
+// } ;
template <> struct wrap_type_traits<long double> { typedef wrap_type_primitive_tag wrap_category; } ;
@@ -84,7 +84,7 @@
template <> struct wrap_type_traits<unsigned short> { typedef wrap_type_primitive_tag wrap_category; } ;
// #ifdef RCPP_HAS_LONG_LONG_TYPES
-// [romain] : don't think we need this anymore as we deal with int64_t and uint64_t below
+// [romain] : don't think we need this anymore as we deal with int64_t and uint64_t below
// 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
Modified: pkg/Rcpp/inst/include/RcppCommon.h
===================================================================
--- pkg/Rcpp/inst/include/RcppCommon.h 2011-11-05 03:29:51 UTC (rev 3285)
+++ pkg/Rcpp/inst/include/RcppCommon.h 2011-11-05 08:21:49 UTC (rev 3286)
@@ -41,6 +41,11 @@
# error "This compiler is not supported"
#endif
+/* we define this so that INT64_MAX, etc ... are defined */
+#define __STDC_LIMIT_MACROS
+#include <limits.h>
+
+
#include <Rcpp/config.h>
#include <Rcpp/macros/unroll.h>
#include <stdint.h>
@@ -119,7 +124,6 @@
#include <numeric>
#include <algorithm>
#include <complex>
-#include <limits.h>
#include <typeinfo>
#include <Rcpp/sprintf.h>
@@ -252,15 +256,15 @@
#include <typeinfo>
#endif
-#ifdef __GNUC__
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
-#ifdef 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
-#endif
+// #ifdef __GNUC__
+// #ifdef __GXX_EXPERIMENTAL_CXX0X__
+// #ifdef 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
+// #endif
// DO NOT CHANGE THE ORDER OF THESE INCLUDES
#include <Rcpp/traits/integral_constant.h>
Modified: pkg/Rcpp/inst/unitTests/runit.macros.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.macros.R 2011-11-05 03:29:51 UTC (rev 3285)
+++ pkg/Rcpp/inst/unitTests/runit.macros.R 2011-11-05 08:21:49 UTC (rev 3286)
@@ -218,7 +218,7 @@
}
### regression test for long long support
-test.long.long <- function(){
+test.int64 <- function(){
fx <- cxxfunction( signature(), '
return foo() ;
Modified: pkg/Rcpp/inst/unitTests/testRcppModule/src/stdVector.cpp
===================================================================
--- pkg/Rcpp/inst/unitTests/testRcppModule/src/stdVector.cpp 2011-11-05 03:29:51 UTC (rev 3285)
+++ pkg/Rcpp/inst/unitTests/testRcppModule/src/stdVector.cpp 2011-11-05 08:21:49 UTC (rev 3286)
@@ -30,6 +30,12 @@
double vec_front(vec *obj){ return obj->front() ; }
double vec_at(vec *obj, int i){ return obj->at(i) ; }
+int vec_size(vec* obj){ return obj->size(); }
+int vec_max_size(vec* obj){ return obj->max_size(); }
+int vec_capacity(vec* obj){ return obj->capacity(); }
+void vec_reserve(vec* obj, int n){ obj->reserve(n); }
+
+
RCPP_MODULE(stdVector){
using namespace Rcpp ;
@@ -40,11 +46,11 @@
.constructor()
// exposing member functions
- .method( "size", &vec::size)
- .method( "max_size", &vec::max_size)
- .method( "capacity", &vec::capacity)
+ .method( "size", &vec_size)
+ .method( "max_size", &vec_max_size)
+ .method( "capacity", &vec_capacity)
.method( "empty", &vec::empty)
- .method( "reserve", &vec::reserve)
+ .method( "reserve", &vec_reserve)
.method( "pop_back", &vec::pop_back )
.method( "clear", &vec::clear )
More information about the Rcpp-commits
mailing list