Skip to content

Commit 7986f89

Browse files
tighting modules
1 parent b766732 commit 7986f89

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

inst/include/Rcpp/Module.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,10 @@ namespace Rcpp{
200200
} ;
201201

202202
template <typename Class>
203-
class S4_CppConstructor : public Rcpp::Reference {
203+
class S4_CppConstructor : public Reference {
204204
public:
205205
typedef XPtr<class_Base> XP_Class ;
206+
typedef Reference::Storage Storage ;
206207

207208
S4_CppConstructor( SignedConstructor<Class>* m, const XP_Class& class_xp, const std::string& class_name, std::string& buffer ) : Reference( "C++Constructor" ){
208209
RCPP_DEBUG( "S4_CppConstructor( SignedConstructor<Class>* m, SEXP class_xp, const std::string& class_name, std::string& buffer" ) ;
@@ -214,6 +215,8 @@ namespace Rcpp{
214215
field( "docstring" ) = m->docstring ;
215216
}
216217

218+
RCPP_CTOR_ASSIGN(S4_CppConstructor)
219+
217220
} ;
218221

219222
template <typename Class>
@@ -250,6 +253,8 @@ namespace Rcpp{
250253

251254
}
252255

256+
RCPP_CTOR_ASSIGN(S4_CppOverloadedMethods)
257+
253258
} ;
254259

255260
#include <Rcpp/module/Module_generated_CppMethod.h>
@@ -323,6 +328,8 @@ namespace Rcpp{
323328
field( "docstring" ) = p->docstring ;
324329
}
325330

331+
RCPP_CTOR_ASSIGN(S4_field)
332+
326333
} ;
327334

328335
#include <Rcpp/module/Module_Property.h>
@@ -374,7 +381,6 @@ namespace Rcpp {
374381
typedef XPtr<class_Base> XP_Class ;
375382
typedef Rcpp::XPtr<Rcpp::Module> XP ;
376383
CppClass( SEXP x) : S4(x){};
377-
CppClass( const CppClass& other) : S4(other.get__()){}
378384

379385
CppClass( Module* p, class_Base* cl, std::string& buffer ) : S4("C++Class") {
380386
XP_Class clxp( cl, false, R_NilValue, R_NilValue ) ;
@@ -395,9 +401,7 @@ namespace Rcpp {
395401
slot( "parents" ) = cl->parents ;
396402
}
397403

398-
CppClass& operator=( const CppClass& other) {
399-
return Storage::copy__( other ) ;
400-
}
404+
RCPP_CTOR_ASSIGN(CppClass)
401405

402406
} ;
403407

@@ -409,14 +413,7 @@ namespace Rcpp {
409413
slot( "cppclass" ) = Rcpp::XPtr<class_Base>( clazz, false ) ;
410414
slot( "pointer" ) = xp ;
411415
}
412-
CppObject( const CppObject& other){
413-
Storage::copy__( other ) ;
414-
}
415-
416-
CppObject& operator=( const CppObject& other ) {
417-
return Storage::copy__( other ) ;
418-
}
419-
416+
RCPP_CTOR_ASSIGN(CppObject)
420417
} ;
421418

422419
}

inst/include/Rcpp/macros/interface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
#define RCPP_GENERATE_CTOR_ASSIGN(__CLASS__) \
2222
typedef StoragePolicy<__CLASS__> Storage ; \
2323
typedef AttributeProxyPolicy<__CLASS__> AttributePolicy ; \
24+
RCPP_CTOR_ASSIGN(__CLASS__)
25+
26+
#define RCPP_CTOR_ASSIGN(__CLASS__) \
2427
__CLASS__( const __CLASS__& other ){ \
2528
Storage::copy__(other) ; \
2629
} \

0 commit comments

Comments
 (0)