Skip to content

Commit 49944cf

Browse files
committed
further Module renamings
1 parent aee3594 commit 49944cf

File tree

5 files changed

+42
-43
lines changed

5 files changed

+42
-43
lines changed

inst/unitTests/cpp/Module.cpp

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ void clearWorld(ModuleWorld* w) {
7474
w->set("");
7575
}
7676

77-
class Num{
77+
class ModuleNum{
7878
public:
79-
Num() : x(0.0), y(0) {};
79+
ModuleNum() : x(0.0), y(0) {};
8080

8181
double getX() const { return x; }
8282
void setX(double value) { x = value; }
@@ -88,19 +88,19 @@ class Num{
8888
int y;
8989
};
9090

91-
class Number{
91+
class ModuleNumber{
9292
public:
93-
Number() : x(0.0), y(0) {};
93+
ModuleNumber() : x(0.0), y(0) {};
9494

9595
double x;
9696
int y;
9797
};
9898

99-
class Randomizer {
99+
class ModuleRandomizer {
100100
public:
101101

102102
// Randomizer() : min(0), max(1) {}
103-
Randomizer(double min_, double max_) : min(min_), max(max_) {}
103+
ModuleRandomizer(double min_, double max_) : min(min_), max(max_) {}
104104

105105
NumericVector get(int n) {
106106
RNGScope scope;
@@ -111,28 +111,28 @@ class Randomizer {
111111
double min, max;
112112
};
113113

114-
RCPP_EXPOSED_CLASS(Test)
115-
class Test{
114+
RCPP_EXPOSED_CLASS(ModuleTest)
115+
class ModuleTest {
116116
public:
117117
double value;
118-
Test(double v) : value(v) {}
118+
ModuleTest(double v) : value(v) {}
119119
private:
120120
// hiding those on purpose
121121
// we work by reference or pointers here. Not by copy.
122-
Test(const Test& other);
123-
Test& operator=(const Test&);
122+
ModuleTest(const ModuleTest& other);
123+
ModuleTest& operator=(const ModuleTest&);
124124
};
125125

126-
double Test_get_x_const_ref(const Test& x) {
126+
double Test_get_x_const_ref(const ModuleTest& x) {
127127
return x.value;
128128
}
129-
double Test_get_x_ref(Test& x) {
129+
double Test_get_x_ref(ModuleTest& x) {
130130
return x.value;
131131
}
132-
double Test_get_x_const_pointer(const Test* x) {
132+
double Test_get_x_const_pointer(const ModuleTest* x) {
133133
return x->value;
134134
}
135-
double Test_get_x_pointer(Test* x) {
135+
double Test_get_x_pointer(ModuleTest* x) {
136136
return x->value;
137137
}
138138

@@ -148,7 +148,7 @@ RCPP_MODULE(demoModule) {
148148
function("test_const_reference", test_const_reference);
149149
function("test_const", test_const);
150150

151-
class_<Test>("Test")
151+
class_<ModuleTest>("ModuleTest")
152152
.constructor<double>()
153153
;
154154

@@ -161,25 +161,25 @@ RCPP_MODULE(demoModule) {
161161
.method("clear", &clearWorld)
162162
;
163163

164-
class_<Num>("Num")
164+
class_<ModuleNum>("ModuleNum")
165165
.constructor()
166166

167167
// read and write property
168-
.property("x", &Num::getX, &Num::setX)
168+
.property("x", &ModuleNum::getX, &ModuleNum::setX)
169169

170170
// read-only property
171-
.property("y", &Num::getY)
171+
.property("y", &ModuleNum::getY)
172172
;
173173

174-
class_<Number>("Number")
174+
class_<ModuleNumber>("ModuleNumber")
175175

176176
.constructor()
177177

178178
// read and write data member
179-
.field("x", &Number::x)
179+
.field("x", &ModuleNumber::x)
180180

181181
// read only data member
182-
.field_readonly("y", &Number::y)
182+
.field_readonly("y", &ModuleNumber::y)
183183
;
184184

185185
function("Test_get_x_const_ref", Test_get_x_const_ref);
@@ -188,32 +188,31 @@ RCPP_MODULE(demoModule) {
188188
function("Test_get_x_pointer", Test_get_x_pointer);
189189

190190

191-
class_<Randomizer>("Randomizer")
191+
class_<ModuleRandomizer>("ModuleRandomizer")
192192
// No default: .default_constructor()
193193
.constructor<double,double>()
194194

195-
.method("get" , &Randomizer::get)
195+
.method("get" , &ModuleRandomizer::get)
196196
;
197197
}
198198

199199
// [[Rcpp::export]]
200-
double attr_Test_get_x_const_ref(const Test& x) {
200+
double attr_Test_get_x_const_ref(const ModuleTest& x) {
201201
return x.value;
202202
}
203203

204204
// [[Rcpp::export]]
205-
double attr_Test_get_x_ref(Test& x) {
205+
double attr_Test_get_x_ref(ModuleTest& x) {
206206
return x.value;
207207
}
208208

209209
// [[Rcpp::export]]
210-
double attr_Test_get_x_const_pointer(const Test* x) {
210+
double attr_Test_get_x_const_pointer(const ModuleTest* x) {
211211
return x->value;
212212
}
213213

214214
// [[Rcpp::export]]
215-
double attr_Test_get_x_pointer(Test* x) {
215+
double attr_Test_get_x_pointer(ModuleTest* x) {
216216
return x->value;
217217
}
218218

219-

inst/unitTests/runit.Module.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ if( .runThisTest && Rcpp:::capabilities()[["Rcpp modules"]] ) {
4646
}
4747

4848
test.Module.exposed.class <- function(){
49-
test <- new( Test, 3.0 )
49+
test <- new( ModuleTest, 3.0 )
5050
checkEquals( Test_get_x_const_ref(test), 3.0 )
5151
checkEquals( Test_get_x_const_pointer(test), 3.0 )
5252
checkEquals( Test_get_x_ref(test), 3.0 )
@@ -59,7 +59,7 @@ if( .runThisTest && Rcpp:::capabilities()[["Rcpp modules"]] ) {
5959
}
6060

6161
test.Module.property <- function(){
62-
w <- new( Num )
62+
w <- new( ModuleNum )
6363
checkEquals( w$x, 0.0 )
6464
checkEquals( w$y, 0L )
6565

@@ -70,7 +70,7 @@ if( .runThisTest && Rcpp:::capabilities()[["Rcpp modules"]] ) {
7070
}
7171

7272
test.Module.member <- function(){
73-
w <- new( Number )
73+
w <- new( ModuleNumber )
7474
checkEquals( w$x, 0.0 )
7575
checkEquals( w$y, 0L )
7676

@@ -81,7 +81,7 @@ if( .runThisTest && Rcpp:::capabilities()[["Rcpp modules"]] ) {
8181
}
8282

8383
test.Module.Constructor <- function() {
84-
r <- new( Randomizer, 10.0, 20.0 )
84+
r <- new( ModuleRandomizer, 10.0, 20.0 )
8585
set.seed(123)
8686
x10 <- runif(10, 10.0, 20.0)
8787
set.seed(123)

inst/unitTests/testRcppModule/R/zzz.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
## For R 2.15.1 and later this also works. Note that calling loadModule() triggers
77
## a load action, so this does not have to be placed in .onLoad() or evalqOnLoad().
8-
loadModule("NumEx", TRUE)
8+
loadModule("RcppModuleNumEx", TRUE)
99
loadModule("RcppModuleWorld", TRUE)
1010
loadModule("stdVector", TRUE)
1111

inst/unitTests/testRcppModule/src/Num.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// Num.cpp: Rcpp R/C++ interface class library -- Rcpp Module example
44
//
5-
// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois
5+
// Copyright (C) 2010 - 2015 Dirk Eddelbuettel and Romain Francois
66
//
77
// This file is part of Rcpp.
88
//
@@ -21,9 +21,9 @@
2121

2222
#include <Rcpp.h>
2323

24-
class Num { // simple class with two private variables
24+
class RcppModuleNum { // simple class with two private variables
2525
public: // which have a getter/setter and getter
26-
Num() : x(0.0), y(0){} ;
26+
RcppModuleNum() : x(0.0), y(0){} ;
2727

2828
double getX() { return x ; }
2929
void setX(double value){ x = value ; }
@@ -35,17 +35,17 @@ class Num { // simple class with two private variables
3535
int y ;
3636
};
3737

38-
RCPP_MODULE(NumEx){
38+
RCPP_MODULE(RcppModuleNumEx){
3939
using namespace Rcpp ;
4040

41-
class_<Num>( "Num" )
41+
class_<RcppModuleNum>( "RcppModuleNum" )
4242

4343
.default_constructor()
4444

4545
// read and write property
46-
.property( "x", &Num::getX, &Num::setX )
46+
.property( "x", &RcppModuleNum::getX, &RcppModuleNum::setX )
4747

4848
// read-only property
49-
.property( "y", &Num::getY )
49+
.property( "y", &RcppModuleNum::getY )
5050
;
5151
}

inst/unitTests/testRcppModule/src/rcpp_module.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ void bla( ) { // no input or return but output side effect
3535
}
3636

3737
void bla1(int x) { // output reflecting a single input
38-
Rprintf( "hello (x = %d)\n", x);
38+
Rprintf("hello (x = %d)\n", x);
3939
}
4040

4141
void bla2(int x, double y) { // output reflecting two inputs
42-
Rprintf( "hello (x = %d, y = %5.2f)\n", x, y);
42+
Rprintf("hello (x = %d, y = %5.2f)\n", x, y);
4343
}
4444

4545

0 commit comments

Comments
 (0)