Skip to content

Commit f1f8935

Browse files
WeakReference
1 parent 6945dea commit f1f8935

3 files changed

Lines changed: 14 additions & 22 deletions

File tree

inst/include/Rcpp/WeakReference.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@
2121

2222
namespace Rcpp{
2323

24-
class WeakReference :
25-
RCPP_POLICIES(WeakReference)
26-
{
24+
RCPP_API_CLASS(WeakReference_Impl) {
2725
public:
2826

29-
RCPP_GENERATE_CTOR_ASSIGN(WeakReference)
27+
RCPP_GENERATE_CTOR_ASSIGN__(WeakReference_Impl)
3028

3129
/**
3230
* wraps a weak reference
@@ -35,17 +33,25 @@ namespace Rcpp{
3533
*
3634
* @throw not_compatible if x is not a weak reference
3735
*/
38-
WeakReference( SEXP x) ;
36+
WeakReference_Impl( SEXP x){
37+
if( TYPEOF(x) != WEAKREFSXP )
38+
throw not_compatible( "not a weak reference" ) ;
39+
Storage::set__(x) ;
40+
}
3941

4042
/**
4143
* Retrieve the key
4244
*/
43-
SEXP key() ;
45+
SEXP key() {
46+
return R_WeakRefKey(Storage::get__()) ;
47+
}
4448

4549
/**
4650
* Retrieve the value
4751
*/
48-
SEXP value() ;
52+
SEXP value(){
53+
return R_WeakRefValue(Storage::get__());
54+
}
4955

5056
void update(SEXP){}
5157
} ;

inst/include/RcppCommon.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ namespace Rcpp{
9797
RCPP_API_CLASS_DECL(Pairlist) ;
9898
RCPP_API_CLASS_DECL(Environment) ;
9999
RCPP_API_CLASS_DECL(Promise) ;
100-
class WeakReference ;
100+
RCPP_API_CLASS_DECL(WeakReference) ;
101101
class Reference ;
102102
class S4 ;
103103
class Formula ;

src/api.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -262,20 +262,6 @@ namespace Rcpp {
262262
}
263263
}
264264

265-
// {{{ WeakReference
266-
WeakReference::WeakReference( SEXP x) {
267-
if( TYPEOF(x) != WEAKREFSXP )
268-
throw not_compatible( "not a weak reference" ) ;
269-
set__(x) ;
270-
}
271-
272-
SEXP WeakReference::key() {
273-
return R_WeakRefKey(get__()) ;
274-
}
275-
276-
SEXP WeakReference::value() {
277-
return R_WeakRefValue(get__());
278-
}
279265
// }}}
280266

281267
// {{{ Symbol

0 commit comments

Comments
 (0)