Skip to content

Commit 127a6f1

Browse files
committed
indentation and whitespace
1 parent 2148e96 commit 127a6f1

File tree

1 file changed

+80
-77
lines changed

1 file changed

+80
-77
lines changed

inst/unitTests/cpp/Module.cpp

Lines changed: 80 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
1+
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2+
// jedit: :folding=explicit:
23
//
34
// Module.cpp: Rcpp R/C++ interface class library -- module unit tests
45
//
5-
// Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois
6+
// Copyright (C) 2013 - 2014 Dirk Eddelbuettel and Romain Francois
67
//
78
// This file is part of Rcpp.
89
//
@@ -20,45 +21,46 @@
2021
// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
2122

2223
#include <Rcpp.h>
24+
2325
using namespace Rcpp ;
2426

25-
std::string hello(){
26-
return "hello" ;
27+
std::string hello() {
28+
return "hello" ;
2729
}
2830

29-
int bar( int x){
30-
return x*2 ;
31+
int bar(int x) {
32+
return x*2 ;
3133
}
3234

33-
double foo( int x, double y){
34-
return x * y ;
35+
double foo(int x, double y) {
36+
return x * y ;
3537
}
3638

37-
void bla( ){
38-
Rprintf( "hello\\n" ) ;
39+
void bla() {
40+
Rprintf("hello\\n") ;
3941
}
4042

41-
void bla1( int x){
42-
Rprintf( "hello (x = %d)\\n", x ) ;
43+
void bla1(int x) {
44+
Rprintf("hello (x = %d)\\n", x) ;
4345
}
4446

45-
void bla2( int x, double y){
46-
Rprintf( "hello (x = %d, y = %5.2f)\\n", x, y ) ;
47+
void bla2(int x, double y) {
48+
Rprintf("hello (x = %d, y = %5.2f)\\n", x, y) ;
4749
}
4850

49-
int test_reference( std::vector<double>& ref ){
51+
int test_reference(std::vector<double>& ref) {
5052
return ref.size() ;
5153
}
52-
int test_const_reference( const std::vector<double>& ref ){
54+
int test_const_reference(const std::vector<double>& ref) {
5355
return ref.size() ;
5456
}
55-
int test_const( const std::vector<double> ref ){
57+
int test_const(const std::vector<double> ref) {
5658
return ref.size() ;
5759
}
5860

5961
class World {
6062
public:
61-
World() : msg("hello"){}
63+
World() : msg("hello") {}
6264
void set(std::string msg_) { this->msg = msg_; }
6365
void set_ref(std::string& msg_) { this->msg = msg_; }
6466
void set_const_ref(const std::string& msg_) { this->msg = msg_; }
@@ -68,16 +70,16 @@ class World {
6870
std::string msg;
6971
};
7072

71-
void clearWorld( World* w ){
72-
w->set( "" );
73+
void clearWorld(World* w) {
74+
w->set("");
7375
}
7476

7577
class Num{
7678
public:
77-
Num() : x(0.0), y(0){} ;
79+
Num() : x(0.0), y(0) {} ;
7880

7981
double getX() const { return x ; }
80-
void setX(double value){ x = value ; }
82+
void setX(double value) { x = value ; }
8183

8284
int getY() { return y ; }
8385

@@ -88,7 +90,7 @@ class Num{
8890

8991
class Number{
9092
public:
91-
Number() : x(0.0), y(0){} ;
93+
Number() : x(0.0), y(0) {} ;
9294

9395
double x ;
9496
int y ;
@@ -97,12 +99,12 @@ class Number{
9799
class Randomizer {
98100
public:
99101

100-
// Randomizer() : min(0), max(1){}
101-
Randomizer( double min_, double max_) : min(min_), max(max_){}
102+
// Randomizer() : min(0), max(1) {}
103+
Randomizer(double min_, double max_) : min(min_), max(max_) {}
102104

103-
NumericVector get( int n ){
105+
NumericVector get(int n) {
104106
RNGScope scope ;
105-
return runif( n, min, max );
107+
return runif(n, min, max);
106108
}
107109

108110
private:
@@ -113,105 +115,106 @@ RCPP_EXPOSED_CLASS(Test)
113115
class Test{
114116
public:
115117
double value ;
116-
Test(double v) : value(v){}
118+
Test(double v) : value(v) {}
117119
private:
118120
// hiding those on purpose
119121
// we work by reference or pointers here. Not by copy.
120-
Test( const Test& other) ;
121-
Test& operator=( const Test& ) ;
122+
Test(const Test& other) ;
123+
Test& operator=(const Test&) ;
122124
} ;
123125

124-
double Test_get_x_const_ref( const Test& x){
126+
double Test_get_x_const_ref(const Test& x) {
125127
return x.value ;
126128
}
127-
double Test_get_x_ref( Test& x){
129+
double Test_get_x_ref(Test& x) {
128130
return x.value;
129131
}
130-
double Test_get_x_const_pointer( const Test* x){
132+
double Test_get_x_const_pointer(const Test* x) {
131133
return x->value ;
132134
}
133-
double Test_get_x_pointer( Test* x){
135+
double Test_get_x_pointer(Test* x) {
134136
return x->value ;
135137
}
136138

137-
RCPP_MODULE(yada){
138-
function( "hello" , &hello ) ;
139-
function( "bar" , &bar ) ;
140-
function( "foo" , &foo ) ;
141-
function( "bla" , &bla ) ;
142-
function( "bla1" , &bla1 ) ;
143-
function( "bla2" , &bla2 ) ;
139+
RCPP_MODULE(yada) {
140+
function("hello", &hello);
141+
function("bar" , &bar );
142+
function("foo" , &foo );
143+
function("bla" , &bla );
144+
function("bla1" , &bla1 );
145+
function("bla2" , &bla2 );
144146

145-
function( "test_reference", test_reference );
146-
function( "test_const_reference", test_const_reference ) ;
147-
function( "test_const", test_const ) ;
147+
function("test_reference", test_reference);
148+
function("test_const_reference", test_const_reference) ;
149+
function("test_const", test_const) ;
148150

149-
class_<Test>("Test")
151+
class_<Test>("Test")
150152
.constructor<double>()
151-
;
153+
;
152154

153-
class_<World>( "World" )
155+
class_<World>("World")
154156

155-
.constructor()
157+
.constructor()
156158

157-
.method( "greet", &World::greet )
158-
.method( "set", &World::set )
159-
.method( "set_ref", &World::set_ref )
160-
.method( "set_const_ref", &World::set_const_ref )
161-
.method( "clear", &clearWorld )
159+
.method("greet", &World::greet)
160+
.method("set", &World::set)
161+
.method("set_ref", &World::set_ref)
162+
.method("set_const_ref", &World::set_const_ref)
163+
.method("clear", &clearWorld)
162164
;
163165

164-
class_<Num>( "Num" )
165-
.constructor()
166+
class_<Num>("Num")
167+
.constructor()
166168

167-
// read and write property
168-
.property( "x", &Num::getX, &Num::setX )
169+
// read and write property
170+
.property("x", &Num::getX, &Num::setX)
169171

170-
// read-only property
171-
.property( "y", &Num::getY )
172-
;
172+
// read-only property
173+
.property("y", &Num::getY)
174+
;
173175

174-
class_<Number>( "Number" )
176+
class_<Number>("Number")
175177

176178
.constructor()
177179

178-
// read and write data member
179-
.field( "x", &Number::x )
180+
// read and write data member
181+
.field("x", &Number::x)
182+
183+
// read only data member
184+
.field_readonly("y", &Number::y)
185+
;
180186

181-
// read only data member
182-
.field_readonly( "y", &Number::y )
183-
;
184-
function( "Test_get_x_const_ref", Test_get_x_const_ref );
185-
function( "Test_get_x_ref", Test_get_x_ref );
186-
function( "Test_get_x_const_pointer", Test_get_x_const_pointer );
187-
function( "Test_get_x_pointer", Test_get_x_pointer );
187+
function("Test_get_x_const_ref", Test_get_x_const_ref);
188+
function("Test_get_x_ref", Test_get_x_ref);
189+
function("Test_get_x_const_pointer", Test_get_x_const_pointer);
190+
function("Test_get_x_pointer", Test_get_x_pointer);
188191

189192

190-
class_<Randomizer>( "Randomizer" )
193+
class_<Randomizer>("Randomizer")
191194
// No default: .default_constructor()
192195
.constructor<double,double>()
193196

194-
.method( "get" , &Randomizer::get )
195-
;
197+
.method("get" , &Randomizer::get)
198+
;
196199
}
197200

198201
// [[Rcpp::export]]
199-
double attr_Test_get_x_const_ref( const Test& x){
202+
double attr_Test_get_x_const_ref(const Test& x) {
200203
return x.value ;
201204
}
202205

203206
// [[Rcpp::export]]
204-
double attr_Test_get_x_ref( Test& x){
207+
double attr_Test_get_x_ref(Test& x) {
205208
return x.value;
206209
}
207210

208211
// [[Rcpp::export]]
209-
double attr_Test_get_x_const_pointer( const Test* x){
212+
double attr_Test_get_x_const_pointer(const Test* x) {
210213
return x->value ;
211214
}
212215

213216
// [[Rcpp::export]]
214-
double attr_Test_get_x_pointer( Test* x){
217+
double attr_Test_get_x_pointer(Test* x) {
215218
return x->value ;
216219
}
217220

0 commit comments

Comments
 (0)