[Rcpp-commits] r4407 - in pkg/Rcpp: . src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jul 25 11:50:41 CEST 2013


Author: romain
Date: 2013-07-25 11:50:41 +0200 (Thu, 25 Jul 2013)
New Revision: 4407

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/src/attributes.cpp
Log:
collect function in a FunctionMap

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2013-07-25 09:00:54 UTC (rev 4406)
+++ pkg/Rcpp/ChangeLog	2013-07-25 09:50:41 UTC (rev 4407)
@@ -6,6 +6,8 @@
         * include/Rcpp/Datetime.h : added is_na method
         * unitTests/cpp/dates.cpp : removed the ignoreme useless parameters
         * unitTests/runit.Date.R : idem
+        * src/attributes.cpp: collecting functions in a FunctionMap. Will use this
+        for dispatching
         
 2013-07-24  Romain Francois <romain at r-enthusiasts.com>
 

Modified: pkg/Rcpp/src/attributes.cpp
===================================================================
--- pkg/Rcpp/src/attributes.cpp	2013-07-25 09:00:54 UTC (rev 4406)
+++ pkg/Rcpp/src/attributes.cpp	2013-07-25 09:50:41 UTC (rev 4407)
@@ -252,6 +252,18 @@
         std::vector<std::string> roxygen_;
     };
 
+    class FunctionMap {
+        std::map< std::string, std::vector<Function> > map_ ;
+        
+    public:
+        FunctionMap(){};
+        ~FunctionMap(){} ;
+        
+        void insert( const Function& fun ){
+            map_[ fun.name() ].push_back( fun ) ;
+        }
+    } ;
+    
     // Operator << for parsed types
     std::ostream& operator<<(std::ostream& os, const Type& type); 
     std::ostream& operator<<(std::ostream& os, const Argument& argument); 
@@ -389,6 +401,7 @@
         std::string sourceFile_;
         CharacterVector lines_;
         std::vector<Attribute> attributes_;
+        FunctionMap functionMap_ ;
         std::vector<std::string> modules_;
         std::vector<std::string> embeddedR_;
         std::vector<std::vector<std::string> > roxygenChunks_; 
@@ -868,8 +881,13 @@
                         continue;
                     
                     // add the attribute
-                    attributes_.push_back(parseAttribute(
-                        Rcpp::as<std::vector<std::string> >(match),  i));
+                    Attribute attr = parseAttribute(
+                        Rcpp::as<std::vector<std::string> >(match),  i); 
+                    attributes_.push_back(attr);
+                    
+                    if( attr.isExportedFunction() ){
+                        functionMap_.insert(attr.function());
+                    }
                 } 
                 
                 // if it's not an attribute line then it could still be a 
@@ -889,8 +907,8 @@
                     }
                 } 
             }
-            
-             // Scan for Rcpp modules 
+             
+            // Scan for Rcpp modules 
             commentState.reset();
             Rcpp::List modMatches = regexMatches(lines_, 
                 "^\\s*RCPP_MODULE\\s*\\(\\s*(\\w+)\\s*\\).*$");



More information about the Rcpp-commits mailing list