[Rcpp-commits] r2644 - in pkg/Rcpp/src: . deprecated

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Dec 2 09:43:44 CET 2010


Author: romain
Date: 2010-12-02 09:43:43 +0100 (Thu, 02 Dec 2010)
New Revision: 2644

Added:
   pkg/Rcpp/src/deprecated/RcppDate.cpp
   pkg/Rcpp/src/deprecated/RcppDateVector.cpp
   pkg/Rcpp/src/deprecated/RcppDatetime.cpp
   pkg/Rcpp/src/deprecated/RcppDatetimeVector.cpp
   pkg/Rcpp/src/deprecated/RcppFrame.cpp
   pkg/Rcpp/src/deprecated/RcppFunction.cpp
   pkg/Rcpp/src/deprecated/RcppList.cpp
   pkg/Rcpp/src/deprecated/RcppNumList.cpp
   pkg/Rcpp/src/deprecated/RcppParams.cpp
   pkg/Rcpp/src/deprecated/RcppResultSet.cpp
   pkg/Rcpp/src/deprecated/RcppStringVector.cpp
   pkg/Rcpp/src/deprecated/RcppStringVectorView.cpp
   pkg/Rcpp/src/deprecated/copyMessageToR.cpp
Removed:
   pkg/Rcpp/src/RcppDate.cpp
   pkg/Rcpp/src/RcppDateVector.cpp
   pkg/Rcpp/src/RcppDatetime.cpp
   pkg/Rcpp/src/RcppDatetimeVector.cpp
   pkg/Rcpp/src/RcppFrame.cpp
   pkg/Rcpp/src/RcppFunction.cpp
   pkg/Rcpp/src/RcppList.cpp
   pkg/Rcpp/src/RcppNumList.cpp
   pkg/Rcpp/src/RcppParams.cpp
   pkg/Rcpp/src/RcppResultSet.cpp
   pkg/Rcpp/src/RcppStringVector.cpp
   pkg/Rcpp/src/RcppStringVectorView.cpp
   pkg/Rcpp/src/copyMessageToR.cpp
Log:
adding deprecation hooks (2)

Deleted: pkg/Rcpp/src/RcppDate.cpp
===================================================================
--- pkg/Rcpp/src/RcppDate.cpp	2010-12-02 08:32:45 UTC (rev 2643)
+++ pkg/Rcpp/src/RcppDate.cpp	2010-12-02 08:43:43 UTC (rev 2644)
@@ -1,142 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// RcppDate.h: Rcpp R/C++ interface class library -- Date type support
-//
-// Copyright (C) 2005 - 2006 Dominick Samperi
-// Copyright (C) 2008        Dirk Eddelbuettel
-// Copyright (C) 2009 - 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/>.
-
-#include <deprecation.h>
-#ifndef RCPP_NO_CLASSIC_API
-#include <classic/RcppDate.h>
-
-const int RcppDate::Jan1970Offset = 2440588;    // Offset from R date representation to Julian day number.
-const int RcppDate::QLtoJan1970Offset = 25569;  // Offset between R / Unix epoch date and the QL base date
-
-RcppDate::RcppDate() : month(1), 
-		       day(1), 
-		       year(1970) { 
-    mdy2jdn(); 
-}
-
-RcppDate::RcppDate(int Rjdn) { 
-    jdn = Rjdn+Jan1970Offset; 
-    jdn2mdy(); 
-}
-
-RcppDate::RcppDate(int month_, int day_, int year_) : month(month_), 
-						      day(day_), 
-						      year(year_) { 
-    if (month < 1 || month > 12 || day < 1 || day > 31)
-	throw std::range_error("RcppDate: invalid date");
-    mdy2jdn();
-}
-
-RcppDate::RcppDate(SEXP dt) {
-    if (Rf_length(dt) != 1) {
-	throw std::range_error("RcppDate: expect one argument in SEXP constructor");
-    }
-    //jdn = Rcpp::as<int>(dt) + Jan1970Offset;
-    jdn = INTEGER(dt)[0] + Jan1970Offset;
-    jdn2mdy();
-}
-
-// Print an RcppDate.
-std::ostream& operator<<(std::ostream& os, const RcppDate& date) {
-    os << date.getYear() << "-" << date.getMonth() << "-" << date.getDay();
-    return os;
-}
-
-// A few basic date operations.
-RcppDate operator+(const RcppDate& date, int offset) {
-    RcppDate temp(date.month, date.day, date.year);
-    temp.jdn += offset;
-    temp.jdn2mdy();
-    return temp;
-}
-
-int operator-(const RcppDate& date2, const RcppDate& date1) {
-    return date2.jdn - date1.jdn;
-}
-
-bool  operator<(const RcppDate &date1, const RcppDate& date2) {
-    return date1.jdn < date2.jdn;
-}
-
-bool  operator>(const RcppDate &date1, const RcppDate& date2) {
-    return date1.jdn > date2.jdn;
-}
-
-bool  operator>=(const RcppDate &date1, const RcppDate& date2) {
-    return date1.jdn >= date2.jdn;
-}
-
-bool  operator<=(const RcppDate &date1, const RcppDate& date2) {
-    return date1.jdn <= date2.jdn;
-}
-
-bool  operator==(const RcppDate &date1, const RcppDate& date2) {
-    return date1.jdn == date2.jdn;
-}
-
-// The Julian day number (jdn) is the number of days since Monday,
-// Jan 1, 4713BC (year = -4712). Here 1BC is year 0, 2BC is year -1, etc.
-// On the other hand, R measures days since Jan 1, 1970, and these dates are
-// converted to jdn's by adding Jan1970Offset.
-//
-// mdy2jdn and jdn2mdy are inverse functions for dates back to 
-// year = -4799 (4800BC).
-//
-// See the Wikipedia entry on Julian day number for more information 
-// on these algorithms.
-//
-
-// Transform month/day/year to Julian day number.
-void RcppDate::mdy2jdn() {
-    int m = month, d = day, y = year;
-    int a = (14 - m)/12;
-    y += 4800 - a;
-    m += 12*a - 3;
-    jdn = (d + (153*m + 2)/5 + 365*y
-	   + y/4 - y/100 + y/400 - 32045);
-}
-
-// Transform from Julian day number to month/day/year.
-void RcppDate::jdn2mdy() {
-    int jul = jdn + 32044;
-    int g = jul/146097;
-    int dg = jul % 146097;
-    int c = (dg/36524 + 1)*3/4;
-    int dc = dg - c*36524;
-    int b = dc/1461;
-    int db = dc % 1461;
-    int a = (db/365 + 1)*3/4;
-    int da = db - a*365;
-    int y = g*400 + c*100 + b*4 + a;
-    int m = (da*5 + 308)/153 - 2;
-    int d = da - (m + 4)*153 /5 + 122;
-    y = y - 4800 + (m + 2)/12;
-    m = (m + 2) % 12 + 1;
-    d = d + 1;
-    month = m;
-    day   = d;
-    year  = y;
-}
-#else
-RCPP_DUMMY(RcppDate)
-#endif

Deleted: pkg/Rcpp/src/RcppDateVector.cpp
===================================================================
--- pkg/Rcpp/src/RcppDateVector.cpp	2010-12-02 08:32:45 UTC (rev 2643)
+++ pkg/Rcpp/src/RcppDateVector.cpp	2010-12-02 08:43:43 UTC (rev 2644)
@@ -1,67 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// RcppDateVector.cpp: Rcpp R/C++ interface class library -- Date vector support
-//
-// Copyright (C) 2005 - 2006 Dominick Samperi
-// Copyright (C) 2008 - 2009 Dirk Eddelbuettel
-// 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/>.
-
-#include <deprecation.h>
-#ifndef RCPP_NO_CLASSIC_API
-#include <classic/RcppDateVector.h>
-
-RcppDateVector::RcppDateVector(SEXP vec) {
-    int i;
-    if (!Rf_isNumeric(vec) || Rf_isMatrix(vec) || Rf_isLogical(vec))
-	throw std::range_error("RcppDateVector: invalid numeric vector in constructor");
-    int len = Rf_length(vec);
-    if (len == 0)
-	throw std::range_error("RcppDateVector: null vector in constructor");
-    v.resize(len);
-    for (i = 0; i < len; i++)
-	v[i] = RcppDate( (int) REAL(vec)[i]);
-}
-
-RcppDateVector::RcppDateVector(int n) {
-    v.resize(n);
-}
-
-const RcppDate& RcppDateVector::operator()(int i) const {
-    if (i < 0 || i >= static_cast<int>(v.size())) {
-	std::ostringstream oss;
-	oss << "RcppDateVector: subscript out of range: " << i;
-	throw std::range_error(oss.str());
-    }
-    return v[i];
-}
-
-RcppDate& RcppDateVector::operator()(int i) {
-    if (i < 0 || i >= static_cast<int>(v.size())) {
-	std::ostringstream oss;
-	oss << "RcppDateVector: subscript out of range: " << i;
-	throw std::range_error(oss.str());
-    }
-    return v[i];
-}
-
-int RcppDateVector::size() const { 
-    return v.size(); 
-}
-#else
-RCPP_DUMMY(RcppDateVector)
-#endif

Deleted: pkg/Rcpp/src/RcppDatetime.cpp
===================================================================
--- pkg/Rcpp/src/RcppDatetime.cpp	2010-12-02 08:32:45 UTC (rev 2643)
+++ pkg/Rcpp/src/RcppDatetime.cpp	2010-12-02 08:43:43 UTC (rev 2644)
@@ -1,77 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// RcppDatetime.h: Rcpp R/C++ interface class library -- Datetime type support
-//
-// Copyright (C) 2008 - 2009 Dirk Eddelbuettel
-// 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/>.
-
-#include <deprecation.h>
-#ifndef RCPP_NO_CLASSIC_API
-#include <classic/RcppDatetime.h>
-#include <time.h> // for strftime
-#include <Rmath.h> // for Rf_fround
-
-RcppDatetime::RcppDatetime(void) : m_d(0), 
-				   m_parsed(false), 
-				   m_us(0) { 
-}
-
-RcppDatetime::RcppDatetime(const double d) : m_d(d), 
-					     m_parsed(false), 
-					     m_us(0) { 
-}
-
-RcppDatetime::RcppDatetime(SEXP ds) { 
-    if (Rf_length(ds) != 1) {
-	throw std::range_error("RcppDatetime: expect one argument in SEXP constructor");
-    }
-    m_d = REAL(ds)[0]; 
-    m_parsed = false; 
-    m_us = 0;
-}
-
-void RcppDatetime::parseTime() {
-    // tt is the nb of seconds, ignores fractional microsec
-    time_t tt = static_cast<time_t>(floor(m_d));	
-    m_tm = *localtime(&tt);			// parse time type into time structure 
-
-    // m_us is fractional (micro)secs is diff. between (fractional) m_d and m_tm
-    m_us = static_cast<int>( ::Rf_fround( (m_d - tt) * 1.0e6, 0.0 ) );	
-
-    m_parsed = true;				// and note that we parsed the time type
-}
-
-std::ostream& operator<<(std::ostream& os, const RcppDatetime &datetime) {
-    RcppDatetime dt(datetime);
-    dt.parseTime();
-    char buf[32], usec[16];
-    strftime(buf, 31, "%Y-%m-%d %H:%M:%S", &dt.m_tm);
-    snprintf(usec, 15, ".%.06d", dt.m_us);
-    os << buf << usec;
-    return os;
-}
-
-RcppDatetime operator+(const RcppDatetime &date,   double offset) {
-    RcppDatetime tmp(date.m_d);
-    tmp.m_d += offset;
-    tmp.m_parsed = false;
-    return tmp;
-}
-#else
-RCPP_DUMMY(RcppDateTime)
-#endif

Deleted: pkg/Rcpp/src/RcppDatetimeVector.cpp
===================================================================
--- pkg/Rcpp/src/RcppDatetimeVector.cpp	2010-12-02 08:32:45 UTC (rev 2643)
+++ pkg/Rcpp/src/RcppDatetimeVector.cpp	2010-12-02 08:43:43 UTC (rev 2644)
@@ -1,62 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// RcppDatetimeVector.cpp: Rcpp R/C++ interface class library -- Datetime vector support
-//
-// Copyright (C) 2008 - 2009 Dirk Eddelbuettel
-// 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/>.
-
-#include <deprecation.h>
-#ifndef RCPP_NO_CLASSIC_API
-#include <classic/RcppDatetimeVector.h>
-
-RcppDatetimeVector::RcppDatetimeVector(SEXP vec) {
-    int i;
-    if (!Rf_isNumeric(vec) || Rf_isMatrix(vec) || Rf_isLogical(vec))
-	throw std::range_error("RcppDatetimeVector: invalid numeric vector in constructor");
-    int len = Rf_length(vec);
-    if (len == 0)
-	throw std::range_error("RcppDatetimeVector: null vector in constructor");
-    v.resize(len);
-    for (i = 0; i < len; i++)
-	v[i] = RcppDatetime(REAL(vec)[i]);
-}
-
-const RcppDatetime & RcppDatetimeVector::operator()(int i) const {
-    if (i < 0 || i >= static_cast<int>(v.size())) {
-	std::ostringstream oss;
-	oss << "RcppDatetimeVector: subscript out of range: " << i;
-	throw std::range_error(oss.str());
-    }
-    return v[i];
-}
-
-RcppDatetime & RcppDatetimeVector::operator()(int i) {
-    if (i < 0 || i >= static_cast<int>(v.size())) {
-	std::ostringstream oss;
-	oss << "RcppDatetimeVector: subscript out of range: " << i;
-	throw std::range_error(oss.str());
-    }
-    return v[i];
-}
-
-int RcppDatetimeVector::size() const { 
-    return v.size(); 
-}
-#else
-RCPP_DUMMY(RcppDateTimeVector)
-#endif

Deleted: pkg/Rcpp/src/RcppFrame.cpp
===================================================================
--- pkg/Rcpp/src/RcppFrame.cpp	2010-12-02 08:32:45 UTC (rev 2643)
+++ pkg/Rcpp/src/RcppFrame.cpp	2010-12-02 08:43:43 UTC (rev 2644)
@@ -1,423 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// RcppFrame.cpp: Rcpp R/C++ interface class library -- data.frame support
-//
-// Copyright (C) 2005 - 2006 Dominick Samperi
-// Copyright (C) 2008 - 2009 Dirk Eddelbuettel
-//
-// 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/>.
-
-#include <deprecation.h>
-#ifndef RCPP_NO_CLASSIC_API
-#include <Rcpp.h>
-
-ColDatum::ColDatum() : type(COLTYPE_UNKNOWN), level(0) { }
-
-ColDatum::ColDatum(const ColDatum& datum) {
-    // Need deep copy so contruction/destruction is synchronized.
-    s = datum.s;
-    x = datum.x;
-    i = datum.i;
-    type = datum.type;
-    level = datum.level;
-    numLevels = datum.numLevels;
-    d = datum.d;
-    if (type == COLTYPE_FACTOR) {
-	levelNames = new std::string[numLevels];
-	for (int j = 0; j < numLevels; j++)
-	    levelNames[j] = datum.levelNames[j];
-    }
-}
-
-ColDatum::~ColDatum() {
-    if (type == COLTYPE_FACTOR) {
-	// For this to work we need a deep copy when type == COLTYPE_FACTOR.
-	// See the copy constructor below. It is wasteful to have
-	// evey factor cell own a separate copy of levelNames, but we leave
-	// the task of factoring it out (using reference counts) for
-	// later.
-	delete [] levelNames;
-    }
-}
-
-void ColDatum::setDoubleValue(double val) { 
-    x = val; 
-    type = COLTYPE_DOUBLE; 
-}
-
-void ColDatum::setIntValue(int val) { 
-    i = val; 
-    type = COLTYPE_INT; 
-}
-
-void ColDatum::setLogicalValue(int val) { 
-    if (val != 0 && val != 1)
-	throw std::range_error("ColDatum::setLogicalValue: logical values must be 0/1.");
-    i = val; 
-    type = COLTYPE_LOGICAL; 
-}
-
-void ColDatum::setStringValue(std::string val) { 
-    s = val; 
-    type = COLTYPE_STRING; 
-}
-
-void ColDatum::setDateValue(RcppDate date) {
-    d = date;
-    type = COLTYPE_DATE;
-}
- 
-void ColDatum::setDatetimeValue(RcppDatetime datetime) {
-    x = datetime.m_d;
-    type = COLTYPE_DATETIME;
-}
- 
-void ColDatum::setFactorValue(std::string *names, int numNames, int factorLevel) {
-    if (factorLevel < 1 || factorLevel > numNames)
-	throw std::range_error("ColDatum::setFactorValue: factor level out of range");
-    level = factorLevel;
-    numLevels = numNames;
-    levelNames = new std::string[numLevels];
-    for (int j = 0; j < numLevels; j++)
-	levelNames[j] = names[j];
-    type = COLTYPE_FACTOR;
-}
-
-double ColDatum::getDoubleValue() const { 
-    if (type != COLTYPE_DOUBLE)
-	throw std::range_error("ColDatum::getDoubleValue: wrong data type in getDoubleValue");
-    return x; 
-}
-
-int ColDatum::getIntValue() const { 
-    if (type != COLTYPE_INT)
-	throw std::range_error("ColDatum::getIntValue: wrong data type in getIntValue");
-    return i; 
-}
-
-int ColDatum::getLogicalValue() const { 
-    if (type != COLTYPE_LOGICAL)
-	throw std::range_error("ColDatum::getLogicalValue: wrong data type in getLogicalValue");
-    return i; 
-}
-
-std::string ColDatum::getStringValue() const { 
-    if (type != COLTYPE_STRING)
-	throw std::range_error("ColDatum::getStringValue: wrong data type in getStringValue");
-    return s; 
-}
-
-RcppDate ColDatum::getDateValue() const {
-    if (type != COLTYPE_DATE)
-	throw std::range_error("ColDatum::getDateValue: wrong data type in getDateValue");
-    return d; 
-}
-
-double ColDatum::getDateRCode() const { 
-    return (double)(d.getJDN() - RcppDate::Jan1970Offset); 
-}
- 
-RcppDatetime ColDatum::getDatetimeValue() const {
-    if (type != COLTYPE_DATETIME)
-	throw std::range_error("ColDatum::getDatetimeValue: wrong data type in getDatetimeValue");
-    return RcppDatetime(x); 
-}
-
-void ColDatum::checkFactorType() const {
-    if (type != COLTYPE_FACTOR)
-	throw std::range_error("ColDatun::checkFactorType: wrong data type in getFactor...");
-}
-
-int ColDatum::getFactorNumLevels() const { 
-    checkFactorType(); 
-    return numLevels; 
-}
-
-int ColDatum::getFactorLevel() const { 
-    checkFactorType(); 
-    return level; 
-}
-
-std::string *ColDatum::getFactorLevelNames() { 
-    checkFactorType(); 
-    return levelNames; 
-}
-
-std::string ColDatum::getFactorLevelName() { 
-    checkFactorType(); 
-    return levelNames[level-1];
-}
-
-RcppFrame::RcppFrame(std::vector<std::string> colNames_) : colNames(colNames_), table() {
-    if (colNames.size() == 0)
-	throw std::range_error("RcppFrame::RcppFrame: zero length colNames");
-}
-
-RcppFrame::RcppFrame(SEXP df) : colNames(), table() {
-    if (!Rf_isNewList(df))
-	throw std::range_error("RcppFrame::RcppFrame: invalid data frame.");
-    int ncol = Rf_length(df);
-    SEXP names = Rf_getAttrib(df, R_NamesSymbol);
-    colNames.resize(ncol);
-    SEXP colData = VECTOR_ELT(df,0); // First column of data.
-    int nrow = Rf_length(colData);
-    if (nrow == 0)
-	throw std::range_error("RcppFrame::RcppFrame: zero lenth column.");
-
-    // Allocate storage for table.
-    table.resize(nrow);
-    for (int r = 0; r < nrow; r++)
-	table[r].resize(ncol);
-    
-    for (int i=0; i < ncol; i++) {
-	colNames[i] = std::string(CHAR(STRING_ELT(names,i)));
-	SEXP colData = VECTOR_ELT(df,i);
-	if (!Rf_isVector(colData) || Rf_length(colData) != nrow)
-	    throw std::range_error("RcppFrame::RcppFrame: invalid column.");
-
-	// Check for Date class. Currently R stores the date ordinal in a
-	// real value. We check for Date under both Real and Integer values
-	// as insurance against future changes.
-	bool isDateClass = false;
-	SEXP classname = Rf_getAttrib(colData, R_ClassSymbol);
-	if (classname != R_NilValue)
-	    isDateClass = (strcmp(CHAR(STRING_ELT(classname,0)),"Date") == 0);
-
-	if (Rf_isReal(colData)) {
-	    if (isDateClass) {
-		for (int j=0; j < nrow; j++) // Column of Date's
-		    table[j][i].setDateValue(RcppDate((int)REAL(colData)[j]));
-	    }
-	    else // Column of REAL's
-		for (int j=0; j < nrow; j++)
-		    table[j][i].setDoubleValue(REAL(colData)[j]);
-	}
-	else if (Rf_isInteger(colData)) {
-	    if (isDateClass) {
-		for (int j=0; j < nrow; j++) // Column of Date's
-		    table[j][i].setDateValue(RcppDate(INTEGER(colData)[j]));
-	    }
-	    else
-		for (int j=0; j < nrow; j++)
-		    table[j][i].setIntValue(INTEGER(colData)[j]);
-	}
-	else if (Rf_isString(colData)) { // Non-factor string column
-	    for (int j=0; j < nrow; j++)
-		table[j][i].setStringValue(std::string(CHAR(STRING_ELT(colData,j))));
-	}
-	else if (Rf_isFactor(colData)) { // Factor column.
-	    SEXP names = Rf_getAttrib(colData, R_LevelsSymbol);
-	    int numLevels = Rf_length(names);
-	    std::string *levelNames = new std::string[numLevels];
-	    for (int k=0; k < numLevels; k++)
-		levelNames[k] = std::string(CHAR(STRING_ELT(names,k)));
-	    for (int j=0; j < nrow; j++)
-		table[j][i].setFactorValue(levelNames, numLevels,
-					   INTEGER(colData)[j]);
-	    delete [] levelNames;
-	}
-	else if (Rf_isLogical(colData)) {
-	    for (int j=0; j < nrow; j++) {
-		table[j][i].setLogicalValue(INTEGER(colData)[j]);
-	    }
-	}
-	else
-	    throw std::range_error("RcppFrame::RcppFrame: unsupported data frame column type.");
-    }
-}
-
-std::vector<std::string>& RcppFrame::getColNames() { 
-    return colNames; 
-}
-
-std::vector<std::vector<ColDatum> >& RcppFrame::getTableData() { 
-    return table; 
-}
-
-void RcppFrame::addRow(std::vector<ColDatum> rowData) {
-    if (rowData.size() != colNames.size())
-	throw std::range_error("RcppFrame::addRow: incorrect row length.");
-    if (table.size() > 0) {
-
-	// First row added determines column types. Check for consistency
-	// for rows after the first...
-	for (int i = 0; i < (int)colNames.size(); i++) {
-	    if (rowData[i].getType() != table[0][i].getType()) {
-		std::ostringstream oss;
-		oss << "RcppFrame::addRow: incorrect data type at posn "
-		    << i;
-		throw std::range_error(oss.str());
-	    }
-	}
-    }
-    table.push_back(rowData);
-}
-
-int RcppFrame::rows() const { 
-    return table.size(); 
-}
-
-int RcppFrame::cols() const { 
-    return table[0].size(); 
-}
-
-namespace Rcpp{
-namespace internal {
-	inline SEXP factor_levels( std::string* names, int nlevels){
-		return Rcpp::wrap( names, names + nlevels ) ;
-	}
-}
-}
-
-template<> 
-SEXP RcppFrame::getColumn<COLTYPE_DOUBLE>( int i ) const {
-	int nr = rows() ;
-	SEXP value = PROTECT(Rf_allocVector(REALSXP,nr));
-	double* p = REAL(value);
-	for (int j=0; j < nr; j++,p++)
-	*p = table[j][i].getDoubleValue();
-	UNPROTECT(1) ;
-	return value ;
-}
-
-template<> 
-SEXP RcppFrame::getColumn<COLTYPE_INT>( int i ) const {
-	int nr = rows() ;
-	SEXP value = PROTECT(Rf_allocVector(INTSXP,nr));
-	int* p = INTEGER(value) ;
-	for (int j=0; j < nr; j++,p++)
-	*p = table[j][i].getIntValue();
-	UNPROTECT(1) ;
-	return value ;
-}
-
-template<> 
-SEXP RcppFrame::getColumn<COLTYPE_FACTOR>( int i ) const {
-	int nr = rows() ;
-	SEXP value = PROTECT(Rf_allocVector(INTSXP,nr));
-	int* p = INTEGER(value) ;
-	for (int j=0; j < nr; j++,p++) {
-	*p = table[j][i].getFactorLevel();
-	}
-	const ColDatum& first = table[0][i] ;  
-	Rf_setAttrib(value, R_LevelsSymbol, 
-		Rcpp::internal::factor_levels( 
-			const_cast<ColDatum&>(first).getFactorLevelNames(), 
-			first.getFactorNumLevels() )
-		);
-	Rf_setAttrib(value, R_ClassSymbol, Rf_mkString("factor") );
-	UNPROTECT(1);
-	return value ;                                                                 
-}
-
-template<> 
-SEXP RcppFrame::getColumn<COLTYPE_STRING>( int i ) const {
-	int nr = rows() ;
-	SEXP value = PROTECT(Rf_allocVector(STRSXP,nr));
-	for (int j=0; j < nr; j++) {
-	SET_STRING_ELT(value, j, Rf_mkChar(table[j][i].getStringValue().c_str()));
-	}
-	UNPROTECT(1) ;
-	return value ;
-}
-
-template<> 
-SEXP RcppFrame::getColumn<COLTYPE_LOGICAL>( int i ) const {
-	int nr = rows() ;
-	SEXP value = PROTECT(Rf_allocVector(LGLSXP,nr));
-	int* p = LOGICAL(value) ;
-	for (int j=0; j < nr; j++,p++) {
-	*p = table[j][i].getLogicalValue();
-	}
-	UNPROTECT(1) ;
-	return value ;
-}
-
-template<> 
-SEXP RcppFrame::getColumn<COLTYPE_DATE>( int i ) const {
-	int nr = rows() ;
-	SEXP value = PROTECT(Rf_allocVector(REALSXP,nr));
-	double* p = REAL(value) ;
-	for (int j=0; j < nr; j++,p++)
-	*p = table[j][i].getDateRCode();
-	Rf_setAttrib(value, R_ClassSymbol, Rf_mkString("Date"));
-	UNPROTECT(1) ;
-	return value ;
-}
-
-template<> 
-SEXP RcppFrame::getColumn<COLTYPE_DATETIME>( int i ) const {
-	int nr = rows() ;
-	SEXP value = PROTECT(Rf_allocVector(REALSXP,nr));
-	double* p = REAL(value) ;
-	for (int j=0; j < nr; j++,p++) {
-	// we could access the seconds as the internal double via getDouble but it's
-	// more proper to use the proper accessor (and if we ever added code ...)
-	*p = table[j][i].getDatetimeValue().getFractionalTimestamp();
-	}
-	Rf_setAttrib(value, R_ClassSymbol, Rcpp::internal::getPosixClasses() );
-	UNPROTECT(1) ;
-	return value ;
-}
-
-
-namespace Rcpp{
-	template <> SEXP wrap<RcppFrame>( const RcppFrame& frame){
-		
-		std::vector<std::string> colNames = const_cast<RcppFrame&>(frame).getColNames();
-	    std::vector<std::vector<ColDatum> > table = const_cast<RcppFrame&>(frame).getTableData();
-	    int ncol = colNames.size();
-	    
-	    SEXP rl = PROTECT( Rf_allocVector( VECSXP, ncol ) ) ;
-	    SEXP nm = PROTECT( Rf_allocVector( STRSXP, ncol ) ) ;
-	    
-	    for (int i=0; i < ncol; i++) { 
-			SET_STRING_ELT( nm, i, Rf_mkChar(colNames[i].c_str()) ) ;
-			
-			switch( table[0][i].getType() ){
-
-#undef RCPP_HANDLE_DF
-#define RCPP_HANDLE_DF(TYPE)                        \
-            case TYPE:                              \
-               SET_VECTOR_ELT( rl, i,  frame.getColumn<TYPE>(i) ) ;  \
-               break ;
-				
-			RCPP_HANDLE_DF(COLTYPE_DOUBLE)
-			RCPP_HANDLE_DF(COLTYPE_INT)
-			RCPP_HANDLE_DF(COLTYPE_FACTOR)
-			RCPP_HANDLE_DF(COLTYPE_STRING)
-			RCPP_HANDLE_DF(COLTYPE_LOGICAL)
-			RCPP_HANDLE_DF(COLTYPE_DATE)
-			RCPP_HANDLE_DF(COLTYPE_DATETIME)
-		
-			default:
-				// throw std::range_error("RcppResultSet::add invalid column type");
-				break ;
-				
-			}
-#undef RCPP_HANDLE_DF
-			
-		}
-		Rf_setAttrib( rl, R_NamesSymbol, nm ) ;
-		
-		UNPROTECT(2) ;
-	    return rl ;			
-	}
-}	
-
-#else
-RCPP_DUMMY(RcppFrame)
-#endif

Deleted: pkg/Rcpp/src/RcppFunction.cpp
===================================================================
--- pkg/Rcpp/src/RcppFunction.cpp	2010-12-02 08:32:45 UTC (rev 2643)
+++ pkg/Rcpp/src/RcppFunction.cpp	2010-12-02 08:43:43 UTC (rev 2644)
@@ -1,144 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// RcppFunction.cpp: Rcpp R/C++ interface class library -- function support
-//
-// Copyright (C) 2005 - 2006 Dominick Samperi
-// Copyright (C) 2008 - 2009 Dirk Eddelbuettel
-//
-// 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/>.
-
-#include <deprecation.h>
-#ifndef RCPP_NO_CLASSIC_API
-#include <Rcpp.h>
-
-RcppFunction::RcppFunction(SEXP fn_) : fn(fn_) { 
-    if (!Rf_isFunction(fn))
-	throw std::range_error("RcppFunction: non-function where function expected");
-    numProtected = 0;
-    currListPosn = 0;
-    listSize = 0;
-    vectorArg = listArg = R_NilValue;
-}
-
-RcppFunction::~RcppFunction() {
-    UNPROTECT(numProtected);
-}
-
-SEXP RcppFunction::listCall() {
-    if (names.size() != (unsigned)listSize)
-	throw std::range_error("RcppFunction::listCall: no. of names != no. of items");
-    if (currListPosn != listSize)
-	throw std::range_error("RcppFunction::listCall: list has incorrect size");
-    SEXP nm = PROTECT(Rf_allocVector(STRSXP,listSize));
-    numProtected++;
-    for (int i=0; i < listSize; i++)
-	SET_STRING_ELT(nm, i, Rf_mkChar(names[i].c_str()));
-    Rf_setAttrib(listArg, R_NamesSymbol, nm);
-    SEXP R_fcall;
-    PROTECT(R_fcall = Rf_lang2(fn, R_NilValue));
-    numProtected++;
-    SETCADR(R_fcall, listArg);
-    SEXP result = Rf_eval(R_fcall, R_NilValue);
-    names.clear();
-    listSize = currListPosn = 0; // Ready for next call.
-    return result;
-}
-
-SEXP RcppFunction::vectorCall() {
-    if (vectorArg == R_NilValue)
-	throw std::range_error("RcppFunction::vectorCall: vector has not been set");
-    SEXP R_fcall;
-    PROTECT(R_fcall = Rf_lang2(fn, R_NilValue));
-    numProtected++;
-    SETCADR(R_fcall, vectorArg);
-    SEXP result = Rf_eval(R_fcall, R_NilValue);
-    vectorArg = R_NilValue; // Ready for next call.
-    return result;
-}
-
-void RcppFunction::setRVector(std::vector<double>& v) {
-    vectorArg = PROTECT( Rcpp::wrap( v ) );
-    numProtected++;
-}
-
-void RcppFunction::setRListSize(int n) {
-    listSize = n;
-    listArg = PROTECT(Rf_allocVector(VECSXP, n));
-    numProtected++;
-}
-
-void RcppFunction::appendToRList(std::string name, double value) {
-    if (currListPosn < 0 || currListPosn >= listSize)
-	throw std::range_error("RcppFunction::appendToRList(double): list posn out of range");
-    SEXP valsxp = PROTECT( Rf_ScalarReal( value ) ) ;
-	numProtected++;
-    // FIXME: valsxp does not need to be protected anymore
-    //        since it is protected by listArg
-	SET_VECTOR_ELT(listArg, currListPosn++, valsxp);
-    names.push_back(name);
-}
-
-void RcppFunction::appendToRList(std::string name, int value) {
-    if (currListPosn < 0 || currListPosn >= listSize)
-	throw std::range_error("RcppFunction::appendToRlist(int): posn out of range");
-    SEXP valsxp = PROTECT(Rf_ScalarInteger(value));
-    numProtected++;
-    // FIXME: valsxp does not need to be protected anymore
-    //        since it is protected by listArg
-	SET_VECTOR_ELT(listArg, currListPosn++, valsxp);
-    names.push_back(name);
-}
-
-void RcppFunction::appendToRList(std::string name, std::string value) {
-    if (currListPosn < 0 || currListPosn >= listSize)
-	throw std::range_error("RcppFunction::appendToRlist(string): posn out of range");
-    SEXP valsxp = PROTECT(Rf_mkString(value.c_str()));
-    numProtected++;
-    // FIXME: valsxp does not need to be protected anymore
-    //        since it is protected by listArg
-	SET_VECTOR_ELT(listArg, currListPosn++, valsxp);
-    names.push_back(name);
-}
-
-void RcppFunction::appendToRList(std::string name, RcppDate& date) {
-    if (currListPosn < 0 || currListPosn >= listSize)
-	throw std::range_error("RcppFunction::appendToRlist(RcppDate): list posn out of range");
-	SEXP valsxp = PROTECT(Rcpp::wrap(date));
-    numProtected++;
-    // FIXME: valsxp does not need to be protected anymore
-    //        since it is protected by listArg
-	SET_VECTOR_ELT(listArg, currListPosn++, valsxp);
-    names.push_back(name);
-}
-
-void RcppFunction::appendToRList(std::string name, RcppDatetime& datetime) {
-    if (currListPosn < 0 || currListPosn >= listSize)
-	throw std::range_error("RcppFunction::appendToRlist(RcppDatetime): list posn out of range");
-	SEXP valsxp = PROTECT(Rcpp::wrap(datetime));
-    numProtected++;
-    // FIXME: valsxp does not need to be protected anymore
-    //        since it is protected by listArg
-    SET_VECTOR_ELT(listArg, currListPosn++, valsxp);
-    names.push_back(name);
-}
-
-void RcppFunction::clearProtectionStack() {
-    UNPROTECT(numProtected);
-    numProtected = 0;
-}
-#else
-RCPP_DUMMY(RcppFunction)
-#endif

Deleted: pkg/Rcpp/src/RcppList.cpp
===================================================================
--- pkg/Rcpp/src/RcppList.cpp	2010-12-02 08:32:45 UTC (rev 2643)
+++ pkg/Rcpp/src/RcppList.cpp	2010-12-02 08:43:43 UTC (rev 2644)
@@ -1,57 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// RcppList.h: Rcpp.h: R/C++ interface class library -- 'list' type support
-//
-// Copyright (C) 2009 Dirk Eddelbuettel
-//
-// 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/>.
-
-#include <deprecation.h>
-#ifndef RCPP_NO_CLASSIC_API
-#include <classic/RcppList.h>
-
-RcppList::RcppList(void) : listArg(R_NilValue), 
-			   listSize(0), 
-			   currListPosn(0), 
-			   numProtected(0) { 
-}
-
-RcppList::~RcppList(void) {
-    clearProtectionStack() ;
-}
-
-void RcppList::setSize(int n) {
-	// FIXME: this should clear the protection stack
-    listSize = n;
-    listArg = PROTECT(Rf_allocVector(VECSXP, n));
-    numProtected++;
-}
-
-void RcppList::clearProtectionStack() {
-    UNPROTECT(numProtected);
-    numProtected = 0;
-}
-
-SEXP RcppList::getList(void) const { 
-    SEXP li = PROTECT(Rf_duplicate( listArg )) ;
-    Rf_setAttrib(li, R_NamesSymbol, Rcpp::wrap(names) );
-    UNPROTECT(1) ;
-    return li; 
-}
-
-#else
-RCPP_DUMMY(RcppList)
-#endif

Deleted: pkg/Rcpp/src/RcppNumList.cpp
===================================================================
--- pkg/Rcpp/src/RcppNumList.cpp	2010-12-02 08:32:45 UTC (rev 2643)
+++ pkg/Rcpp/src/RcppNumList.cpp	2010-12-02 08:43:43 UTC (rev 2644)
@@ -1,66 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// RcppNumList.cpp: Rcpp R/C++ interface class library -- numlist support
-//
-// Copyright (C) 2005 - 2006 Dominick Samperi
-// Copyright (C) 2008 - 2009 Dirk Eddelbuettel
-//
-// 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
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/rcpp -r 2644


More information about the Rcpp-commits mailing list