Skip to content

Commit cd1d98f

Browse files
committed
Merge branch 'master' of github.com:RcppCore/Rcpp
2 parents 0dcd2e2 + 62d951e commit cd1d98f

File tree

182 files changed

+3564
-3528
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+3564
-3528
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
inst/lib
2-
*.Rproj
32
.Rproj.user
43
src/*.o
54
src/*.so
@@ -9,4 +8,4 @@ src/*.dll
98
## QtCreator
109
Rcpp.pro
1110
Rcpp.pro.user
12-
*.autosave
11+
*.autosave

ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2014-05-18 Kevin Ushey <[email protected]>
2+
3+
* inst/include/Rcpp/vector/Vector.h: Safer casting to fix #146
4+
* inst/include/Rcpp/Environment.h: Idem
5+
* inst/include/Rcpp/api/meat/Environment.h: Idem
6+
* inst/include/Rcpp/vector/Vector.h: Idem
7+
18
2014-05-10 Dirk Eddelbuettel <[email protected]>
29

310
* R/Attributes.R (compileAttributes): Read Imports: as well

Rcpp.Rproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Version: 1.0
2+
3+
RestoreWorkspace: Default
4+
SaveWorkspace: Default
5+
AlwaysSaveHistory: Default
6+
7+
EnableCodeIndexing: Yes
8+
UseSpacesForTab: Yes
9+
NumSpacesForTab: 4
10+
Encoding: UTF-8
11+
12+
RnwWeave: knitr
13+
LaTeX: pdfLaTeX
14+
15+
AutoAppendNewline: Yes
16+
StripTrailingWhitespace: Yes
17+
18+
BuildType: Package
19+
PackageUseDevtools: Yes
20+
PackageInstallArgs: --no-multiarch --with-keep.source

inst/include/Rcpp/Date.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
namespace Rcpp {
2626

2727
class Date {
28-
public:
28+
public:
2929
Date(){
3030
m_d = 0;
3131
update_tm();
@@ -64,7 +64,7 @@ namespace Rcpp {
6464
}
6565

6666
~Date() {};
67-
67+
6868
double getDate(void) const {
6969
return m_d;
7070
}
@@ -97,13 +97,13 @@ namespace Rcpp {
9797
inline int is_na() const {
9898
return traits::is_na<REALSXP>( m_d ) ;
9999
}
100-
100+
101101
private:
102102
double m_d; // (fractional) day number, relative to epoch of Jan 1, 1970
103103
struct tm m_tm; // standard time representation
104104

105105
// update m_tm based on m_d
106-
void update_tm(){
106+
void update_tm(){
107107
if (R_FINITE(m_d)) {
108108
time_t t = 24*60*60 * m_d; // (fractional) days since epoch to seconds since epoch
109109
m_tm = *gmtime_(&t);
@@ -161,7 +161,7 @@ namespace Rcpp {
161161
inline SEXP new_posixt_object( double d){
162162
Shield<SEXP> x( Rf_ScalarReal( d ) ) ;
163163
Rf_setAttrib(x, R_ClassSymbol, getPosixClasses() );
164-
return x ;
164+
return x ;
165165
}
166166

167167
inline SEXP new_date_object( double d){
@@ -172,7 +172,7 @@ namespace Rcpp {
172172

173173
}
174174

175-
175+
176176
}
177177

178178
#endif

inst/include/Rcpp/Datetime.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@
2727
namespace Rcpp {
2828

2929
class Datetime {
30-
public:
30+
public:
3131
Datetime() {
3232
m_dt = 0;
3333
update_tm();
3434
}
3535
Datetime(SEXP s);
36-
36+
3737
// from double, just like POSIXct
3838
Datetime(const double &dt){
3939
m_dt = dt;
4040
update_tm();
4141
}
4242
Datetime(const std::string &s, const std::string &fmt="%Y-%m-%d %H:%M:%OS");
43-
43+
4444
double getFractionalTimestamp(void) const { return m_dt; }
4545

4646
int getMicroSeconds() const { return m_us; }
@@ -64,7 +64,7 @@ namespace Rcpp {
6464
friend bool operator!=(const Datetime &dt1, const Datetime& dt2);
6565

6666
inline int is_na() const { return traits::is_na<REALSXP>( m_dt ) ; }
67-
67+
6868
private:
6969
double m_dt; // fractional seconds since epoch
7070
struct tm m_tm; // standard time representation
@@ -73,17 +73,17 @@ namespace Rcpp {
7373
// update m_tm based on m_dt
7474
void update_tm() {
7575
if (R_FINITE(m_dt)) {
76-
time_t t = static_cast<time_t>(std::floor(m_dt));
76+
time_t t = static_cast<time_t>(std::floor(m_dt));
7777
m_tm = *gmtime_(&t);
7878
// m_us is fractional (micro)secs as diff. between (fractional) m_dt and m_tm
79-
m_us = static_cast<int>(::Rf_fround( (m_dt - t) * 1.0e6, 0.0));
79+
m_us = static_cast<int>(::Rf_fround( (m_dt - t) * 1.0e6, 0.0));
8080
} else {
8181
m_dt = NA_REAL; // NaN and Inf need it set
8282
m_tm.tm_sec = m_tm.tm_min = m_tm.tm_hour = m_tm.tm_isdst = NA_INTEGER;
8383
m_tm.tm_min = m_tm.tm_hour = m_tm.tm_mday = m_tm.tm_mon = m_tm.tm_year = NA_INTEGER;
8484
m_us = NA_INTEGER;
8585
}
86-
}
86+
}
8787

8888
};
8989

@@ -102,13 +102,13 @@ namespace Rcpp {
102102
}
103103

104104
template<> SEXP wrap_extra_steps<Rcpp::Datetime>( SEXP x ) ;
105-
105+
106106
inline Datetime operator+(const Datetime &datetime, double offset) {
107107
Datetime newdt(datetime.m_dt);
108108
newdt.m_dt += offset;
109-
time_t t = static_cast<time_t>(std::floor(newdt.m_dt));
110-
newdt.m_tm = *gmtime_(&t);
111-
newdt.m_us = static_cast<int>(::Rf_fround( (newdt.m_dt - t) * 1.0e6, 0.0));
109+
time_t t = static_cast<time_t>(std::floor(newdt.m_dt));
110+
newdt.m_tm = *gmtime_(&t);
111+
newdt.m_us = static_cast<int>(::Rf_fround( (newdt.m_dt - t) * 1.0e6, 0.0));
112112
return newdt;
113113
}
114114

inst/include/Rcpp/Dimension.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ namespace Rcpp{
2828
public:
2929
typedef std::vector<int>::reference reference ;
3030
typedef std::vector<int>::const_reference const_reference ;
31-
31+
3232
Dimension() : dims(){}
33-
33+
3434
Dimension(SEXP dims) ;
35-
35+
3636
Dimension( const Dimension& other ) : dims(other.dims){}
3737
Dimension& operator=( const Dimension& other ) {
3838
if( *this != other )
@@ -52,14 +52,14 @@ namespace Rcpp{
5252
dims[2] = n3 ;
5353
}
5454
operator SEXP() const ;
55-
55+
5656
inline int size() const {
5757
return (int) dims.size() ;
5858
}
5959
inline int prod() const {
6060
return std::accumulate( dims.begin(), dims.end(), 1, std::multiplies<int>() ) ;
6161
}
62-
62+
6363
inline reference operator[](int i){
6464
if( i < 0 || i>=static_cast<int>(dims.size()) ) throw std::range_error("index out of bounds") ;
6565
return dims[i] ;
@@ -68,7 +68,7 @@ namespace Rcpp{
6868
if( i < 0 || i>=static_cast<int>(dims.size()) ) throw std::range_error("index out of bounds") ;
6969
return dims[i] ;
7070
}
71-
71+
7272
private:
7373
std::vector<int> dims;
7474
};

inst/include/Rcpp/DottedPair.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ RCPP_API_CLASS(DottedPair_Impl),
3131
RCPP_GENERATE_CTOR_ASSIGN(DottedPair_Impl)
3232

3333
DottedPair_Impl(){}
34-
34+
3535
DottedPair_Impl(SEXP x) {
3636
Storage::set__(x) ;
3737
}
38-
38+
3939
#include <Rcpp/generated/DottedPair__ctors.h>
4040

4141
void update(SEXP){}
42-
42+
4343
};
4444

4545
typedef DottedPair_Impl<PreserveStorage> DottedPair ;

inst/include/Rcpp/DottedPairImpl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,19 @@ namespace Rcpp{
7777
* @param index position where the element is to be removed
7878
*/
7979
void remove( const size_t& index );
80-
80+
8181
template <typename T>
8282
friend DottedPairImpl& operator<<(DottedPairImpl& os, const T& t){
8383
os.push_back( t ) ;
8484
return os ;
8585
}
86-
86+
8787
template <typename T>
8888
friend DottedPairImpl& operator>>( const T& t, DottedPairImpl& s){
8989
s.push_front(t);
9090
return s ;
9191
}
92-
92+
9393
} ;
9494

9595
}

inst/include/Rcpp/Environment.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ namespace Rcpp{
5252
* if the SEXP is not an environment, and exception is thrown
5353
*/
5454
Environment_Impl(SEXP x) {
55-
Storage::set__( as_environment(x) ) ;
55+
Shield<SEXP> env(as_environment(x));
56+
Storage::set__(env) ;
5657
}
5758

5859
/**

inst/include/Rcpp/InternalFunction.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ namespace Rcpp{
3333

3434
RCPP_GENERATE_CTOR_ASSIGN(InternalFunction_Impl)
3535

36-
#include <Rcpp/generated/InternalFunction__ctors.h>
37-
36+
#include <Rcpp/generated/InternalFunction__ctors.h>
37+
3838
private:
39-
39+
4040
inline void set( SEXP xp){
4141
Environment RCPP = Environment::Rcpp_namespace() ;
4242
Function intf = RCPP["internal_function"] ;
4343
Storage::set__( intf( xp ) ) ;
4444
}
45-
45+
4646
};
4747

4848
typedef InternalFunction_Impl<PreserveStorage> InternalFunction ;

0 commit comments

Comments
 (0)