[Rcpp-commits] r2528 - in pkg/Rcpp: . inst/include inst/include/Rcpp inst/include/Rcpp/traits inst/include/Rcpp/vector

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Nov 26 12:45:24 CET 2010


Author: romain
Date: 2010-11-26 12:45:24 +0100 (Fri, 26 Nov 2010)
New Revision: 2528

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/include/Rcpp.h
   pkg/Rcpp/inst/include/Rcpp/Named.h
   pkg/Rcpp/inst/include/Rcpp/traits/named_object.h
   pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
   pkg/Rcpp/inst/include/RcppCommon.h
Log:
update the behavior of the magic underscore

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2010-11-26 11:16:05 UTC (rev 2527)
+++ pkg/Rcpp/ChangeLog	2010-11-26 11:45:24 UTC (rev 2528)
@@ -1,3 +1,9 @@
+2010-11-26  Romain Francois <romain at r-enthusiasts.com>
+
+    * inst/include/Rcpp/vector/Vector.h: List::create( _["foo"] ) sets the SEXP 
+    to R_MissingArg, usueful for formal arguments specifications, simpler form
+    than List::create( _["foo"] = R_MissingArg )
+    
 2010-11-25  Romain Francois <romain at r-enthusiasts.com>
 
     * inst/include/Rcpp/module/Module_generated_function.h: new .function with

Modified: pkg/Rcpp/inst/include/Rcpp/Named.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/Named.h	2010-11-26 11:16:05 UTC (rev 2527)
+++ pkg/Rcpp/inst/include/Rcpp/Named.h	2010-11-26 11:45:24 UTC (rev 2528)
@@ -19,16 +19,16 @@
 // You should have received a copy of the GNU General Public License
 // along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
 
-#ifndef Rcpp_Named_h
+#ifndef Rcpp_Named_h    
 #define Rcpp_Named_h
 
 #include <RcppCommon.h>
 
-#include <Rcpp/Symbol.h>
-#include <Rcpp/RObject.h>
+// #include <Rcpp/Symbol.h>
+// #include <Rcpp/RObject.h>
 
 namespace Rcpp{ 
-
+                    
 class Argument {
 public:
 	Argument() : name(){} ;
@@ -39,7 +39,6 @@
 		return traits::named_object<T>( name, t ) ;	
 	}
 	
-private:
 	std::string name ;	
 } ;
 

Modified: pkg/Rcpp/inst/include/Rcpp/traits/named_object.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/named_object.h	2010-11-26 11:16:05 UTC (rev 2527)
+++ pkg/Rcpp/inst/include/Rcpp/traits/named_object.h	2010-11-26 11:45:24 UTC (rev 2528)
@@ -24,6 +24,8 @@
 #define Rcpp__traits__named_object__h
 
 namespace Rcpp{
+class Argument ;
+
 namespace traits{
 
 template <typename T> class named_object {
@@ -35,6 +37,7 @@
 } ;
 template <typename T> struct is_named : public false_type{} ;
 template <typename T> struct is_named< named_object<T> >   : public true_type {} ;
+template <> struct is_named< Rcpp::Argument >   : public true_type {} ;
 
 } // namespace traits
 } // namespace Rcpp

Modified: pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/vector/Vector.h	2010-11-26 11:16:05 UTC (rev 2527)
+++ pkg/Rcpp/inst/include/Rcpp/vector/Vector.h	2010-11-26 11:45:24 UTC (rev 2528)
@@ -508,12 +508,24 @@
 	
 	template <typename U>
 	static void replace_element__dispatch( traits::true_type, iterator it, SEXP names, int index, const U& u){
-		RCPP_DEBUG_2( "  Vector::replace_element__dispatch<%s>(true, index= %d) ", DEMANGLE(U), index ) ; 
+		replace_element__dispatch__isArgument( typename traits::same_type<U,Argument>(), it, names, index, u ) ;
+	}
+
+    template <typename U>
+	static void replace_element__dispatch__isArgument( traits::false_type, iterator it, SEXP names, int index, const U& u){
+	    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() ) ) ;
 	}
 	
+	template <typename U>
+	static void replace_element__dispatch__isArgument( traits::true_type, iterator it, SEXP names, int index, const U& u){
+	    RCPP_DEBUG_2( "  Vector::replace_element__dispatch<%s>(true, index= %d) ", DEMANGLE(U), index ) ; 
+		
+	    *it = R_MissingArg ;
+		SET_STRING_ELT( names, index, ::Rf_mkChar( u.name.c_str() ) ) ;
+	}
 	
 public:
 	void set_sexp(SEXP x){

Modified: pkg/Rcpp/inst/include/Rcpp.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp.h	2010-11-26 11:16:05 UTC (rev 2527)
+++ pkg/Rcpp/inst/include/Rcpp.h	2010-11-26 11:45:24 UTC (rev 2528)
@@ -34,7 +34,6 @@
 #include <Rcpp/exceptions.h>
 
 #include <Rcpp/RObject.h>
-#include <Rcpp/Named.h>
 
 #include <Rcpp/S4.h>
 #include <Rcpp/Reference.h>

Modified: pkg/Rcpp/inst/include/RcppCommon.h
===================================================================
--- pkg/Rcpp/inst/include/RcppCommon.h	2010-11-26 11:16:05 UTC (rev 2527)
+++ pkg/Rcpp/inst/include/RcppCommon.h	2010-11-26 11:45:24 UTC (rev 2528)
@@ -226,6 +226,7 @@
 #include <Rcpp/traits/integral_constant.h>
 #include <Rcpp/traits/same_type.h>
 #include <Rcpp/traits/named_object.h>
+#include <Rcpp/Named.h>
 #include <Rcpp/traits/is_convertible.h>
 #include <Rcpp/traits/has_iterator.h>
 #include <Rcpp/traits/expands_to_logical.h>



More information about the Rcpp-commits mailing list