[Rcpp-commits] r3832 - in pkg/RcppBDT: . inst/include src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Oct 24 21:52:00 CEST 2012


Author: romain
Date: 2012-10-24 21:51:59 +0200 (Wed, 24 Oct 2012)
New Revision: 3832

Modified:
   pkg/RcppBDT/ChangeLog
   pkg/RcppBDT/DESCRIPTION
   pkg/RcppBDT/inst/include/RcppBDT.h
   pkg/RcppBDT/inst/include/RcppBDTdu.h
   pkg/RcppBDT/inst/include/RcppBDTpt.h
   pkg/RcppBDT/src/RcppBDTdu.cpp
   pkg/RcppBDT/src/RcppBDTpt.cpp
Log:
using const bdt[...]& instead of object<bdt[...]>

Modified: pkg/RcppBDT/ChangeLog
===================================================================
--- pkg/RcppBDT/ChangeLog	2012-10-24 19:31:17 UTC (rev 3831)
+++ pkg/RcppBDT/ChangeLog	2012-10-24 19:51:59 UTC (rev 3832)
@@ -1,3 +1,8 @@
+2012-10-24  Romain Francois  <romain at r-enthusiasts.com>
+
+    * inst/include/RcppBDTdu.h: using const bdtDu& instead of object<bdtDu>
+    * inst/include/RcppBDTpt.h: using const bdtPt& instead of object<bdtPt>
+    
 2012-10-23  Romain Francois  <romain at r-enthusiasts.com>
 
 	* src/RcppBDTdu.cpp: using bdtDu* instead of object<bdtDu> for function returns

Modified: pkg/RcppBDT/DESCRIPTION
===================================================================
--- pkg/RcppBDT/DESCRIPTION	2012-10-24 19:31:17 UTC (rev 3831)
+++ pkg/RcppBDT/DESCRIPTION	2012-10-24 19:51:59 UTC (rev 3832)
@@ -14,7 +14,7 @@
  provide supplementary date to/from strings conversion functions. 
 License: GPL (>= 2)
 LazyLoad: yes
-Depends: Rcpp (>= 0.9.15.2), methods
+Depends: Rcpp (>= 0.9.15.3), methods
 Imports: methods, Rcpp
 LinkingTo: Rcpp, BoostHeaders
 SystemRequirements: Boost (or the BoostHeaders package)

Modified: pkg/RcppBDT/inst/include/RcppBDT.h
===================================================================
--- pkg/RcppBDT/inst/include/RcppBDT.h	2012-10-24 19:31:17 UTC (rev 3831)
+++ pkg/RcppBDT/inst/include/RcppBDT.h	2012-10-24 19:51:59 UTC (rev 3832)
@@ -24,6 +24,12 @@
 
 #include <RcppCommon.h>
 
+/* forward declarations and helping module classes */
+class bdtDu ;
+class bdtPt ;
+RCPP_EXPOSED_CLASS(bdtDu) ;
+RCPP_EXPOSED_CLASS(bdtPt) ;
+
 // Setting this variable enables use of nanoseconds (as opposed to microseconds)
 // for the maximum resolution; this comes at a cost of 96 bits as opposed to 64 bits
 // We enable it to experiement with it knowing that R already has a 64 bit resolution

Modified: pkg/RcppBDT/inst/include/RcppBDTdu.h
===================================================================
--- pkg/RcppBDT/inst/include/RcppBDTdu.h	2012-10-24 19:31:17 UTC (rev 3831)
+++ pkg/RcppBDT/inst/include/RcppBDTdu.h	2012-10-24 19:51:59 UTC (rev 3832)
@@ -56,11 +56,10 @@
 private:
     boost::posix_time::time_duration m_td;
 
-    friend bdtDu* arith_bdtDu_bdtDu(Rcpp::object<bdtDu>, Rcpp::object<bdtDu>, std::string);
-    friend bdtDu* arith_bdtDu_int(Rcpp::object<bdtDu>, int, std::string);
-    friend bool compare_bdtDu_bdtDu(Rcpp::object<bdtDu>, Rcpp::object<bdtDu>, std::string);
-
-    friend bdtPt* arith_bdtPt_bdtDu(Rcpp::object<bdtPt>, Rcpp::object<bdtDu>, std::string);
+    friend bdtDu* arith_bdtDu_bdtDu(const bdtDu& , const bdtDu& , std::string);
+    friend bdtDu* arith_bdtDu_int(const bdtDu&, int, std::string);
+    friend bool compare_bdtDu_bdtDu(const bdtDu&, const bdtDu&, std::string);
+    friend bdtPt* arith_bdtPt_bdtDu(const bdtPt&, const bdtDu&, std::string);
 };
 
 #endif

Modified: pkg/RcppBDT/inst/include/RcppBDTpt.h
===================================================================
--- pkg/RcppBDT/inst/include/RcppBDTpt.h	2012-10-24 19:31:17 UTC (rev 3831)
+++ pkg/RcppBDT/inst/include/RcppBDTpt.h	2012-10-24 19:51:59 UTC (rev 3832)
@@ -66,8 +66,8 @@
 private:
     boost::posix_time::ptime m_pt; 		// private ptime instace
 
-    friend bdtPt* arith_bdtPt_bdtDu(Rcpp::object<bdtPt>, Rcpp::object<bdtDu>, std::string);
-    friend bool compare_bdtPt_bdtPt(Rcpp::object<bdtPt>, Rcpp::object<bdtPt>, std::string);
+    friend bdtPt* arith_bdtPt_bdtDu(const bdtPt& , const bdtDu&, std::string);
+    friend bool compare_bdtPt_bdtPt(const bdtPt& , const bdtPt&, std::string);
 };
 
 #endif

Modified: pkg/RcppBDT/src/RcppBDTdu.cpp
===================================================================
--- pkg/RcppBDT/src/RcppBDTdu.cpp	2012-10-24 19:31:17 UTC (rev 3831)
+++ pkg/RcppBDT/src/RcppBDTdu.cpp	2012-10-24 19:51:59 UTC (rev 3832)
@@ -28,47 +28,47 @@
 bdtDu* microseconds(int ms)	{ return new bdtDu( boost::posix_time::microseconds(ms) ); }
 bdtDu* nanoseconds(int ms) 	{ return new bdtDu( boost::posix_time::nanoseconds(ms) ); }
   
-bdtDu* arith_bdtDu_bdtDu( Rcpp::object<bdtDu> e1, Rcpp::object<bdtDu> e2, std::string op ){
+bdtDu* arith_bdtDu_bdtDu( const bdtDu& e1, const bdtDu& e2, std::string op ){
     if( ! op.compare("+") ){
-        return new bdtDu( e1->m_td + e2->m_td ) ;   
+        return new bdtDu( e1.m_td + e2.m_td ) ;   
     } else if( ! op.compare("-") ){
-        return new bdtDu( e1->m_td - e2->m_td ) ;
+        return new bdtDu( e1.m_td - e2.m_td ) ;
     }
     Rf_error( "operator not implemented" )  ;
     // not reached
     return new bdtDu( 0,0,0,0 )  ;
 }
 
-bdtDu* arith_bdtDu_int( Rcpp::object<bdtDu> e1, int e2, std::string op ){
+bdtDu* arith_bdtDu_int( const bdtDu& e1, int e2, std::string op ){
     if( ! op.compare("*") ){
-        return new bdtDu( e1->m_td * e2 ) ;   
+        return new bdtDu( e1.m_td * e2 ) ;   
     } else if( ! op.compare("/") ){
-        return new bdtDu( e1->m_td / e2 ) ;
+        return new bdtDu( e1.m_td / e2 ) ;
     } else if( ! op.compare("+") ){
         //Rf_warning("Interpreting int as seconds");
-        return new bdtDu(e1->m_td + boost::posix_time::time_duration(0,0,e2,0));
+        return new bdtDu(e1.m_td + boost::posix_time::time_duration(0,0,e2,0));
     } else if( ! op.compare("-") ){
         //Rf_warning("Interpreting int as seconds");
-        return new bdtDu(e1->m_td - boost::posix_time::time_duration(0, 0, e2, 0));
+        return new bdtDu(e1.m_td - boost::posix_time::time_duration(0, 0, e2, 0));
     }
     Rf_error( "operator not implemented" )  ;
     // not reached
     return new bdtDu( 0,0,0,0 )  ;
 }
 
-bool compare_bdtDu_bdtDu( Rcpp::object<bdtDu> e1, Rcpp::object<bdtDu> e2, std::string op ){
+bool compare_bdtDu_bdtDu( const bdtDu& e1, const bdtDu& e2, std::string op ){
     if( !op.compare( "==" ) ){
-        return e1->m_td == e2->m_td ;   
+        return e1.m_td == e2.m_td ;   
     } else if( !op.compare( "!=" ) ){
-        return e1->m_td != e2->m_td ;
+        return e1.m_td != e2.m_td ;
     } else if( !op.compare( ">" ) ){
-        return e1->m_td > e2->m_td ;
+        return e1.m_td > e2.m_td ;
     } else if( !op.compare( "<" ) ){
-        return e1->m_td < e2->m_td ;
+        return e1.m_td < e2.m_td ;
     } else if( !op.compare( ">=" ) ){
-        return e1->m_td >= e2->m_td ;
+        return e1.m_td >= e2.m_td ;
     } else if( !op.compare( "<=" ) ){
-        return e1->m_td <= e2->m_td ;
+        return e1.m_td <= e2.m_td ;
     }
     Rf_error( "unknown operator" ) ;
     return R_NilValue ;

Modified: pkg/RcppBDT/src/RcppBDTpt.cpp
===================================================================
--- pkg/RcppBDT/src/RcppBDTpt.cpp	2012-10-24 19:31:17 UTC (rev 3831)
+++ pkg/RcppBDT/src/RcppBDTpt.cpp	2012-10-24 19:51:59 UTC (rev 3832)
@@ -9,13 +9,13 @@
 // RcppBDT is free software: you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by
 // the Free Software Foundation, either version 2 of the License, or
-// (at your option) any later version.
+// (at your option) any later version.  
 //                           
 // RcppBDT is distributed in the hope that it will be useful, but
 // WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 // GNU General Public License for more details.
-//
+//                 
 // You should have received a copy of the GNU General Public License
 // along with RcppBDT.  If not, see <http://www.gnu.org/licenses/>.
 
@@ -38,30 +38,30 @@
     }
 }
 
-bdtPt* arith_bdtPt_bdtDu(Rcpp::object<bdtPt> e1, Rcpp::object<bdtDu> e2, std::string op){
+bdtPt* arith_bdtPt_bdtDu(const bdtPt& e1, const bdtDu& e2, std::string op){
     if( ! op.compare("+") ){
-        return new bdtPt( e1->m_pt + e2->m_td ) ;   
+        return new bdtPt( e1.m_pt + e2.m_td ) ;   
     } else if( ! op.compare("-") ){
-        return new bdtPt( e1->m_pt - e2->m_td ) ;
+        return new bdtPt( e1.m_pt - e2.m_td ) ;
     }
     Rf_error( "operator not implemented" )  ;
     // not reached
     return new bdtPt();
 }
 
-bool compare_bdtPt_bdtPt(Rcpp::object<bdtPt> e1, Rcpp::object<bdtPt> e2, std::string op) {
+bool compare_bdtPt_bdtPt(const bdtPt& e1, const bdtPt& e2, std::string op) {
     if( !op.compare( "==" ) ){
-        return e1->m_pt == e2->m_pt ;   
+        return e1.m_pt == e2.m_pt ;   
     } else if( !op.compare( "!=" ) ){
-        return e1->m_pt != e2->m_pt ;
+        return e1.m_pt != e2.m_pt ;
     } else if( !op.compare( ">" ) ){
-        return e1->m_pt > e2->m_pt ;
+        return e1.m_pt > e2.m_pt ;
     } else if( !op.compare( "<" ) ){
-        return e1->m_pt < e2->m_pt ;
+        return e1.m_pt < e2.m_pt ;
     } else if( !op.compare( ">=" ) ){
-        return e1->m_pt >= e2->m_pt ;
+        return e1.m_pt >= e2.m_pt ;
     } else if( !op.compare( "<=" ) ){
-        return e1->m_pt <= e2->m_pt ;
+        return e1.m_pt <= e2.m_pt ;
     }
     Rf_error("unknown operator in bdtPt comparison");
     return R_NilValue ;



More information about the Rcpp-commits mailing list