[Rcpp-commits] r2228 - in pkg/Rcpp: inst/include inst/include/Rcpp inst/include/Rcpp/generated inst/include/Rcpp/sugar/functions inst/include/Rcpp/vector inst/unitTests src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Sep 28 13:36:01 CEST 2010


Author: romain
Date: 2010-09-28 13:36:01 +0200 (Tue, 28 Sep 2010)
New Revision: 2228

Modified:
   pkg/Rcpp/inst/include/Rcpp/RObject.h
   pkg/Rcpp/inst/include/Rcpp/generated/Vector__create.h
   pkg/Rcpp/inst/include/Rcpp/sugar/functions/ifelse.h
   pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
   pkg/Rcpp/inst/include/Rcpp/vector/traits.h
   pkg/Rcpp/inst/include/RcppCommon.h
   pkg/Rcpp/inst/unitTests/runit.sugar.R
   pkg/Rcpp/src/RObject.cpp
Log:
adding some debugging, still no clue about the segfault

Modified: pkg/Rcpp/inst/include/Rcpp/RObject.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/RObject.h	2010-09-28 10:11:40 UTC (rev 2227)
+++ pkg/Rcpp/inst/include/Rcpp/RObject.h	2010-09-28 11:36:01 UTC (rev 2228)
@@ -262,7 +262,9 @@
 
     void preserve(){ if( m_sexp != R_NilValue ) R_PreserveObject(m_sexp) ; } 
     void release() { if( m_sexp != R_NilValue ) R_ReleaseObject(m_sexp) ; } 
-    virtual void update() {} ;
+    virtual void update() {
+        RCPP_DEBUG_1( "RObject::update(SEXP = <%p> )", m_sexp ) ; 
+    } ;
     
 };
 

Modified: pkg/Rcpp/inst/include/Rcpp/generated/Vector__create.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/generated/Vector__create.h	2010-09-28 10:11:40 UTC (rev 2227)
+++ pkg/Rcpp/inst/include/Rcpp/generated/Vector__create.h	2010-09-28 11:36:01 UTC (rev 2228)
@@ -191,6 +191,7 @@
 	
 	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 ) ;  		
@@ -215,7 +216,8 @@
 	
 	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 ) ;                                                                      
+		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/functions/ifelse.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/functions/ifelse.h	2010-09-28 10:11:40 UTC (rev 2227)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/ifelse.h	2010-09-28 11:36:01 UTC (rev 2228)
@@ -42,12 +42,14 @@
 	typedef Rcpp::VectorBase<RTYPE ,RHS_NA ,RHS_T>  RHS_TYPE ;
 	typedef typename traits::storage_type<RTYPE>::type STORAGE ;
 	
-	typedef typename Rcpp::traits::Extractor<RTYPE ,LHS_NA ,LHS_T>::type  LHS_EXT ;
-	typedef typename Rcpp::traits::Extractor<RTYPE ,RHS_NA ,RHS_T>::type  RHS_EXT ;
+	// typedef typename Rcpp::traits::Extractor<RTYPE ,LHS_NA ,LHS_T>::type  LHS_EXT ;
+	// typedef typename Rcpp::traits::Extractor<RTYPE ,RHS_NA ,RHS_T>::type  RHS_EXT ;
 	
 	IfElse( const COND_TYPE& cond_, const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) : 
 		cond(cond_), lhs(lhs_.get_ref()), rhs(rhs_.get_ref()) {
-			/* FIXME : cond, lhs and rhs must all have the same size */	
+			/* FIXME : cond, lhs and rhs must all have the same size */
+			
+		RCPP_DEBUG( DEMANGLE(IfElse) ) ;	
 	}
 	
 	inline STORAGE operator[]( int i ) const {
@@ -61,8 +63,8 @@
 	         
 private:
 	const COND_TYPE& cond ;
-	const LHS_EXT& lhs ;
-	const RHS_EXT& rhs ;
+	const LHS_T& lhs ;
+	const RHS_T& rhs ;
 	
 } ;
   

Modified: pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/vector/Vector.h	2010-09-28 10:11:40 UTC (rev 2227)
+++ pkg/Rcpp/inst/include/Rcpp/vector/Vector.h	2010-09-28 11:36:01 UTC (rev 2228)
@@ -126,6 +126,7 @@
     }
     
     Vector( const int& size ) : RObject()  {
+    	RCPP_DEBUG_2( "Vector<%d>( int = %d )", RTYPE, size ) ;
     	RObject::setSEXP( Rf_allocVector( RTYPE, size) ) ;
 		init() ;
     }
@@ -484,7 +485,7 @@
 	}
 	
 	void update_vector(){
-		RCPP_DEBUG_1(  "update_vector, VECTOR = %s", DEMANGLE(Vector) ) ;
+		RCPP_DEBUG_2(  " update_vector( VECTOR = %s, SEXP = < %p > )", DEMANGLE(Vector), reinterpret_cast<void*>( RObject::asSexp() ) ) ;
 		cache.update(*this) ;
 	}
 		
@@ -507,7 +508,9 @@
 	
 	template <typename U>
 	static void replace_element__dispatch( traits::true_type, iterator it, SEXP names, int index, const U& u){
-		*it = converter_type::get(u.object ) ;
+		RCPP_DEBUG_2( "  Vector::replace_element__dispatch<%s>(true, index= %d) ", DEMANGLE(U), index ) ; 
+		
+	    *it = converter_type::get(u.object ) ;
 		SET_STRING_ELT( names, index, ::Rf_mkChar( u.name.c_str() ) ) ;
 	}
 	
@@ -765,7 +768,7 @@
 	}
 
 	virtual void update(){
-		RCPP_DEBUG_1( "%s::update", DEMANGLE(Vector) ) ;
+		RCPP_DEBUG_2( "Vector<%d>::update( SEXP = <%p> )", RTYPE, RObject::asSexp() ) ;
 		update_vector() ;
 	}
 	

Modified: pkg/Rcpp/inst/include/Rcpp/vector/traits.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/vector/traits.h	2010-09-28 10:11:40 UTC (rev 2227)
+++ pkg/Rcpp/inst/include/Rcpp/vector/traits.h	2010-09-28 11:36:01 UTC (rev 2228)
@@ -35,6 +35,7 @@
 		r_vector_cache() : start(0){} ;
 		void update( const VECTOR& v ) {
 			start = ::Rcpp::internal::r_vector_start<RTYPE,storage_type>(v.asSexp()) ;
+			RCPP_DEBUG_3( " cache<%d>::update( <%p> ), start = <%p>", RTYPE, reinterpret_cast<void*>(v.asSexp()),  reinterpret_cast<void*>(start) ) ;
 		}
 		inline iterator get() const { return start; }
 		inline iterator get(int i) const { return start + i ; }
@@ -58,6 +59,7 @@
 		~proxy_cache(){}
 		void update( const VECTOR& v ){
 			p = const_cast<VECTOR*>(&v) ;
+			RCPP_DEBUG_3( " cache<%d>::update( <%p> ), p = <%p>", RTYPE, reinterpret_cast<void*>(v.asSexp()),  reinterpret_cast<void*>(p) ) ;
 		}
 		inline iterator get() const { return iterator( proxy(*p, 0 ) ) ;}
 		inline iterator get(int i) const { return iterator( proxy(*p, i ) ) ;}

Modified: pkg/Rcpp/inst/include/RcppCommon.h
===================================================================
--- pkg/Rcpp/inst/include/RcppCommon.h	2010-09-28 10:11:40 UTC (rev 2227)
+++ pkg/Rcpp/inst/include/RcppCommon.h	2010-09-28 11:36:01 UTC (rev 2228)
@@ -191,13 +191,15 @@
 #endif
 
 #if RCPP_DEBUG_LEVEL > 0
-	#define RCPP_DEBUG( MSG ) Rprintf( "%s:%d %s" , __FILE__, __LINE__, MSG ) ;
-	#define RCPP_DEBUG_1( fmt, MSG ) Rprintf( "%s:%d " fmt "%s" , __FILE__, __LINE__, MSG ) ;
-	#define RCPP_DEBUG_2( fmt, M1, M2 ) Rprintf( "%s:%d " fmt "%s" , __FILE__, __LINE__, M1, M2 ) ;
+	#define RCPP_DEBUG( MSG ) Rprintf( "%s:%d %s\n" , __FILE__, __LINE__, MSG ) ;
+	#define RCPP_DEBUG_1( fmt, MSG ) Rprintf( "%s:%d " fmt "\n" , __FILE__, __LINE__, MSG ) ;
+	#define RCPP_DEBUG_2( fmt, M1, M2 ) Rprintf( "%s:%d" fmt "\n" , __FILE__, __LINE__, M1, M2 ) ;
+	#define RCPP_DEBUG_3( fmt, M1, M2, M3 ) Rprintf( "%s:%d" fmt "\n" , __FILE__, __LINE__, M1, M2, M3) ;
 #else
 	#define RCPP_DEBUG( MSG )
 	#define RCPP_DEBUG_1( fmt, MSG )
 	#define RCPP_DEBUG_2( fmt, M1, M2 )
+	#define RCPP_DEBUG_3( fmt, M1, M2, M3 )
 #endif
 
 SEXP stack_trace( const char *file, int line) ;

Modified: pkg/Rcpp/inst/unitTests/runit.sugar.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.sugar.R	2010-09-28 10:11:40 UTC (rev 2227)
+++ pkg/Rcpp/inst/unitTests/runit.sugar.R	2010-09-28 11:36:01 UTC (rev 2228)
@@ -235,7 +235,7 @@
 				'
 					NumericVector xx(x) ;
 					NumericVector yy(y) ;
-					
+					       
 					return List::create( 
 						 _["vec_vec" ]  = ifelse( xx < yy, xx*xx, -(yy*yy) ),  
 						 _["vec_prim"]  = ifelse( xx < yy, 1.0  , -(yy*yy) ), 
@@ -913,7 +913,7 @@
 	checkEquals( fx( 1:10) , rep(FALSE,10) )
 }
 
-test.sugar.isna.isna <- function( ){
+test.sugar.isna.isna <- function( ){                                                                                                  
 	fx <- .rcpp.sugar$runit_isna_isna
 	checkEquals( fx( c(1:5,NA,7:10) ) , rep(FALSE,10) )
 }

Modified: pkg/Rcpp/src/RObject.cpp
===================================================================
--- pkg/Rcpp/src/RObject.cpp	2010-09-28 10:11:40 UTC (rev 2227)
+++ pkg/Rcpp/src/RObject.cpp	2010-09-28 11:36:01 UTC (rev 2228)
@@ -25,6 +25,8 @@
 namespace Rcpp {
 
 void RObject::setSEXP(SEXP x){
+    RCPP_DEBUG_1( "RObject::setSEXP(SEXP = <%p> )", x ) ; 
+    
 	/* if we are setting to the same SEXP as we already have, do nothing */
 	if( x != m_sexp ){
 		



More information about the Rcpp-commits mailing list