Skip to content

Commit 5cd8f34

Browse files
committed
white-space only changes
1 parent 2b38bc3 commit 5cd8f34

File tree

1 file changed

+80
-80
lines changed

1 file changed

+80
-80
lines changed

src/barrier.cpp

Lines changed: 80 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// barrier.cpp: Rcpp R/C++ interface class library -- write barrier
44
//
5-
// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
5+
// Copyright (C) 2010 - 2015 Dirk Eddelbuettel and Romain Francois
66
//
77
// This file is part of Rcpp.
88
//
@@ -29,57 +29,57 @@
2929
#include <Rcpp/protection/Shield.h>
3030

3131
// [[Rcpp::register]]
32-
SEXP get_string_elt(SEXP x, int i){
33-
return STRING_ELT(x, i ) ;
32+
SEXP get_string_elt(SEXP x, int i) {
33+
return STRING_ELT(x, i);
3434
}
3535

3636
// [[Rcpp::register]]
37-
const char* char_get_string_elt(SEXP x, int i){
38-
return CHAR(STRING_ELT(x, i )) ;
37+
const char* char_get_string_elt(SEXP x, int i) {
38+
return CHAR(STRING_ELT(x, i));
3939
}
4040

4141
// [[Rcpp::register]]
42-
void set_string_elt(SEXP x, int i, SEXP value){
43-
STRING_ELT(x, i) = value ;
42+
void set_string_elt(SEXP x, int i, SEXP value) {
43+
STRING_ELT(x, i) = value;
4444
}
4545

4646
// [[Rcpp::register]]
47-
void char_set_string_elt(SEXP x, int i, const char* value){
48-
STRING_ELT(x, i) = Rf_mkChar(value) ;
47+
void char_set_string_elt(SEXP x, int i, const char* value) {
48+
STRING_ELT(x, i) = Rf_mkChar(value);
4949
}
5050

5151
// [[Rcpp::register]]
52-
SEXP* get_string_ptr(SEXP x){
53-
return STRING_PTR(x) ;
52+
SEXP* get_string_ptr(SEXP x) {
53+
return STRING_PTR(x);
5454
}
5555

5656
// [[Rcpp::register]]
57-
SEXP get_vector_elt(SEXP x, int i){
58-
return VECTOR_ELT(x, i ) ;
57+
SEXP get_vector_elt(SEXP x, int i) {
58+
return VECTOR_ELT(x, i);
5959
}
6060

6161
// [[Rcpp::register]]
62-
void set_vector_elt(SEXP x, int i, SEXP value){
63-
SET_VECTOR_ELT(x, i, value ) ;
62+
void set_vector_elt(SEXP x, int i, SEXP value) {
63+
SET_VECTOR_ELT(x, i, value);
6464
}
6565

6666
// [[Rcpp::register]]
67-
SEXP* get_vector_ptr(SEXP x){
68-
return VECTOR_PTR(x) ;
67+
SEXP* get_vector_ptr(SEXP x) {
68+
return VECTOR_PTR(x);
6969
}
7070

7171
// [[Rcpp::register]]
72-
void* dataptr(SEXP x){
72+
void* dataptr(SEXP x) {
7373
return DATAPTR(x);
7474
}
7575

7676
// [[Rcpp::register]]
77-
const char* char_nocheck( SEXP x ){
77+
const char* char_nocheck(SEXP x) {
7878
return CHAR(x);
7979
}
8080

81-
static bool Rcpp_cache_know = false ;
82-
static SEXP Rcpp_cache = R_NilValue ;
81+
static bool Rcpp_cache_know = false;
82+
static SEXP Rcpp_cache = R_NilValue;
8383

8484
#define RCPP_HASH_CACHE_INDEX 4
8585
#define RCPP_CACHE_SIZE 5
@@ -90,120 +90,120 @@ static SEXP Rcpp_cache = R_NilValue ;
9090

9191
// only used for debugging
9292
SEXP get_rcpp_cache() {
93-
if( ! Rcpp_cache_know ){
93+
if (! Rcpp_cache_know) {
9494

9595
SEXP getNamespaceSym = Rf_install("getNamespace"); // cannot be gc()'ed once in symbol table
96-
Rcpp::Shield<SEXP> RcppString( Rf_mkString("Rcpp") );
97-
Rcpp::Shield<SEXP> call( Rf_lang2( getNamespaceSym, RcppString ) );
98-
Rcpp::Shield<SEXP> RCPP( Rf_eval(call, R_GlobalEnv) ) ;
96+
Rcpp::Shield<SEXP> RcppString(Rf_mkString("Rcpp"));
97+
Rcpp::Shield<SEXP> call(Rf_lang2(getNamespaceSym, RcppString));
98+
Rcpp::Shield<SEXP> RCPP(Rf_eval(call, R_GlobalEnv));
9999

100-
Rcpp_cache = Rf_findVarInFrame( RCPP, Rf_install(".rcpp_cache") ) ;
101-
Rcpp_cache_know = true ;
100+
Rcpp_cache = Rf_findVarInFrame(RCPP, Rf_install(".rcpp_cache"));
101+
Rcpp_cache_know = true;
102102
}
103-
return Rcpp_cache ;
103+
return Rcpp_cache;
104104
}
105105

106106
namespace Rcpp {
107107
namespace internal {
108108
// [[Rcpp::register]]
109-
SEXP get_Rcpp_namespace(){
110-
return VECTOR_ELT( get_rcpp_cache() , 0 ) ;
109+
SEXP get_Rcpp_namespace() {
110+
return VECTOR_ELT(get_rcpp_cache() , 0);
111111
}
112112
}
113113
}
114114

115115
// [[Rcpp::register]]
116-
SEXP rcpp_get_stack_trace(){
117-
return VECTOR_ELT( get_rcpp_cache(), 3 ) ;
116+
SEXP rcpp_get_stack_trace() {
117+
return VECTOR_ELT(get_rcpp_cache(), 3);
118118
}
119119

120120
// [[Rcpp::register]]
121-
SEXP rcpp_set_stack_trace(SEXP e){
122-
SET_VECTOR_ELT( get_rcpp_cache(), 3, e ) ;
123-
return R_NilValue ;
121+
SEXP rcpp_set_stack_trace(SEXP e) {
122+
SET_VECTOR_ELT(get_rcpp_cache(), 3, e);
123+
return R_NilValue;
124124
}
125125

126-
SEXP set_error_occured(SEXP cache, SEXP e){
127-
SET_VECTOR_ELT( cache, 1, e ) ;
128-
return R_NilValue ;
126+
SEXP set_error_occured(SEXP cache, SEXP e) {
127+
SET_VECTOR_ELT(cache, 1, e);
128+
return R_NilValue;
129129
}
130130

131-
SEXP set_current_error(SEXP cache, SEXP e){
132-
SET_VECTOR_ELT( cache, 2, e ) ;
133-
return R_NilValue ;
131+
SEXP set_current_error(SEXP cache, SEXP e) {
132+
SET_VECTOR_ELT(cache, 2, e);
133+
return R_NilValue;
134134
}
135135

136-
SEXP init_Rcpp_cache(){
136+
SEXP init_Rcpp_cache() {
137137
SEXP getNamespaceSym = Rf_install("getNamespace"); // cannot be gc()'ed once in symbol table
138-
Rcpp::Shield<SEXP> RcppString( Rf_mkString("Rcpp") );
139-
Rcpp::Shield<SEXP> call( Rf_lang2( getNamespaceSym, RcppString ) );
140-
Rcpp::Shield<SEXP> RCPP( Rf_eval(call, R_GlobalEnv) ) ;
141-
Rcpp::Shield<SEXP> cache( Rf_allocVector( VECSXP, RCPP_CACHE_SIZE ) );
138+
Rcpp::Shield<SEXP> RcppString(Rf_mkString("Rcpp"));
139+
Rcpp::Shield<SEXP> call(Rf_lang2(getNamespaceSym, RcppString));
140+
Rcpp::Shield<SEXP> RCPP(Rf_eval(call, R_GlobalEnv));
141+
Rcpp::Shield<SEXP> cache(Rf_allocVector(VECSXP, RCPP_CACHE_SIZE));
142142

143143
// the Rcpp namespace
144-
SET_VECTOR_ELT( cache, 0, RCPP ) ;
145-
set_error_occured( cache, Rf_ScalarLogical(FALSE) ) ; // error occured
146-
set_current_error( cache, R_NilValue ) ; // current error
147-
SET_VECTOR_ELT( cache, 3, R_NilValue ) ; // stack trace
148-
Rcpp::Shield<SEXP> tmp( Rf_allocVector(INTSXP, RCPP_HASH_CACHE_INITIAL_SIZE) );
149-
SET_VECTOR_ELT( cache, RCPP_HASH_CACHE_INDEX, tmp );
150-
Rf_defineVar( Rf_install(".rcpp_cache"), cache, RCPP );
144+
SET_VECTOR_ELT(cache, 0, RCPP);
145+
set_error_occured(cache, Rf_ScalarLogical(FALSE)); // error occured
146+
set_current_error(cache, R_NilValue); // current error
147+
SET_VECTOR_ELT(cache, 3, R_NilValue); // stack trace
148+
Rcpp::Shield<SEXP> tmp(Rf_allocVector(INTSXP, RCPP_HASH_CACHE_INITIAL_SIZE));
149+
SET_VECTOR_ELT(cache, RCPP_HASH_CACHE_INDEX, tmp);
150+
Rf_defineVar(Rf_install(".rcpp_cache"), cache, RCPP);
151151

152-
return cache ;
152+
return cache;
153153
}
154154

155155
// [[Rcpp::register]]
156-
SEXP reset_current_error(){
157-
SEXP cache = get_rcpp_cache() ;
156+
SEXP reset_current_error() {
157+
SEXP cache = get_rcpp_cache();
158158

159159
// error occured
160-
set_error_occured( cache, Rf_ScalarLogical(FALSE) ) ;
160+
set_error_occured(cache, Rf_ScalarLogical(FALSE));
161161

162162
// current error
163-
set_current_error( cache, R_NilValue ) ;
163+
set_current_error(cache, R_NilValue);
164164

165165
// stack trace
166-
SET_VECTOR_ELT( cache, 3, R_NilValue ) ;
166+
SET_VECTOR_ELT(cache, 3, R_NilValue);
167167

168-
return R_NilValue ;
168+
return R_NilValue;
169169
}
170170

171171
// [[Rcpp::register]]
172-
int error_occured(){
173-
SEXP err = VECTOR_ELT( get_rcpp_cache(), 1 ) ;
174-
return LOGICAL(err)[0] ;
172+
int error_occured() {
173+
SEXP err = VECTOR_ELT(get_rcpp_cache(), 1);
174+
return LOGICAL(err)[0];
175175
}
176176

177177
// [[Rcpp::internal]]
178-
SEXP rcpp_error_recorder(SEXP e){
179-
SEXP cache = get_rcpp_cache() ;
178+
SEXP rcpp_error_recorder(SEXP e) {
179+
SEXP cache = get_rcpp_cache();
180180

181181
// error occured
182-
set_error_occured( cache, Rf_ScalarLogical(TRUE) ) ;
182+
set_error_occured(cache, Rf_ScalarLogical(TRUE));
183183

184184
// current error
185-
set_current_error(cache, e ) ;
185+
set_current_error(cache, e);
186186

187-
return R_NilValue ;
187+
return R_NilValue;
188188
}
189189

190190
// [[Rcpp::register]]
191-
SEXP rcpp_get_current_error(){
192-
return VECTOR_ELT( get_rcpp_cache(), 2 ) ;
191+
SEXP rcpp_get_current_error() {
192+
return VECTOR_ELT(get_rcpp_cache(), 2);
193193
}
194194

195195
// [[Rcpp::register]]
196-
int* get_cache( int m){
197-
SEXP cache = get_rcpp_cache() ;
198-
SEXP hash_cache = VECTOR_ELT( cache, RCPP_HASH_CACHE_INDEX) ;
199-
int n = Rf_length(hash_cache) ;
200-
if( m > n ){
201-
Rcpp::Shield<SEXP> new_hash_cache( Rf_allocVector( INTSXP, m) ) ;
202-
hash_cache = new_hash_cache ;
196+
int* get_cache(int m) {
197+
SEXP cache = get_rcpp_cache();
198+
SEXP hash_cache = VECTOR_ELT(cache, RCPP_HASH_CACHE_INDEX);
199+
int n = Rf_length(hash_cache);
200+
if (m > n) {
201+
Rcpp::Shield<SEXP> new_hash_cache(Rf_allocVector(INTSXP, m));
202+
hash_cache = new_hash_cache;
203203
SET_VECTOR_ELT(cache,RCPP_HASH_CACHE_INDEX, hash_cache);
204204
}
205-
int *res = INTEGER(hash_cache) ;
206-
std::fill(res, res+m, 0 ) ;
207-
return res ;
205+
int *res = INTEGER(hash_cache);
206+
std::fill(res, res+m, 0);
207+
return res;
208208
}
209209

0 commit comments

Comments
 (0)