[Rcpp-commits] r4477 - in pkg/Rcpp: . inst/include inst/include/Rcpp src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Sep 13 17:22:51 CEST 2013
Author: romain
Date: 2013-09-13 17:22:50 +0200 (Fri, 13 Sep 2013)
New Revision: 4477
Added:
pkg/Rcpp/inst/include/Rcpp/InputParameter.h
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/DESCRIPTION
pkg/Rcpp/inst/include/RcppCommon.h
pkg/Rcpp/src/attributes.cpp
Log:
added InputParameter for an extra layer of abstraction that we can use to define custom handling of references. For example this is used in RcppArmadillo
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2013-09-13 09:11:04 UTC (rev 4476)
+++ pkg/Rcpp/ChangeLog 2013-09-13 15:22:50 UTC (rev 4477)
@@ -3,7 +3,11 @@
* src/api.cpp : added "long long" to the capabilities function.
* include/Rcpp/platform/compiler.h : demangling is definitely available
on all mac versions using gcc. No point is testing for OSX version.
-
+ * include/Rcpp/InputParameter.h : extra layer of abstraction to allow for
+ custom handling of references etc ... used in RcppArmadillo
+ * src/attributes.cpp : using InputParameter
+ * DESCRIPTION: bump to 0.10.4.4
+
2013-09-12 Romain Francois <romain at r-enthusiasts.com>
* include/Rcpp/platform/compiler.h : patch submitted by Murray for better
Modified: pkg/Rcpp/DESCRIPTION
===================================================================
--- pkg/Rcpp/DESCRIPTION 2013-09-13 09:11:04 UTC (rev 4476)
+++ pkg/Rcpp/DESCRIPTION 2013-09-13 15:22:50 UTC (rev 4477)
@@ -1,6 +1,6 @@
Package: Rcpp
Title: Seamless R and C++ Integration
-Version: 0.10.4.3
+Version: 0.10.4.4
Date: $Date$
Author: Dirk Eddelbuettel and Romain Francois, with contributions
by Douglas Bates, John Chambers and JJ Allaire
Added: pkg/Rcpp/inst/include/Rcpp/InputParameter.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/InputParameter.h (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/InputParameter.h 2013-09-13 15:22:50 UTC (rev 4477)
@@ -0,0 +1,40 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
+//
+// InputParameter.h: Rcpp R/C++ interface class library --
+//
+// Copyright (C) 2013 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__InputParameter__h
+#define Rcpp__InputParameter__h
+
+namespace Rcpp {
+
+ template <typename T>
+ class InputParameter {
+ public:
+ InputParameter(SEXP x_) : x(x_){}
+
+ inline operator T() { return as<T>(x) ; }
+
+ private:
+ SEXP x ;
+ } ;
+
+}
+
+#endif
Modified: pkg/Rcpp/inst/include/RcppCommon.h
===================================================================
--- pkg/Rcpp/inst/include/RcppCommon.h 2013-09-13 09:11:04 UTC (rev 4476)
+++ pkg/Rcpp/inst/include/RcppCommon.h 2013-09-13 15:22:50 UTC (rev 4477)
@@ -110,6 +110,7 @@
#include <Rcpp/internal/export.h>
#include <Rcpp/internal/r_coerce.h>
#include <Rcpp/as.h>
+#include <Rcpp/InputParameter.h>
#include <Rcpp/is.h>
#include <Rcpp/vector/VectorBase.h>
Modified: pkg/Rcpp/src/attributes.cpp
===================================================================
--- pkg/Rcpp/src/attributes.cpp 2013-09-13 09:11:04 UTC (rev 4476)
+++ pkg/Rcpp/src/attributes.cpp 2013-09-13 15:22:50 UTC (rev 4477)
@@ -2167,9 +2167,8 @@
for (size_t i = 0; i<arguments.size(); i++) {
const Argument& argument = arguments[i];
- ostr << " " << argument.type().full_name() << " " << argument.name()
- << " = " << "Rcpp::as<" << argument.type().full_name() << " >("
- << argument.name() << "SEXP);" << std::endl;
+ ostr << " Rcpp::InputParameter< " << argument.type().full_name() << "> " << argument.name()
+ << "(" << argument.name() << "SEXP );" << std::endl;
}
ostr << " ";
More information about the Rcpp-commits
mailing list