[Rcpp-commits] r3902 - pkg/Rcpp/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Nov 6 22:37:59 CET 2012
Author: jjallaire
Date: 2012-11-06 22:37:58 +0100 (Tue, 06 Nov 2012)
New Revision: 3902
Modified:
pkg/Rcpp/src/Attributes.cpp
Log:
never write exports if there are no attributes
Modified: pkg/Rcpp/src/Attributes.cpp
===================================================================
--- pkg/Rcpp/src/Attributes.cpp 2012-11-06 21:09:11 UTC (rev 3901)
+++ pkg/Rcpp/src/Attributes.cpp 2012-11-06 21:37:58 UTC (rev 3902)
@@ -424,6 +424,11 @@
virtual bool commit(const std::vector<std::string>& includes,
const std::vector<std::string>& prototypes) = 0;
+ // Remove the generated file entirely
+ bool remove() {
+ return removeFile(targetFile_);
+ }
+
// Allow generator to appear as a std::ostream&
operator std::ostream&() {
return codeStream_;
@@ -477,11 +482,6 @@
}
}
- // Remove the generated file entirely
- bool remove() {
- return removeFile(targetFile_);
- }
-
private:
// Check whether it's safe to overwrite this file (i.e. whether we
@@ -775,8 +775,9 @@
(*it)->writeEnd();
}
- // Commit and return a list of the files that were update
- std::vector<std::string> commit(const std::vector<std::string>& includes,
+ // Commit and return a list of the files that were updated
+ std::vector<std::string> commit(
+ const std::vector<std::string>& includes,
const std::vector<std::string>& prototypes) {
std::vector<std::string> updated;
@@ -788,7 +789,17 @@
return updated;
}
-
+
+ // Remove and return a list of files that were removed
+ std::vector<std::string> remove() {
+ std::vector<std::string> removed;
+ for(Itr it = generators_.begin(); it != generators_.end(); ++it) {
+ if ((*it)->remove())
+ removed.push_back((*it)->targetFile());
+ }
+ return removed;
+ }
+
private:
// prohibit copying
ExportsGenerators(const ExportsGenerators&);
@@ -892,6 +903,7 @@
generators.writeBegin();
// Parse attributes from each file and generate code as required.
+ bool haveAttributes = false;
for (std::size_t i=0; i<cppFiles.size(); i++) {
// parse attributes (continue if there are none)
@@ -900,6 +912,9 @@
if (attributes.empty())
continue;
+ // confirm we have attributes
+ haveAttributes = true;
+
// copy prototypes
std::copy(attributes.prototypes().begin(),
attributes.prototypes().end(),
@@ -912,8 +927,12 @@
// write end
generators.writeEnd();
- // commit
- std::vector<std::string> updated = generators.commit(includes, prototypes);
+ // commit or remove
+ std::vector<std::string> updated;
+ if (haveAttributes)
+ updated = generators.commit(includes, prototypes);
+ else
+ updated = generators.remove();
// verbose output
if (verbose) {
More information about the Rcpp-commits
mailing list