Skip to content

Commit 2f69b28

Browse files
kevinusheyeddelbuettel
authored andcommitted
use documented R API function for extptr addr
1 parent a9ca85d commit 2f69b28

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
* inst/NEWS.Rd: Idem
77
* vignettes/rmd/Rcpp.bib: Idem
88
* inst/bib/Rcpp.bib: Idem
9+
2020-06-29 Kevin Ushey <[email protected]>
10+
11+
* inst/include/Rcpp/module/class.h: EXTPTR_PTR -> R_ExternalPtrAddr
12+
* src/api.cpp: Idem
13+
* src/module.cpp: Idem
914

1015
2020-06-27 Dirk Eddelbuettel <[email protected]>
1116

inst/include/Rcpp/module/class.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
SEXP invoke( SEXP method_xp, SEXP object, SEXP *args, int nargs ){
168168
BEGIN_RCPP
169169

170-
vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( EXTPTR_PTR( method_xp ) ) ;
170+
vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( R_ExternalPtrAddr( method_xp ) ) ;
171171
typename vec_signed_method::iterator it = mets->begin() ;
172172
int n = mets->size() ;
173173
method_class* m = 0 ;
@@ -194,7 +194,7 @@
194194
SEXP invoke_void( SEXP method_xp, SEXP object, SEXP *args, int nargs ){
195195
BEGIN_RCPP
196196

197-
vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( EXTPTR_PTR( method_xp ) ) ;
197+
vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( R_ExternalPtrAddr( method_xp ) ) ;
198198
typename vec_signed_method::iterator it = mets->begin() ;
199199
int n = mets->size() ;
200200
method_class* m = 0 ;
@@ -216,7 +216,7 @@
216216
SEXP invoke_notvoid( SEXP method_xp, SEXP object, SEXP *args, int nargs ){
217217
BEGIN_RCPP
218218

219-
vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( EXTPTR_PTR( method_xp ) ) ;
219+
vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( R_ExternalPtrAddr( method_xp ) ) ;
220220
typename vec_signed_method::iterator it = mets->begin() ;
221221
int n = mets->size() ;
222222
method_class* m = 0 ;
@@ -393,14 +393,14 @@
393393

394394
SEXP getProperty( SEXP field_xp , SEXP object) {
395395
BEGIN_RCPP
396-
prop_class* prop = reinterpret_cast< prop_class* >( EXTPTR_PTR( field_xp ) ) ;
396+
prop_class* prop = reinterpret_cast< prop_class* >( R_ExternalPtrAddr( field_xp ) ) ;
397397
return prop->get( XP(object) );
398398
END_RCPP
399399
}
400400

401401
void setProperty( SEXP field_xp, SEXP object, SEXP value) {
402402
BEGIN_RCPP
403-
prop_class* prop = reinterpret_cast< prop_class* >( EXTPTR_PTR( field_xp ) ) ;
403+
prop_class* prop = reinterpret_cast< prop_class* >( R_ExternalPtrAddr( field_xp ) ) ;
404404
return prop->set( XP(object), value );
405405
VOID_END_RCPP
406406
}

src/api.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ const char* short_file_name(const char* file) { // #nocov start
145145
// [[Rcpp::internal]]
146146
SEXP as_character_externalptr(SEXP xp) {
147147
char buffer[20];
148-
snprintf(buffer, 20, "%p", (void*)EXTPTR_PTR(xp));
148+
snprintf(buffer, 20, "%p", (void*)R_ExternalPtrAddr(xp));
149149
return Rcpp::wrap((const char*)buffer);
150150
} // #nocov end
151151

src/module.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ RCPP_FUN_2(Rcpp::CppClass, Module__get_class, XP_Module module, std::string cl)
5353
return module->get_class(cl);
5454
}
5555
RCPP_FUN_1(bool, CppObject__needs_init, SEXP xp) { // #nocov start
56-
return EXTPTR_PTR(xp) == 0;
56+
return R_ExternalPtrAddr(xp) == 0;
5757
}
5858
RCPP_FUN_1(Rcpp::CharacterVector, CppClass__methods, XP_Class cl) {
5959
return cl->method_names();

0 commit comments

Comments
 (0)