[Rcpp-commits] r3804 - in pkg/Rcpp: . inst/include/Rcpp inst/include/Rcpp/traits src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Oct 22 10:45:54 CEST 2012


Author: romain
Date: 2012-10-22 10:45:54 +0200 (Mon, 22 Oct 2012)
New Revision: 3804

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/DESCRIPTION
   pkg/Rcpp/inst/include/Rcpp/Module.h
   pkg/Rcpp/inst/include/Rcpp/as.h
   pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h
   pkg/Rcpp/src/Module.cpp
Log:
support for as< module object > 

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2012-10-21 16:46:15 UTC (rev 3803)
+++ pkg/Rcpp/ChangeLog	2012-10-22 08:45:54 UTC (rev 3804)
@@ -1,3 +1,10 @@
+2012-10-22  Romain Francois <romain at r-enthusiasts.com>
+
+        * include/Rcpp/as.h: support for as<> for module objects
+        * include/Rcpp/Module.h: idem
+        * include/Rcpp/traits/r_type_traits.h: idem
+        * src/Module.cpp: idem
+
 2012-10-21  Romain Francois <romain at r-enthusiasts.com>
 
         * include/Rcpp/traits/wrap_type_traits.h: support for wrapping module objects
@@ -3,5 +10,4 @@
         * include/Rcpp/internal/wrap.h : idem
         * include/Rcpp/Module.h: idem
-        
 
 2012-10-13  Dirk Eddelbuettel  <edd at debian.org>

Modified: pkg/Rcpp/DESCRIPTION
===================================================================
--- pkg/Rcpp/DESCRIPTION	2012-10-21 16:46:15 UTC (rev 3803)
+++ pkg/Rcpp/DESCRIPTION	2012-10-22 08:45:54 UTC (rev 3804)
@@ -1,6 +1,6 @@
 Package: Rcpp
 Title: Seamless R and C++ Integration
-Version: 0.9.15.1
+Version: 0.9.15.2
 Date: $Date$
 Author: Dirk Eddelbuettel and Romain Francois, with contributions 
  by Douglas Bates and John Chambers

Modified: pkg/Rcpp/inst/include/Rcpp/Module.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/Module.h	2012-10-21 16:46:15 UTC (rev 3803)
+++ pkg/Rcpp/inst/include/Rcpp/Module.h	2012-10-22 08:45:54 UTC (rev 3804)
@@ -44,6 +44,8 @@
         typedef T object_type ;
         object( T* ptr_ ) : ptr(ptr_){}
         operator T*(){ return ptr ; }
+        T* operator->(){ return ptr ; }
+        T& operator&(){ return *ptr ; }  
         T* ptr ;
     } ;
 

Modified: pkg/Rcpp/inst/include/Rcpp/as.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/as.h	2012-10-21 16:46:15 UTC (rev 3803)
+++ pkg/Rcpp/inst/include/Rcpp/as.h	2012-10-22 08:45:54 UTC (rev 3804)
@@ -2,7 +2,7 @@
 //
 // as.h: Rcpp R/C++ interface class library -- convert SEXP to C++ objects
 //
-// Copyright (C) 2009 - 2011    Dirk Eddelbuettel and Romain Francois
+// Copyright (C) 2009 - 2012    Dirk Eddelbuettel and Romain Francois
 //
 // This file is part of Rcpp.
 //
@@ -53,6 +53,15 @@
             return exporter.get() ;
         }
         
+        void* as_module_object_internal(SEXP) ;
+        template <typename T> object<T> as_module_object(SEXP x){
+            return (T*) as_module_object_internal(x) ;
+        }
+        
+        template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_module_object_tag ) {
+            return as_module_object<typename T::object_type>( x ) ;
+        }
+        
     }
         
         

Modified: pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h	2012-10-21 16:46:15 UTC (rev 3803)
+++ pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h	2012-10-22 08:45:54 UTC (rev 3804)
@@ -3,7 +3,7 @@
 //
 // r_type_traits.h: Rcpp R/C++ interface class library -- traits to help wrap
 //
-// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
+// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois
 //
 // This file is part of Rcpp.
 //
@@ -60,10 +60,20 @@
 struct r_type_pairstring_generic_tag{} ;
 
 /**
+ * identifies a module object
+ */ 
+struct r_type_module_object_tag{} ;
+
+/**
  * R type trait. Helps wrap.
  */
 template <typename T> struct r_type_traits { typedef r_type_generic_tag r_category ; } ;
 
+/**
+ * module object type
+ */
+template <typename T> struct r_type_traits< Rcpp::object<T> >{ typedef r_type_module_object_tag r_category ; } ;
+
 /** 
  * special cases pair<string,T> to deal with map<string,T> etc ...
  */

Modified: pkg/Rcpp/src/Module.cpp
===================================================================
--- pkg/Rcpp/src/Module.cpp	2012-10-21 16:46:15 UTC (rev 3803)
+++ pkg/Rcpp/src/Module.cpp	2012-10-22 08:45:54 UTC (rev 3804)
@@ -416,5 +416,12 @@
 		END_RCPP
 	}
 	
+	namespace internal{
+	    void* as_module_object_internal(SEXP obj){
+	        Environment env(obj) ;
+	        SEXP xp = env.get(".pointer") ;
+	        return R_ExternalPtrAddr(xp );
+	    }
+	}
 }
 



More information about the Rcpp-commits mailing list