Skip to content

Commit e53b122

Browse files
committed
Less meat (AttributeProxy needs fix)
1 parent 257c8be commit e53b122

File tree

12 files changed

+105
-37
lines changed

12 files changed

+105
-37
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
#include <Rcpp/api/meat/Rcpp_eval.h>
2626
#include <Rcpp/api/meat/Dimension.h>
2727

28-
#include <Rcpp/api/meat/TagProxy.h>
29-
#include <Rcpp/api/meat/ProtectedProxy.h>
30-
#include <Rcpp/api/meat/EnvironmentBinding.h>
31-
#include <Rcpp/api/meat/AttributeProxy.h>
32-
#include <Rcpp/api/meat/NamesProxy.h>
33-
#include <Rcpp/api/meat/DottedPairProxy.h>
34-
#include <Rcpp/api/meat/SlotProxy.h>
35-
#include <Rcpp/api/meat/FieldProxy.h>
28+
// #include <Rcpp/api/meat/TagProxy.h>
29+
// #include <Rcpp/api/meat/ProtectedProxy.h>
30+
// #include <Rcpp/api/meat/EnvironmentBinding.h>
31+
// #include <Rcpp/api/meat/AttributeProxy.h>
32+
// #include <Rcpp/api/meat/NamesProxy.h>
33+
// #include <Rcpp/api/meat/DottedPairProxy.h>
34+
// #include <Rcpp/api/meat/SlotProxy.h>
35+
// #include <Rcpp/api/meat/FieldProxy.h>
3636

3737
#include <Rcpp/api/meat/Date.h>
3838
#include <Rcpp/api/meat/Datetime.h>

inst/include/Rcpp/internal/wrap.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
// don't include it directly
3030

3131
namespace Rcpp{
32-
namespace RcppEigen{
32+
33+
namespace RcppEigen{
3334
template <typename T> SEXP eigen_wrap( const T& object ) ;
3435
}
3536

@@ -737,6 +738,7 @@ inline SEXP wrap_dispatch_unknown( const T& object, ::Rcpp::traits::false_type){
737738
* wrapping a __single__ primitive type : int, double, std::string, size_t,
738739
* Rbyte, Rcomplex
739740
*/
741+
740742
template <typename T>
741743
inline SEXP wrap_dispatch( const T& object, ::Rcpp::traits::wrap_type_primitive_tag ){
742744
return primitive_wrap( object ) ;

inst/include/Rcpp/proxy/AttributeProxy.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,14 @@ class AttributeProxyPolicy {
3535
return *this ;
3636
}
3737

38-
template <typename T> AttributeProxy& operator=(const T& rhs) ;
38+
template <typename T> AttributeProxy& operator=(const T& rhs) {
39+
set( wrap( rhs ) );
40+
return *this;
41+
} ;
3942

40-
template <typename T> operator T() const ;
43+
template <typename T> operator T() const {
44+
return as<T>( get() );
45+
};
4146

4247
inline operator SEXP() const {
4348
return get() ;
@@ -60,7 +65,9 @@ class AttributeProxyPolicy {
6065
const_AttributeProxy( const CLASS& v, const std::string& name)
6166
: parent(v), attr_name(Rf_install(name.c_str())){}
6267

63-
template <typename T> operator T() const ;
68+
template <typename T> operator T() const {
69+
return as<T>( get() );
70+
};
6471
inline operator SEXP() const {
6572
return get() ;
6673
}

inst/include/Rcpp/proxy/Binding.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,13 @@ class BindingPolicy {
5050
return *this ;
5151
}
5252

53-
template <typename WRAPPABLE> Binding& operator=(const WRAPPABLE& rhs) ;
54-
template <typename T> operator T() const ;
53+
template <typename WRAPPABLE> Binding& operator=(const WRAPPABLE& rhs) {
54+
set( wrap(rhs) );
55+
return *this;
56+
} ;
57+
template <typename T> operator T() const {
58+
return as<T>( get() );
59+
} ;
5560

5661
private:
5762

@@ -81,7 +86,9 @@ class BindingPolicy {
8186
inline bool exists() const {
8287
return env.exists(name) ;
8388
}
84-
template <typename T> operator T() const ;
89+
template <typename T> operator T() const {
90+
return as<T>( get() );
91+
} ;
8592

8693
private:
8794

inst/include/Rcpp/proxy/DottedPairProxy.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,18 @@ class DottedPairProxyPolicy {
4141
}
4242

4343
template <typename T>
44-
DottedPairProxy& operator=(const T& rhs) ;
44+
DottedPairProxy& operator=(const T& rhs) {
45+
return set( wrap(rhs) );
46+
}
4547

4648
template <typename T>
47-
DottedPairProxy& operator=(const traits::named_object<T>& rhs) ;
49+
DottedPairProxy& operator=(const traits::named_object<T>& rhs) {
50+
return set( wrap(rhs.object), rhs.name ) ;
51+
}
4852

49-
template <typename T> operator T() const ;
53+
template <typename T> operator T() const {
54+
return as<T>( get() );
55+
}
5056

5157
inline SEXP get() const {
5258
return CAR(node);
@@ -78,7 +84,9 @@ class DottedPairProxyPolicy {
7884
node = x ;
7985
}
8086

81-
template <typename T> operator T() const ;
87+
template <typename T> operator T() const {
88+
return as<T>( get() );
89+
}
8290

8391
inline SEXP get() const {
8492
return CAR(node);

inst/include/Rcpp/proxy/FieldProxy.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,14 @@ class FieldProxyPolicy {
3434
return *this ;
3535
}
3636

37-
template <typename T> FieldProxy& operator=(const T& rhs) ;
37+
template <typename T> FieldProxy& operator=(const T& rhs) {
38+
set( wrap(rhs) );
39+
return *this;
40+
}
3841

39-
template <typename T> operator T() const ;
42+
template <typename T> operator T() const {
43+
return as<T>( get() );
44+
}
4045
inline operator SEXP() const {
4146
return get() ;
4247
}
@@ -61,7 +66,9 @@ class FieldProxyPolicy {
6166
const_FieldProxy( const CLASS& v, const std::string& name) :
6267
parent(v), field_name(name) {}
6368

64-
template <typename T> operator T() const ;
69+
template <typename T> operator T() const {
70+
return as<T>( get() );
71+
}
6572
inline operator SEXP() const {
6673
return get() ;
6774
}

inst/include/Rcpp/proxy/NamesProxy.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,14 @@ class NamesProxyPolicy{
3535
}
3636

3737
template <typename T>
38-
NamesProxy& operator=(const T& rhs) ;
38+
NamesProxy& operator=(const T& rhs) {
39+
set( wrap(rhs) );
40+
return *this;
41+
}
3942

40-
template <typename T> operator T() const ;
43+
template <typename T> operator T() const {
44+
return as<T>( get() );
45+
}
4146

4247
private:
4348
CLASS& parent;
@@ -66,7 +71,9 @@ class NamesProxyPolicy{
6671
public:
6772
const_NamesProxy( const CLASS& v) : parent(v){} ;
6873

69-
template <typename T> operator T() const ;
74+
template <typename T> operator T() const {
75+
return as<T>( get() );
76+
}
7077

7178
private:
7279
const CLASS& parent;

inst/include/Rcpp/proxy/ProtectedProxy.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#define Rcpp_ProtectedProxy_h
2020

2121
namespace Rcpp{
22+
23+
template <typename T> T as(SEXP x);
2224

2325
template <class XPtrClass>
2426
class ProtectedProxyPolicy{
@@ -29,10 +31,15 @@ namespace Rcpp{
2931
ProtectedProxy( XPtrClass& xp_ ): xp(xp_){}
3032

3133
template <typename U>
32-
ProtectedProxy& operator=( const U& u) ;
34+
ProtectedProxy& operator=( const U& u) {
35+
set( wrap( u ) );
36+
return *this;
37+
}
3338

3439
template <typename U>
35-
operator U() const ;
40+
operator U() const {
41+
return as<U>( get() );
42+
}
3643

3744
operator SEXP() const{
3845
return get() ;
@@ -56,7 +63,9 @@ namespace Rcpp{
5663
const_ProtectedProxy( const XPtrClass& xp_ ): xp(xp_){}
5764

5865
template <typename U>
59-
operator U() const ;
66+
operator U() const {
67+
return as<U>( get() );
68+
};
6069

6170
operator SEXP() const{
6271
return get() ;

inst/include/Rcpp/proxy/SlotProxy.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace Rcpp{
2323
template <typename CLASS>
2424
class SlotProxyPolicy {
2525
public:
26-
26+
2727
class SlotProxy : public GenericProxy<SlotProxy>{
2828
public:
2929
SlotProxy( CLASS& v, const std::string& name) : parent(v), slot_name(Rf_install(name.c_str())) {
@@ -37,9 +37,14 @@ class SlotProxyPolicy {
3737
return *this ;
3838
}
3939

40-
template <typename T> SlotProxy& operator=(const T& rhs) ;
40+
template <typename T> SlotProxy& operator=(const T& rhs) {
41+
set( wrap(rhs) );
42+
return *this;
43+
}
4144

42-
template <typename T> operator T() const ;
45+
template <typename T> operator T() const {
46+
return as<T>( get() );
47+
}
4348
inline operator SEXP() const {
4449
return get() ;
4550
}
@@ -61,7 +66,9 @@ class SlotProxyPolicy {
6166
const_SlotProxy( const CLASS& v, const std::string& name) ;
6267
const_SlotProxy& operator=(const const_SlotProxy& rhs) ;
6368

64-
template <typename T> operator T() const ;
69+
template <typename T> operator T() const {
70+
return as<T>( get() );
71+
}
6572
inline operator SEXP() const {
6673
return get() ;
6774
}

inst/include/Rcpp/proxy/TagProxy.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define Rcpp_TagProxy_h
2020

2121
namespace Rcpp{
22-
22+
2323
template <typename XPtrClass>
2424
class TagProxyPolicy {
2525
public:
@@ -29,10 +29,15 @@ namespace Rcpp{
2929
TagProxy( XPtrClass& xp_ ): xp(xp_){}
3030

3131
template <typename U>
32-
TagProxy& operator=( const U& u) ;
32+
TagProxy& operator=( const U& u) {
33+
set( wrap( u ) ) ;
34+
return *this ;
35+
}
3336

3437
template <typename U>
35-
operator U() const ;
38+
operator U() const {
39+
return as<U>( get() ) ;
40+
}
3641

3742
operator SEXP() const {
3843
return get();
@@ -57,7 +62,9 @@ namespace Rcpp{
5762
const_TagProxy( XPtrClass& xp_ ): xp(xp_){}
5863

5964
template <typename U>
60-
operator U() const ;
65+
operator U() const {
66+
return as<U>( get() );
67+
};
6168

6269
operator SEXP() const {
6370
return get();

0 commit comments

Comments
 (0)