[Rcpp-commits] r562 - in pkg/src: . Rcpp

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Feb 2 11:41:24 CET 2010


Author: romain
Date: 2010-02-02 11:41:24 +0100 (Tue, 02 Feb 2010)
New Revision: 562

Removed:
   pkg/src/SimpleVector.cpp
Modified:
   pkg/src/Rcpp/LogicalVector.h
   pkg/src/Rcpp/SimpleVector.h
Log:
removed some code duplication and now LogicalVector is directly generated by the SimpleVector template rather than derived from it since wrap can handle iterators of bool

Modified: pkg/src/Rcpp/LogicalVector.h
===================================================================
--- pkg/src/Rcpp/LogicalVector.h	2010-02-02 10:30:11 UTC (rev 561)
+++ pkg/src/Rcpp/LogicalVector.h	2010-02-02 10:41:24 UTC (rev 562)
@@ -27,34 +27,8 @@
 
 namespace Rcpp{
 
-typedef SimpleVector<LGLSXP,int> LogicalVector_Base ;
+typedef SimpleVector<LGLSXP,int> LogicalVector ;
 
-class LogicalVector : public LogicalVector_Base{ 
-public:
-	LogicalVector() : LogicalVector_Base(){} ;
-	LogicalVector(SEXP x) : LogicalVector_Base(x){} ;
-	LogicalVector(const size_t& size) : LogicalVector_Base(size){}; 
-
-#ifdef HAS_INIT_LISTS
-	LogicalVector( std::initializer_list<int> list) : LogicalVector_Base(list){};
-	LogicalVector( std::initializer_list<bool> list) : LogicalVector_Base(){ 
-		bool_fill(list.begin(), list.end());
-	} ;
-#endif
-	
-private:
-	template <typename InputIterator>
-	void bool_fill( InputIterator first, InputIterator last){
-		size_t size = std::distance( first, last) ;
-		SEXP x = PROTECT( Rf_allocVector( LGLSXP, size ) );
-		std::transform( first, last, get_pointer<LGLSXP,int>(x), bool_to_Rboolean  ) ;
-		setSEXP( x ) ;
-		UNPROTECT(1) ;
-	}
-
-} ;
-
-
 } // namespace
 
 #endif

Modified: pkg/src/Rcpp/SimpleVector.h
===================================================================
--- pkg/src/Rcpp/SimpleVector.h	2010-02-02 10:30:11 UTC (rev 561)
+++ pkg/src/Rcpp/SimpleVector.h	2010-02-02 10:41:24 UTC (rev 562)
@@ -30,13 +30,6 @@
 
 namespace Rcpp{
 
-template <int sexptype, typename T> T* get_pointer(SEXP x){ throw std::exception( "not implemented" ) ; return static_cast<T*>(0); }
-template<> double* get_pointer<REALSXP,double>(SEXP x) ;
-template<> int* get_pointer<INTSXP,int>(SEXP x) ;
-template<> int* get_pointer<LGLSXP,int>(SEXP x) ;
-template<> Rcomplex* get_pointer<CPLXSXP,Rcomplex>(SEXP x) ;
-template<> Rbyte* get_pointer<RAWSXP,Rbyte>(SEXP x) ;
-
 template <int RTYPE, typename CTYPE>
 class SimpleVector : public VectorBase {
 public:
@@ -97,7 +90,7 @@
 	CTYPE* start ;
 	
 	virtual void update(){ 
-		start = get_pointer<RTYPE,CTYPE>(m_sexp) ;
+		start = internal::r_vector_start<RTYPE,CTYPE>(m_sexp) ;
 	}
 	
 	void init(){

Deleted: pkg/src/SimpleVector.cpp
===================================================================
--- pkg/src/SimpleVector.cpp	2010-02-02 10:30:11 UTC (rev 561)
+++ pkg/src/SimpleVector.cpp	2010-02-02 10:41:24 UTC (rev 562)
@@ -1,33 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// SimpleVector.h: Rcpp R/C++ interface class library -- simple vectors
-//
-// 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/>.
-
-#include <RcppCommon.h>
-#include <Rcpp/SimpleVector.h>
-
-namespace Rcpp{
-    	
-	template<> double* get_pointer<REALSXP,double>(SEXP x){ return REAL(x) ; }
-	template<> int* get_pointer<INTSXP,int>(SEXP x){ return INTEGER(x) ; }
-	template<> int* get_pointer<LGLSXP,int>(SEXP x){ return LOGICAL(x) ; }
-	template<> Rcomplex* get_pointer<CPLXSXP,Rcomplex>(SEXP x){ return COMPLEX(x) ; }
-	template<> Rbyte* get_pointer<RAWSXP,Rbyte>(SEXP x){ return RAW(x) ; }
-
-} // namespace 



More information about the Rcpp-commits mailing list