[Rcpp-commits] r2643 - in pkg/Rcpp: inst/include src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Dec 2 09:32:46 CET 2010


Author: romain
Date: 2010-12-02 09:32:45 +0100 (Thu, 02 Dec 2010)
New Revision: 2643

Added:
   pkg/Rcpp/inst/include/deprecation.h
   pkg/Rcpp/src/copyMessageToR.cpp
   pkg/Rcpp/src/deprecated/
Modified:
   pkg/Rcpp/inst/include/Rcpp.h
   pkg/Rcpp/inst/include/RcppCommon.h
   pkg/Rcpp/src/RcppCommon.cpp
   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
Log:
adding deprecation hooks (1)

Modified: pkg/Rcpp/inst/include/Rcpp.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp.h	2010-12-02 04:59:12 UTC (rev 2642)
+++ pkg/Rcpp/inst/include/Rcpp.h	2010-12-02 08:32:45 UTC (rev 2643)
@@ -28,7 +28,9 @@
 #include <RcppCommon.h>
 
 /* classic api */
+#ifndef RCPP_NO_CLASSIC_API
 #include <classic/classic.h>
+#endif
 
 /* new api */
 #include <Rcpp/exceptions.h>
@@ -72,6 +74,8 @@
 #include <Rcpp/sugar/sugar.h>
 #include <Rcpp/stats/stats.h>
 
+#ifndef RCPP_NO_CLASSIC_API
 #include <classic/classic_backward.h>
+#endif
 
 #endif

Modified: pkg/Rcpp/inst/include/RcppCommon.h
===================================================================
--- pkg/Rcpp/inst/include/RcppCommon.h	2010-12-02 04:59:12 UTC (rev 2642)
+++ pkg/Rcpp/inst/include/RcppCommon.h	2010-12-02 08:32:45 UTC (rev 2643)
@@ -24,6 +24,8 @@
 #ifndef RcppCommon_h
 #define RcppCommon_h
 
+#include <deprecation.h>
+
 #ifdef __GNUC__
 #define GOOD_COMPILER_FOR_RCPP
 #endif
@@ -131,11 +133,7 @@
 
 #include <Rcpp/complex.h>
 
-// #ifdef BUILDING_DLL
-// #define RcppExport extern "C" __declspec(dllexport)
-// #else
 #define RcppExport extern "C"
-// #endif
 
 #include <Rcpp/internal/posixt.h>
 
@@ -152,7 +150,9 @@
 
 extern "C" SEXP rcpp_call_test(SEXP x) ;
 
+#ifndef RCPP_NO_CLASSIC_API
 char *copyMessageToR(const char* const mesg);
+#endif 
 
 /* in exceptions.cpp */
 void forward_uncaught_exceptions_to_r() ;

Added: pkg/Rcpp/inst/include/deprecation.h
===================================================================
--- pkg/Rcpp/inst/include/deprecation.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/deprecation.h	2010-12-02 08:32:45 UTC (rev 2643)
@@ -0,0 +1,29 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
+//
+// deprecation.h: Rcpp R/C++ interface class library -- 
+//
+// 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 deprecation_H
+#define deprecation_H
+
+// uncomment this to not include the deprecated api
+// #define RCPP_NO_CLASSIC_API
+#define RCPP_DUMMY(NAME) void Rcpp_dummy_##NAME(){}
+
+#endif

Modified: pkg/Rcpp/src/RcppCommon.cpp
===================================================================
--- pkg/Rcpp/src/RcppCommon.cpp	2010-12-02 04:59:12 UTC (rev 2642)
+++ pkg/Rcpp/src/RcppCommon.cpp	2010-12-02 08:32:45 UTC (rev 2643)
@@ -25,19 +25,6 @@
 #include <cstring>
 #include <stdio.h>
 
-// Paul Roebuck has observed that the memory used by an exception message
-// is not reclaimed if error() is called inside of a catch block (due to
-// a setjmp() call), and he suggested the following work-around.
-char *copyMessageToR(const char* const mesg) {
-    char* Rmesg;
-    const char* prefix = "Exception: ";
-    void* Rheap = R_alloc(strlen(prefix)+strlen(mesg)+1,sizeof(char));
-    Rmesg = static_cast<char*>(Rheap);
-    strcpy(Rmesg, prefix);
-    strcat(Rmesg, mesg);
-    return Rmesg;
-}
-
 void logTxtFunction(const char* file, const int line, const char* expression) {
     Rprintf("%s:%d %s\n", file, line, expression);
 }

Modified: pkg/Rcpp/src/RcppDate.cpp
===================================================================
--- pkg/Rcpp/src/RcppDate.cpp	2010-12-02 04:59:12 UTC (rev 2642)
+++ pkg/Rcpp/src/RcppDate.cpp	2010-12-02 08:32:45 UTC (rev 2643)
@@ -21,6 +21,8 @@
 // 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.
@@ -135,4 +137,6 @@
     day   = d;
     year  = y;
 }
-
+#else
+RCPP_DUMMY(RcppDate)
+#endif

Modified: pkg/Rcpp/src/RcppDateVector.cpp
===================================================================
--- pkg/Rcpp/src/RcppDateVector.cpp	2010-12-02 04:59:12 UTC (rev 2642)
+++ pkg/Rcpp/src/RcppDateVector.cpp	2010-12-02 08:32:45 UTC (rev 2643)
@@ -21,6 +21,8 @@
 // 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) {
@@ -60,4 +62,6 @@
 int RcppDateVector::size() const { 
     return v.size(); 
 }
-
+#else
+RCPP_DUMMY(RcppDateVector)
+#endif

Modified: pkg/Rcpp/src/RcppDatetime.cpp
===================================================================
--- pkg/Rcpp/src/RcppDatetime.cpp	2010-12-02 04:59:12 UTC (rev 2642)
+++ pkg/Rcpp/src/RcppDatetime.cpp	2010-12-02 08:32:45 UTC (rev 2643)
@@ -20,6 +20,8 @@
 // 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
@@ -70,3 +72,6 @@
     tmp.m_parsed = false;
     return tmp;
 }
+#else
+RCPP_DUMMY(RcppDateTime)
+#endif

Modified: pkg/Rcpp/src/RcppDatetimeVector.cpp
===================================================================
--- pkg/Rcpp/src/RcppDatetimeVector.cpp	2010-12-02 04:59:12 UTC (rev 2642)
+++ pkg/Rcpp/src/RcppDatetimeVector.cpp	2010-12-02 08:32:45 UTC (rev 2643)
@@ -20,6 +20,8 @@
 // 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) {
@@ -55,4 +57,6 @@
 int RcppDatetimeVector::size() const { 
     return v.size(); 
 }
-
+#else
+RCPP_DUMMY(RcppDateTimeVector)
+#endif

Modified: pkg/Rcpp/src/RcppFrame.cpp
===================================================================
--- pkg/Rcpp/src/RcppFrame.cpp	2010-12-02 04:59:12 UTC (rev 2642)
+++ pkg/Rcpp/src/RcppFrame.cpp	2010-12-02 08:32:45 UTC (rev 2643)
@@ -20,6 +20,8 @@
 // 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) { }
@@ -416,3 +418,6 @@
 	}
 }	
 
+#else
+RCPP_DUMMY(RcppFrame)
+#endif

Modified: pkg/Rcpp/src/RcppFunction.cpp
===================================================================
--- pkg/Rcpp/src/RcppFunction.cpp	2010-12-02 04:59:12 UTC (rev 2642)
+++ pkg/Rcpp/src/RcppFunction.cpp	2010-12-02 08:32:45 UTC (rev 2643)
@@ -20,6 +20,8 @@
 // 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_) { 
@@ -137,3 +139,6 @@
     UNPROTECT(numProtected);
     numProtected = 0;
 }
+#else
+RCPP_DUMMY(RcppFunction)
+#endif

Modified: pkg/Rcpp/src/RcppList.cpp
===================================================================
--- pkg/Rcpp/src/RcppList.cpp	2010-12-02 04:59:12 UTC (rev 2642)
+++ pkg/Rcpp/src/RcppList.cpp	2010-12-02 08:32:45 UTC (rev 2643)
@@ -19,6 +19,8 @@
 // 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), 
@@ -50,4 +52,6 @@
     return li; 
 }
 
-
+#else
+RCPP_DUMMY(RcppList)
+#endif

Modified: pkg/Rcpp/src/RcppNumList.cpp
===================================================================
--- pkg/Rcpp/src/RcppNumList.cpp	2010-12-02 04:59:12 UTC (rev 2642)
+++ pkg/Rcpp/src/RcppNumList.cpp	2010-12-02 08:32:45 UTC (rev 2643)
@@ -20,6 +20,8 @@
 // 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/RcppNumList.h>
 
 RcppNumList::RcppNumList(SEXP theList) {
@@ -58,3 +60,7 @@
 int RcppNumList::size() const { 
     return len; 
 }
+#else
+RCPP_DUMMY(RcppNumList)
+#endif
+

Modified: pkg/Rcpp/src/RcppParams.cpp
===================================================================
--- pkg/Rcpp/src/RcppParams.cpp	2010-12-02 04:59:12 UTC (rev 2642)
+++ pkg/Rcpp/src/RcppParams.cpp	2010-12-02 08:32:45 UTC (rev 2643)
@@ -20,6 +20,8 @@
 // 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/RcppParams.h>
 
 RcppParams::RcppParams(SEXP params) {
@@ -181,3 +183,7 @@
     }
     return RcppDatetime(d);
 }
+#else
+RCPP_DUMMY(RcppParams)
+#endif
+

Modified: pkg/Rcpp/src/RcppResultSet.cpp
===================================================================
--- pkg/Rcpp/src/RcppResultSet.cpp	2010-12-02 04:59:12 UTC (rev 2642)
+++ pkg/Rcpp/src/RcppResultSet.cpp	2010-12-02 08:32:45 UTC (rev 2643)
@@ -21,6 +21,8 @@
 // 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>
 
 RcppResultSet::RcppResultSet() : numProtected(0), values() { }
@@ -112,4 +114,7 @@
     UNPROTECT(numProtected);
     return val;
 }
+#else
+RCPP_DUMMY(RcppResultSet)
+#endif
 

Modified: pkg/Rcpp/src/RcppStringVector.cpp
===================================================================
--- pkg/Rcpp/src/RcppStringVector.cpp	2010-12-02 04:59:12 UTC (rev 2642)
+++ pkg/Rcpp/src/RcppStringVector.cpp	2010-12-02 08:32:45 UTC (rev 2643)
@@ -21,6 +21,7 @@
 // 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_NO_CLASSIC_API
 #include <classic/RcppStringVector.h>
 
 RcppStringVector::RcppStringVector(SEXP vec) {
@@ -61,3 +62,6 @@
 std::vector<std::string> RcppStringVector::stlVector() const {
     return v;
 }
+#else
+RCPP_DUMMY(RcppStringVector)
+#endif

Modified: pkg/Rcpp/src/RcppStringVectorView.cpp
===================================================================
--- pkg/Rcpp/src/RcppStringVectorView.cpp	2010-12-02 04:59:12 UTC (rev 2642)
+++ pkg/Rcpp/src/RcppStringVectorView.cpp	2010-12-02 08:32:45 UTC (rev 2643)
@@ -20,6 +20,7 @@
 // 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_NO_CLASSIC_API
 #include <classic/RcppStringVectorView.h>
 
 RcppStringVectorView::RcppStringVectorView(SEXP vec) {
@@ -46,3 +47,7 @@
 int RcppStringVectorView::size() const { 
     return length; 
 }
+#else
+RCPP_DUMMY(RcppStringVectorView)
+#endif
+

Added: pkg/Rcpp/src/copyMessageToR.cpp
===================================================================
--- pkg/Rcpp/src/copyMessageToR.cpp	                        (rev 0)
+++ pkg/Rcpp/src/copyMessageToR.cpp	2010-12-02 08:32:45 UTC (rev 2643)
@@ -0,0 +1,46 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
+//
+// copyMessageToR.cpp: R/C++ interface class library -- common functions
+//
+// 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 <Rcpp.h>
+#include <cstring>
+#include <stdio.h>
+
+// Paul Roebuck has observed that the memory used by an exception message
+// is not reclaimed if error() is called inside of a catch block (due to
+// a setjmp() call), and he suggested the following work-around.
+char *copyMessageToR(const char* const mesg) {
+    char* Rmesg;
+    const char* prefix = "Exception: ";
+    void* Rheap = R_alloc(strlen(prefix)+strlen(mesg)+1,sizeof(char));
+    Rmesg = static_cast<char*>(Rheap);
+    strcpy(Rmesg, prefix);
+    strcat(Rmesg, mesg);
+    return Rmesg;
+}
+
+#else 
+RCPP_DUMMY(copyMessageToR)
+#endif



More information about the Rcpp-commits mailing list