[Rcpp-commits] r2229 - in pkg/Rcpp: inst/include/Rcpp inst/include/Rcpp/generated inst/include/Rcpp/sugar/operators src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Sep 28 15:21:46 CEST 2010


Author: romain
Date: 2010-09-28 15:21:46 +0200 (Tue, 28 Sep 2010)
New Revision: 2229

Modified:
   pkg/Rcpp/inst/include/Rcpp/Fast.h
   pkg/Rcpp/inst/include/Rcpp/generated/Vector__create.h
   pkg/Rcpp/inst/include/Rcpp/sugar/operators/times.h
   pkg/Rcpp/src/RObject.cpp
Log:
need to keep a reference to the origin vector in Fast, otherwise bad things happen

Modified: pkg/Rcpp/inst/include/Rcpp/Fast.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/Fast.h	2010-09-28 11:36:01 UTC (rev 2228)
+++ pkg/Rcpp/inst/include/Rcpp/Fast.h	2010-09-28 13:21:46 UTC (rev 2229)
@@ -27,16 +27,16 @@
 class Fast {
 public:
     typedef typename VECTOR::stored_type value_type ;
-    Fast( VECTOR& v) : data( v.begin() ), n(v.size()) {} 
-    Fast( const VECTOR& v) : data( v.begin() ), n(v.size()) {} 
     
+    Fast( const VECTOR& v_) : v(v_), data( v_.begin() ){} 
+    
     inline value_type& operator[]( int i){ return data[i] ; }
     inline value_type& operator[]( int i) const { return data[i] ; }
-    inline int size() const { return n ; }
+    inline int size() const { return v.size() ; }
     
 private:
+    const VECTOR& v ;
     value_type* data ;
-    int n ;
     
 } ;
 }

Modified: pkg/Rcpp/inst/include/Rcpp/generated/Vector__create.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/generated/Vector__create.h	2010-09-28 11:36:01 UTC (rev 2228)
+++ pkg/Rcpp/inst/include/Rcpp/generated/Vector__create.h	2010-09-28 13:21:46 UTC (rev 2229)
@@ -191,7 +191,6 @@
 	
 	template <typename T1, typename T2, typename T3, typename T4>
 	static Vector create(const T1& t1, const T2& t2, const T3& t3, const T4& t4){
-		RCPP_DEBUG( "  Vector::create[4]( ) " ) ; 
 		return create__dispatch( typename traits::integral_constant<bool, 
   traits::is_named<T1>::value  ||  traits::is_named<T2>::value  ||  traits::is_named<T3>::value  ||  traits::is_named<T4>::value  
 		>::type(), t1, t2, t3, t4 ) ;  		
@@ -217,7 +216,6 @@
 	template <typename T1, typename T2, typename T3, typename T4>
 	static Vector create__dispatch( traits::true_type, const T1& t1, const T2& t2, const T3& t3, const T4& t4){
 		Vector res( 4 ) ;
-		RCPP_DEBUG( "  Vector::create_dispatch[4]( true ) " ) ; 
 		SEXP names = PROTECT( ::Rf_allocVector( STRSXP, 4 ) ) ;
 		int index = 0 ;
 		iterator it( res.begin() );

Modified: pkg/Rcpp/inst/include/Rcpp/sugar/operators/times.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/operators/times.h	2010-09-28 11:36:01 UTC (rev 2228)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/operators/times.h	2010-09-28 13:21:46 UTC (rev 2229)
@@ -36,7 +36,8 @@
 		typedef typename Rcpp::traits::Extractor< RTYPE, RHS_NA, RHS_T>::type RHS_EXT ;
 		
 		Times_Vector_Vector( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) : 
-			lhs(lhs_.get_ref()), rhs(rhs_.get_ref()) {}
+			lhs(lhs_.get_ref()), rhs(rhs_.get_ref()) {
+		}
 		
 		inline STORAGE operator[]( int i ) const {
 			STORAGE lhs_ = lhs[i] ;

Modified: pkg/Rcpp/src/RObject.cpp
===================================================================
--- pkg/Rcpp/src/RObject.cpp	2010-09-28 11:36:01 UTC (rev 2228)
+++ pkg/Rcpp/src/RObject.cpp	2010-09-28 13:21:46 UTC (rev 2229)
@@ -122,7 +122,13 @@
 }
 
 void RObject::AttributeProxy::set(SEXP x) const{
-	Rf_setAttrib( parent, Rf_install(attr_name.c_str()), x ) ;
+#if RCPP_DEBUG_LEVEL > 0
+RCPP_DEBUG_1( "RObject::AttributeProxy::set() before = <%p>", parent.asSexp() ) ;
+SEXP res = Rf_setAttrib( parent, Rf_install(attr_name.c_str()), x ) ;
+RCPP_DEBUG_1( "RObject::AttributeProxy::set() after  = <%p>", res ) ;
+#else
+Rf_setAttrib( parent, Rf_install(attr_name.c_str()), x ) ;
+#endif
 }
 
 RObject::AttributeProxy::AttributeProxy( const RObject& v, const std::string& name) :



More information about the Rcpp-commits mailing list