Skip to content

Commit bedc6af

Browse files
move CppClass and CppObject to headers
1 parent f70f937 commit bedc6af

3 files changed

Lines changed: 11 additions & 12 deletions

File tree

inst/include/Rcpp/Module.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,7 @@ namespace Rcpp {
419419
}
420420

421421
CppClass& operator=( const CppClass& other) {
422-
Storage::copy__( static_cast<const S4&>(other) ) ;
423-
return *this ;
422+
return Storage::copy__( other ) ;
424423
}
425424

426425
} ;
@@ -433,8 +432,13 @@ namespace Rcpp {
433432
slot( "cppclass" ) = Rcpp::XPtr<class_Base>( clazz, false ) ;
434433
slot( "pointer" ) = xp ;
435434
}
436-
CppObject( const CppObject& ) ;
437-
CppObject& operator=( const CppObject& ) ;
435+
CppObject( const CppObject& other){
436+
Storage::copy( other ) ;
437+
}
438+
439+
CppObject& operator=( const CppObject& other ) {
440+
return Storage::copy__( other ) ;
441+
}
438442

439443
} ;
440444

inst/include/Rcpp/storage/PreserveStorage.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ namespace Rcpp{
3232
return out ;
3333
}
3434

35-
inline CLASS& copy__(const CLASS& other){
35+
template <typename T>
36+
inline T& copy__(const T& other){
3637
if( this != &other){
3738
set__(other.get__());
3839
}
39-
return static_cast<CLASS&>(*this) ;
40+
return static_cast<T&>(*this) ;
4041
}
4142

4243
inline bool inherits(const char* clazz) const {

src/Module.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,6 @@ extern "C" void R_init_Rcpp( DllInfo* info){
241241

242242
namespace Rcpp{
243243

244-
CppObject::CppObject( const CppObject& other) : S4(other.asSexp()){}
245-
CppObject& CppObject::operator=( const CppObject& other){
246-
setSEXP( other.asSexp() ) ;
247-
return *this ;
248-
}
249-
250244
namespace internal{
251245
void* as_module_object_internal(SEXP obj){
252246
Environment env(obj) ;

0 commit comments

Comments
 (0)