[Rcpp-commits] r793 - in pkg/Rcpp: inst inst/unitTests src src/Rcpp src/Rcpp/internal src/Rcpp/traits

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Feb 28 14:52:46 CET 2010


Author: romain
Date: 2010-02-28 14:52:46 +0100 (Sun, 28 Feb 2010)
New Revision: 793

Added:
   pkg/Rcpp/src/Rcpp/Vector.h
Removed:
   pkg/Rcpp/src/CharacterVector.cpp
   pkg/Rcpp/src/Rcpp/CharacterVector.h
   pkg/Rcpp/src/Rcpp/ExpressionVector.h
   pkg/Rcpp/src/Rcpp/MatrixColumn.h
   pkg/Rcpp/src/Rcpp/MatrixRow.h
   pkg/Rcpp/src/Rcpp/SEXP_Vector.h
   pkg/Rcpp/src/Rcpp/SimpleVector.h
   pkg/Rcpp/src/Rcpp/VectorBase.h
Modified:
   pkg/Rcpp/inst/ChangeLog
   pkg/Rcpp/inst/unitTests/runit.GenericVector.R
   pkg/Rcpp/inst/unitTests/runit.IntegerVector.R
   pkg/Rcpp/src/ExpressionVector.cpp
   pkg/Rcpp/src/Rcpp.h
   pkg/Rcpp/src/Rcpp/Promise.h
   pkg/Rcpp/src/Rcpp/exceptions.h
   pkg/Rcpp/src/Rcpp/internal/Proxy_Iterator.h
   pkg/Rcpp/src/Rcpp/traits/r_type_traits.h
Log:
more generic Rcpp::Vector<int RTYPE> instead of previous templates SimpleVector, SEXP_Vector and CharacterVector

Modified: pkg/Rcpp/inst/ChangeLog
===================================================================
--- pkg/Rcpp/inst/ChangeLog	2010-02-27 15:41:38 UTC (rev 792)
+++ pkg/Rcpp/inst/ChangeLog	2010-02-28 13:52:46 UTC (rev 793)
@@ -1,5 +1,12 @@
 2010-02-24  Romain Francois <romain at r-enthusiasts.com>
 
+    * src/Rcpp/Vector.h : more generic code for vectors. All vector 
+    types are now generated from the template Rcpp::Vector<int RTYPE>
+    where RTYPE is one of INTSXP, LGLSXP, REALSXP, RAWSXP, STRSXP, 
+    VECSXP or EXPRSXP. 
+
+2010-02-24  Romain Francois <romain at r-enthusiasts.com>
+
 	* src/Rcpp/exceptions.h: some exception classes factored out 
 	
 	* src/Rcpp/VectorBase.h: now a template, using the 

Modified: pkg/Rcpp/inst/unitTests/runit.GenericVector.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.GenericVector.R	2010-02-27 15:41:38 UTC (rev 792)
+++ pkg/Rcpp/inst/unitTests/runit.GenericVector.R	2010-02-28 13:52:46 UTC (rev 793)
@@ -159,7 +159,7 @@
 	'
 	List list(x) ;
 	list.push_back( 10 ) ;
-	list.push_back( Named( "foo", "bar" ) ) ;
+	list.push_back( "bar", "foo" ) ;
 	return list ;
 	', Rcpp = TRUE, includes = "using namespace Rcpp;" )
 	d <- list( x = 1:10, y = letters[1:10] )
@@ -175,7 +175,7 @@
 	'
 	List list(x) ;
 	list.push_front( 10 ) ;
-	list.push_front( Named( "foo", "bar" ) ) ;
+	list.push_front( "bar", "foo" ) ;
 	return list ;
 	', Rcpp = TRUE, includes = "using namespace Rcpp;" )
 	d <- list( x = 1:10, y = letters[1:10] )
@@ -185,21 +185,21 @@
 		msg = "List.push_front" )
 }
 
-test.List.insert <- function(){
-	
-	funx <- cfunction( signature(x = "list"), 
-	'
-	List list(x) ;
-	list.insert( list.begin(), 10 ) ;
-	list.insert( list.end(), Named("foo", "bar" ) ) ;
-	return list ;
-	', Rcpp = TRUE, includes = "using namespace Rcpp;" )
-	d <- list( x = 1:10, y = letters[1:10] )
-	res <- funx( d )
-	checkEquals( res,
-		list( 10L, x = 1:10, y = letters[1:10], foo = "bar" ), 
-		msg = "List.insert" )
-}
+# test.List.insert <- function(){
+# 	
+# 	funx <- cfunction( signature(x = "list"), 
+# 	'
+# 	List list(x) ;
+# 	list.insert( list.begin(), 10 ) ;
+# 	list.insert( list.end(), Named("foo", "bar" ) ) ;
+# 	return list ;
+# 	', Rcpp = TRUE, includes = "using namespace Rcpp;" )
+# 	d <- list( x = 1:10, y = letters[1:10] )
+# 	res <- funx( d )
+# 	checkEquals( res,
+# 		list( 10L, x = 1:10, y = letters[1:10], foo = "bar" ), 
+# 		msg = "List.insert" )
+# }
 
 test.List.erase <- function(){
 	

Modified: pkg/Rcpp/inst/unitTests/runit.IntegerVector.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.IntegerVector.R	2010-02-27 15:41:38 UTC (rev 792)
+++ pkg/Rcpp/inst/unitTests/runit.IntegerVector.R	2010-02-28 13:52:46 UTC (rev 793)
@@ -147,7 +147,7 @@
 test.IntegerVector.names.indexing <- function(){
 	funx <- cfunction(signature(x = "integer"), '
 		IntegerVector y(x) ;
-		return wrap( y["foo"]) ;
+		return wrap( y["foo"] ) ;
 	', Rcpp = TRUE, includes = "using namespace Rcpp;"  )
 	x <- c( "foo" = 1L, "bar" = 2L )
 	checkEquals( funx( x ), 1L, msg = "IntegerVector names based indexing" )
@@ -163,3 +163,91 @@
 	checkEquals( funx(), 0:3, msg = "IntegerVector comma initialization" )
 }
 
+test.IntegerVector.push.back <- function(){
+	funx <- cfunction(signature(x = "integer"), '
+	IntegerVector y(x) ;
+	y.push_back( 5 ) ;
+	return y ;', 
+		Rcpp=TRUE, verbose=FALSE, includes = "using namespace Rcpp;" )
+	checkEquals( funx(1:4), 1:5, msg = "IntegerVector push back" )
+	
+	x <- 1:4
+	names(x) <- letters[1:4]
+	
+	target <- 1:5
+	names(target) <- c( letters[1:4], "")
+	checkEquals( funx(x), target, msg = "IntegerVector push back names" )
+}
+
+test.IntegerVector.push.front <- function(){
+	funx <- cfunction(signature(x = "integer"), '
+	IntegerVector y(x) ;
+	y.push_front( 5 ) ;
+	return y ;', 
+		Rcpp=TRUE, verbose=FALSE, includes = "using namespace Rcpp;" )
+	checkEquals( funx(1:4), c(5L,1:4), msg = "IntegerVector push front" )
+
+	x <- 1:4
+	names(x) <- letters[1:4]
+	
+	target <- c( 5L, 1:4 )
+	names(target) <- c( "", letters[1:4])
+	
+	checkEquals( funx(x), target, msg = "IntegerVector push front names" )
+}
+
+test.IntegerVector.insert <- function(){
+	funx <- cfunction(signature(x = "integer"), '
+	IntegerVector y(x) ;
+	y.insert( 0, 5 ) ;
+	y.insert( 2, 7 ) ;
+	return y ;', 
+		Rcpp=TRUE, verbose=FALSE, includes = "using namespace Rcpp;" )
+	checkEquals( funx(1:4), c(5L,1L, 7L, 2:4), msg = "IntegerVector insert" )
+	
+	x <- 1:4
+	names(x) <- letters[1:4]
+	
+	target <- c( 5L, 1L, 7L, 2:4 )
+	names(target) <- c( "", "a", "", letters[2:4])
+	
+	checkEquals( funx(x), target, msg = "IntegerVector insert names" )
+	
+}
+
+test.IntegerVector.erase <- function(){
+	funx <- cfunction(signature(x = "integer"), '
+	IntegerVector y(x) ;
+	y.erase(2) ;
+	return y ;', 
+		Rcpp=TRUE, verbose=FALSE, includes = "using namespace Rcpp;" )
+	checkEquals( funx(1:4), c(1L, 2L, 4L), msg = "IntegerVector erase" )
+	
+	x <- 1:4
+	names(x) <- letters[1:4]
+	
+	target <- c(1L, 2L, 4L)
+	names(target) <- c( "a", "b", "d" )
+	
+	checkEquals( funx(x), target, msg = "IntegerVector erase" )
+	
+}
+
+test.IntegerVector.erase <- function(){
+	funx <- cfunction(signature(x = "integer"), '
+	IntegerVector y(x) ;
+	y.erase(1,2) ;
+	return y ;', 
+		Rcpp=TRUE, verbose=FALSE, includes = "using namespace Rcpp;" )
+	checkEquals( funx(1:4), c(1L, 4L), msg = "IntegerVector erase" )
+	
+	x <- 1:4
+	names(x) <- letters[1:4]
+	
+	target <- c(1L, 4L)
+	names(target) <- c( "a", "d" )
+	
+	checkEquals( funx(x), target, msg = "IntegerVector erase" )
+	
+}
+

Deleted: pkg/Rcpp/src/CharacterVector.cpp
===================================================================
--- pkg/Rcpp/src/CharacterVector.cpp	2010-02-27 15:41:38 UTC (rev 792)
+++ pkg/Rcpp/src/CharacterVector.cpp	2010-02-28 13:52:46 UTC (rev 793)
@@ -1,150 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// CharacterVector.cpp: Rcpp R/C++ interface class library -- character 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 <Rcpp/CharacterVector.h>
-#include <Rcpp/exceptions.h>
-
-namespace Rcpp{
-
-CharacterVector::CharacterVector() : Base(){}
-
-CharacterVector::CharacterVector(const CharacterVector& other) : Base(other.asSexp()){}
-
-CharacterVector& CharacterVector::operator=(const CharacterVector& other ){
-	setSEXP( other.asSexp() ) ;
-	return *this ;
-}
-
-CharacterVector::CharacterVector(SEXP x) throw(not_compatible) : Base(x) {}
-
-CharacterVector::CharacterVector(const size_t& size) : Base(size){}
-
-CharacterVector::CharacterVector( const std::string& x) : Base(1) {
-	SET_STRING_ELT( m_sexp, 0, Rf_mkChar( x.c_str() ) ) ;
-}
-
-CharacterVector::CharacterVector( const std::vector<std::string>& x): Base() {
-	assign( x.begin(), x.end() ) ;
-}
-
-CharacterVector::CharacterVector( const Dimension& dims): Base(dims){}
-
-/* proxy stuff */
-
-internal::VectorElement_Proxy<STRSXP>::VectorElement_Proxy(CharacterVector& v, int i) :
-	parent(v), index(i){}
-
-internal::VectorElement_Proxy<STRSXP>::VectorElement_Proxy(const VectorElement_Proxy& other) :
-	parent(other.parent), index(other.index){}
-
-internal::VectorElement_Proxy<STRSXP>::VectorElement_Proxy::operator SEXP() const{
-	return STRING_ELT( parent, index ) ;
-}
-
-internal::VectorElement_Proxy<STRSXP>::VectorElement_Proxy::operator /*const*/ char*() const {
-	return const_cast<char*>( CHAR(STRING_ELT( parent, index )) );
-}
-
-// CharacterVector::Proxy::operator std::string() const {
-// 	return std::string( CHAR(STRING_ELT( parent, index )) );
-// }
-
-internal::VectorElement_Proxy<STRSXP>& internal::VectorElement_Proxy<STRSXP>::VectorElement_Proxy::operator=( const VectorElement_Proxy& rhs){
-	SET_STRING_ELT( parent, index, STRING_ELT( rhs.parent, rhs.index) ) ;
-	return *this ;
-}
-
-internal::VectorElement_Proxy<STRSXP>& internal::VectorElement_Proxy<STRSXP>::VectorElement_Proxy::operator+=( const std::string& rhs){
-	std::string full( CHAR(STRING_ELT(parent,index)) ) ;
-	full += rhs ;
-	SET_STRING_ELT( parent, index, Rf_mkChar( full.c_str() ) ) ;
-	return *this ;
-}
-
-internal::VectorElement_Proxy<STRSXP>& internal::VectorElement_Proxy<STRSXP>::VectorElement_Proxy::operator+=( const VectorElement_Proxy& rhs){
-	std::string full( CHAR(STRING_ELT(parent,index)) ) ;
-	full += CHAR(STRING_ELT( rhs.parent, rhs.index)) ;
-	SET_STRING_ELT( parent, index, Rf_mkChar(full.c_str()) ) ;
-	return *this ;
-}
-
-internal::VectorElement_Proxy<STRSXP>& internal::VectorElement_Proxy<STRSXP>::VectorElement_Proxy::operator=( const std::string& rhs){
-	SET_STRING_ELT( parent, index, Rf_mkChar( rhs.c_str() ) ) ;
-	return *this ;
-}
-
-std::ostream& operator<<(std::ostream& os, const internal::VectorElement_Proxy<STRSXP>& proxy) {
-    os << std::string(proxy) ;
-    return os;
-}
-
-const CharacterVector::Proxy CharacterVector::operator[](int i) const throw(index_out_of_bounds){
-	return Proxy(const_cast<CharacterVector&>(*this), offset(i) ) ;
-}                                          
-
-CharacterVector::Proxy CharacterVector::operator[](const std::string& name) throw(index_out_of_bounds) {
-	return Proxy(*this, offset(name) ) ;
-}
-
-const CharacterVector::Proxy CharacterVector::operator[](const std::string& name) const throw(index_out_of_bounds){
-	return Proxy(const_cast<CharacterVector&>(*this), offset(name) ) ;
-}                                          
-
-CharacterVector::Proxy CharacterVector::operator[](int i) throw(index_out_of_bounds) {
-	return Proxy(*this, offset(i) ) ;
-}
-
-
-CharacterVector::Proxy CharacterVector::operator()( const size_t& i) throw(index_out_of_bounds){
-	return Proxy(*this, offset(i) ) ;
-}
-
-CharacterVector::Proxy CharacterVector::operator()( const size_t& i, const size_t&j ) throw(index_out_of_bounds,not_a_matrix){
-	return Proxy(*this, offset(i,j) ) ;
-}
-
-void internal::VectorElement_Proxy<STRSXP>::swap( VectorElement_Proxy& other){
-	SEXP tmp = PROTECT( STRING_ELT(parent, index)) ;
-	SET_STRING_ELT( parent, index, STRING_ELT(other.parent, other.index) ) ;
-	SET_STRING_ELT( other.parent, other.index, tmp ) ;
-	UNPROTECT(1) ;
-}
-
-namespace internal{
-
-std::string operator+( const std::string& x, const VectorElement_Proxy<STRSXP>& y ){
-	return x + static_cast<const char*>(y) ;
-}
-	
-}
-} // namespace Rcpp
-
-
-namespace std{
-	template<> 
-	void swap< Rcpp::internal::VectorElement_Proxy<STRSXP> >( 
-		Rcpp::internal::VectorElement_Proxy<STRSXP>& a, 
-		Rcpp::internal::VectorElement_Proxy<STRSXP>& b){
-	a.swap(b) ;
-}
-} ;
-
-

Modified: pkg/Rcpp/src/ExpressionVector.cpp
===================================================================
--- pkg/Rcpp/src/ExpressionVector.cpp	2010-02-27 15:41:38 UTC (rev 792)
+++ pkg/Rcpp/src/ExpressionVector.cpp	2010-02-28 13:52:46 UTC (rev 793)
@@ -19,47 +19,37 @@
 // You should have received a copy of the GNU General Public License
 // along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
 
-#include <Rcpp/ExpressionVector.h>
+#include <Rcpp/Vector.h>
+#include <Rcpp/Environment.h>
 
 namespace Rcpp{
-	
-	ExpressionVector::parse_error::parse_error() throw(){}
-	ExpressionVector::parse_error::~parse_error() throw(){}
-	const char* ExpressionVector::parse_error::what() const throw(){ return "parse error" ; }
-	
-	ExpressionVector::ExpressionVector(SEXP x) throw(not_compatible) : ExpressionVector_Base(x) {}
-	ExpressionVector::ExpressionVector(const size_t& size) : ExpressionVector_Base(size) {}
-	
-	ExpressionVector::ExpressionVector(const std::string& code) throw(parse_error) : ExpressionVector_Base() {
+namespace internal{
+
+	template <> 
+	SEXP vector_from_string<EXPRSXP>( const std::string& code ){
 		ParseStatus status;
 		SEXP expr = PROTECT( Rf_mkString( code.c_str() ) );
 		SEXP res  = PROTECT( R_ParseVector(expr, -1, &status, R_NilValue));
 		switch( status ){
 		case PARSE_OK:
-			setSEXP( res) ;
 			UNPROTECT( 2) ;
+			return(res) ;
 			break;
 		default:
 			UNPROTECT(2) ;
 			throw parse_error() ;
 		}
+		return R_NilValue ; /* -Wall */
 	}
-        
-	ExpressionVector::ExpressionVector( const ExpressionVector& other ) : ExpressionVector_Base() {
-		setSEXP( other.asSexp() ) ;
-	}
 	
-	ExpressionVector& ExpressionVector::operator=( const ExpressionVector& other){
-		setSEXP( other.asSexp() ) ;
-		return *this ;
-	}
+	SEXP eval_methods< ::Rcpp::Vector<EXPRSXP> >::eval(){
+		SEXP xp = ( static_cast< ::Rcpp::Vector<EXPRSXP>& >(*this) ).asSexp() ;
+		return try_catch( ::Rf_lcons( ::Rf_install( "eval" ) , ::Rf_cons( xp, R_NilValue) ) ) ;
+	} ;
+	SEXP eval_methods< ::Rcpp::Vector<EXPRSXP> >::eval( const ::Rcpp::Environment& env ){
+		SEXP xp = ( static_cast< ::Rcpp::Vector<EXPRSXP>& >(*this) ).asSexp() ;
+		return try_catch( ::Rf_lcons( ::Rf_install( "eval" ) , ::Rf_cons( xp, ::Rf_cons(env.asSexp(), R_NilValue)) ) ) ;
+	} ;
 	
-	SEXP ExpressionVector::eval() throw(Evaluator::eval_error){
-		return Evaluator::run( Rf_lcons( Rf_install( "eval" ) , Rf_cons( m_sexp, R_NilValue) )) ;
-	}
-	
-	SEXP ExpressionVector::eval(const Environment& env) throw(Evaluator::eval_error){
-		return Evaluator::run( Rf_lcons( Rf_install( "eval" ) , Rf_cons( m_sexp, Rf_cons(env.asSexp(), R_NilValue)) ) ) ;
-	}
-
-} // namespace 
+} // namespace internal
+} // namespace Rcpp 

Deleted: pkg/Rcpp/src/Rcpp/CharacterVector.h
===================================================================
--- pkg/Rcpp/src/Rcpp/CharacterVector.h	2010-02-27 15:41:38 UTC (rev 792)
+++ pkg/Rcpp/src/Rcpp/CharacterVector.h	2010-02-28 13:52:46 UTC (rev 793)
@@ -1,272 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// CharacterVector.h: Rcpp R/C++ interface class library -- character 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/>.
-
-#ifndef Rcpp_CharacterVector_h
-#define Rcpp_CharacterVector_h
-
-#include <RcppCommon.h>
-#include <Rcpp/exceptions.h>
-#include <Rcpp/VectorBase.h>
-#include <Rcpp/MatrixRow.h>
-#include <Rcpp/MatrixColumn.h>
-#include <Rcpp/Dimension.h>
-#include <Rcpp/r_cast.h>
-
-namespace Rcpp{ 
-
-	class CharacterVector ;
-	
-namespace internal{
-	
-	template<> class VectorElement_Proxy<STRSXP>{
-	public:
-		/**
-		 * Creates a proxy
-		 *
-		 * @param v reference to the associated character vector
-		 * @param index index 
-		 */
-		VectorElement_Proxy( CharacterVector& v, int index ) ;
-		VectorElement_Proxy( const VectorElement_Proxy& other ) ;
-		
-		/**
-		 * lhs use. Assign the value of the referred element to 
-		 * the current content of the element referred by the 
-		 * rhs proxy
-		 *
-		 * @param rhs another proxy, possibly from another vector
-		 */
-		VectorElement_Proxy& operator=(const VectorElement_Proxy& rhs) ;
-		
-		/**
-		 * lhs use. Assigns the value of the referred element
-		 * of the character vector
-		 *
-		 * @param rhs new content for the element referred by this proxy
-		 */
-		VectorElement_Proxy& operator=(const std::string& rhs) ;
-		
-		/**
-		 * lhs use. Adds the content of the rhs proxy to the 
-		 * element this proxy refers to.
-		 */
-		VectorElement_Proxy& operator+=(const VectorElement_Proxy& rhs) ;
-		
-		/**
-		 * lhs use. Adds the string to the element this proxy refers to
-		 */
-		VectorElement_Proxy& operator+=(const std::string& rhs) ;
-		
-		/**
-		 * rhs use. Retrieves the current value of the 
-		 * element this proxy refers to.
-		 */
-		operator SEXP() const ;
-		
-		/**
-		 * rhs use. Retrieves the current value of the 
-		 * element this proxy refers to and convert it to a 
-		 * C string
-		 */
-		operator /*const */ char*() const ;
-		
-		/**
-		 * Prints the element this proxy refers to to an 
-		 * output stream
-		 */
-		friend std::ostream& operator<<(std::ostream& os, const VectorElement_Proxy& proxy);
-		friend std::string operator+( const std::string& x, const VectorElement_Proxy& proxy);
-		
-		void swap( VectorElement_Proxy& other ) ;
-		friend class CharacterVector ;
-		
-		CharacterVector& parent; 
-		int index ;
-		inline void move( int n ){ index += n ;}
-	} ;
-	
-}
-	
-	
-/**
- * Representation of character vectors (STRSXP)
- */
-class CharacterVector : public VectorBase<CharacterVector> {     
-public:
-
-	const static int r_type = STRSXP ;
-	typedef VectorBase<CharacterVector> Base ;
-	
-	typedef internal::VectorElement_Proxy<STRSXP> Proxy ;
-	typedef internal::Proxy_Iterator<CharacterVector,Proxy> iterator ;
-	
-	typedef Proxy value_type ;
-	typedef MatrixRow<CharacterVector> Row ;
-	typedef MatrixColumn<CharacterVector> Column ;
-	typedef Proxy reference ;
-	
-	/**
-	 * Default constructor. Sets the underlying object to NULL
-	 */
-	CharacterVector() ;
-	
-	/**
-	 * Copy constructor. Grab the underlying SEXP from the copied
-	 * object. This does not make a copy of the SEXP.
-	 */
-	CharacterVector( const CharacterVector& other ) ;
-	
-	/**
-	 * Assign the underlying object to be the same as the copied object
-	 * This does not make a copy of the object
-	 */
-	CharacterVector& operator=( const CharacterVector& other ) ;
-	
-	internal::ListInitialization<iterator,std::string> operator=( const std::string& x){
-		SET_STRING_ELT( m_sexp, 0, Rf_mkChar( x.c_str() ) ) ;
-		return internal::ListInitialization<iterator,std::string>( iterator(*this, 1) ) ; 
-	}
-	
-	/**
-	 * encapsulates an R object
-	 *
-	 * @param x R object, presumably a character vector (STRSXP)
-	 *
-	 * @throw not_compatible if the R object can not be converted
-	 *        to a character vector
-	 */
-	CharacterVector( SEXP x) throw(not_compatible);
-	
-	/**
-	 * Creates a new character vector of the requested length
-	 */
-	CharacterVector( const size_t& size) ;
-	
-	/** 
-	 * Creates a new character vector of length 1 containing the 
-	 * given string
-	 */
-	CharacterVector( const std::string& x );
-	
-	/**
-	 * Creates a character vector by copying the strings of the input vector
-	 */
-	CharacterVector( const std::vector<std::string>& x );
-	
-	/**
-	 * Creates a character vector of the requested dimensions
-	 */
-	CharacterVector( const Dimension& dims) ;
-	
-	/**
-	 * Range based constructor. InputIterator must be an iterator 
-	 * over std::string
-	 */
-	template <typename InputIterator>
-	CharacterVector( InputIterator first, InputIterator last): Base() {
-		assign( first, last ) ;
-	}
-	
-#ifdef HAS_INIT_LISTS
-	/**
-	 * Initializer list constructor. Copies the strings
-	 *
-	 * Example: CharacterVector x = { "foo", "bar" } ;
-	 */
-	CharacterVector( std::initializer_list<std::string> list ) : Base() {
-		assign( list.begin(), list.end() ) ;
-	}
-#endif
-	
-	/**
-	 * Returns a proxy to the given element of the character vector
-	 * The proxy can then be used to get or set the undelting value
-	 */
-	const Proxy operator[]( int i ) const throw(index_out_of_bounds);
-	
-	/**
-	 * Returns a proxy to the given element of the character vector
-	 * The proxy can then be used to get or set the undelting value
-	 */
-	Proxy operator[]( int i ) throw(index_out_of_bounds);
-
-	const Proxy operator[]( const std::string& name) const throw(index_out_of_bounds); 
-	Proxy operator[]( const std::string& name ) throw(index_out_of_bounds);
-
-	/* '(' indexing */
-	/**
-	 * Returns a proxy to the given element of the character vector
-	 * The proxy can then be used to get or set the undelting value
-	 *
-	 * @throw index_out_of_bounds when the given index is invalid
-	 */
-	Proxy operator()( const size_t& i) throw(index_out_of_bounds) ;
-	
-	/**
-	 * Returns a proxy to the given element of the character vector, 
-	 * expressed in terms of matrix-style indexing. 
-	 * 
-	 * The proxy can then be used to get or set the undelting value
-	 *
-	 * @throw not_a_matrix if the underlying object is not a matrix
-	 * @throw index_out_of_bounds when the given indices do not produce a valid offset
-	 */
-	Proxy operator()( const size_t& i, const size_t& j) throw(index_out_of_bounds,not_a_matrix) ;
-
-	inline iterator begin() { return iterator(*this, 0 ) ; }
-	
-	inline iterator end() { return iterator(*this,::Rf_length(m_sexp));}
-	
-	template <typename InputIterator>
-	void assign( InputIterator first, InputIterator last){
-		size_t size = std::distance( first, last ) ;
-		SEXP x = m_sexp ;
-		bool update = false ;
-		if( Rf_isNull(m_sexp) || static_cast<size_t>(length()) != size ){
-			x = Rf_allocVector( STRSXP, size ) ;
-			update = true ;
-		}
-		std::string y ;
-		for( size_t i=0; i<size; i++, ++first){
-			y.assign( *first ) ;
-			SET_STRING_ELT( x, i, Rf_mkChar(y.c_str())) ;
-		}
-		if( update ) setSEXP(x) ;
-	}
-
-	inline Row row( int i ){ return Row( *this, i ) ; }
-	inline Column column( int i ){ return Column( *this, i ) ; }
-
-} ;
-
-typedef CharacterVector StringVector ;
-
-} // namespace
-
-namespace std{
-	template<> void swap< Rcpp::internal::VectorElement_Proxy<STRSXP> >(
-		Rcpp::internal::VectorElement_Proxy<STRSXP>& a, 
-		Rcpp::internal::VectorElement_Proxy<STRSXP>& b) ;
-}
-
-
-
-#endif

Deleted: pkg/Rcpp/src/Rcpp/ExpressionVector.h
===================================================================
--- pkg/Rcpp/src/Rcpp/ExpressionVector.h	2010-02-27 15:41:38 UTC (rev 792)
+++ pkg/Rcpp/src/Rcpp/ExpressionVector.h	2010-02-28 13:52:46 UTC (rev 793)
@@ -1,55 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// ExpressionVector.h: Rcpp R/C++ interface class library -- expression 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/>.
-
-#ifndef Rcpp_ExpressionVector_h
-#define Rcpp_ExpressionVector_h
-
-#include <RcppCommon.h>
-#include <Rcpp/SEXP_Vector.h>
-
-namespace Rcpp{ 
-
-/* lazyness typedef */
-typedef SEXP_Vector<EXPRSXP> ExpressionVector_Base ;
-
-class ExpressionVector : public ExpressionVector_Base {     
-public:
-	class parse_error : public std::exception{
-	public:
-		parse_error() throw();
-		virtual ~parse_error() throw();
-	        virtual const char* what() const throw() ;
-	} ;
-	
-	ExpressionVector(SEXP x) throw(not_compatible);
-	ExpressionVector(const size_t& size) ;
-	ExpressionVector(const std::string& code) throw(parse_error) ;
-	ExpressionVector(const ExpressionVector& other) ;
-	ExpressionVector& operator=(const ExpressionVector& other) ;
-	
-	SEXP eval() throw(Evaluator::eval_error) ;
-	SEXP eval(const Environment& env) throw(Evaluator::eval_error);
-
-} ;
-
-} // namespace
-
-#endif

Deleted: pkg/Rcpp/src/Rcpp/MatrixColumn.h
===================================================================
--- pkg/Rcpp/src/Rcpp/MatrixColumn.h	2010-02-27 15:41:38 UTC (rev 792)
+++ pkg/Rcpp/src/Rcpp/MatrixColumn.h	2010-02-28 13:52:46 UTC (rev 793)
@@ -1,75 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// MatrixColumn.h: Rcpp R/C++ interface class library -- columns of matrices
-//
-// 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__MatrixColumn_h
-#define Rcpp__MatrixColumn_h
-
-#include <RcppCommon.h>
-#include <Rcpp/VectorBase.h>
-#include <Rcpp/exceptions.h>
-
-namespace Rcpp{
-
-template <typename VECTOR>
-class MatrixColumn {
-public:
-
-	typedef typename VECTOR::reference reference ;
-	typedef typename VECTOR::value_type value_type ;
-	typedef typename VECTOR::iterator iterator ;
-	
-	MatrixColumn( VECTOR& object, int i ) : parent(object), index(i){
-		if( ! ::Rf_isMatrix(parent) ) throw not_a_matrix() ;
-		if( i < 0 || i >= parent.ncol() ) throw index_out_of_bounds() ;
-	}
-	
-	MatrixColumn( const MatrixColumn& other ) : parent(other.parent), index(other.index){} ;
-	
-	MatrixColumn& operator=( MatrixColumn& other ){
-		parent = other.parent ;
-		index  = other.index ;
-	}
-	
-	reference operator[]( const int& i ){
-		/* TODO: should we cache nrow and ncol */
-		return parent[ index * parent.ncol() + i ] ;
-	}
-	
-	iterator begin(){
-		return parent.begin() + index * parent.ncol() ;
-	}
-	
-	iterator end(){
-		return parent.begin() + index * parent.ncol() + parent.nrow() ;
-	}
-	
-	inline int size() const {
-		return parent.nrow() ;
-	}
-	
-private:
-	VECTOR& parent; 
-	int index ;
-} ;
-	
-	
-} // namespace Rcpp
-#endif

Deleted: pkg/Rcpp/src/Rcpp/MatrixRow.h
===================================================================
--- pkg/Rcpp/src/Rcpp/MatrixRow.h	2010-02-27 15:41:38 UTC (rev 792)
+++ pkg/Rcpp/src/Rcpp/MatrixRow.h	2010-02-28 13:52:46 UTC (rev 793)
@@ -1,121 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// MatrixRow.h: Rcpp R/C++ interface class library -- rows of matrices
-//
-// 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__MatrixRow_h
-#define Rcpp__MatrixRow_h
-
-#include <RcppCommon.h>
-#include <Rcpp/exceptions.h>
-#include <Rcpp/VectorBase.h>
-
-namespace Rcpp{
-
-template <typename VECTOR>
-class MatrixRow {
-public:
-
-	typedef typename VECTOR::reference reference ;
-	typedef typename VECTOR::value_type value_type ;
-	
-	class iterator {
-	public:
-		typedef int difference_type ;
-		typedef typename VECTOR::reference reference ;
-		typedef typename VECTOR::value_type value_type ;
-		typedef value_type* pointer ;
-	
-		typedef std::random_access_iterator_tag iterator_category ;
-		
-		iterator( MatrixRow& row_, int index_ ) : row(row_), index(index_){}
-		
-		iterator& operator++(){ index++; }
-		iterator& operator++(int) { index++; }
-	
-		iterator& operator--(){ index-- ; } 
-		iterator& operator--(int){ index-- ;}
-		                    
-		iterator operator+(difference_type n) const { return iterator( row, index + n ) ; }
-		iterator operator-(difference_type n) const { return iterator( row, index - n ) ; }
-		
-		iterator& operator+=(difference_type n) { index += n ;} 
-		iterator& operator-=(difference_type n) { index -= n ;} 
-        	
-		reference operator*() {
-			return row[index] ;
-		}
-		pointer operator->(){
-			return &row[index] ;
-		}
-		
-		bool operator==( const iterator& other) { return index == other.index ; } 
-		bool operator!=( const iterator& other) { return index != other.index ; }
-		bool operator<( const iterator& other ) { return index < other.index ;}
-		bool operator>( const iterator& other ) { return index > other.index ;}
-		bool operator<=( const iterator& other ) { return index <= other.index ; }
-		bool operator>=( const iterator& other ) { return index >= other.index ; }
-		
-		difference_type operator-(const iterator& other) {
-			return index - other.index ;
-		}
-		
-	private:
-		MatrixRow& row ;
-		int index ;
-	} ;
-	
-	MatrixRow( VECTOR& object, int i ) : parent(object), index(i){
-		if( ! ::Rf_isMatrix(parent) ) throw not_a_matrix() ;
-		if( i < 0 || i >= parent.nrow() ) throw index_out_of_bounds() ;
-	}
-	
-	MatrixRow( const MatrixRow& other ) : parent(other.parent), index(other.index){} ;
-	                          
-	MatrixRow& operator=( MatrixRow& other ){
-		parent = other.parent ;
-		index = other.index ;
-		return *this ;
-	}
-	
-	reference operator[]( const int& i ){
-		/* TODO: should we cache nrow and ncol */
-		return parent[ index + i * parent.nrow() ] ;
-	}
-	
-	inline iterator begin(){
-		return iterator( *this, 0 ) ;
-	}
-	
-	inline iterator end(){
-		return iterator( *this, size() ) ;
-	}
-	
-	inline int size() const {
-		return parent.ncol() ;
-	}
-	
-private:
-	VECTOR& parent; 
-	int index ;
-} ;
-	
-	
-} // namespace Rcpp
-#endif

Modified: pkg/Rcpp/src/Rcpp/Promise.h
===================================================================
--- pkg/Rcpp/src/Rcpp/Promise.h	2010-02-27 15:41:38 UTC (rev 792)
+++ pkg/Rcpp/src/Rcpp/Promise.h	2010-02-28 13:52:46 UTC (rev 793)
@@ -23,8 +23,7 @@
 #define Rcpp_Promise_h
 
 #include <RcppCommon.h>
-
-#include <Rcpp/ExpressionVector.h>
+#include <Rcpp/Vector.h>
 #include <Rcpp/Environment.h>
 #include <Rcpp/RObject.h>
 

Deleted: pkg/Rcpp/src/Rcpp/SEXP_Vector.h
===================================================================
--- pkg/Rcpp/src/Rcpp/SEXP_Vector.h	2010-02-27 15:41:38 UTC (rev 792)
+++ pkg/Rcpp/src/Rcpp/SEXP_Vector.h	2010-02-28 13:52:46 UTC (rev 793)
@@ -1,411 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// SEXP_Vector.h: Rcpp R/C++ interface class library -- template for expression vector and generic vector
-//
-// 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_SEXP_Vector_h
-#define Rcpp_SEXP_Vector_h
-
-#include <RcppCommon.h>
-#include <Rcpp/exceptions.h>
-#include <Rcpp/VectorBase.h>
-#include <Rcpp/MatrixRow.h>
-#include <Rcpp/MatrixColumn.h>
-#include <Rcpp/Environment.h>
-#include <Rcpp/Dimension.h>
-
-namespace Rcpp{
-
-template <int RTYPE>
-class SEXP_Vector : public VectorBase< SEXP_Vector<RTYPE> > {
-public:
-	const static int r_type = RTYPE ;
-	class NameProxy ;
-	class Proxy ;
-	typedef VectorBase< SEXP_Vector<RTYPE> > Base ;
-	
-	class Proxy {
-	public:
-		Proxy( SEXP_Vector& v, size_t i ) : parent(v), index(i){} ;
-		
-		Proxy& operator=(SEXP rhs) { 
-			set(rhs) ;
-			return *this ;
-		}
-		
-		Proxy& operator=(const Proxy& rhs) {
-			set(rhs.get());
-			return *this ;	
-		}
-               
-		template <typename T>
-		Proxy& operator=( const T& rhs){
-			set( wrap(rhs) ) ;
-			return *this; 
-		}
-		
-		inline operator SEXP() const { return get() ; }
-		template <typename U> operator U(){
-			return as<U>( get() ) ;
-		}
-		
-		void swap(Proxy& other){
-			SEXP tmp = PROTECT( get() ) ;
-			set( other.get() ) ;
-			other.set( tmp ) ;
-			UNPROTECT(1) ;
-		}
-		
-		SEXP_Vector& parent; 
-		size_t index ;
-		inline void move(int n) { index += n ; }
-	private:
-		inline void set(SEXP x) { SET_VECTOR_ELT( parent, index, x ) ;} 
-		inline SEXP get() const { return VECTOR_ELT(parent, index ); } 
-	} ;
-	
-	typedef internal::Proxy_Iterator<SEXP_Vector<RTYPE>,Proxy> iterator ;
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/rcpp -r 793


More information about the Rcpp-commits mailing list