Skip to content

Commit 4daf7f0

Browse files
rm uses of asSexp
1 parent 0a94e89 commit 4daf7f0

File tree

7 files changed

+58
-85
lines changed

7 files changed

+58
-85
lines changed

inst/include/Rcpp/Module.h

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,6 @@ namespace Rcpp{
214214
field( "docstring" ) = m->docstring ;
215215
}
216216

217-
S4_CppConstructor( const S4_CppConstructor& other) : Reference( other.asSexp() ) {}
218-
S4_CppConstructor& operator=( const S4_CppConstructor& other){
219-
setSEXP( other.asSexp() );
220-
return *this ;
221-
}
222217
} ;
223218

224219
template <typename Class>
@@ -228,13 +223,7 @@ namespace Rcpp{
228223
typedef SignedMethod<Class> signed_method_class ;
229224
typedef std::vector<signed_method_class*> vec_signed_method ;
230225

231-
// FIXME: is class_xp protected ?
232226
S4_CppOverloadedMethods( vec_signed_method* m, const XP_Class& class_xp, const char* name, std::string& buffer ) : Reference( "C++OverloadedMethods" ){
233-
RCPP_DEBUG_2( "S4_CppOverloadedMethods( vec_signed_method* m, const XP_Class& class_xp = <%p>, const char* name = %s, std::string& buffer )", name, class_xp.asSexp() )
234-
#if RCPP_DEBUG_LEVEL > 0
235-
Rf_PrintValue( class_xp ) ;
236-
#endif
237-
238227
int n = m->size() ;
239228
Rcpp::LogicalVector voidness(n), constness(n) ;
240229
Rcpp::CharacterVector docstrings(n), signatures(n) ;
@@ -260,13 +249,7 @@ namespace Rcpp{
260249
field( "nargs" ) = nargs ;
261250

262251
}
263-
S4_CppOverloadedMethods( const S4_CppOverloadedMethods& other){
264-
setSEXP( other.asSexp() ) ;
265-
}
266-
S4_CppOverloadedMethods& operator=( const S4_CppOverloadedMethods& other){
267-
setSEXP( other.asSexp() ) ;
268-
return *this ;
269-
}
252+
270253
} ;
271254

272255
#include <Rcpp/module/Module_generated_CppMethod.h>
@@ -339,11 +322,7 @@ namespace Rcpp{
339322
field( "class_pointer" ) = class_xp ;
340323
field( "docstring" ) = p->docstring ;
341324
}
342-
S4_field( const S4_field& other) : Reference(other.asSexp()) {}
343-
S4_field& operator=(const S4_field& other){
344-
setSEXP(other.asSexp());
345-
return *this ;
346-
}
325+
347326
} ;
348327

349328
#include <Rcpp/module/Module_Property.h>

inst/include/Rcpp/api/meat/Matrix.h

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -27,114 +27,114 @@ namespace Rcpp{
2727
template <int RTYPE, template <class> class StoragePolicy >
2828
Matrix<RTYPE, StoragePolicy>::Matrix(SEXP x) : VECTOR( r_cast<RTYPE>( x ) ), nrows( VECTOR::dims()[0] ) {}
2929

30-
template <int RTYPE>
31-
Matrix<RTYPE>::Matrix( const Dimension& dims) : VECTOR( Rf_allocMatrix( RTYPE, dims[0], dims[1] ) ), nrows(dims[0]) {
30+
template <int RTYPE, template <class> class StoragePolicy >
31+
Matrix<RTYPE,StoragePolicy>::Matrix( const Dimension& dims) : VECTOR( Rf_allocMatrix( RTYPE, dims[0], dims[1] ) ), nrows(dims[0]) {
3232
if( dims.size() != 2 ) throw not_compatible("not a matrix") ;
3333
VECTOR::init() ;
3434
}
3535

36-
template <int RTYPE>
37-
Matrix<RTYPE>::Matrix( const int& nrows_, const int& ncols) :
36+
template <int RTYPE, template <class> class StoragePolicy >
37+
Matrix<RTYPE,StoragePolicy>::Matrix( const int& nrows_, const int& ncols) :
3838
VECTOR( Dimension( nrows_, ncols ) ),
3939
nrows(nrows_)
4040
{}
4141

42-
template <int RTYPE>
42+
template <int RTYPE, template <class> class StoragePolicy >
4343
template <typename Iterator>
44-
Matrix<RTYPE>::Matrix( const int& nrows_, const int& ncols, Iterator start ) :
44+
Matrix<RTYPE,StoragePolicy>::Matrix( const int& nrows_, const int& ncols, Iterator start ) :
4545
VECTOR( start, start + (nrows_*ncols) ),
4646
nrows(nrows_)
4747
{
4848
VECTOR::attr( "dim" ) = Dimension( nrows, ncols ) ;
4949
}
5050

51-
template <int RTYPE>
52-
Matrix<RTYPE>::Matrix( const int& n) : VECTOR( Dimension( n, n ) ), nrows(n) {}
51+
template <int RTYPE, template <class> class StoragePolicy >
52+
Matrix<RTYPE,StoragePolicy>::Matrix( const int& n) : VECTOR( Dimension( n, n ) ), nrows(n) {}
5353

54-
template <int RTYPE>
55-
Matrix<RTYPE>::Matrix( const Matrix& other) : VECTOR( other.asSexp() ), nrows(other.nrows) {}
54+
template <int RTYPE, template <class> class StoragePolicy >
55+
Matrix<RTYPE,StoragePolicy>::Matrix( const Matrix& other) : VECTOR( other.get__() ), nrows(other.nrows) {}
5656

57-
template <int RTYPE>
57+
template <int RTYPE, template <class> class StoragePolicy >
5858
template <bool NA, typename MAT>
59-
Matrix<RTYPE>::Matrix( const MatrixBase<RTYPE,NA,MAT>& other ) : VECTOR( Rf_allocMatrix( RTYPE, other.nrow(), other.ncol() ) ), nrows(other.nrow()) {
59+
Matrix<RTYPE,StoragePolicy>::Matrix( const MatrixBase<RTYPE,NA,MAT>& other ) : VECTOR( Rf_allocMatrix( RTYPE, other.nrow(), other.ncol() ) ), nrows(other.nrow()) {
6060
import_matrix_expression<NA,MAT>( other, nrows, ncol() ) ;
6161
}
6262

63-
template <int RTYPE>
64-
Matrix<RTYPE>& Matrix<RTYPE>::operator=(const Matrix& other) {
65-
SEXP x = other.asSexp() ;
63+
template <int RTYPE, template <class> class StoragePolicy >
64+
Matrix<RTYPE, StoragePolicy>& Matrix<RTYPE,StoragePolicy>::operator=(const Matrix& other) {
65+
SEXP x = VECTOR::get__() ;
6666
if( ! ::Rf_isMatrix(x) ) not_compatible("not a matrix") ;
6767
VECTOR::set_sexp( x ) ;
6868
nrows = other.nrows ;
6969
return *this ;
7070
}
7171

72-
template <int RTYPE>
72+
template <int RTYPE, template <class> class StoragePolicy >
7373
template <typename U>
74-
void Matrix<RTYPE>::fill_diag( const U& u){
74+
void Matrix<RTYPE,StoragePolicy>::fill_diag( const U& u){
7575
fill_diag__dispatch( typename traits::is_trivial<RTYPE>::type(), u ) ;
7676
}
7777

78-
template <int RTYPE>
78+
template <int RTYPE, template <class> class StoragePolicy >
7979
template <typename U>
80-
Matrix<RTYPE> Matrix<RTYPE>::diag( int size, const U& diag_value ){
80+
Matrix<RTYPE,StoragePolicy> Matrix<RTYPE,StoragePolicy>::diag( int size, const U& diag_value ){
8181
Matrix res(size,size) ;
8282
res.fill_diag( diag_value ) ;
8383
return res ;
8484
}
8585

86-
template <int RTYPE>
87-
inline typename Matrix<RTYPE>::Proxy Matrix<RTYPE>::operator[]( int i ){
86+
template <int RTYPE, template <class> class StoragePolicy >
87+
inline typename Matrix<RTYPE,StoragePolicy>::Proxy Matrix<RTYPE,StoragePolicy>::operator[]( int i ){
8888
return static_cast< Vector<RTYPE>* >( this )->operator[]( i ) ;
8989
}
9090

91-
template <int RTYPE>
92-
inline typename Matrix<RTYPE>::const_Proxy Matrix<RTYPE>::operator[]( int i ) const {
91+
template <int RTYPE, template <class> class StoragePolicy >
92+
inline typename Matrix<RTYPE,StoragePolicy>::const_Proxy Matrix<RTYPE,StoragePolicy>::operator[]( int i ) const {
9393
return static_cast< const Vector<RTYPE>* >( this )->operator[]( i ) ;
9494
}
9595

96-
template <int RTYPE>
97-
inline typename Matrix<RTYPE>::Proxy Matrix<RTYPE>::operator()( const size_t& i, const size_t& j) {
96+
template <int RTYPE, template <class> class StoragePolicy >
97+
inline typename Matrix<RTYPE,StoragePolicy>::Proxy Matrix<RTYPE,StoragePolicy>::operator()( const size_t& i, const size_t& j) {
9898
return static_cast< Vector<RTYPE>* >( this )->operator[]( offset( i, j ) ) ;
9999
}
100100

101-
template <int RTYPE>
102-
inline typename Matrix<RTYPE>::const_Proxy Matrix<RTYPE>::operator()( const size_t& i, const size_t& j) const {
101+
template <int RTYPE, template <class> class StoragePolicy >
102+
inline typename Matrix<RTYPE,StoragePolicy>::const_Proxy Matrix<RTYPE,StoragePolicy>::operator()( const size_t& i, const size_t& j) const {
103103
return static_cast< const Vector<RTYPE>* >( this )->operator[]( offset( i, j ) ) ;
104104
}
105105

106-
template <int RTYPE>
107-
inline typename Matrix<RTYPE>::Row Matrix<RTYPE>::operator()( int i, internal::NamedPlaceHolder ){
106+
template <int RTYPE, template <class> class StoragePolicy >
107+
inline typename Matrix<RTYPE,StoragePolicy>::Row Matrix<RTYPE,StoragePolicy>::operator()( int i, internal::NamedPlaceHolder ){
108108
return Row( *this, i ) ;
109109
}
110110

111-
template <int RTYPE>
112-
inline typename Matrix<RTYPE>::Column Matrix<RTYPE>::operator()( internal::NamedPlaceHolder, int i ){
111+
template <int RTYPE, template <class> class StoragePolicy >
112+
inline typename Matrix<RTYPE,StoragePolicy>::Column Matrix<RTYPE,StoragePolicy>::operator()( internal::NamedPlaceHolder, int i ){
113113
return Column( *this, i ) ;
114114
}
115115

116-
template <int RTYPE>
117-
inline typename Matrix<RTYPE>::Column Matrix<RTYPE>::operator()( internal::NamedPlaceHolder, int i ) const {
116+
template <int RTYPE, template <class> class StoragePolicy >
117+
inline typename Matrix<RTYPE,StoragePolicy>::Column Matrix<RTYPE,StoragePolicy>::operator()( internal::NamedPlaceHolder, int i ) const {
118118
return Column( *this, i ) ;
119119
}
120120

121-
template <int RTYPE>
122-
inline typename Matrix<RTYPE>::Sub Matrix<RTYPE>::operator()( const Range& row_range, const Range& col_range){
121+
template <int RTYPE, template <class> class StoragePolicy >
122+
inline typename Matrix<RTYPE,StoragePolicy>::Sub Matrix<RTYPE,StoragePolicy>::operator()( const Range& row_range, const Range& col_range){
123123
return Sub( const_cast<Matrix&>(*this), row_range, col_range ) ;
124124
}
125-
template <int RTYPE>
126-
inline typename Matrix<RTYPE>::Sub Matrix<RTYPE>::operator()( internal::NamedPlaceHolder, const Range& col_range){
125+
template <int RTYPE, template <class> class StoragePolicy >
126+
inline typename Matrix<RTYPE,StoragePolicy>::Sub Matrix<RTYPE,StoragePolicy>::operator()( internal::NamedPlaceHolder, const Range& col_range){
127127
return Sub( const_cast<Matrix&>(*this), Range(0,nrow()-1) , col_range ) ;
128128
}
129129

130-
template <int RTYPE>
131-
inline typename Matrix<RTYPE>::Sub Matrix<RTYPE>::operator()( const Range& row_range, internal::NamedPlaceHolder ){
130+
template <int RTYPE, template <class> class StoragePolicy >
131+
inline typename Matrix<RTYPE,StoragePolicy>::Sub Matrix<RTYPE,StoragePolicy>::operator()( const Range& row_range, internal::NamedPlaceHolder ){
132132
return Sub( const_cast<Matrix&>(*this), row_range, Range(0,ncol()-1) ) ;
133133
}
134134

135-
template <int RTYPE>
135+
template <int RTYPE, template <class> class StoragePolicy >
136136
template <typename U>
137-
void Matrix<RTYPE>::fill_diag__dispatch( traits::false_type, const U& u){
137+
void Matrix<RTYPE,StoragePolicy>::fill_diag__dispatch( traits::false_type, const U& u){
138138
Shield<SEXP> elem( converter_type::get( u ) ) ;
139139
int n = Matrix::ncol() ;
140140
int offset = n +1 ;
@@ -145,9 +145,9 @@ namespace Rcpp{
145145
}
146146
}
147147

148-
template <int RTYPE>
148+
template <int RTYPE, template <class> class StoragePolicy >
149149
template <typename U>
150-
void Matrix<RTYPE>::fill_diag__dispatch( traits::true_type, const U& u){
150+
void Matrix<RTYPE,StoragePolicy>::fill_diag__dispatch( traits::true_type, const U& u){
151151
stored_type elem = converter_type::get( u ) ;
152152
int n = Matrix::ncol() ;
153153
int offset = n + 1 ;
@@ -158,9 +158,9 @@ namespace Rcpp{
158158
}
159159
}
160160

161-
template <int RTYPE>
161+
template <int RTYPE, template <class> class StoragePolicy >
162162
template <bool NA, typename MAT>
163-
void Matrix<RTYPE>::import_matrix_expression( const MatrixBase<RTYPE,NA,MAT>& other, int nr, int nc ){
163+
void Matrix<RTYPE,StoragePolicy>::import_matrix_expression( const MatrixBase<RTYPE,NA,MAT>& other, int nr, int nc ){
164164
iterator start = VECTOR::begin() ;
165165
for( int j=0; j<nc; j++){
166166
for( int i=0; i<nr; i++, ++start){

inst/include/Rcpp/vector/SubMatrix.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ class SubMatrix : public Rcpp::MatrixBase< RTYPE, true, SubMatrix<RTYPE> > {
5353
int m_nr, nc, nr ;
5454
} ;
5555

56-
template <int RTYPE>
57-
Matrix<RTYPE>::Matrix( const SubMatrix<RTYPE>& sub ) : VECTOR( Rf_allocMatrix( RTYPE, sub.nrow(), sub.ncol() )), nrows(sub.nrow()) {
56+
template <int RTYPE, template <class> class StoragePolicy >
57+
Matrix<RTYPE,StoragePolicy>::Matrix( const SubMatrix<RTYPE>& sub ) : VECTOR( Rf_allocMatrix( RTYPE, sub.nrow(), sub.ncol() )), nrows(sub.nrow()) {
5858
int nc = sub.ncol() ;
5959
iterator start = VECTOR::begin() ;
6060
iterator rhs_it ;
@@ -66,8 +66,8 @@ Matrix<RTYPE>::Matrix( const SubMatrix<RTYPE>& sub ) : VECTOR( Rf_allocMatrix( R
6666
}
6767
}
6868

69-
template <int RTYPE>
70-
Matrix<RTYPE>& Matrix<RTYPE>::operator=( const SubMatrix<RTYPE>& sub ){
69+
template <int RTYPE, template <class> class StoragePolicy >
70+
Matrix<RTYPE,StoragePolicy>& Matrix<RTYPE,StoragePolicy>::operator=( const SubMatrix<RTYPE>& sub ){
7171
int nc = sub.ncol(), nr = sub.nrow() ;
7272
if( nc != nrow() || nr != ncol() ){
7373
nrows = nr ;

inst/include/Rcpp/vector/proxy.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,9 @@ namespace internal{
134134
public:
135135
typedef ::Rcpp::Vector<RTYPE> VECTOR ;
136136
generic_name_proxy( VECTOR& v, const std::string& name_) :
137-
parent(v), name(name_){
138-
RCPP_DEBUG_2( "generic_name_proxy( VECTOR& = %p, const string& = %s)", v.asSexp(), name_.c_str() );
139-
} ;
137+
parent(v), name(name_){}
140138
generic_name_proxy( const generic_name_proxy& other ) :
141-
parent(other.parent), name(other.name){} ;
139+
parent(other.parent), name(other.name){}
142140
~generic_name_proxy(){} ;
143141

144142
generic_name_proxy& operator=( SEXP rhs ){

inst/include/Rcpp/vector/string_proxy.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ namespace internal{
4040
* @param v reference to the associated character vector
4141
* @param index index
4242
*/
43-
string_proxy( VECTOR& v, int index_ ) :
44-
parent(&v), index(index_){
45-
RCPP_DEBUG_2( "string_proxy( VECTOR& = <%p>, index_ = %d) ", v.asSexp(), index_ ) ;
46-
}
43+
string_proxy( VECTOR& v, int index_ ) : parent(&v), index(index_){}
4744

4845
string_proxy( const string_proxy& other ) :
4946
parent(other.parent), index(other.index){} ;

inst/include/Rcpp/vector/traits.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ namespace traits{
6262
~proxy_cache(){}
6363
void update( const VECTOR& v ){
6464
p = const_cast<VECTOR*>(&v) ;
65-
RCPP_DEBUG_3( " cache<%d>::update( <%p> ), p = <%p>", RTYPE, reinterpret_cast<void*>(v.asSexp()), reinterpret_cast<void*>(p) ) ;
6665
}
6766
inline iterator get() const { return iterator( proxy(*p, 0 ) ) ;}
6867
// inline const_iterator get_const() const { return const_iterator( *p ) ;}

inst/unitTests/cpp/misc.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ class simple {
3636
// [[Rcpp::export]]
3737
SEXP symbol_(){
3838
return LogicalVector::create(
39-
Symbol( Rf_install("foobar") ).asSexp() == Rf_install("foobar"),
40-
Symbol( Rf_mkChar("foobar") ).asSexp() == Rf_install("foobar"),
41-
Symbol( Rf_mkString("foobar") ).asSexp() == Rf_install("foobar"),
42-
Symbol( "foobar" ).asSexp() == Rf_install("foobar")
39+
Symbol( Rf_install("foobar") ) == Rf_install("foobar"),
40+
Symbol( Rf_mkChar("foobar") ) == Rf_install("foobar"),
41+
Symbol( Rf_mkString("foobar") ) == Rf_install("foobar"),
42+
Symbol( "foobar" ) == Rf_install("foobar")
4343
) ;
4444
}
4545

0 commit comments

Comments
 (0)