Skip to content

Feature/more nocov #1042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2020-01-01 Dirk Eddelbuettel <edd@debian.org>

* inst/include/Rcpp/module/Module.h: A few more #nocov tags
* inst/include/Rcpp/XPtr.h: Idem
* inst/include/Rcpp/vector/Vector.h: Idem

2019-12-31 Dirk Eddelbuettel <edd@debian.org>

* DESCRIPTION (Version, Date): Roll minor version
Expand Down
19 changes: 9 additions & 10 deletions inst/include/Rcpp/XPtr.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
//
// XPtr.h: Rcpp R/C++ interface class library -- smart external pointers
//
// Copyright (C) 2009 - 2017 Dirk Eddelbuettel and Romain Francois
// Copyright (C) 2009 - 2020 Dirk Eddelbuettel and Romain Francois
//
// This file is part of Rcpp.
//
Expand All @@ -27,7 +26,7 @@
namespace Rcpp {

template <typename T>
void standard_delete_finalizer(T* obj) {
void standard_delete_finalizer(T* obj) { // #nocov start
delete obj;
}

Expand All @@ -46,7 +45,7 @@ void finalizer_wrapper(SEXP p) {
R_ClearExternalPtr(p);

Finalizer(ptr);
}
} // #nocov end

template <
typename T,
Expand Down Expand Up @@ -102,7 +101,7 @@ class XPtr :
RCPP_DEBUG_2("XPtr(T* p = <%p>, bool set_delete_finalizer = %s, SEXP tag = R_NilValue, SEXP prot = R_NilValue)", p, (set_delete_finalizer ? "true" : "false"))
Storage::set__(R_MakeExternalPtr((void*)p , tag, prot));
if (set_delete_finalizer) {
setDeleteFinalizer();
setDeleteFinalizer(); // #nocov
}
}

Expand Down Expand Up @@ -142,7 +141,7 @@ class XPtr :
inline T* checked_get() const {
T* ptr = get();
if (ptr == NULL)
throw ::Rcpp::exception("external pointer is not valid");
throw ::Rcpp::exception("external pointer is not valid"); // #nocov
return ptr;
}

Expand All @@ -162,10 +161,10 @@ class XPtr :
return checked_get();
}

void setDeleteFinalizer() {
void setDeleteFinalizer() { // #nocov start
R_RegisterCFinalizerEx(Storage::get__(), finalizer_wrapper<T,Finalizer>,
(Rboolean) finalizeOnExit);
}
} // #nocov end

/**
* Release the external pointer (if any) immediately. This will cause
Expand Down Expand Up @@ -197,8 +196,8 @@ class XPtr :
private:
inline void checked_set(SEXP x) {
if (TYPEOF(x) != EXTPTRSXP) {
const char* fmt = "Expecting an external pointer: [type=%s].";
throw ::Rcpp::not_compatible(fmt, Rf_type2char(TYPEOF(x)));
const char* fmt = "Expecting an external pointer: [type=%s]."; // #nocov
throw ::Rcpp::not_compatible(fmt, Rf_type2char(TYPEOF(x))); // #nocov
}
Storage::set__(x);
}
Expand Down
15 changes: 7 additions & 8 deletions inst/include/Rcpp/module/Module.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
//
// Module.h: Rcpp R/C++ interface class library -- Rcpp modules
//
// Copyright (C) 2012 - 2013 Dirk Eddelbuettel and Romain Francois
// Copyright (C) 2012 - 2020 Dirk Eddelbuettel and Romain Francois
//
// This file is part of Rcpp.
//
Expand Down Expand Up @@ -51,7 +50,7 @@ namespace Rcpp {
* @param args an array of R objects to use as arguments for the function
* @param nargs number of arguments
*/
inline SEXP invoke( const std::string& name_, SEXP* args, int nargs){
inline SEXP invoke( const std::string& name_, SEXP* args, int nargs){ // #nocov start
MAP::iterator it = functions.find( name_ );
if( it == functions.end() ){
throw std::range_error( "no such function" ) ;
Expand Down Expand Up @@ -81,7 +80,7 @@ namespace Rcpp {
}
x.names() = names ;
return x ;
}
} // #nocov end

/**
* vector of names of the functions
Expand Down Expand Up @@ -117,7 +116,7 @@ namespace Rcpp {
/**
* completion information
*/
CharacterVector complete(){
CharacterVector complete(){ // #nocov start
size_t nf = functions.size() ;
size_t nc = classes.size() ;
size_t n = nf + nc ;
Expand All @@ -139,7 +138,7 @@ namespace Rcpp {
res[i] = cit->first ;
}
return res ;
}
} // #nocov end

/**
* Returns a list that contains:
Expand Down Expand Up @@ -199,13 +198,13 @@ namespace Rcpp {
classes.insert( CLASS_PAIR( name_ , cptr ) ) ;
}

inline bool has_function( const std::string& m){
inline bool has_function( const std::string& m){ // #nocov start
return functions.find(m) != functions.end() ;
}

inline bool has_class( const std::string& m){
return classes.find(m) != classes.end() ;
}
} // #nocov end

CppClass get_class( const std::string& cl ) ;

Expand Down
19 changes: 9 additions & 10 deletions inst/include/Rcpp/vector/Vector.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
//
// Vector.h: Rcpp R/C++ interface class library -- vectors
//
// Copyright (C) 2010 - 2018 Dirk Eddelbuettel and Romain Francois
// Copyright (C) 2010 - 2020 Dirk Eddelbuettel and Romain Francois
//
// This file is part of Rcpp.
//
Expand Down Expand Up @@ -301,12 +300,12 @@ class Vector :
* one dimensional offset doing bounds checking to ensure
* it is valid
*/
R_xlen_t offset(const R_xlen_t& i) const {
R_xlen_t offset(const R_xlen_t& i) const { // #nocov start
if(i < 0 || i >= ::Rf_xlength(Storage::get__()) ) {
const char* fmt = "Index out of bounds: [index=%i; extent=%i].";
throw index_out_of_bounds(fmt, i, ::Rf_xlength(Storage::get__()) ) ;
}
return i ;
return i ; // #nocov end
}

R_xlen_t offset(const std::string& name) const {
Expand Down Expand Up @@ -352,9 +351,9 @@ class Vector :
inline Proxy at( const size_t& i) {
return cache.ref( offset(i) ) ;
}
inline const_Proxy at( const size_t& i) const {
inline const_Proxy at( const size_t& i) const { // #nocov start
return cache.ref( offset(i) ) ;
}
} // #nocov end

inline Proxy operator()( const size_t& i, const size_t& j) {
return cache.ref( offset(i,j) ) ;
Expand Down Expand Up @@ -632,7 +631,7 @@ class Vector :
iterator this_end(end());
if( Rf_isNull(names) ){
for( ; it < this_end; ++it, ++target_it ){
*target_it = *it ;
*target_it = *it ; // #nocov start
}
} else {
Shield<SEXP> newnames( ::Rf_allocVector( STRSXP, n + 1) ) ;
Expand All @@ -642,7 +641,7 @@ class Vector :
SET_STRING_ELT( newnames, i, STRING_ELT(names, i ) ) ;
}
SET_STRING_ELT( newnames, i, Rf_mkChar("") ) ;
target.attr("names") = newnames ;
target.attr("names") = newnames ; // #nocov end
}
*target_it = object_sexp;
Storage::set__( target.get__() ) ;
Expand Down Expand Up @@ -685,8 +684,8 @@ class Vector :
int i=0;
if( Rf_isNull(names) ){
for( ; it < this_end; ++it, ++target_it,i++ ){
*target_it = *it ;
SET_STRING_ELT( newnames, i , R_BlankString );
*target_it = *it ; // #nocov
SET_STRING_ELT( newnames, i , R_BlankString ); // #nocov
}
} else {
for( ; it < this_end; ++it, ++target_it, i++ ){
Expand Down