[Rcpp-commits] r4439 - in pkg/Rcpp: . inst/include/Rcpp/api/meat inst/include/Rcpp/internal

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Aug 22 08:13:34 CEST 2013


Author: romain
Date: 2013-08-22 08:13:34 +0200 (Thu, 22 Aug 2013)
New Revision: 4439

Added:
   pkg/Rcpp/inst/include/Rcpp/api/meat/export.h
Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/include/Rcpp/api/meat/meat.h
   pkg/Rcpp/inst/include/Rcpp/internal/export.h
Log:
added missing export_range__dispatch implementation

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2013-08-21 07:48:56 UTC (rev 4438)
+++ pkg/Rcpp/ChangeLog	2013-08-22 06:13:34 UTC (rev 4439)
@@ -1,3 +1,10 @@
+2013-08-22 Romain Francois <romain at r-enthusiasts.com>
+
+        * include/Rcpp/internal/export.h : added export_range__dispatch for the 
+        r_type_generic_tag tag. Meaning we can now use as< vector<T> > where 
+        T is not a primitive
+        * include/Rcpp/api/meat/export.h : implementation in meat because it needs as
+        
 2013-08-01 Romain Francois <romain at r-enthusiasts.com>
 
         * unitTests/cpp/wstring.cpp: fix to re-enable wstring test suite. 

Added: pkg/Rcpp/inst/include/Rcpp/api/meat/export.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/api/meat/export.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/api/meat/export.h	2013-08-22 06:13:34 UTC (rev 4439)
@@ -0,0 +1,40 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
+//
+// export.h: Rcpp R/C++ interface class library -- export implementations 
+//
+// 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_api_meat_export_h
+#define Rcpp_api_meat_export_h
+
+namespace Rcpp{ 
+namespace internal{
+        
+    template <typename InputIterator, typename value_type>
+    void export_range__dispatch( SEXP x, InputIterator first, ::Rcpp::traits::r_type_generic_tag ) {
+        R_len_t n = ::Rf_length(x) ;
+        for( R_len_t i=0; i<n; i++, ++first ){
+            *first = ::Rcpp::as<value_type>( VECTOR_ELT(x, i) ) ;
+        }
+    }
+                
+    
+} // namespace internal
+} // namespace Rcpp
+
+#endif

Modified: pkg/Rcpp/inst/include/Rcpp/api/meat/meat.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/api/meat/meat.h	2013-08-21 07:48:56 UTC (rev 4438)
+++ pkg/Rcpp/inst/include/Rcpp/api/meat/meat.h	2013-08-22 06:13:34 UTC (rev 4439)
@@ -29,5 +29,6 @@
 #include <Rcpp/api/meat/Matrix.h>
 #include <Rcpp/api/meat/Reference.h>
 #include <Rcpp/api/meat/is.h>
+#include <Rcpp/api/meat/export.h>
 
 #endif

Modified: pkg/Rcpp/inst/include/Rcpp/internal/export.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/internal/export.h	2013-08-21 07:48:56 UTC (rev 4438)
+++ pkg/Rcpp/inst/include/Rcpp/internal/export.h	2013-08-22 06:13:34 UTC (rev 4439)
@@ -47,27 +47,31 @@
     	
         /* iterating */
         
-        template <typename InputIterator, typename value_type>
-        	void export_range__impl( SEXP x, InputIterator first, ::Rcpp::traits::false_type ) {
-	    	const int RTYPE = ::Rcpp::traits::r_sexptype_traits<value_type>::rtype ;
-	    	typedef typename ::Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
-	    	SEXP y = PROTECT( ::Rcpp::r_cast<RTYPE>(x) ) ;
-	    	STORAGE* start = ::Rcpp::internal::r_vector_start<RTYPE>(y) ;
-	    	std::copy( start, start + ::Rf_length(y), first ) ;
-	    	UNPROTECT(1) ;
-        }
+		template <typename InputIterator, typename value_type>
+			void export_range__impl( SEXP x, InputIterator first, ::Rcpp::traits::false_type ) {
+			const int RTYPE = ::Rcpp::traits::r_sexptype_traits<value_type>::rtype ;
+			typedef typename ::Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
+			SEXP y = PROTECT( ::Rcpp::r_cast<RTYPE>(x) ) ;
+			STORAGE* start = ::Rcpp::internal::r_vector_start<RTYPE>(y) ;
+			std::copy( start, start + ::Rf_length(y), first ) ;
+			UNPROTECT(1) ;
+		}
         
-        template <typename InputIterator, typename value_type>
-        void export_range__impl( SEXP x, InputIterator first, ::Rcpp::traits::true_type ) {
-	    	const int RTYPE = ::Rcpp::traits::r_sexptype_traits<value_type>::rtype ;
-	    	typedef typename ::Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
-	    	SEXP y = PROTECT( ::Rcpp::r_cast<RTYPE>(x) ) ;
-	    	STORAGE* start = ::Rcpp::internal::r_vector_start<RTYPE>(y) ;
-	    	std::transform( start, start + ::Rf_length(y) , first, caster<STORAGE,value_type> ) ;
-	    	UNPROTECT(1) ;
+		template <typename InputIterator, typename value_type>
+		void export_range__impl( SEXP x, InputIterator first, ::Rcpp::traits::true_type ) {
+			const int RTYPE = ::Rcpp::traits::r_sexptype_traits<value_type>::rtype ;
+			typedef typename ::Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
+			SEXP y = PROTECT( ::Rcpp::r_cast<RTYPE>(x) ) ;
+			STORAGE* start = ::Rcpp::internal::r_vector_start<RTYPE>(y) ;
+			std::transform( start, start + ::Rf_length(y) , first, caster<STORAGE,value_type> ) ;
+			UNPROTECT(1) ;
         }
         
+        // implemented in meat
         template <typename InputIterator, typename value_type>
+        void export_range__dispatch( SEXP x, InputIterator first, ::Rcpp::traits::r_type_generic_tag ) ;
+		
+        template <typename InputIterator, typename value_type>
         void export_range__dispatch( SEXP x, InputIterator first, ::Rcpp::traits::r_type_primitive_tag ) {
 			export_range__impl<InputIterator,value_type>(
 				x, 



More information about the Rcpp-commits mailing list