[Rcpp-commits] r3901 - in pkg/Rcpp: . man src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Nov 6 22:09:11 CET 2012


Author: jjallaire
Date: 2012-11-06 22:09:11 +0100 (Tue, 06 Nov 2012)
New Revision: 3901

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/man/compileAttributes.Rd
   pkg/Rcpp/src/Attributes.cpp
Log:
return list of updated files from compileAttributes

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2012-11-06 19:13:27 UTC (rev 3900)
+++ pkg/Rcpp/ChangeLog	2012-11-06 21:09:11 UTC (rev 3901)
@@ -4,7 +4,9 @@
         * src/AttributesParser.h: support for interfaces attribute
         * src/AttributesParser.cpp: support for interfaces attribute
         * src/Attributes.cpp: support for interfaces attribute; refactor 
-        code generators; use single module for exports
+        code generators; use single module for exports; return list of
+        updated files from compileAttributes
+        * man/compileAttributes.Rd: documentation updates
 
 2012-11-05  Romain Francois <romain at r-enthusiasts.com>
 

Modified: pkg/Rcpp/man/compileAttributes.Rd
===================================================================
--- pkg/Rcpp/man/compileAttributes.Rd	2012-11-06 19:13:27 UTC (rev 3900)
+++ pkg/Rcpp/man/compileAttributes.Rd	2012-11-06 21:09:11 UTC (rev 3901)
@@ -26,7 +26,7 @@
     In order to access the declarations for custom \code{Rcpp::as} and \code{Rcpp::wrap} handlers the \code{compileAttributes} function will also call any \link[inline:plugins]{inline plugins} available for packages listed in the \code{LinkingTo} field of the \code{DESCRIPTION} file.
 }
 \value{
-    Returns \code{TRUE} if generated code was updated, \code{FALSE} if no updates were required.
+    Returns (invisibly) a character vector with the paths to any files that were updated as a result of the call.
 }
 
 \seealso{

Modified: pkg/Rcpp/src/Attributes.cpp
===================================================================
--- pkg/Rcpp/src/Attributes.cpp	2012-11-06 19:13:27 UTC (rev 3900)
+++ pkg/Rcpp/src/Attributes.cpp	2012-11-06 21:09:11 UTC (rev 3901)
@@ -73,11 +73,15 @@
     };
     
     // Remove a file (call back into R for this)
-    void removeFile(const std::string& path) {
+    bool removeFile(const std::string& path) {
         if (FileInfo(path).exists()) {
             Rcpp::Function rm = Rcpp::Environment::base_env()["file.remove"];
             rm(path);
+            return true;
         }
+        else {
+            return false;
+        }
     }
     
     // Recursively create a directory (call back into R for this)
@@ -406,6 +410,11 @@
     public:
         virtual ~ExportsGenerator() {}
         
+        // Name of target file
+        const std::string& targetFile() const {
+            return targetFile_;
+        }
+        
         // Abstract interface for code generation
         virtual void writeBegin() = 0;
         virtual void writeFunctions(const SourceFileAttributes &attributes,
@@ -469,8 +478,8 @@
         }
         
         // Remove the generated file entirely
-        void remove() {
-            removeFile(targetFile_);
+        bool remove() {
+            return removeFile(targetFile_);
         }
         
     private:
@@ -658,8 +667,7 @@
                 return ExportsGenerator::commit(ostr.str());
             }
             else {
-                ExportsGenerator::remove();
-                return false;
+                return ExportsGenerator::remove();
             }
         }
         
@@ -767,17 +775,18 @@
                 (*it)->writeEnd();
         }
         
-        bool commit(const std::vector<std::string>& includes,
+        // Commit and return a list of the files that were update
+        std::vector<std::string> commit(const std::vector<std::string>& includes,
                     const std::vector<std::string>& prototypes) {
             
-            bool wrote = false;
+            std::vector<std::string> updated;
             
             for(Itr it = generators_.begin(); it != generators_.end(); ++it) {
-               if ((*it)->commit(includes, prototypes))
-                wrote = true;
+                if ((*it)->commit(includes, prototypes))
+                    updated.push_back((*it)->targetFile());
             }
                
-            return wrote;
+            return updated;
         }
     
     private:
@@ -904,17 +913,15 @@
     generators.writeEnd();
 
     // commit 
-    bool wrote = generators.commit(includes, prototypes);  
+    std::vector<std::string> updated = generators.commit(includes, prototypes);  
                                                                                                                    
     // verbose output
     if (verbose) {
-        if (wrote)
-            Rcpp::Rcout << "Rcpp exports files updated" << std::endl;
-        else
-            Rcpp::Rcout << "Rcpp exports files already up to date" << std::endl;
+        for (size_t i=0; i<updated.size(); i++)
+            Rcpp::Rcout << updated[i] << " updated." << std::endl;
     }
     
-    // return status
-    return Rcpp::wrap<bool>(wrote);
+    // return files updated
+    return Rcpp::wrap<std::vector<std::string> >(updated);
 END_RCPP
 }



More information about the Rcpp-commits mailing list