Skip to content

Commit e0b8e83

Browse files
committed
white-space only: indentation, around operators/braces/function/function arguments, untabified
also updated Copyright year
1 parent bc5f46b commit e0b8e83

File tree

1 file changed

+61
-61
lines changed
  • inst/include/Rcpp

1 file changed

+61
-61
lines changed

inst/include/Rcpp/as.h

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// as.h: Rcpp R/C++ interface class library -- convert SEXP to C++ objects
44
//
5-
// Copyright (C) 2009 - 2013 Dirk Eddelbuettel and Romain Francois
5+
// Copyright (C) 2009 - 2015 Dirk Eddelbuettel and Romain Francois
66
//
77
// This file is part of Rcpp.
88
//
@@ -24,102 +24,102 @@
2424

2525
#include <Rcpp/internal/Exporter.h>
2626

27-
namespace Rcpp{
27+
namespace Rcpp {
2828

29-
namespace internal{
29+
namespace internal {
3030

31-
template <typename T> T primitive_as( SEXP x ){
32-
if( ::Rf_length(x) != 1 ) throw ::Rcpp::not_compatible( "expecting a single value" ) ;
33-
const int RTYPE = ::Rcpp::traits::r_sexptype_traits<T>::rtype ;
34-
Shield<SEXP> y( r_cast<RTYPE>(x) );
31+
template <typename T> T primitive_as(SEXP x) {
32+
if (::Rf_length(x) != 1) throw ::Rcpp::not_compatible("expecting a single value");
33+
const int RTYPE = ::Rcpp::traits::r_sexptype_traits<T>::rtype;
34+
Shield<SEXP> y(r_cast<RTYPE>(x));
3535
typedef typename ::Rcpp::traits::storage_type<RTYPE>::type STORAGE;
36-
T res = caster<STORAGE,T>( *r_vector_start<RTYPE>( y ) ) ;
37-
return res ;
36+
T res = caster<STORAGE,T>(*r_vector_start<RTYPE>(y));
37+
return res;
3838
}
3939

40-
template <typename T> T as( SEXP x, ::Rcpp::traits::r_type_primitive_tag ) {
41-
return primitive_as<T>(x) ;
40+
template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_primitive_tag) {
41+
return primitive_as<T>(x);
4242
}
4343

44-
inline const char* check_single_string( SEXP x){
45-
if( TYPEOF(x) == CHARSXP ) return CHAR( x ) ;
46-
if( ! ::Rf_isString(x) )
47-
throw ::Rcpp::not_compatible( "expecting a string" ) ;
44+
inline const char* check_single_string(SEXP x) {
45+
if (TYPEOF(x) == CHARSXP) return CHAR(x);
46+
if (! ::Rf_isString(x))
47+
throw ::Rcpp::not_compatible("expecting a string");
4848
if (Rf_length(x) != 1)
49-
throw ::Rcpp::not_compatible( "expecting a single value");
50-
return CHAR( STRING_ELT( ::Rcpp::r_cast<STRSXP>(x) ,0 ) ) ;
49+
throw ::Rcpp::not_compatible("expecting a single value");
50+
return CHAR(STRING_ELT(::Rcpp::r_cast<STRSXP>(x), 0));
5151
}
5252

5353

54-
template <typename T> T as_string( SEXP x, Rcpp::traits::true_type){
55-
const char* y = check_single_string(x) ;
56-
return std::wstring( y, y+strlen(y)) ;
54+
template <typename T> T as_string(SEXP x, Rcpp::traits::true_type) {
55+
const char* y = check_single_string(x);
56+
return std::wstring(y, y+strlen(y));
5757
}
5858

59-
template <typename T> T as_string( SEXP x, Rcpp::traits::false_type){
60-
return check_single_string(x) ;
59+
template <typename T> T as_string(SEXP x, Rcpp::traits::false_type) {
60+
return check_single_string(x);
6161
}
6262

63-
template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_string_tag ) {
64-
return as_string<T>( x, typename Rcpp::traits::is_wide_string<T>::type() );
63+
template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_string_tag) {
64+
return as_string<T>(x, typename Rcpp::traits::is_wide_string<T>::type());
6565
}
6666

67-
template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_RcppString_tag ) {
68-
if( ! ::Rf_isString(x) ){
69-
throw ::Rcpp::not_compatible( "expecting a string" ) ;
67+
template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_RcppString_tag) {
68+
if (! ::Rf_isString(x)) {
69+
throw ::Rcpp::not_compatible("expecting a string");
7070
}
7171
if (Rf_length(x) != 1) {
72-
throw ::Rcpp::not_compatible( "expecting a single value");
72+
throw ::Rcpp::not_compatible("expecting a single value");
7373
}
74-
return STRING_ELT( ::Rcpp::r_cast<STRSXP>(x) ,0 ) ;
74+
return STRING_ELT(::Rcpp::r_cast<STRSXP>(x), 0);
7575
}
7676

77-
template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_generic_tag ) {
78-
RCPP_DEBUG_1( "as(SEXP = <%p>, r_type_generic_tag )", x ) ;
77+
template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_generic_tag) {
78+
RCPP_DEBUG_1("as(SEXP = <%p>, r_type_generic_tag )", x);
7979
::Rcpp::traits::Exporter<T> exporter(x);
80-
RCPP_DEBUG_1( "exporter type = %s", DEMANGLE(exporter) ) ;
81-
return exporter.get() ;
80+
RCPP_DEBUG_1("exporter type = %s", DEMANGLE(exporter));
81+
return exporter.get();
8282
}
8383

84-
void* as_module_object_internal(SEXP obj) ;
84+
void* as_module_object_internal(SEXP obj);
8585

86-
template <typename T> object<T> as_module_object(SEXP x){
87-
return (T*) as_module_object_internal(x) ;
86+
template <typename T> object<T> as_module_object(SEXP x) {
87+
return (T*) as_module_object_internal(x);
8888
}
8989

9090
/** handling object<T> */
91-
template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_module_object_const_pointer_tag ) {
92-
typedef typename Rcpp::traits::remove_const<T>::type T_NON_CONST ;
93-
return const_cast<T>( (T_NON_CONST)as_module_object_internal(x) ) ;
91+
template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_module_object_const_pointer_tag) {
92+
typedef typename Rcpp::traits::remove_const<T>::type T_NON_CONST;
93+
return const_cast<T>((T_NON_CONST)as_module_object_internal(x));
9494
}
9595

96-
template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_module_object_pointer_tag ) {
97-
return as_module_object<typename traits::un_pointer<T>::type>( x ) ;
96+
template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_module_object_pointer_tag) {
97+
return as_module_object<typename traits::un_pointer<T>::type>(x);
9898
}
9999

100100
/** handling T such that T is exposed by a module */
101-
template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_module_object_tag ){
102-
T* obj = as_module_object<T>(x) ;
103-
return *obj ;
101+
template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_module_object_tag) {
102+
T* obj = as_module_object<T>(x);
103+
return *obj;
104104
}
105105

106106
/** handling T such that T is a reference of a class handled by a module */
107-
template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_module_object_reference_tag ){
108-
typedef typename traits::remove_reference<T>::type KLASS ;
109-
KLASS* obj = as_module_object<KLASS>(x) ;
110-
return *obj ;
107+
template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_module_object_reference_tag) {
108+
typedef typename traits::remove_reference<T>::type KLASS;
109+
KLASS* obj = as_module_object<KLASS>(x);
110+
return *obj;
111111
}
112112

113113
/** handling T such that T is a reference of a class handled by a module */
114-
template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_module_object_const_reference_tag ){
115-
typedef typename traits::remove_const_and_reference<T>::type KLASS ;
116-
KLASS* obj = as_module_object<KLASS>(x) ;
117-
return const_cast<T>( *obj ) ;
114+
template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_module_object_const_reference_tag) {
115+
typedef typename traits::remove_const_and_reference<T>::type KLASS;
116+
KLASS* obj = as_module_object<KLASS>(x);
117+
return const_cast<T>(*obj);
118118
}
119119

120120
/** handling enums by converting to int first */
121-
template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_enum_tag ){
122-
return T( primitive_as<int>(x) ) ;
121+
template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_enum_tag) {
122+
return T(primitive_as<int>(x));
123123
}
124124

125125
}
@@ -140,20 +140,20 @@ namespace Rcpp{
140140
* Environment x = ... ; // some environment
141141
* Foo y = x["bla"] ; // if as<Foo> makes sense then this works !!
142142
*/
143-
template <typename T> T as( SEXP x) {
144-
return internal::as<T>( x, typename traits::r_type_traits<T>::r_category() ) ;
143+
template <typename T> T as(SEXP x) {
144+
return internal::as<T>(x, typename traits::r_type_traits<T>::r_category());
145145
}
146146

147-
template <> inline char as<char>( SEXP x ){
148-
return internal::check_single_string(x)[0] ;
147+
template <> inline char as<char>(SEXP x) {
148+
return internal::check_single_string(x)[0];
149149
}
150150

151151
template <typename T>
152-
inline typename traits::remove_const_and_reference<T>::type bare_as( SEXP x ){
153-
return as< typename traits::remove_const_and_reference<T>::type >( x ) ;
152+
inline typename traits::remove_const_and_reference<T>::type bare_as(SEXP x) {
153+
return as< typename traits::remove_const_and_reference<T>::type >(x);
154154
}
155155

156-
template<> inline SEXP as(SEXP x) { return x ; }
156+
template<> inline SEXP as(SEXP x) { return x; }
157157

158158
} // Rcpp
159159

0 commit comments

Comments
 (0)