Skip to content

Commit e1ad634

Browse files
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
1 parent dac7fc4 commit e1ad634

File tree

5 files changed

+49
-5
lines changed

5 files changed

+49
-5
lines changed

ChangeLog

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
* src/api.cpp : added "long long" to the capabilities function.
44
* include/Rcpp/platform/compiler.h : demangling is definitely available
55
on all mac versions using gcc. No point is testing for OSX version.
6-
6+
* include/Rcpp/InputParameter.h : extra layer of abstraction to allow for
7+
custom handling of references etc ... used in RcppArmadillo
8+
* src/attributes.cpp : using InputParameter
9+
* DESCRIPTION: bump to 0.10.4.4
10+
711
2013-09-12 Romain Francois <romain@r-enthusiasts.com>
812

913
* include/Rcpp/platform/compiler.h : patch submitted by Murray for better

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: Rcpp
22
Title: Seamless R and C++ Integration
3-
Version: 0.10.4.3
3+
Version: 0.10.4.4
44
Date: $Date$
55
Author: Dirk Eddelbuettel and Romain Francois, with contributions
66
by Douglas Bates, John Chambers and JJ Allaire

inst/include/Rcpp/InputParameter.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2+
//
3+
// InputParameter.h: Rcpp R/C++ interface class library --
4+
//
5+
// Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois
6+
//
7+
// This file is part of Rcpp.
8+
//
9+
// Rcpp is free software: you can redistribute it and/or modify it
10+
// under the terms of the GNU General Public License as published by
11+
// the Free Software Foundation, either version 2 of the License, or
12+
// (at your option) any later version.
13+
//
14+
// Rcpp is distributed in the hope that it will be useful, but
15+
// WITHOUT ANY WARRANTY; without even the implied warranty of
16+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
// GNU General Public License for more details.
18+
//
19+
// You should have received a copy of the GNU General Public License
20+
// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
21+
22+
#ifndef Rcpp__InputParameter__h
23+
#define Rcpp__InputParameter__h
24+
25+
namespace Rcpp {
26+
27+
template <typename T>
28+
class InputParameter {
29+
public:
30+
InputParameter(SEXP x_) : x(x_){}
31+
32+
inline operator T() { return as<T>(x) ; }
33+
34+
private:
35+
SEXP x ;
36+
} ;
37+
38+
}
39+
40+
#endif

inst/include/RcppCommon.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ namespace Rcpp{
110110
#include <Rcpp/internal/export.h>
111111
#include <Rcpp/internal/r_coerce.h>
112112
#include <Rcpp/as.h>
113+
#include <Rcpp/InputParameter.h>
113114
#include <Rcpp/is.h>
114115

115116
#include <Rcpp/vector/VectorBase.h>

src/attributes.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,9 +2167,8 @@ namespace attributes {
21672167
for (size_t i = 0; i<arguments.size(); i++) {
21682168
const Argument& argument = arguments[i];
21692169

2170-
ostr << " " << argument.type().full_name() << " " << argument.name()
2171-
<< " = " << "Rcpp::as<" << argument.type().full_name() << " >("
2172-
<< argument.name() << "SEXP);" << std::endl;
2170+
ostr << " Rcpp::InputParameter< " << argument.type().full_name() << "> " << argument.name()
2171+
<< "(" << argument.name() << "SEXP );" << std::endl;
21732172
}
21742173

21752174
ostr << " ";

0 commit comments

Comments
 (0)