[Rcpp-commits] r593 - in pkg/src: . Rcpp
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Feb 6 12:07:11 CET 2010
Author: romain
Date: 2010-02-06 12:07:11 +0100 (Sat, 06 Feb 2010)
New Revision: 593
Modified:
pkg/src/DottedPair.cpp
pkg/src/Environment.cpp
pkg/src/RObject.cpp
pkg/src/Rcpp/DottedPair.h
pkg/src/Rcpp/Environment.h
pkg/src/Rcpp/RObject.h
pkg/src/Rcpp/SEXP_Vector.h
pkg/src/Rcpp/VectorBase.h
pkg/src/VectorBase.cpp
Log:
removed some unnecessary operator SEXP used in proxy classes (the as<SEXP> takes care of it)
Modified: pkg/src/DottedPair.cpp
===================================================================
--- pkg/src/DottedPair.cpp 2010-02-06 10:53:56 UTC (rev 592)
+++ pkg/src/DottedPair.cpp 2010-02-06 11:07:11 UTC (rev 593)
@@ -65,11 +65,7 @@
SET_TAG( node, Rf_install( rhs.getTag().c_str() ) ) ;
return *this ;
}
-
- DottedPair::Proxy::operator SEXP() {
- return CAR(node) ;
- }
-
+
const DottedPair::Proxy DottedPair::operator[]( int i ) const {
return Proxy( const_cast<DottedPair&>(*this), i) ;
}
Modified: pkg/src/Environment.cpp
===================================================================
--- pkg/src/Environment.cpp 2010-02-06 10:53:56 UTC (rev 592)
+++ pkg/src/Environment.cpp 2010-02-06 11:07:11 UTC (rev 593)
@@ -269,10 +269,6 @@
env.assign( name, rhs.env.get(rhs.name) ) ;
return *this ;
}
-
- Environment::Binding::operator SEXP() const{
- return env.get( name );
- }
const Environment::Binding Environment::operator[]( const std::string& name) const{
return Binding( const_cast<Environment&>(*this), name );
Modified: pkg/src/RObject.cpp
===================================================================
--- pkg/src/RObject.cpp 2010-02-06 10:53:56 UTC (rev 592)
+++ pkg/src/RObject.cpp 2010-02-06 11:07:11 UTC (rev 593)
@@ -128,22 +128,22 @@
Rf_cons( x , R_NilValue) ) )))) ;
}
-RObject::SlotProxy::operator SEXP() const {
- return get() ;
+SEXP RObject::AttributeProxy::get() const {
+ return Rf_getAttrib( parent, Rf_install( attr_name.c_str() ) ) ;
}
+void RObject::AttributeProxy::set(SEXP x) const{
+ Rf_setAttrib( parent, Rf_install(attr_name.c_str()), x ) ;
+}
+
RObject::AttributeProxy::AttributeProxy( const RObject& v, const std::string& name) :
parent(v), attr_name(name) {};
RObject::AttributeProxy& RObject::AttributeProxy::operator=(const AttributeProxy& rhs){
- Rf_setAttrib( parent, Rf_install(attr_name.c_str()), parent.asSexp() ) ;
+ set( rhs.get() ) ;
return *this ;
}
-RObject::AttributeProxy::operator SEXP() const {
- return Rf_getAttrib( parent , Rf_install( attr_name.c_str() ) ) ;
-}
-
RObject::AttributeProxy RObject::attr( const std::string& name) const{
return AttributeProxy( *this, name) ;
}
Modified: pkg/src/Rcpp/DottedPair.h
===================================================================
--- pkg/src/Rcpp/DottedPair.h 2010-02-06 10:53:56 UTC (rev 592)
+++ pkg/src/Rcpp/DottedPair.h 2010-02-06 11:07:11 UTC (rev 593)
@@ -174,9 +174,6 @@
}
Proxy& operator=(const Named& rhs) ;
- /* rvalue use */
- operator SEXP() ;
-
template <typename T> operator T() const {
return as<T>( CAR(node) ) ;
}
@@ -190,6 +187,8 @@
friend class Proxy;
+
+
virtual ~DottedPair() = 0 ;
template <typename T>
Modified: pkg/src/Rcpp/Environment.h
===================================================================
--- pkg/src/Rcpp/Environment.h 2010-02-06 10:53:56 UTC (rev 592)
+++ pkg/src/Rcpp/Environment.h 2010-02-06 11:07:11 UTC (rev 593)
@@ -216,15 +216,7 @@
}
/* rvalue */
- /**
- * retrieves the value for this binding
- *
- * Environment stats = Environment::namespace_env( "stats" ) ;
- * Function f = stats["rnorm"] ;
- */
- operator SEXP() const ;
-
- /**
+ /**
* Retrieves the value of the binding as a T object
*
* The requirement on the T type is that as<T> makes sense
@@ -234,8 +226,7 @@
template <typename T>
operator T() const{
SEXP x = env.get(name) ;
- T t = as<T>(x) ;
- return t;
+ return as<T>(x) ;
}
Modified: pkg/src/Rcpp/RObject.h
===================================================================
--- pkg/src/Rcpp/RObject.h 2010-02-06 10:53:56 UTC (rev 592)
+++ pkg/src/Rcpp/RObject.h 2010-02-06 11:07:11 UTC (rev 593)
@@ -139,24 +139,21 @@
/* lvalue uses */
AttributeProxy& operator=(const AttributeProxy& rhs) ;
- template <typename T>
- AttributeProxy& operator=(const T& rhs){
- Rf_setAttrib( parent, Rf_install(attr_name.c_str()), wrap(rhs) ) ;
+ template <typename T> AttributeProxy& operator=(const T& rhs){
+ set( wrap(rhs) ) ;
return *this ;
}
-
- /* rvalue use */
- operator SEXP() const ;
-
+
template <typename T> operator T() const {
- SEXP att = Rf_getAttrib( parent, Rf_install( attr_name.c_str() ) );
- T t = Rcpp::as<T>(att) ;
- return t ;
+ return as<T>(get()) ;
} ;
private:
const RObject& parent;
std::string attr_name ;
+
+ SEXP get() const ;
+ void set(SEXP x) const ;
} ;
class SlotProxy {
@@ -172,12 +169,8 @@
return *this ;
}
- /* rvalue use */
- operator SEXP() const ;
-
template <typename T> operator T() const {
- T t = Rcpp::as<T>(get()) ;
- return t ;
+ return as<T>(get()) ;
} ;
private:
Modified: pkg/src/Rcpp/SEXP_Vector.h
===================================================================
--- pkg/src/Rcpp/SEXP_Vector.h 2010-02-06 10:53:56 UTC (rev 592)
+++ pkg/src/Rcpp/SEXP_Vector.h 2010-02-06 11:07:11 UTC (rev 593)
@@ -55,11 +55,6 @@
return *this;
}
- /* rvalue use */
- operator SEXP() {
- return VECTOR_ELT( parent, index ) ;
- }
-
template <typename U> operator U(){
SEXP xx = VECTOR_ELT( parent, index) ;
return as<U>( xx ) ;
Modified: pkg/src/Rcpp/VectorBase.h
===================================================================
--- pkg/src/Rcpp/VectorBase.h 2010-02-06 10:53:56 UTC (rev 592)
+++ pkg/src/Rcpp/VectorBase.h 2010-02-06 11:07:11 UTC (rev 593)
@@ -76,12 +76,8 @@
return *this ;
}
- /* rvalue use */
- operator SEXP() const ;
-
template <typename T> operator T() const {
- T t = Rcpp::as<T>(get()) ;
- return t ;
+ return Rcpp::as<T>(get()) ;
} ;
private:
Modified: pkg/src/VectorBase.cpp
===================================================================
--- pkg/src/VectorBase.cpp 2010-02-06 10:53:56 UTC (rev 592)
+++ pkg/src/VectorBase.cpp 2010-02-06 11:07:11 UTC (rev 593)
@@ -47,7 +47,7 @@
set( rhs.get() ) ;
return *this ;
}
- VectorBase::NamesProxy::operator SEXP() const { return get() ; }
+
SEXP VectorBase::NamesProxy::get() const {
return RCPP_GET_NAMES(parent) ;
}
More information about the Rcpp-commits
mailing list