[Rcpp-commits] r3911 - in pkg/Rcpp: . inst/include/Rcpp src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Nov 7 17:12:29 CET 2012
Author: jjallaire
Date: 2012-11-07 17:12:29 +0100 (Wed, 07 Nov 2012)
New Revision: 3911
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/inst/include/Rcpp/exceptions.h
pkg/Rcpp/src/Attributes.cpp
Log:
improved error message when package hpp already exists
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2012-11-07 15:45:41 UTC (rev 3910)
+++ pkg/Rcpp/ChangeLog 2012-11-07 16:12:29 UTC (rev 3911)
@@ -1,7 +1,8 @@
2012-11-07 JJ Allaire <jj at rstudio.org>
* src/Attributes.cpp: validate exported C++ functions before calling;
- use static rather than inline for stubs to avoid call-site bloat
+ use static rather than inline for stubs to avoid call-site bloat;
+ improved error message when package hpp already exists
* src/AttributesParser.h: add signature and isHidden methods
* src/AttributesParser.cpp: add signature and isHidden methods
* src/exceptions.cpp: add function_not_exported exception
Modified: pkg/Rcpp/inst/include/Rcpp/exceptions.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/exceptions.h 2012-11-07 15:45:41 UTC (rev 3910)
+++ pkg/Rcpp/inst/include/Rcpp/exceptions.h 2012-11-07 16:12:29 UTC (rev 3911)
@@ -52,13 +52,15 @@
class file_io_error : public std::exception {
public:
- file_io_error(const std::string& file) throw() : message( std::string("file io error: '") + file + "'" ){} ;
- file_io_error(int code, const std::string& file) throw() : message( "file io error " + toString(code) + ": '" + file + "'") {} ;
- file_io_error(const std::string& msg, const std::string& file) throw() : message( msg + ": '" + file + "'") {} ;
+ file_io_error(const std::string& file) throw() : message( std::string("file io error: '") + file + "'" ), file(file) {} ;
+ file_io_error(int code, const std::string& file) throw() : message( "file io error " + toString(code) + ": '" + file + "'"), file(file) {} ;
+ file_io_error(const std::string& msg, const std::string& file) throw() : message( msg + ": '" + file + "'"), file(file) {} ;
virtual ~file_io_error() throw(){} ;
- virtual const char* what() const throw(){ return message.c_str() ; } ;
+ virtual const char* what() const throw(){ return message.c_str() ; } ;
+ std::string filePath() const throw(){ return file ; } ;
private:
std::string message ;
+ std::string file;
} ;
class file_not_found : public file_io_error {
Modified: pkg/Rcpp/src/Attributes.cpp
===================================================================
--- pkg/Rcpp/src/Attributes.cpp 2012-11-07 15:45:41 UTC (rev 3910)
+++ pkg/Rcpp/src/Attributes.cpp 2012-11-07 16:12:29 UTC (rev 3911)
@@ -714,8 +714,21 @@
ExportsGenerators generators;
generators.add(new CppExportsGenerator(packageDir, packageName, fileSep));
generators.add(new RExportsGenerator(packageDir, packageName, fileSep));
- generators.add(new CppIncludeGenerator(packageDir, packageName, fileSep));
+ // catch file exists exception if the include file already exists
+ // and we are unable to overwrite it
+ try {
+ generators.add(new CppIncludeGenerator(packageDir,
+ packageName,
+ fileSep));
+ }
+ catch(const Rcpp::file_exists& e) {
+ std::string msg =
+ "The header file '" + e.filePath() + "' already exists so "
+ "cannot be overwritten by Rcpp::interfaces";
+ throw Rcpp::exception(msg.c_str(), __FILE__, __LINE__);
+ }
+
// write begin
generators.writeBegin();
More information about the Rcpp-commits
mailing list