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; -*-
22/* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */
33//
44// r_vector.h: Rcpp R/C++ interface class library -- information about R vectors
55//
6- // Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
6+ // Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois
77//
88// This file is part of Rcpp.
99//
@@ -27,63 +27,62 @@ namespace Rcpp{
2727namespace internal {
2828
2929template <int RTYPE>
30- typename Rcpp::traits::storage_type<RTYPE>::type* r_vector_start (SEXP x){
31- typedef typename Rcpp::traits::storage_type<RTYPE>::type* pointer ;
32- return reinterpret_cast <pointer>( dataptr (x) ) ;
30+ typename Rcpp::traits::storage_type<RTYPE>::type* r_vector_start (SEXP x) {
31+ typedef typename Rcpp::traits::storage_type<RTYPE>::type* pointer;
32+ return reinterpret_cast <pointer>(dataptr (x)) ;
3333}
3434
3535/* *
3636 * The value 0 statically casted to the appropriate type for
3737 * the given SEXP type
3838 */
39- template <int RTYPE,typename CTYPE>
40- inline CTYPE get_zero (){
41- return static_cast <CTYPE>(0 ) ;
42- }
39+ template <int RTYPE,typename CTYPE> // #nocov start
40+ inline CTYPE get_zero () {
41+ return static_cast <CTYPE>(0 );
42+ } // #nocov end
4343
4444
4545/* *
4646 * Specialization for Rcomplex
4747 */
4848template <>
4949inline Rcomplex get_zero<CPLXSXP,Rcomplex>(){
50- Rcomplex x ;
51- x.r = 0.0 ;
52- x.i = 0.0 ;
53- return x ;
50+ Rcomplex x;
51+ x.r = 0.0 ;
52+ x.i = 0.0 ;
53+ return x;
5454}
5555
5656/* *
5757 * Initializes a vector of the given SEXP type. The template fills the
5858 * vector with the value 0 of the appropriate type, for example
5959 * an INTSXP vector is initialized with (int)0, etc...
6060 */
61- template <int RTYPE> void r_init_vector (SEXP x){
62- typedef typename ::Rcpp::traits::storage_type<RTYPE>::type CTYPE ;
63- CTYPE* start=r_vector_start<RTYPE>(x) ;
64- std::fill ( start, start + Rf_xlength (x), get_zero<RTYPE,CTYPE>() ) ;
65- }
61+ template <int RTYPE> void r_init_vector (SEXP x) { // #nocov start
62+ typedef typename ::Rcpp::traits::storage_type<RTYPE>::type CTYPE;
63+ CTYPE* start=r_vector_start<RTYPE>(x);
64+ std::fill (start, start + Rf_xlength (x), get_zero<RTYPE,CTYPE>()) ;
65+ } // #nocov end
6666/* *
6767 * Initializes a generic vector (VECSXP). Does nothing since
6868 * R already initializes all elements to NULL
6969 */
7070template <>
71- inline void r_init_vector<VECSXP>(SEXP /* x*/ ){}
71+ inline void r_init_vector<VECSXP>(SEXP /* x*/ ) {}
7272
7373/* *
7474 * Initializes an expression vector (EXPRSXP). Does nothing since
7575 * R already initializes all elements to NULL
7676 */
7777template <>
78- inline void r_init_vector<EXPRSXP>(SEXP /* x*/ ){}
78+ inline void r_init_vector<EXPRSXP>(SEXP /* x*/ ) {}
7979
8080/* *
8181 * Initializes a character vector (STRSXP). Does nothing since
8282 * R already initializes all elements to ""
8383 */
8484template <>
85- inline void r_init_vector<STRSXP>(SEXP /* x*/ ){}
86-
85+ inline void r_init_vector<STRSXP>(SEXP /* x*/ ) {}
8786
8887
8988/* *
@@ -104,36 +103,31 @@ class Sort_is_not_allowed_for_this_type;
104103 * Specialization for CPLXSXP, INTSXP, LGLSXP, REALSXP, and STRSXP
105104 */
106105template <>
107- class Sort_is_not_allowed_for_this_type <CPLXSXP>
108- {
106+ class Sort_is_not_allowed_for_this_type <CPLXSXP> {
109107public:
110108 static void do_nothing () {}
111109};
112110
113111template <>
114- class Sort_is_not_allowed_for_this_type <INTSXP>
115- {
112+ class Sort_is_not_allowed_for_this_type <INTSXP> {
116113public:
117114 static void do_nothing () {}
118115};
119116
120117template <>
121- class Sort_is_not_allowed_for_this_type <LGLSXP>
122- {
118+ class Sort_is_not_allowed_for_this_type <LGLSXP> {
123119public:
124120 static void do_nothing () {}
125121};
126122
127123template <>
128- class Sort_is_not_allowed_for_this_type <REALSXP>
129- {
124+ class Sort_is_not_allowed_for_this_type <REALSXP> {
130125public:
131126 static void do_nothing () {}
132127};
133128
134129template <>
135- class Sort_is_not_allowed_for_this_type <STRSXP>
136- {
130+ class Sort_is_not_allowed_for_this_type <STRSXP> {
137131public:
138132 static void do_nothing () {}
139133};
0 commit comments