[Rcpp-devel] [Rcpp-commits] r224 - in pkg: . inst inst/examples/RcppInline src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Dec 29 17:10:29 CET 2009


Author: romain
Date: 2009-12-29 17:10:29 +0100 (Tue, 29 Dec 2009)
New Revision: 224

Modified:
   pkg/DESCRIPTION
   pkg/inst/ChangeLog
   pkg/inst/examples/RcppInline/RcppSexpTests.r
   pkg/src/RcppSexp.cpp
   pkg/src/RcppSexp.h
   pkg/src/RcppXPtr.h
   pkg/src/exceptions.cpp
Log:
previous commit was too early (i only wanted to commit the file name switch exception_handling.cpp -> exceptions.cpp

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2009-12-29 15:53:03 UTC (rev 223)
+++ pkg/DESCRIPTION	2009-12-29 16:10:29 UTC (rev 224)
@@ -19,7 +19,7 @@
  .
  Several examples are included.
 Depends: R (>= 2.0.0)
-Suggests: inline (>= 0.3.4)
+Suggests: inline (>= 0.3.4), RUnit 
 SystemRequirements: None
 URL: http://dirk.eddelbuettel.com/code/rcpp.html
 License: GPL (>= 2)

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2009-12-29 15:53:03 UTC (rev 223)
+++ pkg/inst/ChangeLog	2009-12-29 16:10:29 UTC (rev 224)
@@ -1,5 +1,14 @@
 2009-12-29  Romain Francois <francoisromain at free.fr>
 
+	* src/RcppXPtr.h: now RcppXPtr extends RcppSexp and RcppSexp manages
+	garbarge collection, attributes, etc ...
+	
+	* src/exceptions.cpp: replaces src/exception_handling.cpp
+	
+	* DESCRIPTION: now suggesting RUnit.
+
+2009-12-29  Romain Francois <francoisromain at free.fr>
+
 	* src/RcppXPtr.h: added operator SEXP() to class
 	RcppXPtr to ease implicit conversion from RcppXPtr to SEXP.
 	This means we can directly return the RcppXPtr object to R when the 

Modified: pkg/inst/examples/RcppInline/RcppSexpTests.r
===================================================================
--- pkg/inst/examples/RcppInline/RcppSexpTests.r	2009-12-29 15:53:03 UTC (rev 223)
+++ pkg/inst/examples/RcppInline/RcppSexpTests.r	2009-12-29 16:10:29 UTC (rev 224)
@@ -204,7 +204,7 @@
 ds.insert( 0.0 );
 ds.insert( 1.0 );
 ds.insert( 0.0 );
-return(RcppSexp( iv ).asSexp()); '
+return(RcppSexp( ds ).asSexp()); '
 funx <- cfunction(signature(), foo, Rcpp=TRUE, verbose=FALSE, includes = "#include <set>")
 print( res <- funx() )
 stopifnot( identical( res, as.numeric(0:1)))
@@ -250,7 +250,7 @@
 stopifnot( res )
 
 funx <- cfunction(signature(x="data.frame"), '
-return RcppSexp(x).attr( "row.names" ).asSexp() ;
+return RcppSexp(x).attr( "row.names" ) ;
 ', Rcpp=TRUE, verbose=FALSE)
 res <- funx( iris )
 stopifnot( identical(res, 1:150) )

Modified: pkg/src/RcppSexp.cpp
===================================================================
--- pkg/src/RcppSexp.cpp	2009-12-29 15:53:03 UTC (rev 223)
+++ pkg/src/RcppSexp.cpp	2009-12-29 16:10:29 UTC (rev 224)
@@ -22,7 +22,6 @@
 
 #include <RcppSexp.h>
 #include <algorithm>
-#include <RcppSuperClass.h>
 
 RcppSexp::RcppSexp(const bool & v) {
     logTxt("RcppSexp from bool\n");
@@ -141,6 +140,7 @@
 }
 
 RcppSexp::~RcppSexp() {
+	release() ;
     logTxt("~RcppSexp");
 }
 
@@ -335,12 +335,6 @@
 
 
 
-
-RcppSexp::~RcppSexp() {
-    logTxt( "~RcppSexp" ) ;
-	release() ;
-}
-
 void RcppSexp::protect(){
 	if( !isProtected ){
 		isProtected = true ;

Modified: pkg/src/RcppSexp.h
===================================================================
--- pkg/src/RcppSexp.h	2009-12-29 15:53:03 UTC (rev 223)
+++ pkg/src/RcppSexp.h	2009-12-29 16:10:29 UTC (rev 224)
@@ -24,10 +24,9 @@
 #define RcppSexp_h
 
 #include <RcppCommon.h>
-#include <RcppSuperClass.h>
 #include <set>
 
-class RcppSexp: public RcppSuperClass {
+class RcppSexp {
 public:
 	
 	/**

Modified: pkg/src/RcppXPtr.h
===================================================================
--- pkg/src/RcppXPtr.h	2009-12-29 15:53:03 UTC (rev 223)
+++ pkg/src/RcppXPtr.h	2009-12-29 16:10:29 UTC (rev 224)
@@ -35,7 +35,7 @@
 }
 
 template <typename T>
-class RcppXPtr : public RcppSuperClass {
+class RcppXPtr : public RcppSexp {
 	public:
 		
 		/** 
@@ -43,7 +43,7 @@
 		 *
 		 * @param xp external pointer to wrap
 		 */
-		 explicit RcppXPtr(SEXP m_sexp) : RcppSuperClass::RcppSuperClass(m_sexp){} ;
+		 explicit RcppXPtr(SEXP m_sexp) : RcppSexp::RcppSexp(m_sexp){} ;
 		
 		/**
 		 * creates a new external pointer wrapping the dumb pointer p. 
@@ -89,8 +89,18 @@
   		
 };
 
+
+template <typename T>
+void delete_finalizer(SEXP p) {
+	if( TYPEOF(p) == EXTPTRSXP ){
+		T* ptr = (T*) EXTPTR_PTR(p) ;
+		delete ptr ;
+	}
+}
+
+
 template<typename T>
-RcppXPtr<T>::RcppXPtr(T* p, bool set_delete_finalizer = true) : RcppSuperClass::RcppSuperClass() {
+RcppXPtr<T>::RcppXPtr(T* p, bool set_delete_finalizer = true) : RcppSexp::RcppSexp() {
 	m_sexp = R_MakeExternalPtr( (void*)p , R_NilValue, R_NilValue) ;
 	if( set_delete_finalizer ){
 		setDeleteFinalizer() ;
@@ -123,4 +133,5 @@
 	return EXTPTR_TAG(m_sexp) ;
 }
 
+
 #endif

Modified: pkg/src/exceptions.cpp
===================================================================
--- pkg/src/exceptions.cpp	2009-12-29 15:53:03 UTC (rev 223)
+++ pkg/src/exceptions.cpp	2009-12-29 16:10:29 UTC (rev 224)
@@ -1,6 +1,6 @@
 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
 //
-// exception_handling.cpp: R/C++ interface class library -- common functions
+// exceptions.cpp: R/C++ interface class library -- common functions
 //
 // Copyright (C) 2009 - 2010 Romain Francois
 //

_______________________________________________
Rcpp-commits mailing list
Rcpp-commits at lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-commits


More information about the Rcpp-devel mailing list