[Rcpp-commits] r3838 - in pkg/Rcpp: . inst/include/Rcpp/internal inst/include/Rcpp/module inst/include/Rcpp/traits

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Oct 25 10:11:49 CEST 2012


Author: romain
Date: 2012-10-25 10:11:48 +0200 (Thu, 25 Oct 2012)
New Revision: 3838

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/DESCRIPTION
   pkg/Rcpp/inst/include/Rcpp/internal/wrap.h
   pkg/Rcpp/inst/include/Rcpp/module/macros.h
   pkg/Rcpp/inst/include/Rcpp/traits/wrap_type_traits.h
Log:
wrapping module objects

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2012-10-25 03:16:46 UTC (rev 3837)
+++ pkg/Rcpp/ChangeLog	2012-10-25 08:11:48 UTC (rev 3838)
@@ -1,3 +1,11 @@
+2012-10-25  Romain Francois <romain at r-enthusiasts.com>
+
+        * include/Rcpp/internal/wrap.h: wrapping module object with the help
+        of the RCPP_EXPOSED_CLASS
+        * include/Rcpp/module/macros.h: improving the macros so that wrap and as
+        are covered
+        * include/Rcpp/traits/wrap_type_traits.h: wrapping module objects 
+
 2012-10-24  Romain Francois <romain at r-enthusiasts.com>
 
         * include/Rcpp/traits/is_pointer.h: traits to identify if a type is a pointer

Modified: pkg/Rcpp/DESCRIPTION
===================================================================
--- pkg/Rcpp/DESCRIPTION	2012-10-25 03:16:46 UTC (rev 3837)
+++ pkg/Rcpp/DESCRIPTION	2012-10-25 08:11:48 UTC (rev 3838)
@@ -1,6 +1,6 @@
 Package: Rcpp
 Title: Seamless R and C++ Integration
-Version: 0.9.15.3
+Version: 0.9.15.4
 Date: $Date$
 Author: Dirk Eddelbuettel and Romain Francois, with contributions 
  by Douglas Bates and John Chambers

Modified: pkg/Rcpp/inst/include/Rcpp/internal/wrap.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/internal/wrap.h	2012-10-25 03:16:46 UTC (rev 3837)
+++ pkg/Rcpp/inst/include/Rcpp/internal/wrap.h	2012-10-25 08:11:48 UTC (rev 3838)
@@ -650,11 +650,16 @@
 }
 
 template <typename T>
-inline SEXP wrap_dispatch( const T& object, ::Rcpp::traits::wrap_type_module_object_tag ){
+inline SEXP wrap_dispatch( const T& object, ::Rcpp::traits::wrap_type_module_object_pointer_tag ){
 	return Rcpp::internal::make_new_object< typename T::object_type >( object.ptr ) ;	
 }
 
 template <typename T>
+inline SEXP wrap_dispatch( const T& object, ::Rcpp::traits::wrap_type_module_object_tag ){
+	return Rcpp::internal::make_new_object<T>( new T(object) ) ;	
+}
+
+template <typename T>
 inline SEXP wrap_dispatch_eigen( const T& object, ::Rcpp::traits::false_type){
 	return wrap_dispatch_unknown( object, typename ::Rcpp::traits::is_convertible<T,SEXP>::type() ) ;
 }

Modified: pkg/Rcpp/inst/include/Rcpp/module/macros.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/module/macros.h	2012-10-25 03:16:46 UTC (rev 3837)
+++ pkg/Rcpp/inst/include/Rcpp/module/macros.h	2012-10-25 08:11:48 UTC (rev 3838)
@@ -26,6 +26,12 @@
  *  as a parameter of a function or method exposed by modules. This defines
  *  the necessary trait that makes the class as<>'able
  */
-#define RCPP_EXPOSED_CLASS(CLASS) namespace Rcpp{ namespace traits { template<> struct r_type_traits< CLASS >{ typedef r_type_module_object_tag r_category ; } ; }}
+#define RCPP_EXPOSED_AS(CLASS)   namespace Rcpp{ namespace traits{ template<> struct r_type_traits< CLASS >{ typedef r_type_module_object_tag r_category ; } ; }}
+#define RCPP_EXPOSED_WRAP(CLASS) namespace Rcpp{ namespace traits{ template<> struct wrap_type_traits< CLASS >{typedef wrap_type_module_object_tag wrap_category ; } ; }}
 
+#define RCPP_EXPOSED_CLASS(CLASS) \
+  RCPP_EXPOSED_AS(CLASS)          \
+  RCPP_EXPOSED_WRAP(CLASS)
+
+
 #endif

Modified: pkg/Rcpp/inst/include/Rcpp/traits/wrap_type_traits.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/wrap_type_traits.h	2012-10-25 03:16:46 UTC (rev 3837)
+++ pkg/Rcpp/inst/include/Rcpp/traits/wrap_type_traits.h	2012-10-25 08:11:48 UTC (rev 3838)
@@ -37,11 +37,16 @@
 struct wrap_type_unknown_tag{};
 
 /**
- * module objects. conversion done using make_new_object<>() 
+ * module objects pointers (object<T>). conversion done using make_new_object<>() 
  */
-struct wrap_type_module_object_tag{} ;
+struct wrap_type_module_object_pointer_tag{} ;
  
 /**
+ * declared module object type (by the RCPP_EXPOSED_CLASS macro)
+ */
+struct wrap_type_module_object_tag{} ;
+
+/**
  * Type trait that helps the dispatch of wrap to the proper method
  *
  * This builds a struct that contains a typedef called wrap_category
@@ -83,7 +88,7 @@
 template <> struct wrap_type_traits<rcpp_ulong_long_type> { typedef wrap_type_primitive_tag wrap_category; } ;
 #endif
 
-template <typename T> struct wrap_type_traits< Rcpp::object<T> > { typedef wrap_type_module_object_tag wrap_category; } ;
+template <typename T> struct wrap_type_traits< Rcpp::object<T> > { typedef wrap_type_module_object_pointer_tag wrap_category; } ;
 
 
 } // namespace traits



More information about the Rcpp-commits mailing list