[Rcpp-commits] r787 - in pkg/Rcpp: inst/unitTests src src/Rcpp src/Rcpp/internal
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Feb 25 14:44:31 CET 2010
Author: romain
Date: 2010-02-25 14:44:31 +0100 (Thu, 25 Feb 2010)
New Revision: 787
Modified:
pkg/Rcpp/inst/unitTests/runit.clone.R
pkg/Rcpp/src/CharacterVector.cpp
pkg/Rcpp/src/Rcpp/CharacterVector.h
pkg/Rcpp/src/Rcpp/SEXP_Vector.h
pkg/Rcpp/src/Rcpp/SimpleVector.h
pkg/Rcpp/src/Rcpp/internal/Proxy_Iterator.h
Log:
numerous fixes
Modified: pkg/Rcpp/inst/unitTests/runit.clone.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.clone.R 2010-02-25 09:26:46 UTC (rev 786)
+++ pkg/Rcpp/inst/unitTests/runit.clone.R 2010-02-25 13:44:31 UTC (rev 787)
@@ -17,6 +17,9 @@
# You should have received a copy of the GNU General Public License
# along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
+.setUp <- function(){
+ require( inline )
+}
test.clone <- function(){
Modified: pkg/Rcpp/src/CharacterVector.cpp
===================================================================
--- pkg/Rcpp/src/CharacterVector.cpp 2010-02-25 09:26:46 UTC (rev 786)
+++ pkg/Rcpp/src/CharacterVector.cpp 2010-02-25 13:44:31 UTC (rev 787)
@@ -128,12 +128,16 @@
UNPROTECT(1) ;
}
-} // namespace Rcpp
+namespace internal{
-std::string operator+( const std::string& x, const Rcpp::internal::VectorElement_Proxy<STRSXP>& y ){
+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> >(
Modified: pkg/Rcpp/src/Rcpp/CharacterVector.h
===================================================================
--- pkg/Rcpp/src/Rcpp/CharacterVector.h 2010-02-25 09:26:46 UTC (rev 786)
+++ pkg/Rcpp/src/Rcpp/CharacterVector.h 2010-02-25 13:44:31 UTC (rev 787)
@@ -93,13 +93,12 @@
* 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 ;
- private:
CharacterVector& parent;
- public:
int index ;
inline void move( int n ){ index += n ;}
} ;
@@ -260,8 +259,6 @@
typedef CharacterVector StringVector ;
-std::string operator+( const std::string& x, const Rcpp::internal::VectorElement_Proxy<STRSXP>& y ) ;
-
} // namespace
namespace std{
Modified: pkg/Rcpp/src/Rcpp/SEXP_Vector.h
===================================================================
--- pkg/Rcpp/src/Rcpp/SEXP_Vector.h 2010-02-25 09:26:46 UTC (rev 786)
+++ pkg/Rcpp/src/Rcpp/SEXP_Vector.h 2010-02-25 13:44:31 UTC (rev 787)
@@ -72,9 +72,7 @@
UNPROTECT(1) ;
}
- private:
SEXP_Vector& parent;
- public:
size_t index ;
inline void move(int n) { index += n ; }
private:
Modified: pkg/Rcpp/src/Rcpp/SimpleVector.h
===================================================================
--- pkg/Rcpp/src/Rcpp/SimpleVector.h 2010-02-25 09:26:46 UTC (rev 786)
+++ pkg/Rcpp/src/Rcpp/SimpleVector.h 2010-02-25 13:44:31 UTC (rev 787)
@@ -43,13 +43,21 @@
SimpleVector() : Base(), start(0){}
- SimpleVector(SEXP x) throw(RObject::not_compatible) : Base(x){}
+ SimpleVector(SEXP x) throw(RObject::not_compatible) : Base(x), start(0) {
+ update_vector() ;
+ }
- SimpleVector( const size_t& size) : Base(size) {}
+ SimpleVector( const size_t& size) : Base(size), start(0) {
+ update_vector() ;
+ }
- SimpleVector( const Dimension& dims) : Base(dims) {}
+ SimpleVector( const Dimension& dims) : Base(dims), start(0) {
+ update_vector() ;
+ }
- SimpleVector( const SimpleVector& other) : Base( other.asSexp() ) {}
+ SimpleVector( const SimpleVector& other) : Base( other.asSexp() ), start(0) {
+ update_vector() ;
+ }
SimpleVector& operator=(const SimpleVector& other){
Base::setSEXP( other.asSexp() ) ;
@@ -62,7 +70,7 @@
}
template <typename InputIterator>
- SimpleVector( InputIterator first, InputIterator last) : Base(), start(){
+ SimpleVector( InputIterator first, InputIterator last) : Base(), start(0){
assign( first, last ) ;
}
@@ -97,6 +105,7 @@
SEXP x = PROTECT( r_cast<RTYPE>( wrap( first, last ) ) );
Base::setSEXP( x) ;
UNPROTECT(1) ;
+ update_vector() ;
}
Modified: pkg/Rcpp/src/Rcpp/internal/Proxy_Iterator.h
===================================================================
--- pkg/Rcpp/src/Rcpp/internal/Proxy_Iterator.h 2010-02-25 09:26:46 UTC (rev 786)
+++ pkg/Rcpp/src/Rcpp/internal/Proxy_Iterator.h 2010-02-25 13:44:31 UTC (rev 787)
@@ -56,10 +56,10 @@
}
inline Proxy_Iterator operator+(difference_type n) const {
- return iterator( proxy.parent, proxy.index + n) ;
+ return Proxy_Iterator( proxy.parent, proxy.index + n) ;
}
inline Proxy_Iterator operator-(difference_type n) const {
- return iterator( proxy.parent, proxy.index - n) ;
+ return Proxy_Iterator( proxy.parent, proxy.index - n) ;
}
inline Proxy_Iterator& operator+=(difference_type n) {
@@ -101,6 +101,8 @@
return other.proxy.index - proxy.index ;
}
+ inline int index() const { return proxy.index ; }
+
private:
PROXY proxy ;
} ;
More information about the Rcpp-commits
mailing list