[Rcpp-commits] r3560 - in pkg/RcppBDT: . R src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Mar 30 19:11:25 CEST 2012


Author: romain
Date: 2012-03-30 19:11:25 +0200 (Fri, 30 Mar 2012)
New Revision: 3560

Modified:
   pkg/RcppBDT/DESCRIPTION
   pkg/RcppBDT/NAMESPACE
   pkg/RcppBDT/R/zzz.R
   pkg/RcppBDT/src/RcppBDT.cpp
Log:
proposal, but will require john's wisdom

Modified: pkg/RcppBDT/DESCRIPTION
===================================================================
--- pkg/RcppBDT/DESCRIPTION	2012-03-29 23:40:49 UTC (rev 3559)
+++ pkg/RcppBDT/DESCRIPTION	2012-03-30 17:11:25 UTC (rev 3560)
@@ -15,6 +15,8 @@
 License: GPL (>= 2)
 LazyLoad: yes
 Depends: Rcpp (>= 0.9.0), methods
+Imports: methods, Rcpp
 SystemRequirements: Boost 
 LinkingTo: Rcpp
+RcppModules: bdtMod
 

Modified: pkg/RcppBDT/NAMESPACE
===================================================================
--- pkg/RcppBDT/NAMESPACE	2012-03-29 23:40:49 UTC (rev 3559)
+++ pkg/RcppBDT/NAMESPACE	2012-03-30 17:11:25 UTC (rev 3560)
@@ -1,3 +1,6 @@
-import(Rcpp)
+import(Rcpp,methods)
 useDynLib(RcppBDT)
+
 exportPattern("^[[:alpha:]]+")
+exportMethods( "format", "show" )
+

Modified: pkg/RcppBDT/R/zzz.R
===================================================================
--- pkg/RcppBDT/R/zzz.R	2012-03-29 23:40:49 UTC (rev 3559)
+++ pkg/RcppBDT/R/zzz.R	2012-03-30 17:11:25 UTC (rev 3560)
@@ -1,7 +1,7 @@
 ##
 ## zzz.R: Loading Rcpp and Boost Date_Time glue
 ##
-## Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
+## Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois
 ##
 ## This file is part of RcppBDT.
 ##
@@ -18,31 +18,20 @@
 ## You should have received a copy of the GNU General Public License
 ## along with RcppBDT.  If not, see <http://www.gnu.org/licenses/>.
 
-## This and the code below in onLoad() owe some gratitude to
-## the wls package inside the Rcpp repository on R-forge
-##
-## grab the namespace of this package for use below
-.NAMESPACE <- environment()
 
-# dummy module, will be replaced later
-bdt <- new( "Module" )
+delayedAssign( "bdt", local( { 
+    x <- new( bdtMod$date ); x$setFromUTC(); x 
+}) )                                                                        
 
-.onLoad <- function (lib, pack) {
+    
 
-    ## we need the methods package
-    require(methods, quiet=TRUE, warn=FALSE)
-
-    unlockBinding("bdt", .NAMESPACE)    	# unlock
-    bdtMod <- Module( "bdt" )			# get the module code
-    bdt <- new( bdtMod$date )                  	# date class default constructor for reference instance
-    bdt$setFromUTC()                    	# but set a default value
-    assign("bdt", bdt, .NAMESPACE)      	# assign the reference instance
-    assign("bdtMod", bdtMod, .NAMESPACE)  	# and the module
-
-    setMethod("print", "Rcpp_date", function(x, ...) print(x$getDate(), ...))
+.onLoad <- function (lib, pkg) {
+    loadRcppModules( direct = FALSE )
+    
+    setMethod("show", "Rcpp_date", function(object) print(object$getDate()))
+    setGeneric( "format", function(x,...) standardGeneric("format") )
     setMethod("format", "Rcpp_date", function(x, ...) format(x$getDate(), ...))
 
-    lockBinding( "bdt", .NAMESPACE)		# and lock
 }
 
 

Modified: pkg/RcppBDT/src/RcppBDT.cpp
===================================================================
--- pkg/RcppBDT/src/RcppBDT.cpp	2012-03-29 23:40:49 UTC (rev 3559)
+++ pkg/RcppBDT/src/RcppBDT.cpp	2012-03-30 17:11:25 UTC (rev 3560)
@@ -2,7 +2,7 @@
 //
 // RcppBDT.cpp: Rcpp and Boost Date_Time glue
 //
-// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
+// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois
 //
 // This file is part of RcppBDT.
 //
@@ -141,7 +141,7 @@
     return Rcpp::wrap(fdab.get_date(dt));
 }
 
-RCPP_MODULE(bdt) {
+RCPP_MODULE(bdtMod) {
 
     using namespace boost::gregorian;
     using namespace Rcpp;



More information about the Rcpp-commits mailing list