[Rcpp-commits] r1118 - pkg/Rcpp pkg/Rcpp/inst pkg/Rcpp/inst/include/Rcpp scripts

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Apr 26 08:42:48 CEST 2010


Author: romain
Date: 2010-04-26 08:42:48 +0200 (Mon, 26 Apr 2010)
New Revision: 1118

Added:
   pkg/Rcpp/inst/include/Rcpp/DataFrame.h
   pkg/Rcpp/inst/include/Rcpp/DataFrame_generated.h
   scripts/DataFrame.R
Modified:
   pkg/Rcpp/NEWS
   pkg/Rcpp/inst/ChangeLog
Log:
added embryo for Rcpp::DataFrame

Modified: pkg/Rcpp/NEWS
===================================================================
--- pkg/Rcpp/NEWS	2010-04-25 20:23:55 UTC (rev 1117)
+++ pkg/Rcpp/NEWS	2010-04-26 06:42:48 UTC (rev 1118)
@@ -29,6 +29,8 @@
 	to enclose the user code
 
     o	new class Rcpp::Formula to help building formulae in C++
+    
+    o   new class Rcpp::DataFrame to help building data frames in C++
 	
     o	Rcpp.package.skeleton gains an argument "example_code" and can now be 
 	used with an empty list, so that only the skeleton is generated. It has also

Modified: pkg/Rcpp/inst/ChangeLog
===================================================================
--- pkg/Rcpp/inst/ChangeLog	2010-04-25 20:23:55 UTC (rev 1117)
+++ pkg/Rcpp/inst/ChangeLog	2010-04-26 06:42:48 UTC (rev 1118)
@@ -1,3 +1,7 @@
+2010-04-26	Romain Francois <romain at r-enthusiasts.com>
+
+	* inst/include/Rcpp/DataFrame_*.h: new class Rcpp::DataFrame
+
 2010-04-16  Dirk Eddelbuettel  <edd at debian.org>
 
 	* DESCRIPTION: Release 0.7.12

Added: pkg/Rcpp/inst/include/Rcpp/DataFrame.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/DataFrame.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/DataFrame.h	2010-04-26 06:42:48 UTC (rev 1118)
@@ -0,0 +1,69 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
+//
+// DataFrame.h: Rcpp R/C++ interface class library -- data frames
+//
+// Copyright (C) 2010	Dirk Eddelbuettel and Romain Francois
+//
+// This file is part of Rcpp.
+//
+// Rcpp is free software: you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// Rcpp is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// 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__DataFrame_h
+#define Rcpp__DataFrame_h
+
+#include <RcppCommon.h>
+#include <Rcpp/Vector.h>
+
+namespace Rcpp{
+	
+	namespace internal{
+		inline SEXP empty_data_frame(){
+			return ::Rf_eval( ::Rf_lang1( ::Rf_install("data.frame") ), R_GlobalEnv ) ;	
+		}
+	}
+	
+	class DataFrame : public List {
+		
+		DataFrame(): List( empty_data_frame() ){}
+		
+		DataFrame(SEXP x) throw(not_compatible) : List(){
+			/* this might throw not_compatible */
+			SEXP y = convert_using_rfunction( x, "as.data.frame" ) ;
+			setSEXP( y ) ;
+		}
+		
+		DataFrame( const DataFrame& other): List(other.asSexp()) {}
+		
+		DataFrame& operator=( DataFrame& other){
+			setSEXP( other.asSexp() ) ;
+			return *this ;
+		}
+		
+		DataFrame& operator=( SEXP x) throw( not_compatible) {
+			SEXP y = convert_using_rfunction( x, "as.data.frame" ) ;
+			setSEXP( y ); 
+			return *this ;
+		}
+		
+		~DataFrame(){}
+
+		static DataFrame create(){ return DataFrame() ; }
+		
+#include <Rcpp/DataFrame_generated.h>		
+
+	}
+	
+}
+
+#endif

Added: pkg/Rcpp/inst/include/Rcpp/DataFrame_generated.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/DataFrame_generated.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/DataFrame_generated.h	2010-04-26 06:42:48 UTC (rev 1118)
@@ -0,0 +1,168 @@
+
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
+//
+// DataFrame_generated.h: Rcpp R/C++ interface class library -- data frames
+//
+// Copyright (C) 2010	Dirk Eddelbuettel and Romain Francois
+//
+// This file is part of Rcpp.
+//
+// Rcpp is free software: you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// Rcpp is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// 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__DataFrame_generated_h
+#define Rcpp__DataFrame_generated_h
+
+
+template <typename T1>
+static DataFrame( const T1& t1 ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( t1 ), "as.data.frame" ) ) ;
+}
+
+
+
+template <typename T1, typename T2>
+static DataFrame( const T1& t1, const T2& t2 ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( t1, t2 ), "as.data.frame" ) ) ;
+}
+
+
+
+template <typename T1, typename T2, typename T3>
+static DataFrame( const T1& t1, const T2& t2, const T3& t3 ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( t1, t2, t3 ), "as.data.frame" ) ) ;
+}
+
+
+
+template <typename T1, typename T2, typename T3, typename T4>
+static DataFrame( const T1& t1, const T2& t2, const T3& t3, const T4& t4 ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( t1, t2, t3, t4 ), "as.data.frame" ) ) ;
+}
+
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5>
+static DataFrame( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5 ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( t1, t2, t3, t4, t5 ), "as.data.frame" ) ) ;
+}
+
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
+static DataFrame( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6 ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( t1, t2, t3, t4, t5, t6 ), "as.data.frame" ) ) ;
+}
+
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
+static DataFrame( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7 ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( t1, t2, t3, t4, t5, t6, t7 ), "as.data.frame" ) ) ;
+}
+
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
+static DataFrame( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8 ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( t1, t2, t3, t4, t5, t6, t7, t8 ), "as.data.frame" ) ) ;
+}
+
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
+static DataFrame( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9 ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( t1, t2, t3, t4, t5, t6, t7, t8, t9 ), "as.data.frame" ) ) ;
+}
+
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10>
+static DataFrame( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10 ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( t1, t2, t3, t4, t5, t6, t7, t8, t9, t10 ), "as.data.frame" ) ) ;
+}
+
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11>
+static DataFrame( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11 ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11 ), "as.data.frame" ) ) ;
+}
+
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12>
+static DataFrame( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12 ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12 ), "as.data.frame" ) ) ;
+}
+
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13>
+static DataFrame( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13 ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13 ), "as.data.frame" ) ) ;
+}
+
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14>
+static DataFrame( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14 ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14 ), "as.data.frame" ) ) ;
+}
+
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15>
+static DataFrame( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15 ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15 ), "as.data.frame" ) ) ;
+}
+
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16>
+static DataFrame( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16 ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16 ), "as.data.frame" ) ) ;
+}
+
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17>
+static DataFrame( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17 ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17 ), "as.data.frame" ) ) ;
+}
+
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18>
+static DataFrame( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17, const T18& t18 ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18 ), "as.data.frame" ) ) ;
+}
+
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19>
+static DataFrame( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17, const T18& t18, const T19& t19 ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19 ), "as.data.frame" ) ) ;
+}
+
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20>
+static DataFrame( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10, const T11& t11, const T12& t12, const T13& t13, const T14& t14, const T15& t15, const T16& t16, const T17& t17, const T18& t18, const T19& t19, const T20& t20 ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20 ), "as.data.frame" ) ) ;
+}
+
+
+#endif
+

Added: scripts/DataFrame.R
===================================================================
--- scripts/DataFrame.R	                        (rev 0)
+++ scripts/DataFrame.R	2010-04-26 06:42:48 UTC (rev 1118)
@@ -0,0 +1,54 @@
+#
+# use this script to generate the file DataFrame_generated.h
+#
+
+DataFrame_generator <- function( i ){
+	
+sprintf( '
+template <%s>
+static DataFrame( %s ) throw(not_compatible){
+	return DataFrame( convert_using_rfunction( List::create( %s ), "as.data.frame" ) ) ;
+}
+', 
+paste( sprintf( "typename T%d", 1:i ), collapse = ", "), 
+paste( sprintf( "const T%d& t%d", 1:i, 1:i ), collapse = ", "), 
+paste( sprintf( "t%d", 1:i ), collapse = ", ")
+)
+	
+}
+
+
+content <- sprintf( '
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
+//
+// DataFrame_generated.h: Rcpp R/C++ interface class library -- data frames
+//
+// Copyright (C) 2010	Dirk Eddelbuettel and Romain Francois
+//
+// This file is part of Rcpp.
+//
+// Rcpp is free software: you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// Rcpp is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// 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__DataFrame_generated_h
+#define Rcpp__DataFrame_generated_h
+
+%s
+
+#endif
+' , 
+paste( sapply( 1:20, DataFrame_generator ), collapse = "\n\n" )
+)
+writeLines( content, "Rcpp/inst/include/Rcpp/DataFrame_generated.h" ) 
+



More information about the Rcpp-commits mailing list