[Rcpp-commits] r3296 - in pkg/Rcpp: . inst/include/Rcpp/internal
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Nov 6 20:25:18 CET 2011
Author: romain
Date: 2011-11-06 20:25:18 +0100 (Sun, 06 Nov 2011)
New Revision: 3296
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/inst/include/Rcpp/internal/export.h
pkg/Rcpp/inst/include/Rcpp/internal/wrap.h
Log:
as< std::vector<int64_t> > and as< std::vector<uint64_t> >
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2011-11-06 18:55:26 UTC (rev 3295)
+++ pkg/Rcpp/ChangeLog 2011-11-06 19:25:18 UTC (rev 3296)
@@ -6,6 +6,9 @@
e.g. OUT Class::foo( ... ) const
* include/Rcpp/modules/Module_generated_Pointer_CppMethod.h: idem
* include/Rcpp/as.h: deal with as<int64_t> and as<uint64_t>
+ * include/Rcpp/internal/export.h : deal with as< some_container<int64_t> >
+ and as< some_container<uint64_t> > where some_container is some container
+ that has iterators, e.g. std::vector
2011-10-31 Romain Francois <romain at r-enthusiasts.com>
Modified: pkg/Rcpp/inst/include/Rcpp/internal/export.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/internal/export.h 2011-11-06 18:55:26 UTC (rev 3295)
+++ pkg/Rcpp/inst/include/Rcpp/internal/export.h 2011-11-06 19:25:18 UTC (rev 3296)
@@ -66,6 +66,50 @@
}
}
+ /* iterators over int64_t */
+ template <typename InputIterator, typename value_type>
+ void export_range__dispatch( SEXP x, InputIterator first, ::Rcpp::traits::r_type_int64_tag ) {
+ int n = Rf_length(x) ;
+ if( Rf_inherits( x, "int64" ) ){
+ Rcpp::int64::LongVector<int64_t> data(x) ;
+ for( int i=0; i<n; i++, ++first){
+ *first = data.get(i) ;
+ }
+ } else if( TYPEOF(x) == INTSXP ){
+ int* p_i_x = INTEGER(x) ;
+ for( int i=0; i<n; i++, ++first){
+ *first = (int64_t)p_i_x[i] ;
+ }
+ } else if( TYPEOF(x) == REALSXP ){
+ double* p_d_x = REAL(x) ;
+ for( int i=0; i<n; i++, ++first){
+ *first = (int64_t)p_d_x[i] ;
+ }
+ }
+ }
+
+ /* iterators over uint64_t */
+ template <typename InputIterator, typename value_type>
+ void export_range__dispatch( SEXP x, InputIterator first, ::Rcpp::traits::r_type_uint64_tag ) {
+ int n = Rf_length(x) ;
+ if( Rf_inherits( x, "uint64" ) ){
+ Rcpp::int64::LongVector<uint64_t> data(x) ;
+ for( int i=0; i<n; i++, ++first){
+ *first = data.get(i) ;
+ }
+ } else if( TYPEOF(x) == INTSXP ){
+ int* p_i_x = INTEGER(x) ;
+ for( int i=0; i<n; i++, ++first){
+ *first = (uint64_t)p_i_x[i] ;
+ }
+ } else if( TYPEOF(x) == REALSXP ){
+ double* p_d_x = REAL(x) ;
+ for( int i=0; i<n; i++, ++first){
+ *first = (uint64_t)p_d_x[i] ;
+ }
+ }
+ }
+
template <typename InputIterator>
void export_range( SEXP x, InputIterator first ) {
export_range__dispatch<InputIterator,typename std::iterator_traits<InputIterator>::value_type>(
@@ -75,7 +119,6 @@
);
}
-
/* indexing */
template <typename T, typename value_type>
Modified: pkg/Rcpp/inst/include/Rcpp/internal/wrap.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/internal/wrap.h 2011-11-06 18:55:26 UTC (rev 3295)
+++ pkg/Rcpp/inst/include/Rcpp/internal/wrap.h 2011-11-06 19:25:18 UTC (rev 3296)
@@ -254,6 +254,10 @@
inline SEXP range_wrap_dispatch___impl( InputIterator first, InputIterator last, ::Rcpp::traits::r_type_int64_tag){
return Rcpp::int64::LongVector<T>( std::distance(first, last), first, last ) ;
}
+template <typename InputIterator, typename T>
+inline SEXP range_wrap_dispatch___impl( InputIterator first, InputIterator last, ::Rcpp::traits::r_type_uint64_tag){
+ return Rcpp::int64::LongVector<T>( std::distance(first, last), first, last ) ;
+}
/**
More information about the Rcpp-commits
mailing list