[Rcpp-commits] r1676 - pkg/Rcpp/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 23 19:21:45 CEST 2010


Author: edd
Date: 2010-06-23 19:21:44 +0200 (Wed, 23 Jun 2010)
New Revision: 1676

Modified:
   pkg/Rcpp/src/RcppResultSet.cpp
Log:
better class(Date) setting


Modified: pkg/Rcpp/src/RcppResultSet.cpp
===================================================================
--- pkg/Rcpp/src/RcppResultSet.cpp	2010-06-23 14:57:12 UTC (rev 1675)
+++ pkg/Rcpp/src/RcppResultSet.cpp	2010-06-23 17:21:44 UTC (rev 1676)
@@ -31,10 +31,8 @@
     template <> SEXP wrap(const RcppDate &date) {
 	SEXP value = PROTECT(Rf_allocVector(REALSXP, 1));
 	REAL(value)[0] = date.getJDN() - RcppDate::Jan1970Offset;
-	SEXP dateclass = PROTECT(Rf_allocVector(STRSXP,1));
-	SET_STRING_ELT(dateclass, 0, Rf_mkChar("Date"));
-	Rf_setAttrib(value, R_ClassSymbol, dateclass); 
-	UNPROTECT(2);
+	Rf_setAttrib(value, R_ClassSymbol, Rf_mkString("Date")); 
+	UNPROTECT(1);
 	return value;
     }
 
@@ -54,10 +52,8 @@
 	for (int i = 0; i < datevec.size(); i++) {
 	    REAL(value)[i] = datevec(i).getJDN() - RcppDate::Jan1970Offset;
 	}
-	SEXP dateclass = PROTECT(Rf_allocVector(STRSXP,1));
-	SET_STRING_ELT(dateclass, 0, Rf_mkChar("Date"));
-	Rf_setAttrib(value, R_ClassSymbol, dateclass); 
-	UNPROTECT(2);
+	Rf_setAttrib(value, R_ClassSymbol, Rf_mkString("Date")); 
+	UNPROTECT(1);
 	return value;
     }
 



More information about the Rcpp-commits mailing list